blob: 7b7594751adbd27f417ae4e5ab6a3ea945d55ec3 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: GPL-2.0-only
5#
6
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007import itertools
8
9def is_optional(feature, d):
Andrew Geissler82c905d2020-04-13 13:39:40 -050010 return bool(d.getVarFlag("FEATURE_PACKAGES_%s" % feature, "optional"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011
12def packages(features, d):
13 for feature in features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014 packages = d.getVar("FEATURE_PACKAGES_%s" % feature)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 for pkg in (packages or "").split():
16 yield pkg
17
18def required_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019 req = [feature for feature in features if not is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 return packages(req, d)
21
22def optional_packages(features, d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060023 opt = [feature for feature in features if is_optional(feature, d)]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 return packages(opt, d)
25
26def active_packages(features, d):
27 return itertools.chain(required_packages(features, d),
28 optional_packages(features, d))
29
30def active_recipes(features, d):
31 import oe.packagedata
32
33 for pkg in active_packages(features, d):
34 recipe = oe.packagedata.recipename(pkg, d)
35 if recipe:
36 yield recipe