diff mbox series

[v2] cache: Add support for BB_CACHE_EXTRAVARS

Message ID 20261128084149.2414987-1-richard.purdie@linuxfoundation.org
State New
Headers show
Series [v2] cache: Add support for BB_CACHE_EXTRAVARS | expand

Commit Message

Richard Purdie Nov. 28, 2026, 8:41 a.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 | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/bb/cache.py b/lib/bb/cache.py
index 39d051402e1..67c3f14ccc1 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,11 @@  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:
+                setattr(self, var, self.getvar(var, metadata))
+
     @classmethod
     def init_cacheData(cls, cachedata):
         # CacheData in Core RecipeInfo Class
@@ -168,6 +173,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 +244,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__ = ()