diff options
Diffstat (limited to 'Biz')
-rw-r--r-- | Biz/Bild.hs | 89 | ||||
-rw-r--r-- | Biz/Bild.nix | 1 |
2 files changed, 58 insertions, 32 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index a5495f7..35932b5 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -211,6 +211,8 @@ exitSummary exits = type Dep = String +type Arg = String + data Out = Lib String | Bin String | None deriving (Show, Eq) @@ -388,32 +390,50 @@ analyze hmap ns = case Map.lookup ns hmap of Namespace.Sh -> pure Nothing Namespace.C -> do let out = detectOut (metaOut "//" <|> metaLib "//") contentLines - let sysdeps = detectSysdeps (metaSys "//") contentLines - ("guile_3_0" `elem` sysdeps) - ?. ( pure mempty, - Process.readProcess "guile-config" ["compile"] "" - /> String.words - /> (++ ["-shared", "-fPIC"]) - /> map Text.pack - ) - +> \guileFlags -> - Target - { langdeps = Set.empty, -- c has no lang deps...? - wrapper = Nothing, - compiler = Gcc, - builder = Local <| user, - compilerFlags = - concat - [ [o, dir, Text.pack absPath] ++ guileFlags - | let outable = out /= None, - o <- outable ?: (["-o"], []), - dir <- outable ?: ([Text.pack <| root </> outToPath out], []) - ], - outPath = outToPath out, - .. - } - |> Just - |> pure + let args = detectMeta (metaArg "//") contentLines + let langdeps = detectMeta (metaDep "//") contentLines + langdepFlags <- + if null langdeps + then pure [] + else + Process.readProcess + "pkg-config" + ("--cflags" : Set.toList langdeps) + "" + /> Text.pack + /> Text.words + + let sysdeps = detectMeta (metaSys "//") contentLines + sysdepFlags <- + if null sysdeps + then pure [] + else + Process.readProcess + "pkg-config" + ("--libs" : Set.toList sysdeps) + "" + /> Text.pack + /> Text.words + Target + { langdeps = Set.empty, -- c has no lang deps...? + wrapper = Nothing, + compiler = Gcc, + builder = Local <| user, + compilerFlags = + concat + [ [o, dir, Text.pack absPath] + ++ langdepFlags + ++ sysdepFlags + ++ (map Text.pack <| Set.toList args) + | let outable = out /= None, + o <- outable ?: (["-o"], []), + dir <- outable ?: ([Text.pack <| root </> outToPath out], []) + ], + outPath = outToPath out, + .. + } + |> Just + |> pure Namespace.Hs -> do langdeps <- detectHaskellImports contentLines let out = detectOut (metaOut "--") contentLines @@ -445,7 +465,7 @@ analyze hmap ns = case Map.lookup ns hmap of ], [] ), - sysdeps = detectSysdeps (metaSys "--") contentLines, + sysdeps = detectMeta (metaSys "--") contentLines, outPath = outToPath out, .. } @@ -581,7 +601,7 @@ analyze hmap ns = case Map.lookup ns hmap of |> catMaybes |> head |> fromMaybe None - detectSysdeps m cl = + detectMeta m cl = cl /> Text.unpack /> Regex.match m @@ -737,10 +757,10 @@ logs ns src = nschunk :: Namespace -> Text nschunk = Namespace.toPath .> Text.pack -metaDep :: Regex.RE Char Dep -metaDep = - Regex.string "-- : dep " - *> Regex.many (Regex.psym Char.isAlpha) +metaDep :: [Char] -> Regex.RE Char Dep +metaDep comment = + Regex.string (comment ++ " : dep ") + *> Regex.many (Regex.psym (not <. Char.isSpace)) metaSys :: [Char] -> Regex.RE Char Dep metaSys comment = @@ -759,6 +779,11 @@ metaLib comment = *> Regex.many (Regex.psym (/= ' ')) /> Lib +metaArg :: [Char] -> Regex.RE Char Arg +metaArg comment = + Regex.string (comment ++ " : arg ") + *> Regex.many Regex.anySym + haskellImports :: Regex.RE Char String haskellImports = Regex.string "import" diff --git a/Biz/Bild.nix b/Biz/Bild.nix index b6946c9..ae3201c 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -42,6 +42,7 @@ rec { bildRuntimeDeps = with nixpkgs; [ pkg-config guile_3_0 + SDL private.ghcPackageSetBild rustc gcc |