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 boptsCLI prefix from BuildOptsCLI field names #6413

Merged
merged 2 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
12 changes: 6 additions & 6 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ instance Exception CabalVersionPrettyException
-- | Helper for build and install commands
buildCmd :: BuildOptsCLI -> RIO Runner ()
buildCmd opts = do
when (any (("-prof" `elem`) . fromRight [] . parseArgs Escaping) opts.boptsCLIGhcOptions) $
when (any (("-prof" `elem`) . fromRight [] . parseArgs Escaping) opts.ghcOptions) $
prettyThrowIO GHCProfOptionInvalid
local (over globalOptsL modifyGO) $
case opts.boptsCLIFileWatch of
case opts.fileWatch of
FileWatchPoll -> fileWatchPoll (inner . Just)
FileWatch -> fileWatch (inner . Just)
NoFileWatch -> inner Nothing
Expand All @@ -112,7 +112,7 @@ buildCmd opts = do
Stack.Build.build setLocalFiles
-- Read the build command from the CLI and enable it to run
modifyGO =
case opts.boptsCLICommand of
case opts.command of
Test -> set
(globalOptsBuildOptsMonoidL . buildOptsMonoidTestsL)
(Just True)
Expand Down Expand Up @@ -150,7 +150,7 @@ build msetLocalFiles = do
stackYaml <- view stackYamlL
for_ msetLocalFiles $ \setLocalFiles -> do
files <-
if boptsCli.boptsCLIWatchAll
if boptsCli.watchAll
then sequence [lpFiles lp | lp <- allLocals]
else forM allLocals $ \lp -> do
let pn = lp.package.name
Expand All @@ -176,7 +176,7 @@ build msetLocalFiles = do
loadPackage
sourceMap
installedMap
boptsCli.boptsCLIInitialBuildSteps
boptsCli.initialBuildSteps

allowLocals <- view $ configL . to (.allowLocals)
unless allowLocals $ case justLocals plan of
Expand All @@ -190,7 +190,7 @@ build msetLocalFiles = do
when bopts.preFetch $
preFetch plan

if boptsCli.boptsCLIDryrun
if boptsCli.dryrun
then printPlan plan
else executePlan
boptsCli
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ constructPlan
toMaybe (k, Just v) = Just (k, v)

takeSubset :: Plan -> RIO env Plan
takeSubset = case baseConfigOpts0.bcoBuildOptsCLI.boptsCLIBuildSubset of
takeSubset = case baseConfigOpts0.bcoBuildOptsCLI.buildSubset of
BSAll -> pure
BSOnlySnapshot -> stripLocals
BSOnlyDependencies -> stripNonDeps
Expand Down
4 changes: 2 additions & 2 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ executePlan
, esKeepGhcRts = False
}
withProcessContext menv' $
forM_ boptsCli.boptsCLIExec $ \(cmd, args) ->
forM_ boptsCli.exec $ \(cmd, args) ->
proc cmd args runProcess_
where
mlargestPackageName =
Expand Down Expand Up @@ -1126,7 +1126,7 @@ withSingleContext
AGOEverything
config.ghcOptionsByCat
++ case config.applyGhcOptions of
AGOEverything -> ee.buildOptsCLI.boptsCLIGhcOptions
AGOEverything -> ee.buildOptsCLI.ghcOptions
AGOTargets -> []
AGOLocals -> []
)
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/ExecuteEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ withSingleContext
AGOEverything
config.ghcOptionsByCat
++ case config.applyGhcOptions of
AGOEverything -> ee.buildOptsCLI.boptsCLIGhcOptions
AGOEverything -> ee.buildOptsCLI.ghcOptions
AGOTargets -> []
AGOLocals -> []
)
Expand Down
6 changes: 3 additions & 3 deletions src/Stack/Build/ExecutePackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ getConfigCache ee task installedMap enableTest enableBench = do
Nothing
-- Expect to instead find it in installedMap if it's
-- an initialBuildSteps target.
| ee.buildOptsCLI.boptsCLIInitialBuildSteps && taskIsTarget task
| ee.buildOptsCLI.initialBuildSteps && taskIsTarget task
, Just (_, installed) <- Map.lookup (pkgName ident) installedMap
-> pure $ installedToGhcPkgId ident installed
Just installed -> pure $ installedToGhcPkgId ident installed
Expand Down Expand Up @@ -561,8 +561,8 @@ singleBuild
Just (_, Executable _) -> True
_ -> False

