diff options
author | Ben Sima <ben@bsima.me> | 2022-08-05 20:37:55 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2022-08-05 20:37:55 -0400 |
commit | 2e2542c51c74bcfd3b6872de97b8bab7d8d7c90f (patch) | |
tree | bd3aa1f643538eaa58afc849625682d75f8ac043 /Biz/Bild.hs | |
parent | 49b4cf05fba4aff0ca8de92f274bfc5c4752f5e2 (diff) |
Combine GhcLib and GhcExe into just Ghc
Diffstat (limited to 'Biz/Bild.hs')
-rw-r--r-- | Biz/Bild.hs | 44 |
1 files changed, 16 insertions, 28 deletions
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 </ pure Target { builder = Local <| user, - compiler = detectGhcCompiler out, + compiler = Ghc, compilerFlags = map Text.pack @@ -592,14 +590,6 @@ ghcPkgFindModule acc m = do /> 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 |