diff --git a/app/ghcup/GHCup/OptParse/Compile.hs b/app/ghcup/GHCup/OptParse/Compile.hs index f50fb9d..d605597 100644 --- a/app/ghcup/GHCup/OptParse/Compile.hs +++ b/app/ghcup/GHCup/OptParse/Compile.hs @@ -76,7 +76,7 @@ data GHCCompileOptions = GHCCompileOptions , setCompile :: Bool , ovewrwiteVer :: Maybe Version , buildFlavour :: Maybe String - , hadrian :: Bool + , buildSystem :: Maybe BuildSystem , isolateDir :: Maybe FilePath } @@ -268,9 +268,15 @@ ghcCompileOpts = "Set the compile build flavour (this value depends on the build system type: 'make' vs 'hadrian')" ) ) - <*> switch - (long "hadrian" <> help "Use the hadrian build system instead of make (only git versions seem to be properly supported atm)" + <*> ( + (\b -> 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 + (long "make" <> help "Use the make build system instead of hadrian. Tries to detect by default." + ) + ) <*> optional (option (eitherReader isolateParser) @@ -577,7 +583,7 @@ compile compileCommand settings Dirs{..} runAppState runLogger = do patches addConfArgs buildFlavour - hadrian + buildSystem (maybe GHCupInternal IsolateDir isolateDir) GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo let vi = getVersionInfo targetVer GHC dls diff --git a/lib/GHCup/GHC.hs b/lib/GHCup/GHC.hs index df59031..0b05bfe 100644 --- a/lib/GHCup/GHC.hs +++ b/lib/GHCup/GHC.hs @@ -764,7 +764,7 @@ compileGHC :: ( MonadMask m -> Maybe (Either FilePath [URI]) -- ^ patches -> [Text] -- ^ additional args to ./configure -> Maybe String -- ^ build flavour - -> Bool + -> Maybe BuildSystem -> InstallDir -> Excepts '[ AlreadyInstalled @@ -793,7 +793,7 @@ compileGHC :: ( MonadMask m ] m GHCTargetVersion -compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs buildFlavour hadrian installDir +compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs buildFlavour buildSystem installDir = do PlatformRequest { .. } <- lift getPlatformReq GHCupInfo { _ghcupDownloads = dls } <- lift getGHCupInfo @@ -927,11 +927,28 @@ compileGHC targetGhc crossTarget ov bstrap jobs mbuildConfig patches aargs build (mBindist, bmk) <- liftE $ runBuildAction tmpUnpack (do - b <- if hadrian - -- prefer 'tver', because the real version carries out compatibility checks - -- we don't want the user to do funny things with it - then compileHadrianBindist (fromMaybe installVer tver) (fromGHCupPath workdir) ghcdir - else compileMakeBindist (fromMaybe installVer tver) (fromGHCupPath workdir) ghcdir + -- prefer 'tver', because the real version carries out compatibility checks + -- we don't want the user to do funny things with it + let doHadrian = compileHadrianBindist (fromMaybe installVer tver) (fromGHCupPath workdir) ghcdir + doMake = compileMakeBindist (fromMaybe installVer tver) (fromGHCupPath workdir) ghcdir + b <- case buildSystem of + Just Hadrian -> do + lift $ logInfo "Requested to use Hadrian" + liftE doHadrian + Just Make -> do + lift $ logInfo "Requested to use Make" + doMake + Nothing -> do + supportsHadrian <- liftE $ catchE @HadrianNotFound @'[HadrianNotFound] @'[] (\_ -> return False) + $ fmap (const True) + $ findHadrianFile (fromGHCupPath workdir) + if supportsHadrian + then do + lift $ logInfo "Detected Hadrian" + liftE doHadrian + else do + lift $ logInfo "Detected Make" + doMake bmk <- liftIO $ handleIO (\_ -> pure "") $ B.readFile (build_mk $ fromGHCupPath workdir) pure (b, bmk) ) diff --git a/lib/GHCup/Types.hs b/lib/GHCup/Types.hs index e67e720..e71b2a5 100644 --- a/lib/GHCup/Types.hs +++ b/lib/GHCup/Types.hs @@ -719,4 +719,6 @@ instance Pretty ToolVersion where - +data BuildSystem = Hadrian + | Make + deriving (Show, Eq)