case ( ee.buildOptsCLI.boptsCLIOnlyConfigure
, ee.buildOptsCLI.boptsCLIInitialBuildSteps && taskIsTarget task
case ( ee.buildOptsCLI.onlyConfigure
, ee.buildOptsCLI.initialBuildSteps && taskIsTarget task
) of
-- A full build is done if there are downstream actions,
-- because their configure step will require that this
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ openHaddocksInBrowser ::
-- ^ Build targets as determined by 'Stack.Build.Source.loadSourceMap'
-> RIO env ()
openHaddocksInBrowser bco pkgLocations buildTargets = do
let cliTargets = bco.bcoBuildOptsCLI.boptsCLITargets
let cliTargets = bco.bcoBuildOptsCLI.targets
getDocIndex = do
let localDocs = haddockIndexFile (localDepsDocDir bco)
localExists <- doesFileExist localDocs
Expand Down
6 changes: 3 additions & 3 deletions src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ loadSourceMap smt boptsCli sma = do
}
packageCliFlags = Map.fromList $
mapMaybe maybeProjectFlags $
Map.toList boptsCli.boptsCLIFlags
Map.toList boptsCli.flags
maybeProjectFlags (ACFByName name, fs) = Just (name, fs)
maybeProjectFlags _ = Nothing
globals = pruneGlobals sma.smaGlobal (Map.keysSet deps)
Expand Down Expand Up @@ -219,7 +219,7 @@ getLocalFlags boptsCli name = Map.unions
, Map.findWithDefault Map.empty ACFAllProjectPackages cliFlags
]
where
cliFlags = boptsCli.boptsCLIFlags
cliFlags = boptsCli.flags

-- | Get the options to pass to @./Setup.hs configure@
generalCabalConfigOpts ::
Expand Down Expand Up @@ -267,7 +267,7 @@ generalGhcOptions bconfig boptsCli isTarget isLocal = concat
else []
, [ "-g" | not $ bopts.libStrip || bopts.exeStrip ]
, if includeExtraOptions
then boptsCli.boptsCLIGhcOptions
then boptsCli.ghcOptions
else []
]
where
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ getRawInput ::
-> Map PackageName ProjectPackage
-> ([Text], [RawInput])
getRawInput boptscli locals =
let textTargets' = boptscli.boptsCLITargets
let textTargets' = boptscli.targets
textTargets =
-- Handle the no targets case, which means we pass in the names of all
-- project packages
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Coverage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ hpcReportCmd hropts = do
let (tixFiles, targetNames) =
L.partition (".tix" `T.isSuffixOf`) hropts.hroptsInputs
boptsCLI = defaultBuildOptsCLI
{ boptsCLITargets = if hropts.hroptsAll then [] else targetNames }
{ targets = if hropts.hroptsAll then [] else targetNames }
withConfig YesReexec $ withEnvConfig AllowNoTargets boptsCLI $
generateHpcReportForTargets hropts tixFiles targetNames

Expand Down
4 changes: 2 additions & 2 deletions src/Stack/DependencyGraph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ withDotConfig opts inner =
runRIO dc inner

