diff options
-rw-r--r-- | Biz/Bild.hs | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 2b7a2e1..2113b5a 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -209,7 +209,11 @@ data Out = Lib String | Bin String | None deriving (Show, Eq) instance Aeson.ToJSON Out where - toJSON out = outdir out |> Text.pack |> Aeson.String + toJSON = + Aeson.String <. Text.pack <. \case + Bin a -> a + Lib a -> a + None -> "" data Compiler = Copy @@ -237,6 +241,8 @@ instance Aeson.ToJSON Compiler where data Target = Target { -- | Output name out :: Out, + -- | Output path (into cabdir) + outPath :: FilePath, -- | Fully qualified namespace partitioned by '.' namespace :: Namespace, -- | Absolute path to file @@ -282,8 +288,8 @@ isBuildableNs = \case ] -- | Emulate the *nix hierarchy in the cabdir. -outdir :: Out -> String -outdir = \case +outToPath :: Out -> FilePath +outToPath = \case Bin o -> "_/bin" </> o Lib o -> "_/lib" </> o None -> mempty @@ -297,8 +303,8 @@ createHier :: String -> IO () createHier root = traverse_ (Dir.createDirectoryIfMissing True) - [ root </> (outdir <| Bin ""), - root </> (outdir <| Lib ""), + [ root </> (outToPath <| Bin ""), + root </> (outToPath <| Lib ""), root </> intdir, root </> nixdir, root </> vardir @@ -375,8 +381,9 @@ analyze hmap ns = case Map.lookup ns hmap of [ [o, dir, Text.pack absPath] ++ guileFlags | let outable = out /= None, o <- outable ?: (["-o"], []), - dir <- outable ?: ([Text.pack <| root </> outdir out], []) + dir <- outable ?: ([Text.pack <| root </> outToPath out], []) ], + outPath = outToPath out, .. } Namespace.Hs -> do @@ -411,7 +418,7 @@ analyze hmap ns = case Map.lookup ns hmap of [ "-main-is", Namespace.toHaskellModule namespace, "-o", - root </> outdir out + root </> outToPath out ], [] ), @@ -421,6 +428,7 @@ analyze hmap ns = case Map.lookup ns hmap of /> Regex.match (metaSys "--") |> catMaybes |> Set.fromList, + outPath = outToPath out, .. } Namespace.Lisp -> do @@ -445,9 +453,10 @@ analyze hmap ns = case Map.lookup ns hmap of "--eval", "(require :asdf)", "--eval", - "(sb-ext:save-lisp-and-die #p\"" <> (root </> outdir out) <> "\" :toplevel #'main :executable t)" + "(sb-ext:save-lisp-and-die #p\"" <> (root </> outToPath out) <> "\" :toplevel #'main :executable t)" ], builder = user <> "@localhost", + outPath = outToPath out, .. } Namespace.Nix -> do @@ -478,6 +487,7 @@ analyze hmap ns = case Map.lookup ns hmap of Text.unpack builder ], out = None, + outPath = outToPath None, .. } Namespace.Scm -> do @@ -504,6 +514,7 @@ analyze hmap ns = case Map.lookup ns hmap of path ], builder = user <> "@localhost", + outPath = outToPath out, .. } Namespace.Rs -> do @@ -520,8 +531,9 @@ analyze hmap ns = case Map.lookup ns hmap of { langdeps = Set.empty, sysdeps = Set.empty, compiler = Rustc, - compilerFlags = map Text.pack [path, "-o", root </> outdir out], + compilerFlags = map Text.pack [path, "-o", root </> outToPath out], builder = user <> "@localhost", + outPath = outToPath out, .. } detectHaskellImports :: [Text] -> IO (Set Dep) @@ -588,7 +600,7 @@ test loud Target {..} = case compiler of run <| Proc { loud = loud, - cmd = root </> outdir out, + cmd = root </> outToPath out, args = ["test"], ns = namespace, onFailure = Log.fail ["test", nschunk namespace] >> Log.br, @@ -629,7 +641,7 @@ build andTest loud analysis = do _ <- proc loud namespace "guild" compilerFlags when (out /= None) <| do writeFile - (root </> outdir out) + (root </> outToPath out) <| Text.pack <| joinWith "\n" @@ -641,8 +653,8 @@ build andTest loud analysis = do <> Namespace.toPath namespace <> " \"$@\"" ] - p <- Dir.getPermissions <| root </> outdir out - Dir.setPermissions (root </> outdir out) (Dir.setOwnerExecutable True p) + p <- Dir.getPermissions <| root </> outToPath out + Dir.setPermissions (root </> outToPath out) (Dir.setOwnerExecutable True p) pure Exit.ExitSuccess NixBuild -> do Log.info ["bild", "nix", builder, nschunk namespace] |