]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
lib/oe: Use new visitorcode functionality for qa.handle_error()
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 28 Aug 2024 11:58:30 +0000 (12:58 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 29 Aug 2024 20:57:36 +0000 (21:57 +0100)
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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/__init__.py
meta/lib/oe/qa.py

index 6eb536ad284ca2f028cde2b70e79886aa1edc7fb..d76048128344ef91f0028d774871cfbdda1ea6a2 100644 (file)
@@ -7,6 +7,8 @@
 from pkgutil import extend_path
 __path__ = extend_path(__path__, __name__)
 
-BBIMPORTS = ["data", "path", "utils", "types", "package", "packagedata", \
+# Modules with vistorcode need to go first else anything depending on them won't be
+# processed correctly (e.g. qa)
+BBIMPORTS = ["qa", "data", "path", "utils", "types", "package", "packagedata", \
              "packagegroup", "sstatesig", "lsb", "cachedpath", "license", \
-             "qa", "reproducible", "rust", "buildcfg", "go"]
+             "reproducible", "rust", "buildcfg", "go"]
index f8ae3c743ff5736a486db17c6346716852b31a0a..e338ad6439cdc2b89f8a4a22a82acf87422d7c42 100644 (file)
@@ -4,6 +4,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
+import ast
 import os, struct, mmap
 
 class NotELFFileError(Exception):
@@ -186,6 +187,20 @@ def write_error(type, error, d):
         with open(logfile, "a+") as f:
             f.write("%s: %s [%s]\n" % (p, error, type))
 
+def handle_error_visitorcode(name, args):
+    execs = set()
+    contains = {}
+    warn = None
+    if isinstance(args[0], ast.Constant) and isinstance(args[0].value, str):
+        for i in ["ERROR_QA", "WARN_QA"]:
+            if i not in contains:
+                contains[i] = set()
+            contains[i].add(args[0].value)
+    else:
+        warn = args[0]
+        execs.add(name)
+    return contains, execs, warn
+
 def handle_error(error_class, error_msg, d):
     if error_class in (d.getVar("ERROR_QA") or "").split():
         write_error(error_class, error_msg, d)
@@ -198,6 +213,7 @@ def handle_error(error_class, error_msg, d):
     else:
         bb.note("QA Issue: %s [%s]" % (error_msg, error_class))
     return True
+handle_error.visitorcode = handle_error_visitorcode
 
 def add_message(messages, section, new_msg):
     if section not in messages: