Permalink
Browse files

Move the register-inplace special-case stuff into the ghc-prim package

  • Loading branch information...
1 parent d82a98b commit 467e0c4d99b31d8467b4dd96fd863b9fab139299 @igfoo igfoo committed May 17, 2008
Showing with 21 additions and 0 deletions.
  1. +21 −0 Setup.hs
View
@@ -17,6 +17,8 @@ import Control.Exception (try)
main :: IO ()
main = do let hooks = defaultUserHooks {
+ regHook = addPrimModule
+ $ regHook defaultUserHooks,
buildHook = build_primitive_sources
$ buildHook defaultUserHooks,
makefileHook = build_primitive_sources
@@ -27,6 +29,25 @@ main = do let hooks = defaultUserHooks {
type Hook a = PackageDescription -> LocalBuildInfo -> UserHooks -> a -> IO ()
+addPrimModule :: Hook a -> Hook a
+addPrimModule f pd lbi uhs x =
+ do let -- I'm not sure which one of these we actually need to change.
+ -- It seems bad that there are two.
+ pd' = addPrimModuleToPD pd
+ lpd = addPrimModuleToPD (localPkgDescr lbi)
+ lbi' = lbi { localPkgDescr = lpd }
+ f pd' lbi' uhs x
+
+addPrimModuleToPD :: PackageDescription -> PackageDescription
+addPrimModuleToPD pd =
+ case library pd of
+ Just lib ->
+ let ems = "GHC.Prim" : exposedModules lib
+ lib' = lib { exposedModules = ems }
+ in pd { library = Just lib' }
+ Nothing ->
+ error "Expected a library, but none found"
+
build_primitive_sources :: Hook a -> Hook a
build_primitive_sources f pd lbi uhs x
= do when (compilerFlavor (compiler lbi) == GHC) $ do

0 comments on commit 467e0c4

Please sign in to comment.