X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=libraries%2FinstallPackage.hs;h=8c6600952eb20d3d61681890cf44a92bc9ebfbb8;hb=a11bb49b97eaba892730baf1565e922715dbc07f;hp=461542956033f7dfd99ba4fbd53ce8618292b614;hpb=fcf6b22d0478be20e27c2245f3e34dd272e12522;p=ghc-hetmet.git diff --git a/libraries/installPackage.hs b/libraries/installPackage.hs index 4615429..8c66009 100644 --- a/libraries/installPackage.hs +++ b/libraries/installPackage.hs @@ -1,5 +1,7 @@ import Distribution.PackageDescription +import Distribution.PackageDescription.Parse +import Distribution.ReadE import Distribution.Simple import Distribution.Simple.Configure import Distribution.Simple.LocalBuildInfo @@ -9,13 +11,14 @@ import Distribution.Simple.Utils import Distribution.Verbosity import System.Environment +-- XXX This will need to be changed +distPref :: FilePath +distPref = defaultDistPref + main :: IO () main = do args <- getArgs case args of - "register" : "--inplace" :args' -> - let verbosity = mkVerbosity args' - in doRegisterInplace verbosity "install" : ghcpkg : ghcpkgconf : destdir : topdir : iprefix : ibindir : ilibdir : ilibexecdir : idynlibdir : idatadir : idocdir : ihtmldir : ihaddockdir : @@ -29,29 +32,9 @@ main mkVerbosity :: [String] -> Verbosity mkVerbosity [] = normal -mkVerbosity ['-':'v':v] = let m = case v of - "" -> Nothing - _ -> Just v - in flagToVerbosity m +mkVerbosity ['-':'v':v] = readEOrFail flagToVerbosity v mkVerbosity args = error ("Bad arguments: " ++ show args) -doRegisterInplace :: Verbosity -> IO () -doRegisterInplace verbosity = - do lbi <- getConfig verbosity - let registerFlags = defaultRegisterFlags { regInPlace = toFlag True } - pd = localPkgDescr lbi - pd_reg = if pkgName (package pd) == "ghc-prim" - 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 -> FilePath @@ -63,11 +46,11 @@ doInstall verbosity ghcpkg ghcpkgconf destdir topdir copyto = if null destdir then NoCopyDest else CopyTo destdir copyFlags = defaultCopyFlags { copyDest = toFlag copyto, - copyVerbose = toFlag verbosity + copyVerbosity = toFlag verbosity } registerFlags = defaultRegisterFlags { regPackageDB = toFlag GlobalPackageDB, - regVerbose = toFlag verbosity, + regVerbosity = toFlag verbosity, regGenScript = toFlag $ False, regInPlace = toFlag $ False } @@ -77,7 +60,7 @@ doInstall verbosity ghcpkg ghcpkgconf destdir topdir -- This is an almighty hack. We need to register -- ghc-prim:GHC.Prim, but it doesn't exist, get built, get -- haddocked, get copied, etc. - pd_reg = if pkgName (package pd) == "ghc-prim" + pd_reg = if packageName pd == PackageName "ghc-prim" then case library pd of Just lib -> let ems = "GHC.Prim" : exposedModules lib @@ -137,7 +120,7 @@ replaceTopdir _ p = p -- Get the build info, merging the setup-config and buildinfo files. getConfig :: Verbosity -> IO LocalBuildInfo getConfig verbosity = do - lbi <- getPersistBuildConfig + lbi <- getPersistBuildConfig distPref maybe_infoFile <- defaultHookedPackageDesc case maybe_infoFile of Nothing -> return lbi