diff options
author | Ben Sima <ben@bsima.me> | 2022-07-14 01:45:28 -0400 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2022-07-17 19:21:12 -0400 |
commit | 7e59ce132303837b05aaa5f173ea2050ac0203f6 (patch) | |
tree | c815a868136e8d725e3d429f504e91fc05c34dd4 /Biz/Bild.hs | |
parent | 973e67f109f634ce347a1894628a8d551f0ccfbd (diff) |
Add basic Rust support
Support for packages and third-party imports will need to come later once I
figure out how to lookup rust packages by their import statements. Until then,
this works to compile "hello world".
Diffstat (limited to 'Biz/Bild.hs')
-rw-r--r-- | Biz/Bild.hs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index d089048..cba5232 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -209,6 +209,7 @@ data Compiler | GhcjsLib | Guile | NixBuild + | Rustc deriving (Eq, Show, Generic, Aeson.ToJSON) data Target = Target @@ -233,6 +234,7 @@ data Target = Target isBuildableNs :: Namespace -> Bool isBuildableNs (Namespace (x : _) Namespace.Hs) | x /= "Hero" = True isBuildableNs (Namespace _ Namespace.Scm) = True +isBuildableNs (Namespace _ Namespace.Rs) = True isBuildableNs ns | ns `elem` nixTargets = True | otherwise = False @@ -370,6 +372,21 @@ analyze path = do builder = user <> "@localhost", .. } + Namespace.Rs -> do + pure + Target + { langdeps = Set.empty, + sysdeps = Set.empty, + compiler = Rustc, + out = + contentLines + /> Text.unpack + /> Regex.match (metaOut "//") + |> catMaybes + |> head, + builder = user <> "@localhost", + .. + } _ -> pure Target @@ -568,6 +585,23 @@ build andTest loud target@Target {..} = do Copy -> do Log.warn ["bild", "copy", "TODO", nschunk namespace] pure Exit.ExitSuccess + Rustc -> do + Log.info + [ "bild", + "rust", + if Text.null builder + then "local" + else builder, + nschunk namespace + ] + proc + loud + namespace + "rustc" + [ path, + "-o", + root </> bindir </> Maybe.fromJust out + ] data Proc = Proc { loud :: Bool, |