Skip to content

Commit d91b1a0

Browse files
author
Krishnan Parthasarathi
committed
Extract logLevel from env
1 parent 3b7f5dd commit d91b1a0

4 files changed

Lines changed: 24 additions & 29 deletions

File tree

src/Stack/Setup.hs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ setupEnv mResolveMissingGHC = do
237237
, soptsGHCJSBootOpts = ["--clean"]
238238
}
239239

240-
(mghcBin, compilerBuild, _) <- ensureCompiler sopts LevelInfo
240+
(mghcBin, compilerBuild, _) <- ensureCompiler sopts
241241

242242
-- Modify the initial environment to include the GHC path, if a local GHC
243243
-- is being used
@@ -376,9 +376,8 @@ addIncludeLib (ExtraDirs _bins includes libs) config = config
376376
-- | Ensure compiler (ghc or ghcjs) is installed and provide the PATHs to add if necessary
377377
ensureCompiler :: (HasConfig env, HasGHCVariant env)
378378
=> SetupOpts
379-
-> LogLevel
380379
-> RIO env (Maybe ExtraDirs, CompilerBuild, Bool)
381-
ensureCompiler sopts logLevel = do
380+
ensureCompiler sopts = do
382381
let wc = whichCompiler (soptsWantedCompiler sopts)
383382
when (getGhcVersion (soptsWantedCompiler sopts) < $(mkVersion "7.8")) $ do
384383
logWarn "Stack will almost certainly fail with GHC below version 7.8"
@@ -467,7 +466,6 @@ ensureCompiler sopts logLevel = do
467466
(soptsWantedCompiler sopts)
468467
(soptsCompilerCheck sopts)
469468
(soptsGHCBindistURL sopts)
470-
logLevel
471469
| otherwise -> do
472470
recommendSystemGhc <-
473471
if soptsUseSystem sopts
@@ -855,9 +853,8 @@ downloadAndInstallCompiler :: (HasConfig env, HasGHCVariant env)
855853
-> CompilerVersion 'CVWanted
856854
-> VersionCheck
857855
-> Maybe String
858-
-> LogLevel
859856
-> RIO env Tool
860-
downloadAndInstallCompiler ghcBuild si wanted@GhcVersion{} versionCheck mbindistURL logLevel = do
857+
downloadAndInstallCompiler ghcBuild si wanted@GhcVersion{} versionCheck mbindistURL = do
861858
ghcVariant <- view ghcVariantL
862859
(selectedVersion, downloadInfo) <- case mbindistURL of
863860
Just bindistURL -> do
@@ -883,7 +880,7 @@ downloadAndInstallCompiler ghcBuild si wanted@GhcVersion{} versionCheck mbindist
883880
let installer =
884881
case configPlatform config of
885882
Platform _ Cabal.Windows -> installGHCWindows selectedVersion
886-
_ -> installGHCPosix selectedVersion downloadInfo logLevel
883+
_ -> installGHCPosix selectedVersion downloadInfo
887884
logInfo $
888885
"Preparing to install GHC" <>
889886
(case ghcVariant of
@@ -897,7 +894,7 @@ downloadAndInstallCompiler ghcBuild si wanted@GhcVersion{} versionCheck mbindist
897894
ghcPkgName <- parsePackageNameFromString ("ghc" ++ ghcVariantSuffix ghcVariant ++ compilerBuildSuffix ghcBuild)
898895
let tool = Tool $ PackageIdentifier ghcPkgName selectedVersion
899896
downloadAndInstallTool (configLocalPrograms config) si (gdiDownloadInfo downloadInfo) tool installer
900-
downloadAndInstallCompiler compilerBuild si wanted versionCheck _mbindistUrl _ = do
897+
downloadAndInstallCompiler compilerBuild si wanted versionCheck _mbindistUrl = do
901898
config <- view configL
902899
ghcVariant <- view ghcVariantL
903900
case (ghcVariant, compilerBuild) of
@@ -936,10 +933,9 @@ downloadAndInstallPossibleCompilers
936933
-> CompilerVersion 'CVWanted
937934
-> VersionCheck
938935
-> Maybe String
939-
-> LogLevel
940936
-> RIO env (Tool, CompilerBuild)
941-
downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbindistURL logLevel =
942-
go logLevel possibleCompilers Nothing
937+
downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbindistURL =
938+
go possibleCompilers Nothing
943939
where
944940
-- This will stop as soon as one of the builds doesn't throw an @UnknownOSKey@ or
945941
-- @UnknownCompilerVersion@ exception (so it will only try subsequent builds if one is non-existent,
@@ -948,26 +944,26 @@ downloadAndInstallPossibleCompilers possibleCompilers si wanted versionCheck mbi
948944
-- (if only @UnknownOSKey@ is thrown, then the first of those is rethrown, but if any
949945
-- @UnknownCompilerVersion@s are thrown then the attempted OS keys and available versions
950946
-- are unioned).
951-
go _ [] Nothing = throwM UnsupportedSetupConfiguration
952-
go _ [] (Just e) = throwM e
953-
go ll (b:bs) e = do
947+
go [] Nothing = throwM UnsupportedSetupConfiguration
948+
go [] (Just e) = throwM e
949+
go (b:bs) e = do
954950
logDebug $ "Trying to setup GHC build: " <> T.pack (compilerBuildName b)
955-
er <- try $ downloadAndInstallCompiler b si wanted versionCheck mbindistURL ll
951+
er <- try $ downloadAndInstallCompiler b si wanted versionCheck mbindistURL
956952
case er of
957953
Left e'@(UnknownCompilerVersion ks' w' vs') ->
958954
case e of
959-
Nothing -> go ll bs (Just e')
955+
Nothing -> go bs (Just e')
960956
Just (UnknownOSKey k) ->
961-
go ll bs $ Just $ UnknownCompilerVersion (Set.insert k ks') w' vs'
957+
go bs $ Just $ UnknownCompilerVersion (Set.insert k ks') w' vs'
962958
Just (UnknownCompilerVersion ks _ vs) ->
963-
go ll bs $ Just $ UnknownCompilerVersion (Set.union ks' ks) w' (Set.union vs' vs)
959+
go bs $ Just $ UnknownCompilerVersion (Set.union ks' ks) w' (Set.union vs' vs)
964960
Just x -> throwM x
965961
Left e'@(UnknownOSKey k') ->
966962
case e of
967-
Nothing -> go ll bs (Just e')
968-
Just (UnknownOSKey _) -> go ll bs e
963+
Nothing -> go bs (Just e')
964+
Just (UnknownOSKey _) -> go bs e
969965
Just (UnknownCompilerVersion ks w vs) ->
970-
go ll bs $ Just $ UnknownCompilerVersion (Set.insert k' ks) w vs
966+
go bs $ Just $ UnknownCompilerVersion (Set.insert k' ks) w vs
971967
Just x -> throwM x
972968
Left e' -> throwM e'
973969
Right r -> return (r, b)
@@ -1051,14 +1047,13 @@ data ArchiveType
10511047
installGHCPosix :: HasConfig env
10521048
=> Version
10531049
-> GHCDownloadInfo
1054-
-> LogLevel
10551050
-> SetupInfo
10561051
-> Path Abs File
10571052
-> ArchiveType
10581053
-> Path Abs Dir
10591054
-> Path Abs Dir
10601055
-> RIO env ()
1061-
installGHCPosix version downloadInfo logLevel _ archiveFile archiveType tempDir destDir = do
1056+
installGHCPosix version downloadInfo _ archiveFile archiveType tempDir destDir = do
10621057
platform <- view platformL
10631058
menv0 <- view envOverrideL
10641059
menv <- mkEnvOverride (removeHaskellEnvVars (unEnvOverride menv0))
@@ -1091,6 +1086,7 @@ installGHCPosix version downloadInfo logLevel _ archiveFile archiveType tempDir
10911086

10921087
let runStep step wd env cmd args = do
10931088
menv' <- modifyEnvOverride menv (Map.union env)
1089+
logLevel <- logMinLevel <$> view logOptionsL
10941090
result <- case logLevel of
10951091
LevelDebug -> do
10961092
let logLines = CB.lines .| CL.mapM_ (logInfo . T.decodeUtf8With T.lenientDecode)

src/Stack/SetupCmd.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,12 @@ setupParser = SetupCmdOpts
101101

102102
setup
103103
:: (HasConfig env, HasGHCVariant env)
104-
=> GlobalOpts
105-
-> SetupCmdOpts
104+
=> SetupCmdOpts
106105
-> CompilerVersion 'CVWanted
107106
-> VersionCheck
108107
-> Maybe (Path Abs File)
109108
-> RIO env ()
110-
setup gopts SetupCmdOpts{..} wantedCompiler compilerCheck mstack = do
109+
setup SetupCmdOpts{..} wantedCompiler compilerCheck mstack = do
111110
Config{..} <- view configL
112111
(_, _, sandboxedGhc) <- ensureCompiler SetupOpts
113112
{ soptsInstallIfMissing = True
@@ -124,7 +123,7 @@ setup gopts SetupCmdOpts{..} wantedCompiler compilerCheck mstack = do
124123
, soptsSetupInfoYaml = scoSetupInfoYaml
125124
, soptsGHCBindistURL = scoGHCBindistURL
126125
, soptsGHCJSBootOpts = scoGHCJSBootOpts ++ ["--clean" | scoGHCJSBootClean]
127-
} (globalLogLevel gopts)
126+
}
128127
let compiler = case wantedCompiler of
129128
GhcVersion _ -> "GHC"
130129
GhcjsVersion {} -> "GHCJS"

src/Stack/Solver.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ setupCompiler compiler = do
290290
, soptsSetupInfoYaml = defaultSetupInfoYaml
291291
, soptsGHCBindistURL = Nothing
292292
, soptsGHCJSBootOpts = ["--clean"]
293-
} LevelInfo
293+
}
294294
return dirs
295295

296296
-- | Runs the given inner command with an updated configuration that

src/main/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ setupCmd sco@SetupCmdOpts{..} go@GlobalOpts{..} = loadConfigWithOpts go $ \lc ->
602602
, configCompilerCheck (lcConfig lc)
603603
, Just $ view stackYamlL bc
604604
)
605-
runRIO (loadMiniConfig (lcConfig lc)) $ setup go sco wantedCompiler compilerCheck mstack
605+
runRIO (loadMiniConfig (lcConfig lc)) $ setup sco wantedCompiler compilerCheck mstack
606606
)
607607
Nothing
608608
(Just $ munlockFile lk)

0 commit comments

Comments
 (0)