From 140edb96aa4725e5aabc19f7c4a3691e2693aa53 Mon Sep 17 00:00:00 2001 From: Yoann Congal Date: Thu, 29 Feb 2024 10:59:36 +0100 Subject: waf: Improve version parsing to avoid failing on warnings waf uses an inline tar file extracted by the tarfile module. The tarfile module may print a warning when used with default 'filter' argument[0]. When called to get the version, the first time after unpack, the output may look like: # output from lower modules (e.g: warnings from tarfile, ...) waf X.Y.Z ... This patch makes the version parsing more precise by looking at the first line matching "waf ". [0]: https://docs.python.org/3.12/library/tarfile.html#extraction-filters (From OE-Core rev: 643b799a0c11d82907dd82991c19b003fe20a8b0) Signed-off-by: Yoann Congal Signed-off-by: Richard Purdie --- meta/classes-recipe/waf.bbclass | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'meta/classes-recipe') diff --git a/meta/classes-recipe/waf.bbclass b/meta/classes-recipe/waf.bbclass index 70bf3be8fd..01707c8e2c 100644 --- a/meta/classes-recipe/waf.bbclass +++ b/meta/classes-recipe/waf.bbclass @@ -54,11 +54,21 @@ python waf_preconfigure() { wafbin = os.path.join(subsrcdir, 'waf') try: result = subprocess.check_output([python, wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT) - version = result.decode('utf-8').split()[1] - if not bb.utils.is_semver(version): + # Output looks like: + # # output from lower modules (e.g. warnings, ...) + # waf X.Y.Z ... + # So, look for the line starting with "waf " + version = None + for line in result.decode('utf-8').split("\n"): + if line.startswith("waf "): + version = line.split()[1] + break + + if not version or not bb.utils.is_semver(version): bb.warn("Unable to parse \"waf --version\" output. Assuming waf version without bindir/libdir support.") bb.warn("waf·--version·output = \n%s" % result.decode('utf-8')) elif bb.utils.vercmp_string_op(version, "1.8.7", ">="): + bb.note("waf version is high enough to add --bindir and --libdir") d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}") except subprocess.CalledProcessError as e: bb.warn("Unable to execute waf --version, exit code %d. Assuming waf version without bindir/libdir support." % e.returncode) -- cgit v1.2.3-54-g00ecf