diff options
Diffstat (limited to 'import-layers/yocto-poky/meta/lib/oe/utils.py')
-rw-r--r-- | import-layers/yocto-poky/meta/lib/oe/utils.py | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/import-layers/yocto-poky/meta/lib/oe/utils.py b/import-layers/yocto-poky/meta/lib/oe/utils.py index 330a5ff94..643ab78df 100644 --- a/import-layers/yocto-poky/meta/lib/oe/utils.py +++ b/import-layers/yocto-poky/meta/lib/oe/utils.py @@ -126,6 +126,46 @@ def features_backfill(var,d): if addfeatures: d.appendVar(var, " " + " ".join(addfeatures)) +def all_distro_features(d, features, truevalue="1", falsevalue=""): + """ + Returns truevalue if *all* given features are set in DISTRO_FEATURES, + else falsevalue. The features can be given as single string or anything + that can be turned into a set. + + This is a shorter, more flexible version of + bb.utils.contains("DISTRO_FEATURES", features, truevalue, falsevalue, d). + + Without explicit true/false values it can be used directly where + Python expects a boolean: + if oe.utils.all_distro_features(d, "foo bar"): + bb.fatal("foo and bar are mutually exclusive DISTRO_FEATURES") + + With just a truevalue, it can be used to include files that are meant to be + used only when requested via DISTRO_FEATURES: + require ${@ oe.utils.all_distro_features(d, "foo bar", "foo-and-bar.inc") + """ + return bb.utils.contains("DISTRO_FEATURES", features, truevalue, falsevalue, d) + +def any_distro_features(d, features, truevalue="1", falsevalue=""): + """ + Returns truevalue if at least *one* of the given features is set in DISTRO_FEATURES, + else falsevalue. The features can be given as single string or anything + that can be turned into a set. + + This is a shorter, more flexible version of + bb.utils.contains_any("DISTRO_FEATURES", features, truevalue, falsevalue, d). + + Without explicit true/false values it can be used directly where + Python expects a boolean: + if not oe.utils.any_distro_features(d, "foo bar"): + bb.fatal("foo, bar or both must be set in DISTRO_FEATURES") + + With just a truevalue, it can be used to include files that are meant to be + used only when requested via DISTRO_FEATURES: + require ${@ oe.utils.any_distro_features(d, "foo bar", "foo-or-bar.inc") + + """ + return bb.utils.contains_any("DISTRO_FEATURES", features, truevalue, falsevalue, d) def packages_filter_out_system(d): """ @@ -184,25 +224,30 @@ def multiprocess_exec(commands, function): def init_worker(): signal.signal(signal.SIGINT, signal.SIG_IGN) + fails = [] + + def failures(res): + fails.append(res) + nproc = min(multiprocessing.cpu_count(), len(commands)) pool = bb.utils.multiprocessingpool(nproc, init_worker) - imap = pool.imap(function, commands) try: - res = list(imap) + mapresult = pool.map_async(function, commands, error_callback=failures) + pool.close() pool.join() - results = [] - for result in res: - if result is not None: - results.append(result) - return results - + results = mapresult.get() except KeyboardInterrupt: pool.terminate() pool.join() raise + if fails: + raise fails[0] + + return results + def squashspaces(string): import re return re.sub("\s+", " ", string).strip() |