Use installPackage for register --inplace as well as installing
authorIan Lynagh <igloo@earth.li>
Fri, 7 Dec 2007 23:46:52 +0000 (23:46 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 7 Dec 2007 23:46:52 +0000 (23:46 +0000)
We also need to do the GHC.Prim hack when registering inplace or the
tests that use it fail.

libraries/Makefile
libraries/installPackage.hs

index bbcfdd2..9b61df2 100644 (file)
@@ -268,7 +268,7 @@ make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
          setup/Setup makefile -f GNUmakefile; \
          cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
          $(MAKE) $(MFLAGS) && \
-         setup/Setup register --inplace; \
+         ../installPackage/installPackage register --inplace; \
        fi
 
 # Build the library using 'setup build' (not the default)
@@ -359,7 +359,7 @@ $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
        if ifBuildable/ifBuildable $*; then \
          cd $* && \
-         ../installPackage/installPackage '$(GHC_PKG_PROG)' '$(DESTDIR)$(libdir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(iinterfacedir)' ; \
+         ../installPackage/installPackage install '$(GHC_PKG_PROG)' '$(DESTDIR)$(libdir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(iinterfacedir)' ; \
        fi
 
 .PHONY: binary-dist binary-dist.library.%
index 1fafe7c..decf2d4 100644 (file)
@@ -13,29 +13,50 @@ main :: IO ()
 main
   = do args <- getArgs
        case args of
-           ghcpkg : ghcpkgconf : destdir : topdir :
+           "register" : "--inplace" :args' ->
+               let verbosity = mkVerbosity args'
+               in doRegisterInplace verbosity
+           "install" : ghcpkg : ghcpkgconf : destdir : topdir :
                     iprefix : ibindir : ilibdir : ilibexecdir :
                     idatadir : idocdir : ihtmldir : iinterfacedir :
                     args' ->
-               let verbosity = case args' of
-                           [] -> normal
-                           ['-':'v':v] ->
-                               let m = case v of
-                                           "" -> Nothing
-                                           _ -> Just v
-                               in flagToVerbosity m
-                           _ -> error ("Bad arguments: " ++ show args)
-               in doit verbosity ghcpkg ghcpkgconf destdir topdir
-                       iprefix ibindir ilibdir ilibexecdir idatadir
-                       idocdir ihtmldir iinterfacedir
+               let verbosity = mkVerbosity args'
+               in doInstall verbosity ghcpkg ghcpkgconf destdir topdir
+                            iprefix ibindir ilibdir ilibexecdir idatadir
+                            idocdir ihtmldir iinterfacedir
            _ ->
-               error "Missing arguments"
+               error ("Bad arguments: " ++ show args)
 
-doit :: Verbosity -> FilePath -> FilePath -> FilePath -> FilePath
-     -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath
-     -> FilePath -> FilePath -> FilePath
-     -> IO ()
-doit verbosity ghcpkg ghcpkgconf destdir topdir
+mkVerbosity :: [String] -> Verbosity
+mkVerbosity [] = normal
+mkVerbosity ['-':'v':v] = let m = case v of
+                                      "" -> Nothing
+                                      _ -> Just v
+                          in flagToVerbosity m
+mkVerbosity args = error ("Bad arguments: " ++ show args)
+
+doRegisterInplace :: Verbosity -> IO ()
+doRegisterInplace verbosity =
+       do lbi <- getConfig verbosity
+          let registerFlags = emptyRegisterFlags { regInPlace = True }
+              pd = localPkgDescr lbi
+              pd_reg = if pkgName (package pd) == "base"
+                       then 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"
+                       else pd
+          (regHook simpleUserHooks) pd_reg lbi simpleUserHooks registerFlags
+          return ()
+
+doInstall :: Verbosity -> FilePath -> FilePath -> FilePath -> FilePath
+          -> FilePath -> FilePath -> FilePath -> FilePath -> FilePath
+          -> FilePath -> FilePath -> FilePath
+          -> IO ()
+doInstall verbosity ghcpkg ghcpkgconf destdir topdir
      iprefix ibindir ilibdir ilibexecdir idatadir
      idocdir ihtmldir iinterfacedir =
        do let userHooks = simpleUserHooks