blob: 8fcaecde822d6b1a4160c410cf9c98115ed694b1 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: GPL-2.0-only
3#
4
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005import itertools
6
7def is_optional(feature, d):
Andrew Geissler82c905d2020-04-13 13:39:40 -05008 return bool(d.getVarFlag("FEATURE_PACKAGES_%s" % feature, "optional"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
10def packages(features, d):
11 for feature in features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012 packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013 for pkg in (packages or "").split():
14 yield pkg
15
16def required_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060017 req = [feature for feature in features if not is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018 return packages(req, d)
19
20def optional_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021 opt = [feature for feature in features if is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 return packages(opt, d)
23
24def active_packages(features, d):
25 return itertools.chain(required_packages(features, d),
26 optional_packages(features, d))
27
28def active_recipes(features, d):
29 import oe.packagedata
30
31 for pkg in active_packages(features, d):
32 recipe = oe.packagedata.recipename(pkg, d)
33 if recipe:
34 yield recipe