]> code.ossystems Code Review - openembedded-core.git/commitdiff
license.bbclass: Improve parsing time when INCOMPATIBLE_LICENSES is big
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>
Fri, 12 Mar 2021 03:18:52 +0000 (04:18 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 14 Mar 2021 16:33:03 +0000 (16:33 +0000)
The commit 08cbf1748 (licenses: Update INCOMPATIBLE_LICENSE for
'or-later' handling) increased the parsing time considerably if there
are many licenses in INCOMPATIBLE_LICENSE. Reorganize the code to get
almost all the time back.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/license.bbclass

index bcea0b3cb53e4c6df733992578ac80d2b59d78a2..f7978e266b6aeb5682b54f338eca74a90f3349fd 100644 (file)
@@ -282,16 +282,15 @@ def expand_wildcard_licenses(d, wildcard_licenses):
     """
     import fnmatch
 
-    # Assume if we're passed "GPLv3" or "*GPLv3" it means -or-later as well
-    for lic in wildcard_licenses[:]:
-        if not lic.endswith(("-or-later", "-only", "*")):
-            wildcard_licenses.append(lic + "+")
-
     licenses = wildcard_licenses[:]
     spdxmapkeys = d.getVarFlags('SPDXLICENSEMAP').keys()
     for wld_lic in wildcard_licenses:
         spdxflags = fnmatch.filter(spdxmapkeys, wld_lic)
         licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags]
+        # Assume if we're passed "GPLv3" or "*GPLv3" it means -or-later as well
+        if not wld_lic.endswith(("-or-later", "-only", "*", "+")):
+            spdxflags = fnmatch.filter(spdxmapkeys, wld_lic + "+")
+            licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags]
 
     spdx_lics = d.getVar('AVAILABLE_LICENSES').split()
     for wld_lic in wildcard_licenses: