diff mbox series

[2/3] cache: Add support for BB_CACHE_EXTRAVARS

Message ID 20261127174616.2269186-2-richard.purdie@linuxfoundation.org
State New
Headers show
Series [1/3] uihelper: Fix exception when TaskStarted event handler breaks | expand

Commit Message

Richard Purdie Nov. 27, 2026, 5:46 p.m. UTC
This allows the metadata to specify that some variables should be cached on a per
recipe basis.

This is useful for example to allow RECIPE_HOSTTOOLS in OE-Core to error up front
in a build if tools are missing rather than the build failing part way through.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/cache.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/cache.py b/lib/bb/cache.py
index 39d051402e1..492fc75e3ad 100644
--- a/lib/bb/cache.py
+++ b/lib/bb/cache.py
@@ -27,7 +27,7 @@  import shutil
 
 logger = logging.getLogger("BitBake.Cache")
 
-__cache_version__ = "156"
+__cache_version__ = "157"
 
 def getCacheFile(path, filename, mc, data_hash):
     mcspec = ''
@@ -131,6 +131,14 @@  class CoreRecipeInfo(RecipeInfoCommon):
         self.fakerootnoenv    = self.getvar('FAKEROOTNOENV', metadata)
         self.extradepsfunc    = self.getvar('calculate_extra_depends', metadata)
 
+        self.extravars = self.listvar('BB_CACHE_EXTRAVARS', metadata)
+        if self.extravars:
+            for var in self.extravars:
+                val = self.getvar(var, metadata)
+                if val:
+                    bb.warn(str(val))
+                setattr(self, var, self.getvar(var, metadata))
+
     @classmethod
     def init_cacheData(cls, cachedata):
         # CacheData in Core RecipeInfo Class
@@ -168,6 +176,8 @@  class CoreRecipeInfo(RecipeInfoCommon):
         cachedata.fakerootlogs = {}
         cachedata.extradepsfunc = {}
 
+        cachedata.extravars = {}
+
     def add_cacheData(self, cachedata, fn):
         cachedata.task_deps[fn] = self.task_deps
         cachedata.pkg_fn[fn] = self.pn
@@ -237,6 +247,9 @@  class CoreRecipeInfo(RecipeInfoCommon):
         cachedata.fakerootlogs[fn] = self.fakerootlogs
         cachedata.extradepsfunc[fn] = self.extradepsfunc
 
+        cachedata.extravars[fn] = {}
+        for var in self.extravars:
+            cachedata.extravars[fn][var] = getattr(self, var)
 
 class SiggenRecipeInfo(RecipeInfoCommon):
     __slots__ = ()