Skip to content
Snippets Groups Projects
Commit 10a9c4a4 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Try to not redo building executables if we see the cid in the store.


Actually we could probably do this a bit more properly with
UnitId in the Backpack patchset.

Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 0e408598
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,7 @@ import Distribution.Solver.Types.SourcePackage
import Distribution.Package hiding
(InstalledPackageId, installedPackageId)
import Distribution.System
import qualified Distribution.InstalledPackageInfo as Installed
import qualified Distribution.PackageDescription as Cabal
import qualified Distribution.PackageDescription as PD
import qualified Distribution.PackageDescription.Configuration as PD
......@@ -129,7 +130,7 @@ import Data.Either
import Data.Monoid
import Data.Function
import System.FilePath
import System.Directory (doesDirectoryExist)
import System.Directory (doesDirectoryExist, getDirectoryContents)
------------------------------------------------------------------------------
-- * Elaborated install plan
......@@ -604,8 +605,10 @@ rebuildInstallPlan verbosity
storePkgIndex <- getPackageDBContents verbosity
compiler progdb platform
storePackageDb
storeExeIndex <- getExecutableDBContents storeDirectory
let improvedPlan = improveInstallPlanWithPreExistingPackages
storePkgIndex
storeExeIndex
elaboratedPlan
liftIO $ debugNoWrap verbosity (InstallPlan.showInstallPlan improvedPlan)
return improvedPlan
......@@ -665,6 +668,20 @@ getPackageDBContents verbosity compiler progdb platform packagedb = do
Cabal.getPackageDBContents verbosity compiler
packagedb progdb
-- | Return the list of all already installed executables
getExecutableDBContents
:: FilePath -- store directory
-> Rebuild (Set ComponentId)
getExecutableDBContents storeDirectory = do
monitorFiles [monitorFileGlob (FilePathGlob (FilePathRoot storeDirectory) (GlobFile [WildCard]))]
paths <- liftIO $ getDirectoryContents storeDirectory
return (Set.fromList (map ComponentId (filter valid paths)))
where
valid "." = False
valid ".." = False
valid "package.db" = False
valid _ = True
getSourcePackages :: Verbosity -> (forall a. (RepoContext -> IO a) -> IO a)
-> Rebuild SourcePackageDb
getSourcePackages verbosity withRepoCtx = do
......@@ -2562,9 +2579,10 @@ packageHashConfigInputs
-- installed packages whenever they exist.
--
improveInstallPlanWithPreExistingPackages :: InstalledPackageIndex
-> Set ComponentId
-> ElaboratedInstallPlan
-> ElaboratedInstallPlan
improveInstallPlanWithPreExistingPackages installedPkgIndex installPlan =
improveInstallPlanWithPreExistingPackages installedPkgIndex installedExes installPlan =
replaceWithPreExisting installPlan
[ ipkg
| InstallPlan.Configured pkg
......@@ -2579,8 +2597,16 @@ improveInstallPlanWithPreExistingPackages installedPkgIndex installPlan =
-- since overwriting is never safe.
canPackageBeImproved pkg =
PackageIndex.lookupUnitId
installedPkgIndex (installedUnitId pkg)
case PackageIndex.lookupUnitId
installedPkgIndex (installedUnitId pkg) of
Just x -> Just x
Nothing | SimpleUnitId cid <- installedUnitId pkg
, cid `Set.member` installedExes
-- Same hack as replacewithPrePreExisting
-> Just (Installed.emptyInstalledPackageInfo {
Installed.installedUnitId = installedUnitId pkg
})
| otherwise -> Nothing
replaceWithPreExisting =
foldl' (\plan ipkg -> InstallPlan.preexisting
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment