Skip to content

Commit

Permalink
Don't allow to specify --hadrian and --config
Browse files Browse the repository at this point in the history
Improves UX wrt #1082
  • Loading branch information
hasufell committed Jun 24, 2024
1 parent d6240af commit 8fb86b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
30 changes: 19 additions & 11 deletions lib-opt/GHCup/OptParse/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Examples:

ghcCompileOpts :: Parser GHCCompileOptions
ghcCompileOpts =
GHCCompileOptions
(\targetGhc bootstrapGhc jobs patches crossTarget addConfArgs setCompile overwriteVer buildFlavour (buildSystem, buildConfig) isolateDir -> GHCCompileOptions {..})
<$> ((GHC.SourceDist <$> option
(eitherReader
(first (const "Not a valid version") . version . T.pack)
Expand Down Expand Up @@ -216,14 +216,6 @@ ghcCompileOpts =
<> (completer $ listCompleter $ fmap show ([1..12] :: [Int]))
)
)
<*> optional
(option
str
(short 'c' <> long "config" <> metavar "CONFIG" <> help
"Absolute path to build config file"
<> completer (bashCompleter "file")
)
)
<*> (optional
(
(fmap Right $ many $ option
Expand Down Expand Up @@ -275,13 +267,29 @@ ghcCompileOpts =
)
)
<*> (
(\b -> if b then Just Hadrian else Nothing) <$> switch
(\b -> (, Nothing) $ if b then Just Hadrian else Nothing) <$> switch
(long "hadrian" <> help "Use the hadrian build system instead of make. Tries to detect by default."
)
<|>
(\b -> if b then Just Make else Nothing) <$> switch
((\b c -> case (b, c) of
-- --make specified
(True, _) -> (Just Make, c)
-- only --config specified... assume make
(False, Just _) -> (Just Make, c)
-- otherwise fall back to runtime detection of build
-- system
(False, _) -> (Nothing, c)) <$> switch
(long "make" <> help "Use the make build system instead of hadrian. Tries to detect by default."
)
<*> optional
(option
str
(short 'c' <> long "config" <> metavar "CONFIG" <> help
"Absolute path to build config file (implies make)"
<> completer (bashCompleter "file")
)
)
)
)
<*> optional
(option
Expand Down
4 changes: 2 additions & 2 deletions test/optparse-test/CompileTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ compileGhcCheckList = mapSecond CompileGHC
)
, (baseCmd <> "-j20", baseOptions{GHC.jobs = Just 20})
, (baseCmd <> "--jobs 10", baseOptions{GHC.jobs = Just 10})
, (baseCmd <> "-c build.mk", baseOptions{GHC.buildConfig = Just "build.mk"})
, (baseCmd <> "--config build.mk", baseOptions{GHC.buildConfig = Just "build.mk"})
, (baseCmd <> "-c build.mk", baseOptions{GHC.buildConfig = Just "build.mk", GHC.buildSystem = Just Make})
, (baseCmd <> "--config build.mk", baseOptions{GHC.buildConfig = Just "build.mk", GHC.buildSystem = Just Make})
#ifdef IS_WINDOWS
, (baseCmd <> "--patch file:c:/example.patch", baseOptions{GHC.patches = Just $ Right [[uri|file:c:/example.patch|]]})
#else
Expand Down

0 comments on commit 8fb86b6

Please sign in to comment.