From 7e59ce132303837b05aaa5f173ea2050ac0203f6 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 14 Jul 2022 01:45:28 -0400 Subject: 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". --- Biz/Bild.hs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'Biz/Bild.hs') 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, -- cgit v1.2.3