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 bopts prefix from BuildOpts field names #6410

Merged
merged 1 commit 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
4 changes: 2 additions & 2 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ build msetLocalFiles = do
warnAboutSplitObjs bopts
warnIfExecutablesWithSameNameCouldBeOverwritten locals plan

when bopts.boptsPreFetch $
when bopts.preFetch $
preFetch plan

if boptsCli.boptsCLIDryrun
Expand Down Expand Up @@ -308,7 +308,7 @@ warnIfExecutablesWithSameNameCouldBeOverwritten locals plan = do
collect = Map.mapMaybe nonEmpty . Map.fromDistinctAscList . groupSort

warnAboutSplitObjs :: HasTerm env => BuildOpts -> RIO env ()
warnAboutSplitObjs bopts | bopts.boptsSplitObjs =
warnAboutSplitObjs bopts | bopts.splitObjs =
prettyWarnL
[ flow "Building with"
, style Shell "--split-objs"
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ constructPlan
, planUnregisterLocal =
mkUnregisterLocal tasks dirtyReason localDumpPkgs initialBuildSteps
, planInstallExes =
if baseConfigOpts0.bcoBuildOpts.boptsInstallExes
|| baseConfigOpts0.bcoBuildOpts.boptsInstallCompilerTool
if baseConfigOpts0.bcoBuildOpts.installExes
|| baseConfigOpts0.bcoBuildOpts.installCompilerTool
then installExes
else Map.empty
}
Expand Down
40 changes: 20 additions & 20 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ withExecuteEnv bopts boptsCli baseConfigOpts locals globalPackages snapshotPacka
toDumpPackagesByGhcPkgId = Map.fromList . map (\dp -> (dp.ghcPkgId, dp))

createTempDirFunction
| bopts.boptsKeepTmpFiles = withKeepSystemTempDir
| bopts.keepTmpFiles = withKeepSystemTempDir
| otherwise = withSystemTempDir

dumpLogs :: TChan (Path Abs Dir, Path Abs File) -> Int -> RIO env ()
Expand Down Expand Up @@ -722,7 +722,7 @@ copyExecutables exes | Map.null exes = pure ()
copyExecutables exes = do
snapBin <- (</> bindirSuffix) <$> installationRootDeps
localBin <- (</> bindirSuffix) <$> installationRootLocal
compilerSpecific <- (.boptsInstallCompilerTool) <$> view buildOptsL
compilerSpecific <- (.installCompilerTool) <$> view buildOptsL
destDir <- if compilerSpecific
then bindirCompilerTools
else view $ configL . to (.localBin)
Expand Down Expand Up @@ -800,7 +800,7 @@ executePlan' :: HasEnvConfig env
-> ExecuteEnv
-> RIO env ()
executePlan' installedMap0 targets plan ee = do
when ee.eeBuildOpts.boptsTestOpts.toCoverage deleteHpcReports
when ee.eeBuildOpts.testOpts.toCoverage deleteHpcReports
cv <- view actualCompilerVersionL
case nonEmpty $ Map.toList plan.planUnregisterLocal of
Nothing -> pure ()
Expand Down Expand Up @@ -830,7 +830,7 @@ executePlan' installedMap0 targets plan ee = do
threads <- view $ configL . to (.jobs)
let keepGoing = fromMaybe
(not (Map.null plan.planFinals))
ee.eeBuildOpts.boptsKeepGoing
ee.eeBuildOpts.keepGoing
terminal <- view terminalL
terminalWidth <- view termWidthL
errs <- liftIO $ runActions threads keepGoing actions $
Expand All @@ -850,7 +850,7 @@ executePlan' installedMap0 targets plan ee = do
nowBuilding names = mconcat $
": "
: L.intersperse ", " (map fromPackageName names)
progressFormat = ee.eeBuildOpts.boptsProgressBar
progressFormat = ee.eeBuildOpts.progressBar
progressLine prev' total' =
"Progress "
<> display prev' <> "/" <> display total'
Expand All @@ -870,13 +870,13 @@ executePlan' installedMap0 targets plan ee = do
pure done
loop done
when (total > 1) $ loop 0
when ee.eeBuildOpts.boptsTestOpts.toCoverage $ do
when ee.eeBuildOpts.testOpts.toCoverage $ do
generateHpcUnifiedReport
generateHpcMarkupIndex
unless (null errs) $
prettyThrowM $ ExecutionFailure errs
when ee.eeBuildOpts.boptsHaddock $ do
if ee.eeBuildOpts.boptsHaddockForHackage
when ee.eeBuildOpts.haddock $ do
if ee.eeBuildOpts.haddockForHackage
then
generateLocalHaddockForHackageArchives ee.eeLocals
else do
Expand All @@ -893,7 +893,7 @@ executePlan' installedMap0 targets plan ee = do
ee.eeBaseConfigOpts
ee.eeGlobalDumpPkgs
snapshotDumpPkgs
when ee.eeBuildOpts.boptsOpenHaddocks $ do
when ee.eeBuildOpts.openHaddocks $ do
let planPkgs, localPkgs, installedPkgs, availablePkgs
:: Map PackageName (PackageIdentifier, InstallLocation)
planPkgs =
Expand Down Expand Up @@ -1046,8 +1046,8 @@ toActions installedMap mtestLock runInBase ee (mbuild, mfinal) =
withLock Nothing f = f
withLock (Just lock) f = withMVar lock $ \() -> f
bopts = ee.eeBuildOpts
topts = bopts.boptsTestOpts
beopts = bopts.boptsBenchmarkOpts
topts = bopts.testOpts
beopts = bopts.benchmarkOpts

