[OE-core] [meta-oe][PATCH] meson-with-tests: Allows for build time tests of meson

Alexander Kanavin alex.kanavin at gmail.com
Tue Jun 19 21:25:24 UTC 2018


qemu is notoriously fragile, or non-existent for some MACHINEs. If
something fails, the failure should be reported as a warning.

Also, can this be enabled for anything in oe-core that currently
utilizes plain meson? That way the class will actually get used and
tested.

Alex

2018-06-19 22:20 GMT+02:00 Paulo Neves <ptsneves at gmail.com>:
> meson build system has the functionality of setting
> an executable wrapper to run cross-compiled
> binaries. The setting is called exe_wrapper and can
> be defined in the meson.cross file. With a valid
> exe_wrapper meson build system can test if the built
> binary is sane.
>
> Another advantage of setting exe_wrapper setting
> is that we can run the tests defined in the meson
> build system. This way if this class is inherited
> not only are the default targets built, their tests
> will also run and have an opportunity to fail the
> the build at the recipe level if necessary.
>
> The user of this class should not inherit meson
> directly but leave it to this class. This class
> may later be merged into meson.bbclass itself.
>
> Signed-off-by: Paulo Neves <ptsneves at gmail.com>
> ---
>  meta/classes/meson-with-tests.bbclass | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>  create mode 100644 meta/classes/meson-with-tests.bbclass
>
> diff --git a/meta/classes/meson-with-tests.bbclass b/meta/classes/meson-with-tests.bbclass
> new file mode 100644
> index 0000000000..ddaeebc726
> --- /dev/null
> +++ b/meta/classes/meson-with-tests.bbclass
> @@ -0,0 +1,26 @@
> +inherit meson
> +
> +DEPENDS_append += "qemu-native"
> +
> +do_write_config_append() {
> +  #You need to pass qemu with the sysroot path
> +  #arguments, but internally meson uses Popen
> +  #so we could try lists of arguments
> +  #While passing a list directly in the exe_wrapper
> +  #parameter passes the sanity test, it later on
> +  #fails in the actual test run with:
> +  #TypeError: expect bytes or str, not list
> +  #So we create an in here wrapper.
> +  cat > ${WORKDIR}/meson_exe_wrapper.sh << EOF
> +#!/bin/sh
> +qemu-${TARGET_ARCH} -L ${RECIPE_SYSROOT} \$@
> +EOF
> +
> +  chmod u+x ${WORKDIR}/meson_exe_wrapper.sh
> +
> +  sed "/binaries/a\exe_wrapper = '${WORKDIR}/meson_exe_wrapper.sh'" -i ${WORKDIR}/meson.cross
> +}
> +
> +do_compile_append() {
> +  ninja test
> +}
> --
> 2.14.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



More information about the Openembedded-core mailing list