boptsCLI = defaultBuildOptsCLI
{ boptsCLITargets = opts.dotTargets
, boptsCLIFlags = opts.dotFlags
{ targets = opts.dotTargets
, flags = opts.dotFlags
}
modifyGO =
(if opts.dotTestTargets
Expand Down
4 changes: 1 addition & 3 deletions src/Stack/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ execCmd opts =
eo = opts.eoExtra

targets = concatMap words eo.eoPackages
boptsCLI = defaultBuildOptsCLI
{ boptsCLITargets = map T.pack targets
}
boptsCLI = defaultBuildOptsCLI { targets = map T.pack targets }

-- return the package-id of the first package in GHC_PACKAGE_PATH
getPkgId name = do
Expand Down
16 changes: 8 additions & 8 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ ghciCmd :: GhciOpts -> RIO Runner ()
ghciCmd ghciOpts =
let boptsCLI = defaultBuildOptsCLI
-- using only additional packages, targets then get overridden in `ghci`
{ boptsCLITargets = map T.pack ghciOpts.ghciAdditionalPackages
, boptsCLIInitialBuildSteps = True
, boptsCLIFlags = ghciOpts.ghciFlags
, boptsCLIGhcOptions = map T.pack ghciOpts.ghciGhcOptions
{ targets = map T.pack ghciOpts.ghciAdditionalPackages
, initialBuildSteps = True
, flags = ghciOpts.ghciFlags
, ghcOptions = map T.pack ghciOpts.ghciGhcOptions
}
in withConfig YesReexec $ withEnvConfig AllowNoTargets boptsCLI $ do
bopts <- view buildOptsL
Expand All @@ -221,8 +221,8 @@ ghciCmd ghciOpts =
ghci :: HasEnvConfig env => GhciOpts -> RIO env ()
ghci opts = do
let buildOptsCLI = defaultBuildOptsCLI
{ boptsCLITargets = []
, boptsCLIFlags = opts.ghciFlags
{ targets = []
, flags = opts.ghciFlags
}
sourceMap <- view $ envConfigL . to (.sourceMap)
installMap <- toInstallMap sourceMap
Expand Down Expand Up @@ -320,7 +320,7 @@ preprocessTargets buildOptsCLI sma rawTargets = do
else do
-- Try parsing targets before checking if both file and
-- module targets are specified (see issue#3342).
let boptsCLI = buildOptsCLI { boptsCLITargets = normalTargetsRaw }
let boptsCLI = buildOptsCLI { targets = normalTargetsRaw }
normalTargets <- parseTargets AllowNoTargets False boptsCLI sma
`catch` \pex@(PrettyException ex) ->
case fromException $ toException ex of
Expand All @@ -337,7 +337,7 @@ parseMainIsTargets ::
-> Maybe Text
-> RIO env (Maybe (Map PackageName Target))
parseMainIsTargets buildOptsCLI sma mtarget = forM mtarget $ \target -> do
let boptsCLI = buildOptsCLI { boptsCLITargets = [target] }
let boptsCLI = buildOptsCLI { targets = [target] }
targets <- parseTargets AllowNoTargets False boptsCLI sma
pure targets.smtTargets

Expand Down
4 changes: 1 addition & 3 deletions src/Stack/Hoogle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ hoogleCmd (args, setup, rebuild, startServer) =
T.pack . packageIdentifierString <$>
restrictMinHoogleVersion muted hoogleIdent
config <- view configL
let boptsCLI = defaultBuildOptsCLI
{ boptsCLITargets = [hoogleTarget]
}
let boptsCLI = defaultBuildOptsCLI { targets = [hoogleTarget] }
runRIO config $ withEnvConfig NeedTargets boptsCLI f

restrictMinHoogleVersion ::
Expand Down
10 changes: 4 additions & 6 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -974,19 +974,17 @@ withNewLocalBuildTargets targets f = do
envConfig <- view envConfigL
haddockDeps <- view $ configL . to (.build) . to shouldHaddockDeps
let boptsCLI = envConfig.buildOptsCLI
envConfig' <- rebuildEnv envConfig NeedTargets haddockDeps $
boptsCLI {boptsCLITargets = targets}
envConfig' <-
rebuildEnv envConfig NeedTargets haddockDeps $ boptsCLI {targets = targets}
local (set envConfigL envConfig') f

-- | Add the include and lib paths to the given Config
addIncludeLib :: ExtraDirs -> Config -> Config
addIncludeLib (ExtraDirs _bins includes libs) config = config
{ extraIncludeDirs =
config.extraIncludeDirs ++
map toFilePathNoTrailingSep includes
config.extraIncludeDirs ++ map toFilePathNoTrailingSep includes
, extraLibDirs =
config.extraLibDirs ++
map toFilePathNoTrailingSep libs
config.extraLibDirs ++ map toFilePathNoTrailingSep libs
}

-- | Ensure both the compiler and the msys toolchain are installed and
Expand Down
52 changes: 26 additions & 26 deletions src/Stack/Types/BuildOpts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,18 @@ defaultBuildOpts = BuildOpts

defaultBuildOptsCLI ::BuildOptsCLI
defaultBuildOptsCLI = BuildOptsCLI
{ boptsCLITargets = []
, boptsCLIDryrun = False
, boptsCLIFlags = Map.empty
, boptsCLIGhcOptions = []
, boptsCLIProgsOptions = []
, boptsCLIBuildSubset = BSAll
, boptsCLIFileWatch = NoFileWatch
, boptsCLIWatchAll = False
, boptsCLIExec = []
, boptsCLIOnlyConfigure = False
, boptsCLICommand = Build
, boptsCLIInitialBuildSteps = False
{ targets = []
, dryrun = False
, flags = Map.empty
, ghcOptions = []
, progsOptions = []
, buildSubset = BSAll
, fileWatch = NoFileWatch
, watchAll = False
, exec = []
, onlyConfigure = False
, command = Build
, initialBuildSteps = False
}

-- | How to apply a CLI flag
Expand All @@ -181,32 +181,32 @@ boptsCLIFlagsByName =
Map.fromList .
mapMaybe go .
Map.toList .
(.boptsCLIFlags)
(.flags)
where
go (ACFAllProjectPackages, _) = Nothing
go (ACFByName name, flags) = Just (name, flags)

-- | Build options that may only be specified from the CLI
data BuildOptsCLI = BuildOptsCLI
{ boptsCLITargets :: ![Text]
, boptsCLIDryrun :: !Bool
, boptsCLIGhcOptions :: ![Text]
, boptsCLIProgsOptions :: ![(Text, [Text])]
, boptsCLIFlags :: !(Map ApplyCLIFlag (Map FlagName Bool))
, boptsCLIBuildSubset :: !BuildSubset
, boptsCLIFileWatch :: !FileWatchOpts
, boptsCLIWatchAll :: !Bool
, boptsCLIExec :: ![(String, [String])]
, boptsCLIOnlyConfigure :: !Bool
, boptsCLICommand :: !BuildCommand
, boptsCLIInitialBuildSteps :: !Bool
{ targets :: ![Text]
, dryrun :: !Bool
, ghcOptions :: ![Text]
, progsOptions :: ![(Text, [Text])]
, flags :: !(Map ApplyCLIFlag (Map FlagName Bool))
, buildSubset :: !BuildSubset
, fileWatch :: !FileWatchOpts
, watchAll :: !Bool
, exec :: ![(String, [String])]
, onlyConfigure :: !Bool
, command :: !BuildCommand
, initialBuildSteps :: !Bool
}
deriving Show

-- | Generate a list of --PROG-option="<argument>" arguments for all PROGs.
boptsCLIAllProgOptions :: BuildOptsCLI -> [Text]
boptsCLIAllProgOptions boptsCLI =
concatMap progOptionArgs boptsCLI.boptsCLIProgsOptions
concatMap progOptionArgs boptsCLI.progsOptions
where
-- Generate a list of --PROG-option="<argument>" arguments for a PROG.
progOptionArgs :: (Text, [Text]) -> [Text]
Expand Down
4 changes: 1 addition & 3 deletions src/Stack/Upgrade.hs
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,7 @@ sourceUpgrade builtHash (SourceOpts gitRepo) =
-- stack.yaml file
, globalStackYaml = SYLOverride $ dir </> stackDotYaml
}
boptsCLI = defaultBuildOptsCLI
{ boptsCLITargets = ["stack"]
}
boptsCLI = defaultBuildOptsCLI { targets = ["stack"] }
forM_ mdir $ \dir ->
local (over globalOptsL (modifyGO dir))
$ withConfig NoReexec
Expand Down
Loading