summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-06-09 15:04:04 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-12 15:08:32 +0100
commitbaeafe6dcca69a81357c8e7c3a239bf5d4fffc2c (patch)
treeffdef2f86bbdf894e84d6ae30b52182555627cc0 /meta/lib
parent7b95d5d70172bd1e70748c132d365441c28d54e1 (diff)
downloadpoky-baeafe6dcca69a81357c8e7c3a239bf5d4fffc2c.tar.gz
utils.py: helper function for optional include files
The main intention is to provide easy-to-use and read helper functions for including files only when certain distro features are set. Functionally they are the same as bb.utils.contains and bb.utils.contains_any. Distro features are part of the base configuration and thus safe to use for conditional inclusion in recipes and bbappends, in contrast to recipe variables which might still change during parsing. Therefore the check is limited to DISTRO_FEATURES. This is the reason for having this in OE-core instead of bitbake. Default values are set so that no redundant parameters have to be passed for conditional includes. As a secondary usage, the functions can also be used in boolean checks. (From OE-Core rev: 13024ce5aae453769b546d5fbe533443aec3d6fd) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/utils.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 330a5ff94a..822d0cd586 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -126,6 +126,46 @@ def features_backfill(var,d):
126 if addfeatures: 126 if addfeatures:
127 d.appendVar(var, " " + " ".join(addfeatures)) 127 d.appendVar(var, " " + " ".join(addfeatures))
128 128
129def all_distro_features(d, features, truevalue="1", falsevalue=""):
130 """
131 Returns truevalue if *all* given features are set in DISTRO_FEATURES,
132 else falsevalue. The features can be given as single string or anything
133 that can be turned into a set.
134
135 This is a shorter, more flexible version of
136 bb.utils.contains("DISTRO_FEATURES", features, truevalue, falsevalue, d).
137
138 Without explicit true/false values it can be used directly where
139 Python expects a boolean:
140 if oe.utils.all_distro_features(d, "foo bar"):
141 bb.fatal("foo and bar are mutually exclusive DISTRO_FEATURES")
142
143 With just a truevalue, it can be used to include files that are meant to be
144 used only when requested via DISTRO_FEATURES:
145 require ${@ oe.utils.all_distro_features(d, "foo bar", "foo-and-bar.inc")
146 """
147 return bb.utils.contains("DISTRO_FEATURES", features, truevalue, falsevalue, d)
148
149def any_distro_features(d, features, truevalue="1", falsevalue=""):
150 """
151 Returns truevalue if at least *one* of the given features is set in DISTRO_FEATURES,
152 else falsevalue. The features can be given as single string or anything
153 that can be turned into a set.
154
155 This is a shorter, more flexible version of
156 bb.utils.contains_any("DISTRO_FEATURES", features, truevalue, falsevalue, d).
157
158 Without explicit true/false values it can be used directly where
159 Python expects a boolean:
160 if not oe.utils.any_distro_features(d, "foo bar"):
161 bb.fatal("foo, bar or both must be set in DISTRO_FEATURES")
162
163 With just a truevalue, it can be used to include files that are meant to be
164 used only when requested via DISTRO_FEATURES:
165 require ${@ oe.utils.any_distro_features(d, "foo bar", "foo-or-bar.inc")
166
167 """
168 return bb.utils.contains_any("DISTRO_FEATURES", features, truevalue, falsevalue, d)
129 169
130def packages_filter_out_system(d): 170def packages_filter_out_system(d):
131 """ 171 """