diff options
| -rw-r--r-- | meta/lib/oe/utils.py | 40 |
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 | ||
| 129 | def 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 | |||
| 149 | def 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 | ||
| 130 | def packages_filter_out_system(d): | 170 | def packages_filter_out_system(d): |
| 131 | """ | 171 | """ |
