[libvirt PATCH v3 07/10] ci: Implement 'build' helper action

Erik Skultety eskultet at redhat.com
Mon Mar 15 13:36:30 UTC 2021


On Fri, Mar 12, 2021 at 06:28:19PM +0100, Andrea Bolognani wrote:
> 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 at redhat.com>
> ---
>  ci/helper | 33 ++++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/ci/helper b/ci/helper
> index 8eb521ae40..4a552595df 100755
> --- a/ci/helper
> +++ b/ci/helper
> @@ -55,6 +55,20 @@ 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",

MESON_ARGS are tricky, because --meson-args "-Doption=val" won't work as you'd
expect and that's because argparse cannot handle a dash in the name of the
option value. However, they at least fixed it for the 'key=val' syntax [1], so
I'd suggest giving an example in the help string, how --meson-args should be
specified on the cmdline, otherwise it's confusing why it doesn't work with
the syntax outlined in the help string.

[1] https://github.com/bw2/ConfigArgParse/pull/160

Reviewed-by: Erik Skultety <eskultet at redhat.com>

> +        )
> +        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(
> @@ -72,6 +86,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",
> @@ -115,7 +137,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}",
> @@ -123,6 +145,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")
>  
> @@ -200,6 +228,9 @@ class Application:
>              print(f"cirrus/{host}")
>              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}")
>  
> -- 
> 2.26.2
> 




More information about the libvir-list mailing list