-- | Generate the ConfigCache
getConfigCache ::
Expand Down Expand Up @@ -1135,7 +1135,7 @@ ensureConfig newConfigCache pkgDir ee announce cabal cabalfp task = do
taskAnyMissingHackEnabled <-
view $ actualCompilerVersionL . to getGhcVersion . to (< mkVersion [8, 4])
needConfig <-
if ee.eeBuildOpts.boptsReconfigure
if ee.eeBuildOpts.reconfigure
-- The reason 'taskAnyMissing' is necessary is a bug in Cabal. See:
-- <https://github.com/haskell/cabal/issues/4728#issuecomment-337937673>.
-- The problem is that Cabal may end up generating the same package ID
Expand Down Expand Up @@ -1401,7 +1401,7 @@ withSingleContext

-- If the user requested interleaved output, dump to the console with a
-- prefix.
| ee.eeBuildOpts.boptsInterleavedOutput = inner $
| ee.eeBuildOpts.interleavedOutput = inner $
OTConsole $ Just $ fromString (packageNamePrefix ee package.name)

-- Neither condition applies, dump to a file.
Expand Down Expand Up @@ -1677,7 +1677,7 @@ withSingleContext
(Set.insert package.name oldCustomBuilt, ())
pure outputFile
let cabalVerboseArg =
let CabalVerbosity cv = ee.eeBuildOpts.boptsCabalVerbose
let CabalVerbosity cv = ee.eeBuildOpts.cabalVerbose
in "--verbose=" <> showForCabal cv
runExe exeName $ cabalVerboseArg:setupArgs

Expand Down Expand Up @@ -1740,7 +1740,7 @@ singleBuild
&& maybe True (Set.notMember pname . (.curatorSkipHaddock)) mcurator
expectHaddockFailure =
maybe False (Set.member pname . (.curatorExpectHaddockFailure))
isHaddockForHackage = ee.eeBuildOpts.boptsHaddockForHackage
isHaddockForHackage = ee.eeBuildOpts.haddockForHackage
fulfillHaddockExpectations mcurator action
| expectHaddockFailure mcurator = do
eres <- tryAny $ action KeepOpen
Expand Down Expand Up @@ -2046,13 +2046,13 @@ singleBuild
, "--html-location=../$pkg-$version/"
]
, [ "--haddock-option=--hyperlinked-source"
| ee.eeBuildOpts.boptsHaddockHyperlinkSource
| ee.eeBuildOpts.haddockHyperlinkSource
]
, [ "--internal" | ee.eeBuildOpts.boptsHaddockInternal ]
, [ "--internal" | ee.eeBuildOpts.haddockInternal ]
, quickjump
]
<> [ [ "--haddock-option=" <> opt
| opt <- ee.eeBuildOpts.boptsHaddockOpts.hoAdditionalArgs
| opt <- ee.eeBuildOpts.haddockOpts.hoAdditionalArgs
]
]
)
Expand All @@ -2077,7 +2077,7 @@ singleBuild
when (hasLibrary || hasSubLibraries) $ cabal KeepTHLoading ["register"]

