summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/utils.py
diff options
context:
space:
mode:
authorJoshua Watt <jpewhacker@gmail.com>2018-02-12 19:39:58 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-02-16 18:05:40 (GMT)
commitfeded5fe2755fc6523c235fd6e82a0972e197c08 (patch)
tree91d80f0b7121167e9e7822ee6a450d56d6a06e60 /meta/lib/oe/utils.py
parentc723f7c92a15daba5c8ec1d801ce8debb47d59bf (diff)
downloadpoky-feded5fe2755fc6523c235fd6e82a0972e197c08.tar.gz
utils.py: add parallel make helpers
The code to extract the integer number of parallel build threads and construct a new argument from them has started to be copied in multiple locations, so create two new helper utilities to aid recipes. The first helper (parallel_make()) extracts the integer number of parallel build threads from PARALLEL_MAKE. The second (parallel_make_argument()) does the same and then puts the result back into a format string, optionally clamping it to some maximum value. Additionally, rework the oe-core recipes that were manually doing this to use the new helper utilities. (From OE-Core rev: ccd1142d22b31ed85d8823b1bc9e11ccfd72b61f) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/utils.py')
-rw-r--r--meta/lib/oe/utils.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 7a79d75..ec91927 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -156,6 +156,49 @@ def any_distro_features(d, features, truevalue="1", falsevalue=""):
156 """ 156 """
157 return bb.utils.contains_any("DISTRO_FEATURES", features, truevalue, falsevalue, d) 157 return bb.utils.contains_any("DISTRO_FEATURES", features, truevalue, falsevalue, d)
158 158
159def parallel_make(d):
160 """
161 Return the integer value for the number of parallel threads to use when
162 building, scraped out of PARALLEL_MAKE. If no parallelization option is
163 found, returns None
164
165 e.g. if PARALLEL_MAKE = "-j 10", this will return 10 as an integer.
166 """
167 pm = (d.getVar('PARALLEL_MAKE') or '').split()
168 # look for '-j' and throw other options (e.g. '-l') away
169 while pm:
170 opt = pm.pop(0)
171 if opt == '-j':
172 v = pm.pop(0)
173 elif opt.startswith('-j'):
174 v = opt[2:].strip()
175 else:
176 continue
177
178 return int(v)
179
180 return None
181
182def parallel_make_argument(d, fmt, limit=None):
183 """
184 Helper utility to construct a parallel make argument from the number of
185 parallel threads specified in PARALLEL_MAKE.
186
187 Returns the input format string `fmt` where a single '%d' will be expanded
188 with the number of parallel threads to use. If `limit` is specified, the
189 number of parallel threads will be no larger than it. If no parallelization
190 option is found in PARALLEL_MAKE, returns an empty string
191
192 e.g. if PARALLEL_MAKE = "-j 10", parallel_make_argument(d, "-n %d") will return
193 "-n 10"
194 """
195 v = parallel_make(d)
196 if v:
197 if limit:
198 v = max(limit, v)
199 return fmt % v
200 return ''
201
159def packages_filter_out_system(d): 202def packages_filter_out_system(d):
160 """ 203 """
161 Return a list of packages from PACKAGES with the "system" packages such as 204 Return a list of packages from PACKAGES with the "system" packages such as