summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-20 17:58:04 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-21 16:57:43 +0100
commit0aff94023f931a84d21069d92522e0f5338f09a4 (patch)
treecaaf28fbbf2733651110078a8d1c1d2454705da0 /bitbake
parentcc985986f92186ef73b4dd54f20036f3b351b80e (diff)
downloadpoky-0aff94023f931a84d21069d92522e0f5338f09a4.tar.gz
bitbake: cooker: Fix unmatched files handling leading to misleading warnings
Currently if all recipes in a layer are skipped, there are warnings that the BBFILE_PATTERN_ entry didn't match anything. We probably shouldn't do this for skipped recipes. The current code is hard to understand, not least as it passes variables which functions modify by reference rather than giving a return value. Update calc_bbfile_priority() to return values rather than modifying them. Refactor the code to try and make it clearer what its doing and fix the skipped recipe issue by passing in the list of parsed files. The function is complicated by the need to not rerun regex matching more than we ever have to which complicates the flow, it would be easier if we just reran operations multiple times. (Bitbake rev: 969cb27b4d978551817612ff4558bec81cfb655c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/command.py2
-rw-r--r--bitbake/lib/bb/cooker.py80
-rw-r--r--bitbake/lib/bb/tests/cooker.py2
3 files changed, 52 insertions, 32 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 3902ccca71..805ed9216c 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -396,7 +396,7 @@ class CommandsSync:
396 def sortkey(x): 396 def sortkey(x):
397 vfn, _ = x 397 vfn, _ = x
398 realfn, _, mc = bb.cache.virtualfn2realfn(vfn) 398 realfn, _, mc = bb.cache.virtualfn2realfn(vfn)
399 return (-command.cooker.collections[mc].calc_bbfile_priority(realfn), vfn) 399 return (-command.cooker.collections[mc].calc_bbfile_priority(realfn)[0], vfn)
400 400
401 skipdict = OrderedDict(sorted(command.cooker.skiplist.items(), key=sortkey)) 401 skipdict = OrderedDict(sorted(command.cooker.skiplist.items(), key=sortkey))
402 return list(skipdict.items()) 402 return list(skipdict.items())
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index effd02442c..3a58a3a332 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1588,7 +1588,7 @@ class BBCooker:
1588 self.show_appends_with_no_recipes() 1588 self.show_appends_with_no_recipes()
1589 self.handlePrefProviders() 1589 self.handlePrefProviders()
1590 for mc in self.multiconfigs: 1590 for mc in self.multiconfigs:
1591 self.recipecaches[mc].bbfile_priority = self.collections[mc].collection_priorities(self.recipecaches[mc].pkg_fn, self.data) 1591 self.recipecaches[mc].bbfile_priority = self.collections[mc].collection_priorities(self.recipecaches[mc].pkg_fn, self.parser.mcfilelist[mc], self.data)
1592 self.state = state.running 1592 self.state = state.running
1593 1593
1594 # Send an event listing all stamps reachable after parsing 1594 # Send an event listing all stamps reachable after parsing
@@ -1704,14 +1704,11 @@ class CookerCollectFiles(object):
1704 # the shortest. This allows nested layers to be properly evaluated. 1704 # the shortest. This allows nested layers to be properly evaluated.
1705 self.bbfile_config_priorities = sorted(priorities, key=lambda tup: tup[1], reverse=True) 1705 self.bbfile_config_priorities = sorted(priorities, key=lambda tup: tup[1], reverse=True)
1706 1706
1707 def calc_bbfile_priority( self, filename, matched = None ): 1707 def calc_bbfile_priority(self, filename):
1708 for _, _, regex, pri in self.bbfile_config_priorities: 1708 for _, _, regex, pri in self.bbfile_config_priorities:
1709 if regex.match(filename): 1709 if regex.match(filename):
1710 if matched is not None: 1710 return pri, regex
1711 if not regex in matched: 1711 return 0, None
1712 matched.add(regex)
1713 return pri
1714 return 0
1715 1712
1716 def get_bbfiles(self): 1713 def get_bbfiles(self):
1717 """Get list of default .bb files by reading out the current directory""" 1714 """Get list of default .bb files by reading out the current directory"""
@@ -1744,7 +1741,7 @@ class CookerCollectFiles(object):
1744 config.setVar("BBFILES", " ".join(files)) 1741 config.setVar("BBFILES", " ".join(files))
1745 1742
1746 # Sort files by priority 1743 # Sort files by priority
1747 files.sort( key=lambda fileitem: self.calc_bbfile_priority(fileitem) ) 1744 files.sort( key=lambda fileitem: self.calc_bbfile_priority(fileitem)[0] )
1748 1745
1749 if not len(files): 1746 if not len(files):
1750 files = self.get_bbfiles() 1747 files = self.get_bbfiles()
@@ -1866,39 +1863,62 @@ class CookerCollectFiles(object):
1866 filelist.append(filename) 1863 filelist.append(filename)
1867 return tuple(filelist) 1864 return tuple(filelist)
1868 1865
1869 def collection_priorities(self, pkgfns, d): 1866 def collection_priorities(self, pkgfns, fns, d):
1867 # Return the priorities of the entries in pkgfns
1868 # Also check that all the regexes in self.bbfile_config_priorities are used
1869 # (but to do that we need to ensure skipped recipes aren't counted, nor
1870 # collections in BBFILE_PATTERN_IGNORE_EMPTY)
1870 1871
1871 priorities = {} 1872 priorities = {}
1873 seen = set()
1874 matched = set()
1875
1876 matched_regex = set()
1877 unmatched_regex = set()
1878 for _, _, regex, _ in self.bbfile_config_priorities:
1879 unmatched_regex.add(regex)
1872 1880
1873 # Calculate priorities for each file 1881 # Calculate priorities for each file
1874 matched = set()
1875 for p in pkgfns: 1882 for p in pkgfns:
1876 realfn, cls, mc = bb.cache.virtualfn2realfn(p) 1883 realfn, cls, mc = bb.cache.virtualfn2realfn(p)
1877 priorities[p] = self.calc_bbfile_priority(realfn, matched) 1884 priorities[p], regex = self.calc_bbfile_priority(realfn)
1878 1885 if regex in unmatched_regex:
1879 unmatched = set() 1886 matched_regex.add(regex)
1880 for _, _, regex, pri in self.bbfile_config_priorities: 1887 unmatched_regex.remove(regex)
1881 if not regex in matched: 1888 seen.add(realfn)
1882 unmatched.add(regex) 1889 if regex:
1883 1890 matched.add(realfn)
1884 # Don't show the warning if the BBFILE_PATTERN did match .bbappend files 1891
1885 def find_bbappend_match(regex): 1892 if unmatched_regex:
1893 # Account for bbappend files
1886 for b in self.bbappends: 1894 for b in self.bbappends:
1887 (bbfile, append) = b 1895 (bbfile, append) = b
1888 if regex.match(append): 1896 seen.add(append)
1889 # If the bbappend is matched by already "matched set", return False 1897
1890 for matched_regex in matched: 1898 # Account for skipped recipes
1891 if matched_regex.match(append): 1899 seen.update(fns)
1892 return False 1900
1893 return True 1901 seen.difference_update(matched)
1894 return False
1895 1902
1896 for unmatch in unmatched.copy(): 1903 def already_matched(fn):
1897 if find_bbappend_match(unmatch): 1904 for regex in matched_regex:
1898 unmatched.remove(unmatch) 1905 if regex.match(fn):
1906 return True
1907 return False
1908
1909 for unmatch in unmatched_regex.copy():
1910 for fn in seen:
1911 if unmatch.match(fn):
1912 # If the bbappend or file was already matched by another regex, skip it
1913 # e.g. for a layer within a layer, the outer regex could match, the inner
1914 # regex may match nothing and we should warn about that
1915 if already_matched(fn):
1916 continue
1917 unmatched_regex.remove(unmatch)
1918 break
1899 1919
1900 for collection, pattern, regex, _ in self.bbfile_config_priorities: 1920 for collection, pattern, regex, _ in self.bbfile_config_priorities:
1901 if regex in unmatched: 1921 if regex in unmatched_regex:
1902 if d.getVar('BBFILE_PATTERN_IGNORE_EMPTY_%s' % collection) != '1': 1922 if d.getVar('BBFILE_PATTERN_IGNORE_EMPTY_%s' % collection) != '1':
1903 collectlog.warning("No bb files in %s matched BBFILE_PATTERN_%s '%s'" % (self.mc if self.mc else 'default', 1923 collectlog.warning("No bb files in %s matched BBFILE_PATTERN_%s '%s'" % (self.mc if self.mc else 'default',
1904 collection, pattern)) 1924 collection, pattern))
diff --git a/bitbake/lib/bb/tests/cooker.py b/bitbake/lib/bb/tests/cooker.py
index 74c903f010..c82d4b7b81 100644
--- a/bitbake/lib/bb/tests/cooker.py
+++ b/bitbake/lib/bb/tests/cooker.py
@@ -60,7 +60,7 @@ class CookerTest(unittest.TestCase):
60 log_handler = LogHandler() 60 log_handler = LogHandler()
61 logger.addHandler(log_handler) 61 logger.addHandler(log_handler)
62 collection = bb.cooker.CookerCollectFiles(bbfile_config_priorities) 62 collection = bb.cooker.CookerCollectFiles(bbfile_config_priorities)
63 collection.collection_priorities(pkgfns, self.d) 63 collection.collection_priorities(pkgfns, pkgfns, self.d)
64 logger.removeHandler(log_handler) 64 logger.removeHandler(log_handler)
65 65
66 # Should be empty (no generated messages) 66 # Should be empty (no generated messages)