-- copy ddump-* files
case T.unpack <$> ee.eeBuildOpts.boptsDdumpDir of
case T.unpack <$> ee.eeBuildOpts.ddumpDir of
Just ddumpPath | buildingFinals && not (null ddumpPath) -> do
distDir <- distRelativeDir
ddumpDir <- parseRelDir ddumpPath
Expand Down Expand Up @@ -2703,7 +2703,7 @@ extraBuildOptions wc bopts = do
colorOpt <- appropriateGhcColorFlag
let optsFlag = compilerOptionsCabalFlag wc
baseOpts = maybe "" (" " ++) colorOpt
if bopts.boptsTestOpts.toCoverage
if bopts.testOpts.toCoverage
then do
hpcIndexDir <- toFilePathNoTrailingSep <$> hpcRelativeDir
pure [optsFlag, "-hpcdir " ++ hpcIndexDir ++ baseOpts]
Expand Down
6 changes: 3 additions & 3 deletions src/Stack/Build/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ shouldHaddockPackage ::
-> Bool
shouldHaddockPackage bopts wanted name =
if Set.member name wanted
then bopts.boptsHaddock
then bopts.haddock
else shouldHaddockDeps bopts

-- | Determine whether to build haddocks for dependencies.
shouldHaddockDeps :: BuildOpts -> Bool
shouldHaddockDeps bopts = fromMaybe bopts.boptsHaddock bopts.boptsHaddockDeps
shouldHaddockDeps bopts = fromMaybe bopts.haddock bopts.haddockDeps

