blob: 2419cbb6d3481ee0e64cc1fda2f36cd1cffb1d49 [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):
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008 packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009 if packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010 return bool(d.getVarFlag("FEATURE_PACKAGES_%s" % feature, "optional"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012 return bool(d.getVarFlag("PACKAGE_GROUP_%s" % feature, "optional"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013
14def packages(features, d):
15 for feature in features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016 packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 if not packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050018 packages = d.getVar("PACKAGE_GROUP_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 for pkg in (packages or "").split():
20 yield pkg
21
22def required_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060023 req = [feature for feature in features if not is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 return packages(req, d)
25
26def optional_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060027 opt = [feature for feature in features if is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 return packages(opt, d)
29
30def active_packages(features, d):
31 return itertools.chain(required_packages(features, d),
32 optional_packages(features, d))
33
34def active_recipes(features, d):
35 import oe.packagedata
36
37 for pkg in active_packages(features, d):
38 recipe = oe.packagedata.recipename(pkg, d)
39 if recipe:
40 yield recipe