Skip to contentSkip to conversation

insane: configure option checking

RFC PATCH New Ross Burton 2 participants 4 messages Oct 8, 2013 – Oct 9, 2013

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 insane: configure option checking

Hi,

This is v2 of my unrecognised-configure-options sanity test, that checks for warnings at the end of configure logs and will emit a warning if there are unrecognised options. Useful to detect typos or options that have been removed/renamed.

V2 differs from V1 in that the whitelist can be extended, and defaults to the options commonly used in oe-core classes.

As an example of extending it, xorg-proto-common.inc in my branch has this:

+UNKNOWN_CONFIGURE_WHITELIST += "--without-fop --without-xmlto"

I've also done a full build of core-image-sato with this test enabled, this was the output earlier today: http://pastebin.com/7LCZF55Z. Between some local whitelist patches and the patches I just sent, that list has almost halved in size.

Any thoughts, or does this look good to go?

Ross

#1 lore raw

PATCH 1/1 insane: configure option checking

---
 meta/classes/insane.bbclass |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
meta/classes/insane.bbclass +20 -0
index a784aff..6aaae6b 100644
@@ -42,6 +42,8 @@ ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
 
 ALL_QA = "${WARN_QA} ${ERROR_QA}"
 
+UNKNOWN_CONFIGURE_WHITELIST ?= "--enable-nls --disable-nls --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot"
+
 #
 # dictionary for elf headers
 #
@@ -916,6 +918,24 @@ Missing inherit gettext?""" % (gt, config))
     if not package_qa_check_license(workdir, d):
         bb.fatal("Licensing Error: LIC_FILES_CHKSUM does not match, please fix")
 
+    ###########################################################################
+    # Check unrecognised configure options (with a white list)
+    ###########################################################################
+    if bb.data.inherits_class("autotools", d):
+        bb.note("Checking configure output for unrecognised options")
+        try:
+            flag = "WARNING: unrecognized options:"
+            log = os.path.join(d.getVar('B', True), 'config.log')
+            output = subprocess.check_output(['grep', '-F', flag, log])
+            options = set(map(lambda s: s.strip(' ,'), output.partition(flag)[2].split()))
+            whitelist = set(d.getVar("UNKNOWN_CONFIGURE_WHITELIST", True).split())
+            options -= whitelist
+            if options:
+		pn = d.getVar('PN', True)
+                error_msg = pn + ": configure was passed unrecognised options: " + " ".join(options)
+                package_qa_handle_error("unknown-configure-option", error_msg, d)
+        except subprocess.CalledProcessError:
+            pass
 }
 # The Staging Func, to check all staging
 #addtask qa_staging after do_populate_sysroot before do_build
Signature · 1 line
1.7.10.4
#2 lore raw
Quoted 23 lines · Ross Burton
meta/classes/insane.bbclass +10 -0
+
 ###########################################################################
+    # Check unrecognised configure options (with a white list)
+
 ###########################################################################
+    if bb.data.inherits_class("autotools", d):
+        bb.note("Checking configure output for unrecognised options")
+        try:
+            flag = "WARNING: unrecognized options:"
+            log = os.path.join(d.getVar('B', True), 'config.log')
+            output = subprocess.check_output(['grep', '-F', flag, log])
+            options = set(map(lambda s: s.strip(' ,'),

output.partition(flag)[2].split()))
+ whitelist = set(d.getVar("UNKNOWN_CONFIGURE_WHITELIST",
True).split())

meta/classes/insane.bbclass +4 -0
+            options -= whitelist
+            if options:
+               pn = d.getVar('PN', True)
+                error_msg = pn + ": configure was passed unrecognised

options: " + " ".join(options)
+ package_qa_handle_error("unknown-configure-option",
error_msg, d)

meta/classes/insane.bbclass Missing inherit gettext?""" % (gt, config)) · line 938

Quoted 2 lines
meta/classes/insane.bbclass +2 -0
+        except subprocess.CalledProcessError:
+            pass

Why is the entire block in the try/except rather than just the subprocess.check_output()?

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#3 lore raw
Quoted 2 lines · Chris Larson

Why is the entire block in the try/except rather than just the subprocess.check_output()?

It could easily be just the check_output call if I pull the test into a separate function so it can return after handling the exception (which normally means that no warnings were found). I'm not bothered either way to be honest.

Ross