Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove plan prefix from Plan field names #6426

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ justLocals =
map taskProvides .
filter ((== Local) . taskLocation) .
Map.elems .
(.planTasks)
(.tasks)

checkCabalVersion :: HasEnvConfig env => RIO env ()
checkCabalVersion = do
Expand Down Expand Up @@ -293,7 +293,7 @@ warnIfExecutablesWithSameNameCouldBeOverwritten locals plan = do
exesToBuild =
collect
[ (exe, pkgName')
| (pkgName', task) <- Map.toList plan.planTasks
| (pkgName', task) <- Map.toList plan.tasks
, TTLocalMutable lp <- [task.taskType]
, exe <- (Set.toList . exeComponents . (.components)) lp
]
Expand Down
24 changes: 12 additions & 12 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ constructPlan
then do
let tasks = Map.fromList $ mapMaybe (toMaybe . second toTask) adrs
takeSubset Plan
{ planTasks = tasks
, planFinals = Map.fromList finals
, planUnregisterLocal =
{ tasks = tasks
, finals = Map.fromList finals
, unregisterLocal =
mkUnregisterLocal tasks dirtyReason localDumpPkgs initialBuildSteps
, planInstallExes =
, installExes =
if baseConfigOpts0.bcoBuildOpts.installExes
|| baseConfigOpts0.bcoBuildOpts.installCompilerTool
then installExes
Expand Down Expand Up @@ -234,25 +234,25 @@ constructPlan
-- | Strip out anything from the 'Plan' intended for the local database.
stripLocals :: Plan -> RIO env Plan
stripLocals plan = pure plan
{ planTasks = Map.filter checkTask plan.planTasks
, planFinals = Map.empty
, planUnregisterLocal = Map.empty
, planInstallExes = Map.filter (/= Local) plan.planInstallExes
{ tasks = Map.filter checkTask plan.tasks
, finals = Map.empty
, unregisterLocal = Map.empty
, installExes = Map.filter (/= Local) plan.installExes
}
where
checkTask task = taskLocation task == Snap

stripNonDeps :: Plan -> RIO env Plan
stripNonDeps plan = pure plan
{ planTasks = Map.filter checkTask plan.planTasks
, planFinals = Map.empty
, planInstallExes = Map.empty -- TODO maybe don't disable this?
{ tasks = Map.filter checkTask plan.tasks
, finals = Map.empty
, installExes = Map.empty -- TODO maybe don't disable this?
}
where
deps = Map.keysSet sourceDeps
checkTask task = taskProvides task `Set.member` missingForDeps
providesDep task = pkgName (taskProvides task) `Set.member` deps
tasks = Map.elems plan.planTasks
tasks = Map.elems plan.tasks
missing =
Map.fromList $ map (taskProvides &&& (.configOpts.missing)) tasks
missingForDeps = flip execState mempty $
Expand Down
30 changes: 15 additions & 15 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ preFetch plan
<> mconcat (L.intersperse ", " (display <$> Set.toList pkgLocs))
fetchPackages pkgLocs
where
pkgLocs = Set.unions $ map toPkgLoc $ Map.elems plan.planTasks
pkgLocs = Set.unions $ map toPkgLoc $ Map.elems plan.tasks

toPkgLoc task =
case task.taskType of
Expand All @@ -111,7 +111,7 @@ preFetch plan
-- | Print a description of build plan for human consumption.
printPlan :: (HasRunner env, HasTerm env) => Plan -> RIO env ()
printPlan plan = do
case Map.elems plan.planUnregisterLocal of
case Map.elems plan.unregisterLocal of
[] -> prettyInfo $
flow "No packages would be unregistered."
<> line
Expand All @@ -125,7 +125,7 @@ printPlan plan = do
<> bulletedList (map unregisterMsg xs)
<> line

case Map.elems plan.planTasks of
case Map.elems plan.tasks of
[] -> prettyInfo $
flow "Nothing to build."
<> line
Expand All @@ -138,8 +138,8 @@ printPlan plan = do

let hasTests = not . Set.null . testComponents . taskComponents
hasBenches = not . Set.null . benchComponents . taskComponents
tests = Map.elems $ Map.filter hasTests plan.planFinals
benches = Map.elems $ Map.filter hasBenches plan.planFinals
tests = Map.elems $ Map.filter hasTests plan.finals
benches = Map.elems $ Map.filter hasBenches plan.finals

unless (null tests) $ do
prettyInfo $
Expand All @@ -155,7 +155,7 @@ printPlan plan = do
<> bulletedList (map displayTask benches)
<> line

case Map.toList plan.planInstallExes of
case Map.toList plan.installExes of
[] -> prettyInfo $
flow "No executables to be installed."
<> line
Expand Down Expand Up @@ -238,7 +238,7 @@ executePlan
mlargestPackageName
(executePlan' installedMap targets plan)

copyExecutables plan.planInstallExes
copyExecutables plan.installExes

config <- view configL
menv' <- liftIO $ config.processContextSettings EnvSettings
Expand All @@ -255,7 +255,7 @@ executePlan
mlargestPackageName =
Set.lookupMax $
Set.map (length . packageNameString) $
Map.keysSet plan.planTasks <> Map.keysSet plan.planFinals
Map.keysSet plan.tasks <> Map.keysSet plan.finals

copyExecutables ::
HasEnvConfig env
Expand Down Expand Up @@ -344,14 +344,14 @@ executePlan' :: HasEnvConfig env
executePlan' installedMap0 targets plan ee = do
when ee.buildOpts.testOpts.toCoverage deleteHpcReports
cv <- view actualCompilerVersionL
case nonEmpty $ Map.toList plan.planUnregisterLocal of
case nonEmpty $ Map.toList plan.unregisterLocal of
Nothing -> pure ()
Just ids -> do
localDB <- packageDatabaseLocal
unregisterPackages cv localDB ids

liftIO $ atomically $ modifyTVar' ee.localDumpPkgs $ \initMap ->
foldl' (flip Map.delete) initMap $ Map.keys plan.planUnregisterLocal
foldl' (flip Map.delete) initMap $ Map.keys plan.unregisterLocal

run <- askRunInIO

Expand All @@ -367,11 +367,11 @@ executePlan' installedMap0 targets plan ee = do
(Map.mapMissing (\_ b -> (Just b, Nothing)))
(Map.mapMissing (\_ f -> (Nothing, Just f)))
(Map.zipWithMatched (\_ b f -> (Just b, Just f)))
plan.planTasks
plan.planFinals
plan.tasks
plan.finals
threads <- view $ configL . to (.jobs)
let keepGoing = fromMaybe
(not (Map.null plan.planFinals))
(not (Map.null plan.finals))
ee.buildOpts.keepGoing
terminal <- view terminalL
terminalWidth <- view termWidthL
Expand Down Expand Up @@ -439,7 +439,7 @@ executePlan' installedMap0 targets plan ee = do
let planPkgs, localPkgs, installedPkgs, availablePkgs
:: Map PackageName (PackageIdentifier, InstallLocation)
planPkgs =
Map.map (taskProvides &&& taskLocation) plan.planTasks
Map.map (taskProvides &&& taskLocation) plan.tasks
localPkgs =
Map.fromList
[ (p.name, (packageIdentifier p, Local))
Expand All @@ -456,7 +456,7 @@ executePlan' installedMap0 targets plan ee = do
installedMap' = Map.difference installedMap0
$ Map.fromList
$ map (\(ident, _) -> (pkgName ident, ()))
$ Map.elems plan.planUnregisterLocal
$ Map.elems plan.unregisterLocal

unregisterPackages ::
(HasCompiler env, HasPlatform env, HasProcessContext env, HasTerm env)
Expand Down
8 changes: 4 additions & 4 deletions src/Stack/Types/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ installLocationIsMutable Local = Mutable

-- | A complete plan of what needs to be built and how to do it
data Plan = Plan
{ planTasks :: !(Map PackageName Task)
, planFinals :: !(Map PackageName Task)
{ tasks :: !(Map PackageName Task)
, finals :: !(Map PackageName Task)
-- ^ Final actions to be taken (test, benchmark, etc)
, planUnregisterLocal :: !(Map GhcPkgId (PackageIdentifier, Text))
, unregisterLocal :: !(Map GhcPkgId (PackageIdentifier, Text))
-- ^ Text is reason we're unregistering, for display only
, planInstallExes :: !(Map Text InstallLocation)
, installExes :: !(Map Text InstallLocation)
-- ^ Executables that should be installed after successful building
}
deriving Show
Expand Down
Loading