Patchwork insane: configure option checking

login
register
mail settings
Submitter Ross Burton
Date Oct. 8, 2013, 2:30 p.m.
Message ID <1381242605-13393-2-git-send-email-ross.burton@intel.com>
Download mbox | patch
Permalink /patch/59501/
State Accepted
Commit 9877df030918b654e45f7d699cc6ff7314970f6f
Headers show

Comments

Ross Burton - Oct. 8, 2013, 2:30 p.m.
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/insane.bbclass |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
Chris Larson - Oct. 9, 2013, 11:17 p.m.
On Tue, Oct 8, 2013 at 7:30 AM, Ross Burton <ross.burton@intel.com> wrote:

> +
>  ###########################################################################
> +    # 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
>

Why is the entire block in the try/except rather than just the
subprocess.check_output()?
Ross Burton - Oct. 9, 2013, 11:33 p.m.
On 10 October 2013 00:17, Chris Larson <clarson@kergoth.com> wrote:
> 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

Patch

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index a784aff..6aaae6b 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -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