]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ci: Implement 'build' helper action
authorAndrea Bolognani <abologna@redhat.com>
Fri, 12 Mar 2021 17:00:52 +0000 (18:00 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 15 Mar 2021 17:49:03 +0000 (18:49 +0100)
This simply calls the underlying Makefile target, but allows
additional arguments to be specified in a more convenient and
discoverable way.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
ci/helper

index 1d20afd4a2a6c6e682173608130771cd303467c0..57ebe1f8409496ad55e93e1ca2c83935d17c86b8 100755 (executable)
--- a/ci/helper
+++ b/ci/helper
@@ -42,6 +42,21 @@ class Parser:
             help="use container images with non-default tags",
         )
 
+        # Options that are common to all actions that call the
+        # project's build system
+        mesonparser = argparse.ArgumentParser(add_help=False)
+        mesonparser.add_argument(
+            "--meson-args",
+            default="",
+            help="additional arguments passed to meson "
+                 "(eg --meson-args='-Dopt1=enabled -Dopt2=disabled')",
+        )
+        mesonparser.add_argument(
+            "--ninja-args",
+            default="",
+            help="additional arguments passed to ninja",
+        )
+
         # Options that are common to all actions that use lcitool
         lcitoolparser = argparse.ArgumentParser(add_help=False)
         lcitoolparser.add_argument(
@@ -59,6 +74,14 @@ class Parser:
         )
         subparsers.required = True
 
+        # build action
+        buildparser = subparsers.add_parser(
+            "build",
+            help="run a build in a container",
+            parents=[containerparser, mesonparser],
+        )
+        buildparser.set_defaults(func=Application.action_build)
+
         # shell action
         shellparser = subparsers.add_parser(
             "shell",
@@ -102,7 +125,7 @@ class Application:
             target,
         ]
 
-        if self.args.action == "shell":
+        if self.args.action in ["build", "shell"]:
             args.extend([
                 f"CI_ENGINE={self.args.engine}",
                 f"CI_USER_LOGIN={self.args.login}",
@@ -110,6 +133,12 @@ class Application:
                 f"CI_IMAGE_TAG={self.args.image_tag}",
             ])
 
+        if self.args.action == "build":
+            args.extend([
+                f"CI_MESON_ARGS={self.args.meson_args}",
+                f"CI_NINJA_ARGS={self.args.ninja_args}",
+            ])
+
         if pty.spawn(["make"] + args) != 0:
             sys.exit("error: 'make' failed")
 
@@ -189,6 +218,9 @@ class Application:
 
             self.generate_vars(host)
 
+    def action_build(self):
+        self.make_run(f"ci-build@{self.args.target}")
+
     def action_shell(self):
         self.make_run(f"ci-shell@{self.args.target}")