summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-15 22:06:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-20 08:31:28 +0000
commit3a4aeda0fa67ae4a2f8c79e83c734b45dde95543 (patch)
treee420d1a34403c3cc956f79d91a633dcd5c56f797 /bitbake
parent16ad67809b9b9cc67dfa863de7605126793f31ae (diff)
downloadpoky-3a4aeda0fa67ae4a2f8c79e83c734b45dde95543.tar.gz
bitbake: cache/cookerdata: Move recipe parsing functions from cache to databuilder
When 'NoCache' was written, databuilder/cookerdata didn't exist. It does now and the recipe parsing functionality contained in NoCache clearly belongs there, it isn't a cache function. Move those functions, renaming to match the style in databuilder but otherwise not changing functionality for now. Fix up the callers to match (which make it clear this is the right move). (Bitbake rev: 783879319c6a4cf3639fcbf763b964e42f602eca) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake-worker3
-rw-r--r--bitbake/lib/bb/cache.py71
-rw-r--r--bitbake/lib/bb/command.py3
-rw-r--r--bitbake/lib/bb/cooker.py3
-rw-r--r--bitbake/lib/bb/cookerdata.py51
-rw-r--r--bitbake/lib/bb/runqueue.py3
6 files changed, 60 insertions, 74 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 7be39370b3..d54044f361 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -238,7 +238,6 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha
238 os.umask(umask) 238 os.umask(umask)
239 239
240 try: 240 try:
241 bb_cache = bb.cache.NoCache(databuilder)
242 (realfn, virtual, mc) = bb.cache.virtualfn2realfn(fn) 241 (realfn, virtual, mc) = bb.cache.virtualfn2realfn(fn)
243 the_data = databuilder.mcdata[mc] 242 the_data = databuilder.mcdata[mc]
244 the_data.setVar("BB_WORKERCONTEXT", "1") 243 the_data.setVar("BB_WORKERCONTEXT", "1")
@@ -257,7 +256,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha
257 bb.parse.siggen.set_taskhashes(workerdata["newhashes"]) 256 bb.parse.siggen.set_taskhashes(workerdata["newhashes"])
258 ret = 0 257 ret = 0
259 258
260 the_data = bb_cache.loadDataFull(fn, appends) 259 the_data = databuilder.parseRecipe(fn, appends)
261 the_data.setVar('BB_TASKHASH', taskhash) 260 the_data.setVar('BB_TASKHASH', taskhash)
262 the_data.setVar('BB_UNIHASH', unihash) 261 the_data.setVar('BB_UNIHASH', unihash)
263 262
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 988c596c39..4d715e911d 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -280,75 +280,14 @@ def variant2virtual(realfn, variant):
280 return "mc:" + elems[1] + ":" + realfn 280 return "mc:" + elems[1] + ":" + realfn
281 return "virtual:" + variant + ":" + realfn 281 return "virtual:" + variant + ":" + realfn
282 282
283def parse_recipe(bb_data, bbfile, appends, mc=''):
284 """
285 Parse a recipe
286 """
287
288 bb_data.setVar("__BBMULTICONFIG", mc)
289
290 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
291 bb.parse.cached_mtime_noerror(bbfile_loc)
292
293 if appends:
294 bb_data.setVar('__BBAPPEND', " ".join(appends))
295 bb_data = bb.parse.handle(bbfile, bb_data)
296 return bb_data
297
298
299class NoCache(object):
300
301 def __init__(self, databuilder):
302 self.databuilder = databuilder
303 self.data = databuilder.data
304
305 def loadDataFull(self, virtualfn, appends):
306 """
307 Return a complete set of data for fn.
308 To do this, we need to parse the file.
309 """
310 logger.debug("Parsing %s (full)" % virtualfn)
311 (fn, virtual, mc) = virtualfn2realfn(virtualfn)
312 bb_data = self.load_bbfile(virtualfn, appends, virtonly=True)
313 return bb_data[virtual]
314
315 def load_bbfile(self, bbfile, appends, virtonly = False, mc=None):
316 """
317 Load and parse one .bb build file
318 Return the data and whether parsing resulted in the file being skipped
319 """
320
321 if virtonly:
322 (bbfile, virtual, mc) = virtualfn2realfn(bbfile)
323 bb_data = self.databuilder.mcdata[mc].createCopy()
324 bb_data.setVar("__ONLYFINALISE", virtual or "default")
325 datastores = parse_recipe(bb_data, bbfile, appends, mc)
326 return datastores
327
328 if mc is not None:
329 bb_data = self.databuilder.mcdata[mc].createCopy()
330 return parse_recipe(bb_data, bbfile, appends, mc)
331 283
332 bb_data = self.data.createCopy() 284class Cache(object):
333 datastores = parse_recipe(bb_data, bbfile, appends)
334
335 for mc in self.databuilder.mcdata:
336 if not mc:
337 continue
338 bb_data = self.databuilder.mcdata[mc].createCopy()
339 newstores = parse_recipe(bb_data, bbfile, appends, mc)
340 for ns in newstores:
341 datastores["mc:%s:%s" % (mc, ns)] = newstores[ns]
342
343 return datastores
344
345class Cache(NoCache):
346 """ 285 """
347 BitBake Cache implementation 286 BitBake Cache implementation
348 """ 287 """
349 def __init__(self, databuilder, mc, data_hash, caches_array): 288 def __init__(self, databuilder, mc, data_hash, caches_array):
350 super().__init__(databuilder) 289 self.databuilder = databuilder
351 data = databuilder.data 290 self.data = databuilder.data
352 291
353 # Pass caches_array information into Cache Constructor 292 # Pass caches_array information into Cache Constructor
354 # It will be used later for deciding whether we 293 # It will be used later for deciding whether we
@@ -356,7 +295,7 @@ class Cache(NoCache):
356 self.mc = mc 295 self.mc = mc
357 self.logger = PrefixLoggerAdapter("Cache: %s: " % (mc if mc else "default"), logger) 296 self.logger = PrefixLoggerAdapter("Cache: %s: " % (mc if mc else "default"), logger)
358 self.caches_array = caches_array 297 self.caches_array = caches_array
359 self.cachedir = data.getVar("CACHE") 298 self.cachedir = self.data.getVar("CACHE")
360 self.clean = set() 299 self.clean = set()
361 self.checked = set() 300 self.checked = set()
362 self.depends_cache = {} 301 self.depends_cache = {}
@@ -486,7 +425,7 @@ class Cache(NoCache):
486 """Parse the specified filename, returning the recipe information""" 425 """Parse the specified filename, returning the recipe information"""
487 self.logger.debug("Parsing %s", filename) 426 self.logger.debug("Parsing %s", filename)
488 infos = [] 427 infos = []
489 datastores = self.load_bbfile(filename, appends, mc=self.mc) 428 datastores = self.databuilder.parseRecipeVariants(filename, appends, mc=self.mc)
490 depends = [] 429 depends = []
491 variants = [] 430 variants = []
492 # Process the "real" fn last so we can store variants list 431 # Process the "real" fn last so we can store variants list
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index ec86885220..fa9fd054c2 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -567,8 +567,7 @@ class CommandsSync:
567 envdata = bb.cache.parse_recipe(config_data, fn, appendfiles, mc)[''] 567 envdata = bb.cache.parse_recipe(config_data, fn, appendfiles, mc)['']
568 else: 568 else:
569 # Use the standard path 569 # Use the standard path
570 parser = bb.cache.NoCache(command.cooker.databuilder) 570 envdata = command.cooker.databuilder.parseRecipe(fn, appendfiles)
571 envdata = parser.loadDataFull(fn, appendfiles)
572 idx = command.remotedatastores.store(envdata) 571 idx = command.remotedatastores.store(envdata)
573 return DataStoreConnectionHandle(idx) 572 return DataStoreConnectionHandle(idx)
574 parseRecipeFile.readonly = True 573 parseRecipeFile.readonly = True
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 1da2f03197..1af29f217d 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -617,8 +617,7 @@ class BBCooker:
617 617
618 if fn: 618 if fn:
619 try: 619 try:
620 bb_caches = bb.cache.MulticonfigCache(self.databuilder, self.data_hash, self.caches_array) 620 envdata = self.databuilder.parseRecipe(fn, self.collections[mc].get_file_appends(fn))
621 envdata = bb_caches[mc].loadDataFull(fn, self.collections[mc].get_file_appends(fn))
622 except Exception as e: 621 except Exception as e:
623 parselog.exception("Unable to read %s", fn) 622 parselog.exception("Unable to read %s", fn)
624 raise 623 raise
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 8a354fed7c..c322ab2ffb 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -466,3 +466,54 @@ class CookerDataBuilder(object):
466 466
467 return data 467 return data
468 468
469 @staticmethod
470 def _parse_recipe(bb_data, bbfile, appends, mc=''):
471 bb_data.setVar("__BBMULTICONFIG", mc)
472
473 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
474 bb.parse.cached_mtime_noerror(bbfile_loc)
475
476 if appends:
477 bb_data.setVar('__BBAPPEND', " ".join(appends))
478 bb_data = bb.parse.handle(bbfile, bb_data)
479 return bb_data
480
481 def parseRecipeVariants(self, bbfile, appends, virtonly=False, mc=None):
482 """
483 Load and parse one .bb build file
484 Return the data and whether parsing resulted in the file being skipped
485 """
486
487 if virtonly:
488 (bbfile, virtual, mc) = bb.cache.virtualfn2realfn(bbfile)
489 bb_data = self.mcdata[mc].createCopy()
490 bb_data.setVar("__ONLYFINALISE", virtual or "default")
491 datastores = self._parse_recipe(bb_data, bbfile, appends, mc)
492 return datastores
493
494 if mc is not None:
495 bb_data = self.mcdata[mc].createCopy()
496 return self._parse_recipe(bb_data, bbfile, appends, mc)
497
498 bb_data = self.data.createCopy()
499 datastores = self._parse_recipe(bb_data, bbfile, appends)
500
501 for mc in self.mcdata:
502 if not mc:
503 continue
504 bb_data = self.mcdata[mc].createCopy()
505 newstores = self._parse_recipe(bb_data, bbfile, appends, mc)
506 for ns in newstores:
507 datastores["mc:%s:%s" % (mc, ns)] = newstores[ns]
508
509 return datastores
510
511 def parseRecipe(self, virtualfn, appends):
512 """
513 Return a complete set of data for fn.
514 To do this, we need to parse the file.
515 """
516 logger.debug("Parsing %s (full)" % virtualfn)
517 (fn, virtual, mc) = bb.cache.virtualfn2realfn(virtualfn)
518 bb_data = self.parseRecipeVariants(virtualfn, appends, virtonly=True)
519 return bb_data[virtual]
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 338d1fe36f..437f4a185c 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1610,9 +1610,8 @@ class RunQueue:
1610 self.rqexe.finish() 1610 self.rqexe.finish()
1611 1611
1612 def rq_dump_sigfn(self, fn, options): 1612 def rq_dump_sigfn(self, fn, options):
1613 bb_cache = bb.cache.NoCache(self.cooker.databuilder)
1614 mc = bb.runqueue.mc_from_tid(fn) 1613 mc = bb.runqueue.mc_from_tid(fn)
1615 the_data = bb_cache.loadDataFull(fn, self.cooker.collections[mc].get_file_appends(fn)) 1614 the_data = self.cooker.databuilder.parseRecipe(fn, self.cooker.collections[mc].get_file_appends(fn))
1616 siggen = bb.parse.siggen 1615 siggen = bb.parse.siggen
1617 dataCaches = self.rqdata.dataCaches 1616 dataCaches = self.rqdata.dataCaches
1618 siggen.dump_sigfn(fn, dataCaches, options) 1617 siggen.dump_sigfn(fn, dataCaches, options)