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 task prefix from Task field names, save taskType #6415

Merged
merged 3 commits into from
Jan 13, 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
26 changes: 13 additions & 13 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ constructPlan
providesDep task = pkgName (taskProvides task) `Set.member` deps
tasks = Map.elems plan.planTasks
missing =
Map.fromList $ map (taskProvides &&& (.taskConfigOpts.tcoMissing)) tasks
Map.fromList $ map (taskProvides &&& (.configOpts.tcoMissing)) tasks
missingForDeps = flip execState mempty $
for_ tasks $ \task ->
when (providesDep task) $
Expand Down Expand Up @@ -437,7 +437,7 @@ addFinal lp package isAllInOne buildHaddocks = do
Right (missing, present, _minLoc) -> do
ctx <- ask
pure $ Right Task
{ taskConfigOpts = TaskConfigOpts missing $ \missing' ->
{ configOpts = TaskConfigOpts missing $ \missing' ->
let allDeps = Map.union present missing'
in configureOpts
(view envConfigL ctx)
Expand All @@ -446,12 +446,12 @@ addFinal lp package isAllInOne buildHaddocks = do
True -- local
Mutable
package
, taskBuildHaddock = buildHaddocks
, taskPresent = present
, buildHaddock = buildHaddocks
, present = present
, taskType = TTLocalMutable lp
, taskAllInOne = isAllInOne
, taskCachePkgSrc = CacheSrcLocal (toFilePath (parent lp.cabalFile))
, taskBuildTypeConfig = packageBuildTypeConfig package
, allInOne = isAllInOne
, cachePkgSrc = CacheSrcLocal (toFilePath (parent lp.cabalFile))
, buildTypeConfig = packageBuildTypeConfig package
}
tell mempty { wFinals = Map.singleton package.name res }

Expand Down Expand Up @@ -750,7 +750,7 @@ installPackageGivenDeps isAllInOne buildHaddocks ps package minstalled
pure $ case mRightVersionInstalled of
Just installed -> ADRFound loc installed
Nothing -> ADRToInstall Task
{ taskConfigOpts = TaskConfigOpts missing $ \missing' ->
{ configOpts = TaskConfigOpts missing $ \missing' ->
let allDeps = Map.union present missing'
in configureOpts
(view envConfigL ctx)
Expand All @@ -759,17 +759,17 @@ installPackageGivenDeps isAllInOne buildHaddocks ps package minstalled
(psLocal ps)
mutable
package
, taskBuildHaddock = buildHaddocks
, taskPresent = present
, buildHaddock = buildHaddocks
, present = present
, taskType =
case ps of
PSFilePath lp ->
TTLocalMutable lp
PSRemote pkgLoc _version _fromSnapshot _cp ->
TTRemotePackage mutable package pkgLoc
, taskAllInOne = isAllInOne
, taskCachePkgSrc = toCachePkgSrc ps
, taskBuildTypeConfig = packageBuildTypeConfig package
, allInOne = isAllInOne
, cachePkgSrc = toCachePkgSrc ps
, buildTypeConfig = packageBuildTypeConfig package
}

-- | Is the build type of the package Configure
Expand Down
10 changes: 5 additions & 5 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ displayTask task = fillSep $
| not $ Set.null missing
]
where
missing = task.taskConfigOpts.tcoMissing
missing = task.configOpts.tcoMissing

-- | Perform the actual plan
executePlan :: HasEnvConfig env
Expand Down Expand Up @@ -601,7 +601,7 @@ toActions installedMap mtestLock runInBase ee (mbuild, mfinal) =
[ Action
{ actionId = ActionId (taskProvides task) ATBuild
, actionDeps =
Set.map (`ActionId` ATBuild) task.taskConfigOpts.tcoMissing
Set.map (`ActionId` ATBuild) task.configOpts.tcoMissing
, actionDo =
\ac -> runInBase $ singleBuild ac ee task installedMap False
, actionConcurrency = ConcurrencyAllowed
Expand All @@ -610,12 +610,12 @@ toActions installedMap mtestLock runInBase ee (mbuild, mfinal) =
afinal = case mfinal of
Nothing -> []
Just task ->
( if task.taskAllInOne
( if task.allInOne
then id
else (:) Action
{ actionId = ActionId pkgId ATBuildFinal
, actionDeps = addBuild
(Set.map (`ActionId` ATBuild) task.taskConfigOpts.tcoMissing)
(Set.map (`ActionId` ATBuild) task.configOpts.tcoMissing)
, actionDo =
\ac -> runInBase $ singleBuild ac ee task installedMap True
, actionConcurrency = ConcurrencyAllowed
Expand Down Expand Up @@ -660,7 +660,7 @@ toActions installedMap mtestLock runInBase ee (mbuild, mfinal) =
tests = testComponents comps
benches = benchComponents comps
finalDeps =
if task.taskAllInOne
if task.allInOne
then addBuild mempty
else Set.singleton (ActionId pkgId ATBuildFinal)
addBuild =
Expand Down
24 changes: 12 additions & 12 deletions src/Stack/Build/ExecutePackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ getConfigCache ee task installedMap enableTest enableBench = do
installedToGhcPkgId ident (Library ident' libInfo) =
assert (ident == ident') (installedMapGhcPkgId ident libInfo)
installedToGhcPkgId _ (Executable _) = mempty
TaskConfigOpts missing mkOpts = task.taskConfigOpts
TaskConfigOpts missing mkOpts = task.configOpts
missingMapList <- traverse getMissing $ toList missing
let missing' = Map.unions missingMapList
opts = mkOpts missing'
allDeps = Set.fromList $ Map.elems missing' ++ Map.elems task.taskPresent
allDeps = Set.fromList $ Map.elems missing' ++ Map.elems task.present
cache = ConfigCache
{ opts = opts { coNoDirs = opts.coNoDirs ++ map T.unpack extra }
, deps = allDeps
Expand All @@ -203,11 +203,11 @@ getConfigCache ee task installedMap enableTest enableBench = do
TTLocalMutable lp ->
Set.map (encodeUtf8 . renderComponent) lp.components
TTRemotePackage{} -> Set.empty
, haddock = task.taskBuildHaddock
, pkgSrc = task.taskCachePkgSrc
, haddock = task.buildHaddock
, pkgSrc = task.cachePkgSrc
, pathEnvVar = ee.pathEnvVar
}
allDepsMap = Map.union missing' task.taskPresent
allDepsMap = Map.union missing' task.present
pure (allDepsMap, cache)

-- | Ensure that the configuration for the package matches what is given
Expand Down Expand Up @@ -273,7 +273,7 @@ ensureConfig newConfigCache pkgDir buildOpts announce cabal cabalfp task = do
|| mOldProjectRoot /= Just newProjectRoot
let ConfigureOpts dirs nodirs = newConfigCache.opts

when task.taskBuildTypeConfig $
when task.buildTypeConfig $
-- When build-type is Configure, we need to have a configure script in the
-- local directory. If it doesn't exist, build it with autoreconf -i. See:
-- https://github.com/commercialhaskell/stack/issues/3534
Expand Down Expand Up @@ -387,7 +387,7 @@ singleBuild
pkgId = taskProvides task
PackageIdentifier pname pversion = pkgId
doHaddock mcurator package =
task.taskBuildHaddock
task.buildHaddock
&& not isFinalBuild
-- Works around haddock failing on bytestring-builder since it has no
-- modules when bytestring is new enough.
Expand All @@ -409,17 +409,17 @@ singleBuild
Left _ -> pure ()
fulfillHaddockExpectations _ action = action CloseOnException

buildingFinals = isFinalBuild || task.taskAllInOne
buildingFinals = isFinalBuild || task.allInOne
enableTests = buildingFinals && any isCTest (taskComponents task)
enableBenchmarks = buildingFinals && any isCBench (taskComponents task)

annSuffix executableBuildStatuses =
if result == "" then "" else " (" <> result <> ")"
where
result = T.intercalate " + " $ concat
[ ["lib" | task.taskAllInOne && hasLib]
, ["sub-lib" | task.taskAllInOne && hasSubLib]
, ["exe" | task.taskAllInOne && hasExe]
[ ["lib" | task.allInOne && hasLib]
, ["sub-lib" | task.allInOne && hasSubLib]
, ["exe" | task.allInOne && hasExe]
, ["test" | enableTests]
, ["bench" | enableBenchmarks]
]
Expand Down Expand Up @@ -664,7 +664,7 @@ singleBuild
| config.hideTHLoading = ExcludeTHLoading
| otherwise = KeepTHLoading
cabal stripTHLoading (("build" :) $ (++ extraOpts) $
case (task.taskType, task.taskAllInOne, isFinalBuild) of
case (task.taskType, task.allInOne, isFinalBuild) of
(_, True, True) -> throwM AllInOneBuildBug
(TTLocalMutable lp, False, False) ->
primaryComponentOptions executableBuildStatuses lp
Expand Down
16 changes: 8 additions & 8 deletions src/Stack/Types/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,20 @@ toCachePkgSrc PSRemote{} = CacheSrcUpstream

-- | A type representing tasks to perform when building.
data Task = Task
{ taskType :: !TaskType
{ taskType :: !TaskType
-- ^ The task type, telling us how to build this
, taskConfigOpts :: !TaskConfigOpts
, configOpts :: !TaskConfigOpts
-- ^ A set of the package identifiers of dependencies for which 'GhcPkgId'
-- are missing and a function which yields configure options, given a
-- dictionary of those identifiers and their 'GhcPkgId'.
, taskBuildHaddock :: !Bool
, taskPresent :: !(Map PackageIdentifier GhcPkgId)
, buildHaddock :: !Bool
, present :: !(Map PackageIdentifier GhcPkgId)
-- ^ A dictionary of the package identifiers of already-installed
-- dependencies, and their 'GhcPkgId'.
, taskAllInOne :: !Bool
, allInOne :: !Bool
-- ^ indicates that the package can be built in one step
, taskCachePkgSrc :: !CachePkgSrc
, taskBuildTypeConfig :: !Bool
, cachePkgSrc :: !CachePkgSrc
, buildTypeConfig :: !Bool
-- ^ Is the build type of this package Configure. Check out
-- ensureConfigureScript in Stack.Build.Execute for the motivation
}
Expand Down Expand Up @@ -179,7 +179,7 @@ data TaskType
-- | Were any of the dependencies missing?

taskAnyMissing :: Task -> Bool
taskAnyMissing task = not $ Set.null task.taskConfigOpts.tcoMissing
taskAnyMissing task = not $ Set.null task.configOpts.tcoMissing

-- | A function to yield the package name and version of a given 'TaskType'
-- value.
Expand Down
Loading