blob: eeaa3b44cb526cb8b1173ac0fb156d912f16cecc [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Allow checking of required and conflicting DISTRO_FEATURES
2#
3# ANY_OF_DISTRO_FEATURES: ensure at least one item on this list is included
4# in DISTRO_FEATURES.
5# REQUIRED_DISTRO_FEATURES: ensure every item on this list is included
6# in DISTRO_FEATURES.
7# CONFLICT_DISTRO_FEATURES: ensure no item in this list is included in
8# DISTRO_FEATURES.
9#
10# Copyright 2013 (C) O.S. Systems Software LTDA.
11
12python () {
13 # Assume at least one var is set.
Brad Bishop19323692019-04-05 15:28:33 -040014 distro_features = set((d.getVar('DISTRO_FEATURES') or '').split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015
Brad Bishop19323692019-04-05 15:28:33 -040016 any_of_distro_features = set((d.getVar('ANY_OF_DISTRO_FEATURES') or '').split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 if any_of_distro_features:
Brad Bishop19323692019-04-05 15:28:33 -040018 if set.isdisjoint(any_of_distro_features, distro_features):
19 raise bb.parse.SkipRecipe("one of '%s' needs to be in DISTRO_FEATURES" % ' '.join(any_of_distro_features))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020
Brad Bishop19323692019-04-05 15:28:33 -040021 required_distro_features = set((d.getVar('REQUIRED_DISTRO_FEATURES') or '').split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 if required_distro_features:
Brad Bishop19323692019-04-05 15:28:33 -040023 missing = set.difference(required_distro_features, distro_features)
24 if missing:
25 raise bb.parse.SkipRecipe("missing required distro feature%s '%s' (not in DISTRO_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026
Brad Bishop19323692019-04-05 15:28:33 -040027 conflict_distro_features = set((d.getVar('CONFLICT_DISTRO_FEATURES') or '').split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 if conflict_distro_features:
Brad Bishop19323692019-04-05 15:28:33 -040029 conflicts = set.intersection(conflict_distro_features, distro_features)
30 if conflicts:
31 raise bb.parse.SkipRecipe("conflicting distro feature%s '%s' (in DISTRO_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032}