diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-05-09 13:55:01 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-05-25 13:16:24 +0100 |
commit | 695998f921b691f196825e9067b6db399d691e53 (patch) | |
tree | 29e013e9b3c5046d80974618a3c1e0d841fa1d27 /bitbake/lib/bb/cooker.py | |
parent | 3673a43c22f8adb98945501786077a77a798fb93 (diff) | |
download | poky-695998f921b691f196825e9067b6db399d691e53.tar.gz |
bitbake: cooker: Add FILE_LAYERNAME variable containing the layername for a recipe
There are times when it would be useful for code to know which layer
(or collection in old bitbake terms) it is contained within.
Add support for FILE_LAYERNAME to be set by bitbake when parsing a recipe
so that it is possible to determine this. To do it, we need to pass data
from the cooker into the recipe endpoints, since only the top level cooker
information knows about the layer structure which makes the patch a bit
painful.
The idea is that this would make layer overrides possible:
OVERRIDES .= ":layer-${FILE_LAYERNAME}"
which then opens possibilities like:
WARN_QA:append:layer-core = " patch-fuzz"
as an example where OE-Core could enable specific QA tests only for that
specific layer.
(Bitbake rev: 7090a14b0035842112d073acf7f2ed1a01fdeccf)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 2a0ef28755..0a21f1c2f8 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -643,7 +643,8 @@ class BBCooker: | |||
643 | 643 | ||
644 | if fn: | 644 | if fn: |
645 | try: | 645 | try: |
646 | envdata = self.databuilder.parseRecipe(fn, self.collections[mc].get_file_appends(fn)) | 646 | layername = self.collections[mc].calc_bbfile_priority(fn)[2] |
647 | envdata = self.databuilder.parseRecipe(fn, self.collections[mc].get_file_appends(fn), layername) | ||
647 | except Exception as e: | 648 | except Exception as e: |
648 | parselog.exception("Unable to read %s", fn) | 649 | parselog.exception("Unable to read %s", fn) |
649 | raise | 650 | raise |
@@ -1448,7 +1449,8 @@ class BBCooker: | |||
1448 | 1449 | ||
1449 | bb_caches = bb.cache.MulticonfigCache(self.databuilder, self.data_hash, self.caches_array) | 1450 | bb_caches = bb.cache.MulticonfigCache(self.databuilder, self.data_hash, self.caches_array) |
1450 | 1451 | ||
1451 | infos = bb_caches[mc].parse(fn, self.collections[mc].get_file_appends(fn)) | 1452 | layername = self.collections[mc].calc_bbfile_priority(fn)[2] |
1453 | infos = bb_caches[mc].parse(fn, self.collections[mc].get_file_appends(fn), layername) | ||
1452 | infos = dict(infos) | 1454 | infos = dict(infos) |
1453 | 1455 | ||
1454 | fn = bb.cache.realfn2virtual(fn, cls, mc) | 1456 | fn = bb.cache.realfn2virtual(fn, cls, mc) |
@@ -1833,10 +1835,10 @@ class CookerCollectFiles(object): | |||
1833 | self.bbfile_config_priorities = sorted(priorities, key=lambda tup: tup[1], reverse=True) | 1835 | self.bbfile_config_priorities = sorted(priorities, key=lambda tup: tup[1], reverse=True) |
1834 | 1836 | ||
1835 | def calc_bbfile_priority(self, filename): | 1837 | def calc_bbfile_priority(self, filename): |
1836 | for _, _, regex, pri in self.bbfile_config_priorities: | 1838 | for layername, _, regex, pri in self.bbfile_config_priorities: |
1837 | if regex.match(filename): | 1839 | if regex.match(filename): |
1838 | return pri, regex | 1840 | return pri, regex, layername |
1839 | return 0, None | 1841 | return 0, None, None |
1840 | 1842 | ||
1841 | def get_bbfiles(self): | 1843 | def get_bbfiles(self): |
1842 | """Get list of default .bb files by reading out the current directory""" | 1844 | """Get list of default .bb files by reading out the current directory""" |
@@ -2009,7 +2011,7 @@ class CookerCollectFiles(object): | |||
2009 | # Calculate priorities for each file | 2011 | # Calculate priorities for each file |
2010 | for p in pkgfns: | 2012 | for p in pkgfns: |
2011 | realfn, cls, mc = bb.cache.virtualfn2realfn(p) | 2013 | realfn, cls, mc = bb.cache.virtualfn2realfn(p) |
2012 | priorities[p], regex = self.calc_bbfile_priority(realfn) | 2014 | priorities[p], regex, _ = self.calc_bbfile_priority(realfn) |
2013 | if regex in unmatched_regex: | 2015 | if regex in unmatched_regex: |
2014 | matched_regex.add(regex) | 2016 | matched_regex.add(regex) |
2015 | unmatched_regex.remove(regex) | 2017 | unmatched_regex.remove(regex) |
@@ -2146,7 +2148,7 @@ class Parser(multiprocessing.Process): | |||
2146 | self.results.close() | 2148 | self.results.close() |
2147 | self.results.join_thread() | 2149 | self.results.join_thread() |
2148 | 2150 | ||
2149 | def parse(self, mc, cache, filename, appends): | 2151 | def parse(self, mc, cache, filename, appends, layername): |
2150 | try: | 2152 | try: |
2151 | origfilter = bb.event.LogHandler.filter | 2153 | origfilter = bb.event.LogHandler.filter |
2152 | # Record the filename we're parsing into any events generated | 2154 | # Record the filename we're parsing into any events generated |
@@ -2160,7 +2162,7 @@ class Parser(multiprocessing.Process): | |||
2160 | bb.event.set_class_handlers(self.handlers.copy()) | 2162 | bb.event.set_class_handlers(self.handlers.copy()) |
2161 | bb.event.LogHandler.filter = parse_filter | 2163 | bb.event.LogHandler.filter = parse_filter |
2162 | 2164 | ||
2163 | return True, mc, cache.parse(filename, appends) | 2165 | return True, mc, cache.parse(filename, appends, layername) |
2164 | except Exception as exc: | 2166 | except Exception as exc: |
2165 | tb = sys.exc_info()[2] | 2167 | tb = sys.exc_info()[2] |
2166 | exc.recipe = filename | 2168 | exc.recipe = filename |
@@ -2200,10 +2202,11 @@ class CookerParser(object): | |||
2200 | for mc in self.cooker.multiconfigs: | 2202 | for mc in self.cooker.multiconfigs: |
2201 | for filename in self.mcfilelist[mc]: | 2203 | for filename in self.mcfilelist[mc]: |
2202 | appends = self.cooker.collections[mc].get_file_appends(filename) | 2204 | appends = self.cooker.collections[mc].get_file_appends(filename) |
2205 | layername = self.cooker.collections[mc].calc_bbfile_priority(filename)[2] | ||
2203 | if not self.bb_caches[mc].cacheValid(filename, appends): | 2206 | if not self.bb_caches[mc].cacheValid(filename, appends): |
2204 | self.willparse.add((mc, self.bb_caches[mc], filename, appends)) | 2207 | self.willparse.add((mc, self.bb_caches[mc], filename, appends, layername)) |
2205 | else: | 2208 | else: |
2206 | self.fromcache.add((mc, self.bb_caches[mc], filename, appends)) | 2209 | self.fromcache.add((mc, self.bb_caches[mc], filename, appends, layername)) |
2207 | 2210 | ||
2208 | self.total = len(self.fromcache) + len(self.willparse) | 2211 | self.total = len(self.fromcache) + len(self.willparse) |
2209 | self.toparse = len(self.willparse) | 2212 | self.toparse = len(self.willparse) |
@@ -2314,7 +2317,7 @@ class CookerParser(object): | |||
2314 | self.syncthread.join() | 2317 | self.syncthread.join() |
2315 | 2318 | ||
2316 | def load_cached(self): | 2319 | def load_cached(self): |
2317 | for mc, cache, filename, appends in self.fromcache: | 2320 | for mc, cache, filename, appends, layername in self.fromcache: |
2318 | infos = cache.loadCached(filename, appends) | 2321 | infos = cache.loadCached(filename, appends) |
2319 | yield False, mc, infos | 2322 | yield False, mc, infos |
2320 | 2323 | ||
@@ -2417,9 +2420,10 @@ class CookerParser(object): | |||
2417 | bb.cache.SiggenRecipeInfo.reset() | 2420 | bb.cache.SiggenRecipeInfo.reset() |
2418 | to_reparse = set() | 2421 | to_reparse = set() |
2419 | for mc in self.cooker.multiconfigs: | 2422 | for mc in self.cooker.multiconfigs: |
2420 | to_reparse.add((mc, filename, self.cooker.collections[mc].get_file_appends(filename))) | 2423 | layername = self.cooker.collections[mc].calc_bbfile_priority(filename)[2] |
2424 | to_reparse.add((mc, filename, self.cooker.collections[mc].get_file_appends(filename), layername)) | ||
2421 | 2425 | ||
2422 | for mc, filename, appends in to_reparse: | 2426 | for mc, filename, appends, layername in to_reparse: |
2423 | infos = self.bb_caches[mc].parse(filename, appends) | 2427 | infos = self.bb_caches[mc].parse(filename, appends, layername) |
2424 | for vfn, info_array in infos: | 2428 | for vfn, info_array in infos: |
2425 | self.cooker.recipecaches[mc].add_from_recipeinfo(vfn, info_array) | 2429 | self.cooker.recipecaches[mc].add_from_recipeinfo(vfn, info_array) |