summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-30 22:28:56 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-01-26 21:50:31 +0000
commit557aab215884d10839fa24f797890c99f38e97b2 (patch)
treecc3429ed11f8478db4302c9979d80996555f577c
parent95f4795660f6a66ec2f6b94a822775516bcdd882 (diff)
downloadpoky-557aab215884d10839fa24f797890c99f38e97b2.tar.gz
bitbake: cache/codeparser: Switch to a new BB_CACHEDIR variable for cache location
Currently the codeparser cache is set from CACHE, which is typically in bitbake.conf which means we can't read/write any cache until it is found/read. We may well have python expressions to parse before that happens. The net result is suboptimal functioning of the codeparser cache since it will often be invalidated by data that is never written. This patch changes the codeparser and filechecksum caches to use BB_CACHE as their setting and defaults it to ${TOPDIR}/cache. The patch doesn't change where the "persistent" data such as prserver and hash-equiavalance resides (PERSISTENT_DIR) or where the metadata parsing cache resists (still currently CACHE). I've left those for a later patch. The patch does ensure data parsed by the core datastore parsing calls is written back since this is now much more useful after this change. (Bitbake rev: ee89ade5b5a4cf9c53f336d8b800e06fbe436628) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/cache.py7
-rw-r--r--bitbake/lib/bb/codeparser.py8
-rw-r--r--bitbake/lib/bb/cooker.py2
-rw-r--r--bitbake/lib/bb/cookerdata.py9
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py2
5 files changed, 17 insertions, 11 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 8db4e47674..b309775bb9 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -838,11 +838,10 @@ class MultiProcessCache(object):
838 self.cachedata = self.create_cachedata() 838 self.cachedata = self.create_cachedata()
839 self.cachedata_extras = self.create_cachedata() 839 self.cachedata_extras = self.create_cachedata()
840 840
841 def init_cache(self, d, cache_file_name=None): 841 def init_cache(self, cachedir, cache_file_name=None):
842 cachedir = (d.getVar("PERSISTENT_DIR") or 842 if not cachedir:
843 d.getVar("CACHE"))
844 if cachedir in [None, '']:
845 return 843 return
844
846 bb.utils.mkdirhier(cachedir) 845 bb.utils.mkdirhier(cachedir)
847 self.cachefile = os.path.join(cachedir, 846 self.cachefile = os.path.join(cachedir,
848 cache_file_name or self.__class__.cache_file_name) 847 cache_file_name or self.__class__.cache_file_name)
diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py
index ecae7b0808..d6b8102585 100644
--- a/bitbake/lib/bb/codeparser.py
+++ b/bitbake/lib/bb/codeparser.py
@@ -184,12 +184,12 @@ class CodeParserCache(MultiProcessCache):
184 self.shellcachelines[h] = cacheline 184 self.shellcachelines[h] = cacheline
185 return cacheline 185 return cacheline
186 186
187 def init_cache(self, d): 187 def init_cache(self, cachedir):
188 # Check if we already have the caches 188 # Check if we already have the caches
189 if self.pythoncache: 189 if self.pythoncache:
190 return 190 return
191 191
192 MultiProcessCache.init_cache(self, d) 192 MultiProcessCache.init_cache(self, cachedir)
193 193
194 # cachedata gets re-assigned in the parent 194 # cachedata gets re-assigned in the parent
195 self.pythoncache = self.cachedata[0] 195 self.pythoncache = self.cachedata[0]
@@ -201,8 +201,8 @@ class CodeParserCache(MultiProcessCache):
201 201
202codeparsercache = CodeParserCache() 202codeparsercache = CodeParserCache()
203 203
204def parser_cache_init(d): 204def parser_cache_init(cachedir):
205 codeparsercache.init_cache(d) 205 codeparsercache.init_cache(cachedir)
206 206
207def parser_cache_save(): 207def parser_cache_save():
208 codeparsercache.save_extras() 208 codeparsercache.save_extras()
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index f28951cce5..c5e9fa2941 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -2268,7 +2268,7 @@ class CookerParser(object):
2268 if hasattr(process, "close"): 2268 if hasattr(process, "close"):
2269 process.close() 2269 process.close()
2270 2270
2271 2271 bb.codeparser.parser_cache_save()
2272 bb.codeparser.parser_cache_savemerge() 2272 bb.codeparser.parser_cache_savemerge()
2273 bb.cache.SiggenRecipeInfo.reset() 2273 bb.cache.SiggenRecipeInfo.reset()
2274 bb.fetch.fetcher_parse_done() 2274 bb.fetch.fetcher_parse_done()
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index c6b5658d75..1658bee93c 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -271,7 +271,6 @@ class CookerDataBuilder(object):
271 if self.data.getVar("BB_WORKERCONTEXT", False) is None and not worker: 271 if self.data.getVar("BB_WORKERCONTEXT", False) is None and not worker:
272 bb.fetch.fetcher_init(self.data) 272 bb.fetch.fetcher_init(self.data)
273 bb.parse.init_parser(self.data) 273 bb.parse.init_parser(self.data)
274 bb.codeparser.parser_cache_init(self.data)
275 274
276 bb.event.fire(bb.event.ConfigParsed(), self.data) 275 bb.event.fire(bb.event.ConfigParsed(), self.data)
277 276
@@ -370,6 +369,11 @@ class CookerDataBuilder(object):
370 data.setVar("TOPDIR", os.path.dirname(os.path.dirname(layerconf))) 369 data.setVar("TOPDIR", os.path.dirname(os.path.dirname(layerconf)))
371 data = parse_config_file(layerconf, data) 370 data = parse_config_file(layerconf, data)
372 371
372 if not data.getVar("BB_CACHEDIR"):
373 data.setVar("BB_CACHEDIR", "${TOPDIR}/cache")
374
375 bb.codeparser.parser_cache_init(data.getVar("BB_CACHEDIR"))
376
373 layers = (data.getVar('BBLAYERS') or "").split() 377 layers = (data.getVar('BBLAYERS') or "").split()
374 broken_layers = [] 378 broken_layers = []
375 379
@@ -473,6 +477,9 @@ class CookerDataBuilder(object):
473 477
474 if not data.getVar("TOPDIR"): 478 if not data.getVar("TOPDIR"):
475 data.setVar("TOPDIR", os.path.abspath(os.getcwd())) 479 data.setVar("TOPDIR", os.path.abspath(os.getcwd()))
480 if not data.getVar("BB_CACHEDIR"):
481 data.setVar("BB_CACHEDIR", "${TOPDIR}/cache")
482 bb.codeparser.parser_cache_init(data.getVar("BB_CACHEDIR"))
476 483
477 data = parse_config_file(os.path.join("conf", "bitbake.conf"), data) 484 data = parse_config_file(os.path.join("conf", "bitbake.conf"), data)
478 485
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index b1cd6b25c2..5a7a6024d1 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -518,7 +518,7 @@ def fetcher_init(d):
518 else: 518 else:
519 raise FetchError("Invalid SRCREV cache policy of: %s" % srcrev_policy) 519 raise FetchError("Invalid SRCREV cache policy of: %s" % srcrev_policy)
520 520
521 _checksum_cache.init_cache(d) 521 _checksum_cache.init_cache(d.getVar("BB_CACHEDIR"))
522 522
523 for m in methods: 523 for m in methods:
524 if hasattr(m, "init"): 524 if hasattr(m, "init"):