diff --git a/lib-opt/GHCup/OptParse/Compile.hs b/lib-opt/GHCup/OptParse/Compile.hs index 032a87da..b1678d6a 100644 --- a/lib-opt/GHCup/OptParse/Compile.hs +++ b/lib-opt/GHCup/OptParse/Compile.hs @@ -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) @@ -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 @@ -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 diff --git a/test/optparse-test/CompileTest.hs b/test/optparse-test/CompileTest.hs index 887f05bb..0705f815 100644 --- a/test/optparse-test/CompileTest.hs +++ b/test/optparse-test/CompileTest.hs @@ -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