Skip to contentSkip to conversation

meson.bbclass: warn if cross property defaults are used

PATCH New Ross Burton 1 participant 1 message Jan 3, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 meson.bbclass: warn if cross property defaults are used

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.

---
 meta/classes/meson.bbclass | 9 +++++++++
 1 file changed, 9 insertions(+)
meta/classes/meson.bbclass +9 -0
index 71f9de1a570..6a3c0c55e30 100644
@@ -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}
Signature · 1 line
2.20.1