-- | Generate Haddock index and contents for local packages.
generateLocalHaddockIndex ::
Expand Down Expand Up @@ -242,7 +242,7 @@ generateHaddockIndex descr bco dumpPackages docRelFP destDir = do
( map
(("--optghc=-package-db=" ++ ) . toFilePathNoTrailingSep)
[bco.bcoSnapDB, bco.bcoLocalDB]
++ bco.bcoBuildOpts.boptsHaddockOpts.hoAdditionalArgs
++ bco.bcoBuildOpts.haddockOpts.hoAdditionalArgs
++ ["--gen-contents", "--gen-index"]
++ [x | (xs, _, _, _) <- interfaceOpts, x <- xs]
)
Expand Down
16 changes: 8 additions & 8 deletions src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ loadSourceMap smt boptsCli sma = do
cabalConfigOpts ++ common.cpCabalConfigOpts
, cpHaddocks =
if isTarget
then bopts.boptsHaddock
then bopts.haddock
else shouldHaddockDeps bopts
}
packageCliFlags = Map.fromList $
Expand Down Expand Up @@ -261,11 +261,11 @@ generalGhcOptions bconfig boptsCli isTarget isLocal = concat
, if isTarget
then Map.findWithDefault [] AGOTargets config.ghcOptionsByCat
else []
, concat [["-fhpc"] | isLocal && bopts.boptsTestOpts.toCoverage]
, if bopts.boptsLibProfile || bopts.boptsExeProfile
, concat [["-fhpc"] | isLocal && bopts.testOpts.toCoverage]
, if bopts.libProfile || bopts.exeProfile
then ["-fprof-auto", "-fprof-cafs"]
else []
, [ "-g" | not $ bopts.boptsLibStrip || bopts.boptsExeStrip ]
, [ "-g" | not $ bopts.libStrip || bopts.exeStrip ]
, if includeExtraOptions
then boptsCli.boptsCLIGhcOptions
else []
Expand Down Expand Up @@ -319,11 +319,11 @@ loadLocalPackage pp = do
in (e, t, b)
Just (TargetAll _packageType) ->
( buildableExes pkg
, if bopts.boptsTests
, if bopts.tests
&& maybe True (Set.notMember name . (.curatorSkipTest)) mcurator
then buildableTestSuites pkg
else Set.empty
, if bopts.boptsBenchmarks
, if bopts.benchmarks
&& maybe
True
(Set.notMember name . (.curatorSkipBenchmark))
Expand All @@ -345,7 +345,7 @@ loadLocalPackage pp = do
|| not (null pkg.subLibraries)

filterSkippedComponents =
Set.filter (not . (`elem` bopts.boptsSkipComponents))
Set.filter (not . (`elem` bopts.skipComponents))

(exes, tests, benches) = ( filterSkippedComponents exeCandidates
, filterSkippedComponents testCandidates
Expand Down Expand Up @@ -410,7 +410,7 @@ loadLocalPackage pp = do
, testBench = btpkg
, componentFiles = componentFiles
, buildHaddocks = pp.ppCommon.cpHaddocks
, forceDirty = bopts.boptsForceDirty
, forceDirty = bopts.forceDirty
, dirtyFiles = dirtyFiles
, newBuildCaches = newBuildCaches
, cabalFile = pp.ppCabalFP
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ fillProjectWanted stackYamlFP config project locCache snapCompiler snapPackages
packages0 <- for project.projectPackages $ \fp@(RelFilePath t) -> do
abs' <- resolveDir (parent stackYamlFP) (T.unpack t)
let resolved = ResolvedPath fp abs'
pp <- mkProjectPackage YesPrintWarnings resolved bopts.boptsHaddock
pp <- mkProjectPackage YesPrintWarnings resolved bopts.haddock
pure (pp.ppCommon.cpName, pp)

-- prefetch git repos to avoid cloning per subdirectory
Expand Down
57 changes: 28 additions & 29 deletions src/Stack/Config/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,57 @@ import Stack.Types.BuildOpts
-- | Interprets BuildOptsMonoid options.
buildOptsFromMonoid :: BuildOptsMonoid -> BuildOpts
buildOptsFromMonoid buildMonoid = BuildOpts
{ boptsLibProfile = fromFirstFalse
{ libProfile = fromFirstFalse
(buildMonoid.buildMonoidLibProfile <>
FirstFalse (if tracing || profiling then Just True else Nothing))
, boptsExeProfile = fromFirstFalse
, exeProfile = fromFirstFalse
(buildMonoid.buildMonoidExeProfile <>
FirstFalse (if tracing || profiling then Just True else Nothing))
, boptsLibStrip = fromFirstTrue
, libStrip = fromFirstTrue
(buildMonoid.buildMonoidLibStrip <>
FirstTrue (if noStripping then Just False else Nothing))
, boptsExeStrip = fromFirstTrue
, exeStrip = fromFirstTrue
(buildMonoid.buildMonoidExeStrip <>
FirstTrue (if noStripping then Just False else Nothing))
, boptsHaddock = fromFirstFalse buildMonoid.buildMonoidHaddock
, boptsHaddockOpts = haddockOptsFromMonoid buildMonoid.buildMonoidHaddockOpts
, boptsOpenHaddocks =
, haddock = fromFirstFalse buildMonoid.buildMonoidHaddock
, haddockOpts = haddockOptsFromMonoid buildMonoid.buildMonoidHaddockOpts
, openHaddocks =
not isHaddockFromHackage
&& fromFirstFalse buildMonoid.buildMonoidOpenHaddocks
, boptsHaddockDeps = if isHaddockFromHackage
, haddockDeps = if isHaddockFromHackage
then Nothing
else getFirst buildMonoid.buildMonoidHaddockDeps
, boptsHaddockInternal =
, haddockInternal =
not isHaddockFromHackage
&& fromFirstFalse buildMonoid.buildMonoidHaddockInternal
, boptsHaddockHyperlinkSource =
, haddockHyperlinkSource =
isHaddockFromHackage
|| fromFirstTrue buildMonoid.buildMonoidHaddockHyperlinkSource
, boptsHaddockForHackage = isHaddockFromHackage
, boptsInstallExes = fromFirstFalse buildMonoid.buildMonoidInstallExes
, boptsInstallCompilerTool =
, haddockForHackage = isHaddockFromHackage
, installExes = fromFirstFalse buildMonoid.buildMonoidInstallExes
, installCompilerTool =
fromFirstFalse buildMonoid.buildMonoidInstallCompilerTool
, boptsPreFetch = fromFirstFalse buildMonoid.buildMonoidPreFetch
, boptsKeepGoing = getFirst buildMonoid.buildMonoidKeepGoing
, boptsKeepTmpFiles = fromFirstFalse buildMonoid.buildMonoidKeepTmpFiles
, boptsForceDirty =
, preFetch = fromFirstFalse buildMonoid.buildMonoidPreFetch
, keepGoing = getFirst buildMonoid.buildMonoidKeepGoing
, keepTmpFiles = fromFirstFalse buildMonoid.buildMonoidKeepTmpFiles
, forceDirty =
isHaddockFromHackage || fromFirstFalse buildMonoid.buildMonoidForceDirty
, boptsTests = fromFirstFalse buildMonoid.buildMonoidTests
, boptsTestOpts =
, tests = fromFirstFalse buildMonoid.buildMonoidTests
, testOpts =
testOptsFromMonoid buildMonoid.buildMonoidTestOpts additionalArgs
, boptsBenchmarks = fromFirstFalse buildMonoid.buildMonoidBenchmarks
, boptsBenchmarkOpts =
, benchmarks = fromFirstFalse buildMonoid.buildMonoidBenchmarks
, benchmarkOpts =
benchmarkOptsFromMonoid
buildMonoid.buildMonoidBenchmarkOpts
additionalArgs
, boptsReconfigure = fromFirstFalse buildMonoid.buildMonoidReconfigure
, boptsCabalVerbose =
, reconfigure = fromFirstFalse buildMonoid.buildMonoidReconfigure
, cabalVerbose =
fromFirst (CabalVerbosity normal) buildMonoid.buildMonoidCabalVerbose
, boptsSplitObjs = fromFirstFalse buildMonoid.buildMonoidSplitObjs
, boptsSkipComponents = buildMonoid.buildMonoidSkipComponents
, boptsInterleavedOutput =
fromFirstTrue buildMonoid.buildMonoidInterleavedOutput
, boptsProgressBar = fromFirst CappedBar buildMonoid.buildMonoidProgressBar
, boptsDdumpDir = getFirst buildMonoid.buildMonoidDdumpDir
, splitObjs = fromFirstFalse buildMonoid.buildMonoidSplitObjs
, skipComponents = buildMonoid.buildMonoidSkipComponents
, interleavedOutput = fromFirstTrue buildMonoid.buildMonoidInterleavedOutput
, progressBar = fromFirst CappedBar buildMonoid.buildMonoidProgressBar
, ddumpDir = getFirst buildMonoid.buildMonoidDdumpDir
}
where
isHaddockFromHackage = fromFirstFalse buildMonoid.buildMonoidHaddockForHackage
Expand Down
9 changes: 4 additions & 5 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ ghciCmd ghciOpts =
bopts <- view buildOptsL
-- override env so running of tests and benchmarks is disabled
let boptsLocal = bopts
{ boptsTestOpts = bopts.boptsTestOpts { toDisableRun = True }
, boptsBenchmarkOpts =
bopts.boptsBenchmarkOpts { beoDisableRun = True }
{ testOpts = bopts.testOpts { toDisableRun = True }
, benchmarkOpts = bopts.benchmarkOpts { beoDisableRun = True }
}
local (set buildOptsL boptsLocal) (ghci ghciOpts)

Expand Down Expand Up @@ -959,8 +958,8 @@ wantedPackageComponents bopts (TargetAll PTProject) pkg = S.fromList $
)
<> map CExe buildableExes'
<> map CSubLib buildableSubLibs
<> (if bopts.boptsTests then map CTest buildableTestSuites else [])
<> (if bopts.boptsBenchmarks then map CBench buildableBenchmarks else [])
<> (if bopts.tests then map CTest buildableTestSuites else [])
<> (if bopts.benchmarks then map CBench buildableBenchmarks else [])
where
buildableForeignLibs' = S.toList $ buildableForeignLibs pkg
buildableSubLibs = getBuildableListText pkg.subLibraries
Expand Down
3 changes: 1 addition & 2 deletions src/Stack/SDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,7 @@ buildExtractedTarball pkgDir = do
updateBuildConfig envConfig.envConfigBuildConfig
}
updateBuildConfig bc = bc
{ config = bc.config
{ build = defaultBuildOpts { boptsTests = True } }
{ config = bc.config { build = defaultBuildOpts { tests = True } }
}
in set envConfigL updatedEnvConfig env
updatePackagesInSourceMap sm =
Expand Down
Loading
Loading