[bitbake-devel,v3,2/3] utils.py: get_file_layer(): Exit the loop when file is matched

Submitted by Robert Yang on Sept. 9, 2020, 11:55 a.m. | Patch ID: 176199


Message ID 63718406751e3727dceae45aafd19dac448a836f.1599652176.git.liezhi.yang@windriver.com
State New
Headers show

Commit Message

Robert Yang Sept. 9, 2020, 11:55 a.m.
This can make "$ bitbake-layers show-recipes" save about 60% time (14min ->
6min) in my build (more than 3000 recipes)

The command "bitbake-layers show-recipes" calls bb.utils.get_file_layer() with
each recipe, and get_file_layer() compare the file with each item in BBFILES
which makes it very time consuming when there are a lot of recipes and items in
BBFILES. So use BBFILES_PRIORITIZED and exit when file is matched, it doesn't
make sense to go on the loop when file is matched.

And use fnmatchcase to replace of fnmatch since the comparison should be

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
 bitbake/lib/bb/utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index e51b8ca508..5722fced97 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1477,12 +1477,13 @@  def get_file_layer(filename, d):
         return match
     result = None
-    bbfiles = (d.getVar('BBFILES') or '').split()
+    bbfiles = (d.getVar('BBFILES_PRIORITIZED') or '').split()
     bbfilesmatch = False
     for bbfilesentry in bbfiles:
-        if fnmatch.fnmatch(filename, bbfilesentry):
+        if fnmatch.fnmatchcase(filename, bbfilesentry):
             bbfilesmatch = True
             result = path_to_layer(bbfilesentry)
+            break
     if not bbfilesmatch:
         # Probably a bbclass