[OE-core] [PATCH] meson.bbclass: warn if cross property defaults are used

Ross Burton ross.burton at intel.com
Fri Jan 3 18:09:14 UTC 2020


The Meson idiom for checks which require running code on the target
(which isn't possible in cross compilation) is to use a cross property,
which the user can set in the cross file:

if cc_can_run
  rres = cc.run(test_foo_code)
  have_foo = rres.compiled() and rres.returncode() == 0
else
  have_foo = meson.get_cross_property('have_foo', false)
endif

The default value may be overly conservative so we should review every
property and explicitly set them as apppropriate.  oe-core 669ddaf added
a log message when the default value is used, so look for this message
and emit a warning that the user will see.

Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/classes/meson.bbclass | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index 71f9de1a570..6a3c0c55e30 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -158,6 +158,15 @@ meson_do_configure_prepend_class-native() {
     export PKG_CONFIG="pkg-config-native"
 }
 
+python meson_do_qa_configure() {
+    import re
+    warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE)
+    log = open(d.expand("${B}/meson-logs/meson-log.txt")).read()
+    for (prop, value) in warn_re.findall(log):
+        bb.warn("Meson cross property %s used without explicit assignment, defaulting to %s" % (prop, value))
+}
+do_configure[postfuncs] += "meson_do_qa_configure"
+
 do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
 meson_do_compile() {
     ninja -v ${PARALLEL_MAKE}
-- 
2.20.1



More information about the Openembedded-core mailing list