summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe
diff options
context:
space:
mode:
authorYoann Congal <yoann.congal@smile.fr>2024-02-29 10:59:36 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-03-01 09:31:10 +0000
commit140edb96aa4725e5aabc19f7c4a3691e2693aa53 (patch)
tree5eca4ae10a6c5a4a7344683ae5fcb0d2ef4c3f94 /meta/classes-recipe
parentdeef6a87b564a205f90cafcd7982d78caac008c3 (diff)
downloadpoky-140edb96aa4725e5aabc19f7c4a3691e2693aa53.tar.gz
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 <yoann.congal@smile.fr> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
-rw-r--r--meta/classes-recipe/waf.bbclass14
1 files changed, 12 insertions, 2 deletions
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() {
54 wafbin = os.path.join(subsrcdir, 'waf') 54 wafbin = os.path.join(subsrcdir, 'waf')
55 try: 55 try:
56 result = subprocess.check_output([python, wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT) 56 result = subprocess.check_output([python, wafbin, '--version'], cwd=subsrcdir, stderr=subprocess.STDOUT)
57 version = result.decode('utf-8').split()[1] 57 # Output looks like:
58 if not bb.utils.is_semver(version): 58 # # output from lower modules (e.g. warnings, ...)
59 # waf X.Y.Z ...
60 # So, look for the line starting with "waf "
61 version = None
62 for line in result.decode('utf-8').split("\n"):
63 if line.startswith("waf "):
64 version = line.split()[1]
65 break
66
67 if not version or not bb.utils.is_semver(version):
59 bb.warn("Unable to parse \"waf --version\" output. Assuming waf version without bindir/libdir support.") 68 bb.warn("Unable to parse \"waf --version\" output. Assuming waf version without bindir/libdir support.")
60 bb.warn("waf·--version·output = \n%s" % result.decode('utf-8')) 69 bb.warn("waf·--version·output = \n%s" % result.decode('utf-8'))
61 elif bb.utils.vercmp_string_op(version, "1.8.7", ">="): 70 elif bb.utils.vercmp_string_op(version, "1.8.7", ">="):
71 bb.note("waf version is high enough to add --bindir and --libdir")
62 d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}") 72 d.setVar("WAF_EXTRA_CONF", "--bindir=${bindir} --libdir=${libdir}")
63 except subprocess.CalledProcessError as e: 73 except subprocess.CalledProcessError as e:
64 bb.warn("Unable to execute waf --version, exit code %d. Assuming waf version without bindir/libdir support." % e.returncode) 74 bb.warn("Unable to execute waf --version, exit code %d. Assuming waf version without bindir/libdir support." % e.returncode)