]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
oe/utils: extract method for parallel_make without d context
authorPeter Marko <peter.marko@siemens.com>
Fri, 8 Aug 2025 10:24:11 +0000 (12:24 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 11 Aug 2025 17:03:13 +0000 (18:03 +0100)
oeqa does not have general access to d variable context and needs to
determine parallel make settings.
Extract the code from parallel_make into reusable parallel_make_value.

Also correct function description of return value from None to empty
string.

Signed-off-by: Peter Marko <peter.marko@siemens.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
meta/lib/oe/utils.py

index 779c5e593f452eba68bfb5dab54556d98c4897eb..8aa15373f1966a789210dc7e81bbdf2209d69ca3 100644 (file)
@@ -174,18 +174,14 @@ def any_distro_features(d, features, truevalue="1", falsevalue=""):
     """
     return bb.utils.contains_any("DISTRO_FEATURES", features, truevalue, falsevalue, d)
 
-def parallel_make(d, makeinst=False):
+def parallel_make_value(pm):
     """
     Return the integer value for the number of parallel threads to use when
-    building, scraped out of PARALLEL_MAKE. If no parallelization option is
-    found, returns None
+    building, scraped out of given string. If no parallelization option is
+    found, returns empty string
 
-    e.g. if PARALLEL_MAKE = "-j 10", this will return 10 as an integer.
+    e.g. if string is "-j 10", this will return 10 as an integer.
     """
-    if makeinst:
-        pm = (d.getVar('PARALLEL_MAKEINST') or '').split()
-    else:
-        pm = (d.getVar('PARALLEL_MAKE') or '').split()
     # look for '-j' and throw other options (e.g. '-l') away
     while pm:
         opt = pm.pop(0)
@@ -200,6 +196,20 @@ def parallel_make(d, makeinst=False):
 
     return ''
 
+def parallel_make(d, makeinst=False):
+    """
+    Return the integer value for the number of parallel threads to use when
+    building, scraped out of PARALLEL_MAKE. If no parallelization option is
+    found, returns empty string
+
+    e.g. if PARALLEL_MAKE = "-j 10", this will return 10 as an integer.
+    """
+    if makeinst:
+        pm = (d.getVar('PARALLEL_MAKEINST') or '').split()
+    else:
+        pm = (d.getVar('PARALLEL_MAKE') or '').split()
+    return parallel_make_value(pm)
+
 def parallel_make_argument(d, fmt, limit=None, makeinst=False):
     """
     Helper utility to construct a parallel make argument from the number of