From 2e2542c51c74bcfd3b6872de97b8bab7d8d7c90f Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 5 Aug 2022 20:37:55 -0400 Subject: Combine GhcLib and GhcExe into just Ghc --- Biz/Bild.hs | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'Biz') diff --git a/Biz/Bild.hs b/Biz/Bild.hs index ea5875f..07a4fee 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -223,8 +223,7 @@ instance Aeson.ToJSON Out where data Compiler = Copy | Gcc - | GhcLib - | GhcExe + | Ghc | Guile | NixBuild | Rustc @@ -236,8 +235,7 @@ instance Aeson.ToJSON Compiler where Aeson.String <. \case Copy -> "cp" Gcc -> "gcc" - GhcLib -> "ghc" - GhcExe -> "ghc" + Ghc -> "ghc" Guile -> "guile" NixBuild -> "nix-build" Rustc -> "rustc" @@ -420,7 +418,7 @@ analyze hmap ns = case Map.lookup ns hmap of Set.fromList /> Set.union acc --- | Some rules for detecting the how to compile a ghc module. If there is an --- out, then we know it's some Exe, otherwise it's a Lib. -detectGhcCompiler :: Out -> Compiler -detectGhcCompiler = \case - Bin _ -> GhcExe - Lib _ -> GhcLib - None -> GhcLib - isFailure :: Exit.ExitCode -> Bool isFailure (Exit.ExitFailure _) = True isFailure Exit.ExitSuccess = False @@ -610,7 +600,7 @@ isSuccess _ = False test :: Bool -> Target -> IO Exit.ExitCode test loud Target {..} = case compiler of - GhcExe -> do + Ghc -> do root <- Env.getEnv "BIZ_ROOT" run <| Proc @@ -624,7 +614,7 @@ test loud Target {..} = case compiler of _ -> Log.warn ["test", nschunk namespace, "unavailable"] >> Log.br - >> pure Exit.ExitSuccess + >> pure (Exit.ExitFailure 1) build :: Bool -> Bool -> Analysis -> IO [Exit.ExitCode] build andTest loud analysis = do @@ -638,19 +628,17 @@ build andTest loud analysis = do label = case out of Bin _ -> "bin" _ -> "lib" - GhcExe -> do - Log.info ["bild", "dev", "ghc-exe", nschunk namespace] - exitcode <- proc loud namespace "ghc" compilerFlags - if andTest && isSuccess exitcode - then test loud target - else pure exitcode - GhcLib -> do - Log.info ["bild", "dev", "ghc-lib", nschunk namespace] - proc - loud - namespace - "ghc" - compilerFlags + Ghc -> case out of + None -> pure Exit.ExitSuccess + Bin _ -> do + Log.info ["bild", "dev", "ghc-exe", nschunk namespace] + exitcode <- proc loud namespace "ghc" compilerFlags + if andTest && isSuccess exitcode + then test loud target + else pure exitcode + Lib _ -> do + Log.info ["bild", "dev", "ghc-lib", nschunk namespace] + proc loud namespace "ghc" compilerFlags Guile -> do Log.info ["bild", "dev", "guile", nschunk namespace] _ <- proc loud namespace "guild" compilerFlags -- cgit v1.2.3