Skip to content

Commit 75b65fa

Browse files
committed
Allow to pass additional options to ghcjs-boot
1 parent f0f2e31 commit 75b65fa

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

src/Stack/Setup.hs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ data SetupOpts = SetupOpts
146146
-- ^ Location of the main stack-setup.yaml file
147147
, soptsGHCBindistURL :: !(Maybe String)
148148
-- ^ Alternate GHC binary distribution (requires custom GHCVariant)
149+
, soptsGHCJSBootOpts :: [String]
150+
-- ^ Additional ghcjs-boot options, the default is "--clean"
149151
}
150152
deriving Show
151153
data SetupException = UnsupportedSetupCombo OS Arch
@@ -235,6 +237,7 @@ setupEnv mResolveMissingGHC = do
235237
, soptsResolveMissingGHC = mResolveMissingGHC
236238
, soptsSetupInfoYaml = defaultSetupInfoYaml
237239
, soptsGHCBindistURL = Nothing
240+
, soptsGHCJSBootOpts = ["--clean"]
238241
}
239242

240243
(mghcBin, compilerBuild, _) <- ensureCompiler sopts
@@ -496,7 +499,7 @@ ensureCompiler sopts = do
496499
upgradeCabal menv wc
497500

498501
case mtools of
499-
Just (Just (ToolGhcjs cv), _) -> ensureGhcjsBooted menv cv (soptsInstallIfMissing sopts)
502+
Just (Just (ToolGhcjs cv), _) -> ensureGhcjsBooted menv cv (soptsInstallIfMissing sopts) (soptsGHCJSBootOpts sopts)
500503
_ -> return ()
501504

502505
when (soptsSanityCheck sopts) $ sanityCheck menv wc
@@ -1086,8 +1089,8 @@ installGHCJS si archiveFile archiveType _tempDir destDir = do
10861089
$logStickyDone "Installed GHCJS."
10871090

10881091
ensureGhcjsBooted :: (StackM env m, HasConfig env)
1089-
=> EnvOverride -> CompilerVersion -> Bool -> m ()
1090-
ensureGhcjsBooted menv cv shouldBoot = do
1092+
=> EnvOverride -> CompilerVersion -> Bool -> [String] -> m ()
1093+
ensureGhcjsBooted menv cv shouldBoot bootOpts = do
10911094
eres <- try $ sinkProcessStdout Nothing menv "ghcjs" [] (return ())
10921095
case eres of
10931096
Right () -> return ()
@@ -1117,12 +1120,12 @@ ensureGhcjsBooted menv cv shouldBoot = do
11171120
actualStackYamlExists <- doesFileExist actualStackYaml
11181121
unless actualStackYamlExists $
11191122
fail "Couldn't find GHCJS stack.yaml in old or new location."
1120-
bootGhcjs ghcjsVersion actualStackYaml destDir
1123+
bootGhcjs ghcjsVersion actualStackYaml destDir bootOpts
11211124
Left err -> throwM err
11221125

11231126
bootGhcjs :: StackM env m
1124-
=> Version -> Path Abs File -> Path Abs Dir -> m ()
1125-
bootGhcjs ghcjsVersion stackYaml destDir = do
1127+
=> Version -> Path Abs File -> Path Abs Dir -> [String] -> m ()
1128+
bootGhcjs ghcjsVersion stackYaml destDir bootOpts = do
11261129
envConfig <- loadGhcjsEnvConfig stackYaml (destDir </> $(mkRelDir "bin"))
11271130
menv <- liftIO $ configEnvOverride (view configL envConfig) defaultEnvSettings
11281131
-- Install cabal-install if missing, or if the installed one is old.
@@ -1175,7 +1178,7 @@ bootGhcjs ghcjsVersion stackYaml destDir = do
11751178
"This version is specified by the stack.yaml file included in the ghcjs tarball.\n"
11761179
_ -> return ()
11771180
$logSticky "Booting GHCJS (this will take a long time) ..."
1178-
logProcessStderrStdout Nothing "ghcjs-boot" menv' ["--clean"]
1181+
logProcessStderrStdout Nothing "ghcjs-boot" menv' bootOpts
11791182
$logStickyDone "GHCJS booted."
11801183

11811184
loadGhcjsEnvConfig :: StackM env m

src/Stack/SetupCmd.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ data SetupCmdOpts = SetupCmdOpts
3333
, scoUpgradeCabal :: !Bool
3434
, scoSetupInfoYaml :: !String
3535
, scoGHCBindistURL :: !(Maybe String)
36+
, scoGHCJSBootOpts :: ![String]
37+
, scoGHCJSBootClean :: !Bool
3638
}
3739

3840
setupYamlCompatParser :: OA.Parser String
@@ -67,6 +69,14 @@ setupParser = SetupCmdOpts
6769
(OA.long "ghc-bindist"
6870
<> OA.metavar "URL"
6971
<> OA.help "Alternate GHC binary distribution (requires custom --ghc-variant)"))
72+
<*> OA.many (OA.strOption
73+
(OA.long "ghcjs-boot-options"
74+
<> OA.metavar "GHCJS_BOOT"
75+
<> OA.help "Additional ghcjs-boot options"))
76+
<*> OA.boolFlags True
77+
"ghcjs-boot-clean"
78+
"Control if ghcjs-boot should have --clean option present"
79+
OA.idm
7080
where
7181
readVersion = do
7282
s <- OA.readerAsk
@@ -100,6 +110,7 @@ setup SetupCmdOpts{..} wantedCompiler compilerCheck mstack = do
100110
, soptsResolveMissingGHC = Nothing
101111
, soptsSetupInfoYaml = scoSetupInfoYaml
102112
, soptsGHCBindistURL = scoGHCBindistURL
113+
, soptsGHCJSBootOpts = scoGHCJSBootOpts ++ ["--clean" | scoGHCJSBootClean]
103114
}
104115
let compiler = case wantedCompiler of
105116
GhcVersion _ -> "GHC"

src/Stack/Solver.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,9 @@ setupCompiler compiler = do
301301
, soptsSkipMsys = configSkipMsys config
302302
, soptsUpgradeCabal = False
303303
, soptsResolveMissingGHC = msg
304-
, soptsSetupInfoYaml = defaultSetupInfoYaml
304+
, soptsSetupInfoYaml = defaultSetupInfoYaml
305305
, soptsGHCBindistURL = Nothing
306+
, soptsGHCJSBootOpts = ["--clean"]
306307
}
307308
return dirs
308309

0 commit comments

Comments
 (0)