Commit b60fb2da authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Cache the setup executable for 'Make' and 'Configure' build types.

Can improve 'install -j' times a little bit for large install plans.
parent 38e66c74
...@@ -215,12 +215,10 @@ externalSetupMethod verbosity options pkg bt mkargs = do ...@@ -215,12 +215,10 @@ externalSetupMethod verbosity options pkg bt mkargs = do
createDirectoryIfMissingVerbose verbosity True setupDir createDirectoryIfMissingVerbose verbosity True setupDir
(cabalLibVersion, mCabalLibInstalledPkgId, options') <- cabalLibVersionToUse (cabalLibVersion, mCabalLibInstalledPkgId, options') <- cabalLibVersionToUse
debug verbosity $ "Using Cabal library version " ++ display cabalLibVersion debug verbosity $ "Using Cabal library version " ++ display cabalLibVersion
path <- case bt of path <- if useCachedSetupExecutable
-- TODO: Should we also cache the setup exe for the Make and Configure build then getCachedSetupExecutable options'
-- types?
Simple -> getCachedSetupExecutable options'
cabalLibVersion mCabalLibInstalledPkgId cabalLibVersion mCabalLibInstalledPkgId
_ -> compileSetupExecutable options' else compileSetupExecutable options'
cabalLibVersion mCabalLibInstalledPkgId False cabalLibVersion mCabalLibInstalledPkgId False
invokeSetupScript options' path (mkargs cabalLibVersion) invokeSetupScript options' path (mkargs cabalLibVersion)
...@@ -233,6 +231,8 @@ externalSetupMethod verbosity options pkg bt mkargs = do ...@@ -233,6 +231,8 @@ externalSetupMethod verbosity options pkg bt mkargs = do
setupHs = setupDir </> "setup" <.> "hs" setupHs = setupDir </> "setup" <.> "hs"
setupProgFile = setupDir </> "setup" <.> exeExtension setupProgFile = setupDir </> "setup" <.> exeExtension
useCachedSetupExecutable = (bt == Simple || bt == Configure || bt == Make)
maybeGetInstalledPackages :: SetupScriptOptions -> Compiler maybeGetInstalledPackages :: SetupScriptOptions -> Compiler
-> ProgramConfiguration -> IO PackageIndex -> ProgramConfiguration -> IO PackageIndex
maybeGetInstalledPackages options' comp conf = maybeGetInstalledPackages options' comp conf =
...@@ -255,11 +255,12 @@ externalSetupMethod verbosity options pkg bt mkargs = do ...@@ -255,11 +255,12 @@ externalSetupMethod verbosity options pkg bt mkargs = do
_ -> installedVersion _ -> installedVersion
where where
canUseExistingSetup :: Version -> IO Bool canUseExistingSetup :: Version -> IO Bool
canUseExistingSetup version = case bt of canUseExistingSetup version =
Simple -> do if useCachedSetupExecutable
then do
(_, cachedSetupProgFile) <- cachedSetupDirAndProg options version (_, cachedSetupProgFile) <- cachedSetupDirAndProg options version
doesFileExist cachedSetupProgFile doesFileExist cachedSetupProgFile
_ -> else
(&&) <$> setupProgFile `existsAndIsMoreRecentThan` setupHs (&&) <$> setupProgFile `existsAndIsMoreRecentThan` setupHs
<*> setupProgFile `existsAndIsMoreRecentThan` setupVersionFile <*> setupProgFile `existsAndIsMoreRecentThan` setupVersionFile
...@@ -410,12 +411,14 @@ externalSetupMethod verbosity options pkg bt mkargs = do ...@@ -410,12 +411,14 @@ externalSetupMethod verbosity options pkg bt mkargs = do
cabalDir <- defaultCabalDir cabalDir <- defaultCabalDir
let setupCacheDir = cabalDir </> "setup-exe-cache" let setupCacheDir = cabalDir </> "setup-exe-cache"
cachedSetupProgFile = setupCacheDir cachedSetupProgFile = setupCacheDir
</> ("setup-" ++ cabalVersionString ++ "-" </> ("setup-" ++ buildTypeString ++ "-"
++ cabalVersionString ++ "-"
++ platformString ++ "-" ++ platformString ++ "-"
++ compilerVersionString) ++ compilerVersionString)
<.> exeExtension <.> exeExtension
return (setupCacheDir, cachedSetupProgFile) return (setupCacheDir, cachedSetupProgFile)
where where
buildTypeString = show bt
cabalVersionString = "Cabal-" ++ (display cabalLibVersion) cabalVersionString = "Cabal-" ++ (display cabalLibVersion)
compilerVersionString = display $ compilerVersionString = display $
fromMaybe buildCompilerId fromMaybe buildCompilerId
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment