ci: Implement 'build' helper action

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>
This commit is contained in:
Andrea Bolognani 2021-03-12 18:00:52 +01:00
parent 897974c0b3
commit f0fd72381d

View File

@ -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}")