From 126d06c332478a1c4e16556b1a0d9fca3d19b6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jelmer=20Vernoo=C4=B3?= Date: Sun, 25 Apr 2021 13:32:32 +0100 Subject: [PATCH] Add really basic Bazel support. --- README.md | 1 + ognibuild/buildsystem.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/README.md b/README.md index 24951b2..5374ac2 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ issues (or lack of support for a particular ecosystem), please file a bug. ### Supported Build Systems +- Bazel - Cabal - Cargo - Golang diff --git a/ognibuild/buildsystem.py b/ognibuild/buildsystem.py index 7b0bd10..113ea41 100644 --- a/ognibuild/buildsystem.py +++ b/ognibuild/buildsystem.py @@ -544,6 +544,35 @@ class SetupPy(BuildSystem): return cls(path) +class Bazel(BuildSystem): + + name = "bazel" + + def __init__(self, path): + self.path = path + + def __repr__(self): + return "%s(%r)" % (type(self).__name__, self.path) + + @classmethod + def exists(cls, path): + if not os.path.exists(os.path.join(path, "BUILD")): + return False + return True + + @classmethod + def probe(cls, path): + if cls.exists(path): + logging.debug("Found BUILD, assuming bazel package.") + return cls(path) + + def build(self, session, resolver, fixers): + run_with_build_fixers(session, ["bazel", "build", "//..."], fixers) + + def test(self, session, resolver, fixers): + run_with_build_fixers(session, ["bazel", "test", "//..."], fixers) + + class Octave(BuildSystem): name = "octave" @@ -1542,6 +1571,7 @@ BUILDSYSTEM_CLSES = [ Golang, R, Octave, + Bazel, # Make is intentionally at the end of the list. Make, Composer,