From 861d247efaca37279c55a14f7f2d4d3fb15767a1 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Tue, 12 Feb 2019 03:22:31 +0100 Subject: Make Cabal-HEAD lib v2-build cachable --- .../Compiletime/Program/CabalInstall.hs | 22 ++++++++++++++-------- src/CabalHelper/Compiletime/Program/GHC.hs | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/CabalHelper/Compiletime/Program') diff --git a/src/CabalHelper/Compiletime/Program/CabalInstall.hs b/src/CabalHelper/Compiletime/Program/CabalInstall.hs index f989a02..f6c0018 100644 --- a/src/CabalHelper/Compiletime/Program/CabalInstall.hs +++ b/src/CabalHelper/Compiletime/Program/CabalInstall.hs @@ -138,7 +138,7 @@ runSetupHs -> UnpackedCabalVersion -> CabalInstallVersion -> IO () -runSetupHs ghcVer db srcdir iCabalVer CabalInstallVersion {..} +runSetupHs ghcVer db srcdir cabalVer CabalInstallVersion {..} | cabalInstallVer >= parseVer "1.24" = do go $ \args -> callProcessStderr (Just srcdir) (cabalProgram ?progs) $ [ "act-as-setup", "--" ] ++ args @@ -148,9 +148,9 @@ runSetupHs ghcVer db srcdir iCabalVer CabalInstallVersion {..} where parmake_opt :: Maybe Int -> [String] parmake_opt nproc' - | CabalHEAD _ <- iCabalVer = + | CabalHEAD _ <- cabalVer = ["-j"++nproc] - | CabalVersion ver <- iCabalVer, ver >= Version [1,20] [] = + | CabalVersion ver <- cabalVer, ver >= Version [1,20] [] = ["-j"++nproc] | otherwise = [] @@ -195,13 +195,19 @@ cabalWithGHCProgOpts = concat else [] ] +-- TODO: This needs the big message blub from above installCabalLibV2 :: Env => GhcVersion -> UnpackedCabalVersion -> PackageEnvFile -> IO () -installCabalLibV2 _ (CabalHEAD _) _ = error "TODO: `installCabalLibV2 _ CabalHEAD _` is unimplemented" -installCabalLibV2 _ghcVer (CabalVersion cabalVer) (PackageEnvFile env_file) = do +installCabalLibV2 _ghcVer cv (PackageEnvFile env_file) = do exists <- doesFileExist env_file if exists then return () else do + (target, cwd) <- case cv of + CabalVersion cabalVer -> do + tmp <- getTemporaryDirectory + return $ ("Cabal-"++showVersion cabalVer, tmp) + CabalHEAD (_commitid, CabalSourceDir srcdir) -> do + return (".", srcdir) CabalInstallVersion {..} <- cabalInstallVersion cabal_opts <- return $ concat [ if cabalInstallVer >= Version [1,20] [] @@ -214,16 +220,16 @@ installCabalLibV2 _ghcVer (CabalVersion cabalVer) (PackageEnvFile env_file) = do , cabalV2WithGHCProgOpts , [ "--package-env=" ++ env_file , "--lib" - , "Cabal-"++showVersion cabalVer + , target ] , if | ?verbose 3 -> ["-v2"] | ?verbose 4 -> ["-v3"] | otherwise -> [] ] - tmp <- getTemporaryDirectory - callProcessStderr (Just tmp) (cabalProgram ?progs) cabal_opts + callProcessStderr (Just cwd) (cabalProgram ?progs) cabal_opts hPutStrLn stderr "done" + cabalV2WithGHCProgOpts :: Progs => [String] cabalV2WithGHCProgOpts = concat [ [ "--with-compiler=" ++ ghcProgram ?cprogs ] diff --git a/src/CabalHelper/Compiletime/Program/GHC.hs b/src/CabalHelper/Compiletime/Program/GHC.hs index b58eab0..97b04ed 100644 --- a/src/CabalHelper/Compiletime/Program/GHC.hs +++ b/src/CabalHelper/Compiletime/Program/GHC.hs @@ -94,12 +94,12 @@ getPrivateCabalPkgDb cabalVer = do return $ PackageDbDir db_path getPrivateCabalPkgEnv - :: Verbose => GhcVersion -> Version -> IO PackageEnvFile + :: Verbose => GhcVersion -> ResolvedCabalVersion -> IO PackageEnvFile getPrivateCabalPkgEnv ghcVer cabalVer = do appdir <- appCacheDir let env_path = appdir "ghc-" ++ showGhcVersion ghcVer ++ ".package-envs" - "Cabal-" ++ showVersion cabalVer ++ ".package-env" + "Cabal-" ++ showResolvedCabalVersion cabalVer ++ ".package-env" return $ PackageEnvFile env_path listCabalVersions -- cgit v1.2.3