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:30:39 +0000
commit643b799a0c11d82907dd82991c19b003fe20a8b0 (patch)
tree782ac9db6a9e8e836160b775146aab0832d7bcca /meta/classes-recipe
parenta741be42bde1624dcd49bb914dfa8b3c00fbe38a (diff)
downloadopenembedded-core-643b799a0c11d82907dd82991c19b003fe20a8b0.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 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() {
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)