Commit 3d4d48ce authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Change rebuildInstallPlan to return pre-improvement plan

It takes a solver plan, makes an "elaborated plan" with nix style hashes
but still of mostly source package and then does an improvement phase to
make a plan with pre-existing packages from the store.

Previously it only returned the improved plan, but for some things it's
also useful to see the original elaborated plan with the source
packages. In partciular it will be useful for plan.json status output.
It will also be needed for the freeze command to be able to get at the
flag choices, since this info is not preserved in installed packages.
parent e8aa0562
......@@ -151,7 +151,7 @@ runProjectPreBuildPhase
-- everything in the project. This is independent of any specific targets
-- the user has asked for.
--
(elaboratedPlan, elaboratedShared, projectConfig) <-
(elaboratedPlan, _, elaboratedShared, projectConfig) <-
rebuildInstallPlan verbosity
projectRootDir distDirLayout cabalDirLayout
cliConfig
......
......@@ -231,12 +231,27 @@ sanityCheckElaboratedConfiguredPackage sharedConfig
-- * Deciding what to do: making an 'ElaboratedInstallPlan'
------------------------------------------------------------------------------
-- | Return an up-to-date elaborated install plan and associated config.
--
-- Two variants of the install plan are returned: with and without packages
-- from the store. That is, the \"improved\" plan where source packages are
-- replaced by pre-existing installed packages from the store (when their ids
-- match), and also the original elaborated plan which uses primarily source
-- packages.
-- The improved plan is what we use for building, but the original elaborated
-- plan is useful for reporting and configuration. For example the @freeze@
-- command needs the source package info to know about flag choices and
-- dependencies of executables and setup scripts.
--
rebuildInstallPlan :: Verbosity
-> FilePath -> DistDirLayout -> CabalDirLayout
-> ProjectConfig
-> IO ( ElaboratedInstallPlan
-> IO ( ElaboratedInstallPlan -- with store packages
, ElaboratedInstallPlan -- with source packages
, ElaboratedSharedConfig
, ProjectConfig )
-- ^ @(improvedPlan, elaboratedPlan, _, _)@
rebuildInstallPlan verbosity
projectRootDir
distDirLayout@DistDirLayout {
......@@ -275,16 +290,16 @@ rebuildInstallPlan verbosity
elaboratedShared) <- phaseElaboratePlan projectConfigTransient
compilerEtc
solverPlan localPackages
phaseMaintainPlanOutputs elaboratedPlan elaboratedShared
return (elaboratedPlan, elaboratedShared,
projectConfig)
return (elaboratedPlan, elaboratedShared, projectConfig)
-- The improved plan changes each time we install something, whereas
-- the underlying elaborated plan only changes when input config
-- changes, so it's worth caching them separately.
improvedPlan <- phaseImprovePlan elaboratedPlan elaboratedShared
return (improvedPlan, elaboratedShared, projectConfig)
phaseMaintainPlanOutputs improvedPlan elaboratedPlan elaboratedShared
return (improvedPlan, elaboratedPlan, elaboratedShared, projectConfig)
where
fileMonitorCompiler = newFileMonitorInCacheDir "compiler"
......@@ -537,9 +552,10 @@ rebuildInstallPlan verbosity
-- the libs available. This will need to be after plan improvement phase.
--
phaseMaintainPlanOutputs :: ElaboratedInstallPlan
-> ElaboratedInstallPlan
-> ElaboratedSharedConfig
-> Rebuild ()
phaseMaintainPlanOutputs elaboratedPlan elaboratedShared = do
phaseMaintainPlanOutputs _improvedPlan elaboratedPlan elaboratedShared = do
liftIO $ debug verbosity "Updating plan.json"
liftIO $ writePlanExternalRepresentation
distDirLayout
......
......@@ -231,7 +231,7 @@ planProject testdir cliConfig = do
-- ended in an exception (as we leave the files to help with debugging).
cleanProject testdir
(elaboratedPlan, elaboratedShared, projectConfig) <-
(elaboratedPlan, _, elaboratedShared, projectConfig) <-
rebuildInstallPlan verbosity
projectRootDir distDirLayout cabalDirLayout
cliConfig
......
Supports Markdown
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