summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-28 12:58:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-29 21:58:19 +0100
commit674b49a7f7d28d84eeb7545e567bb4da6b9dcff9 (patch)
tree81f94673d3dceef6081226c87ff78c2bd240a188
parent79253a5668dd6150066a8a89512f65dc940716a9 (diff)
downloadpoky-674b49a7f7d28d84eeb7545e567bb4da6b9dcff9.tar.gz
lib/oe: Use new visitorcode functionality for qa.handle_error()
Early functions like do_recipe_qa (which do_fetch depends upon) reference oe.qa.handle_error() which in turn adds dependencies on ERROR_QA and WARN_QA. This means that ERROR_QA:append = " nothing" will cause literally everything to rebuild and break sstate reuse. Take advantage of new bitbake functionality to add a custom visitorcode function to handle_error which optimises the references into contains expressions which means the ERROR_QA and WARN_QA references are optmised to containing specific strings. This dramatically improves sstate reuse. The qa module has to be imported first since other code in later modules references it and bitbake can't handle the dependency ordering internally without a lot of unwanted complexity. (From OE-Core rev: a911ea9659503e9442a183f366e4545a5efe246e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/__init__.py6
-rw-r--r--meta/lib/oe/qa.py16
2 files changed, 20 insertions, 2 deletions
diff --git a/meta/lib/oe/__init__.py b/meta/lib/oe/__init__.py
index 6eb536ad28..d760481283 100644
--- a/meta/lib/oe/__init__.py
+++ b/meta/lib/oe/__init__.py
@@ -7,6 +7,8 @@
7from pkgutil import extend_path 7from pkgutil import extend_path
8__path__ = extend_path(__path__, __name__) 8__path__ = extend_path(__path__, __name__)
9 9
10BBIMPORTS = ["data", "path", "utils", "types", "package", "packagedata", \ 10# Modules with vistorcode need to go first else anything depending on them won't be
11# processed correctly (e.g. qa)
12BBIMPORTS = ["qa", "data", "path", "utils", "types", "package", "packagedata", \
11 "packagegroup", "sstatesig", "lsb", "cachedpath", "license", \ 13 "packagegroup", "sstatesig", "lsb", "cachedpath", "license", \
12 "qa", "reproducible", "rust", "buildcfg", "go"] 14 "reproducible", "rust", "buildcfg", "go"]
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index f8ae3c743f..e338ad6439 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -4,6 +4,7 @@
4# SPDX-License-Identifier: GPL-2.0-only 4# SPDX-License-Identifier: GPL-2.0-only
5# 5#
6 6
7import ast
7import os, struct, mmap 8import os, struct, mmap
8 9
9class NotELFFileError(Exception): 10class NotELFFileError(Exception):
@@ -186,6 +187,20 @@ def write_error(type, error, d):
186 with open(logfile, "a+") as f: 187 with open(logfile, "a+") as f:
187 f.write("%s: %s [%s]\n" % (p, error, type)) 188 f.write("%s: %s [%s]\n" % (p, error, type))
188 189
190def handle_error_visitorcode(name, args):
191 execs = set()
192 contains = {}
193 warn = None
194 if isinstance(args[0], ast.Constant) and isinstance(args[0].value, str):
195 for i in ["ERROR_QA", "WARN_QA"]:
196 if i not in contains:
197 contains[i] = set()
198 contains[i].add(args[0].value)
199 else:
200 warn = args[0]
201 execs.add(name)
202 return contains, execs, warn
203
189def handle_error(error_class, error_msg, d): 204def handle_error(error_class, error_msg, d):
190 if error_class in (d.getVar("ERROR_QA") or "").split(): 205 if error_class in (d.getVar("ERROR_QA") or "").split():
191 write_error(error_class, error_msg, d) 206 write_error(error_class, error_msg, d)
@@ -198,6 +213,7 @@ def handle_error(error_class, error_msg, d):
198 else: 213 else:
199 bb.note("QA Issue: %s [%s]" % (error_msg, error_class)) 214 bb.note("QA Issue: %s [%s]" % (error_msg, error_class))
200 return True 215 return True
216handle_error.visitorcode = handle_error_visitorcode
201 217
202def add_message(messages, section, new_msg): 218def add_message(messages, section, new_msg):
203 if section not in messages: 219 if section not in messages: