blob: 9b78b03ef64af1f6c496688423e8d5358041f424 [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 Bishop6e60e8b2018-02-01 10:27:11 -050014 distro_features = (d.getVar('DISTRO_FEATURES') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016 any_of_distro_features = d.getVar('ANY_OF_DISTRO_FEATURES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 if any_of_distro_features:
18 any_of_distro_features = any_of_distro_features.split()
19 if set.isdisjoint(set(any_of_distro_features),set(distro_features)):
Brad Bishop316dfdd2018-06-25 12:45:53 -040020 raise bb.parse.SkipRecipe("one of '%s' needs to be in DISTRO_FEATURES" % any_of_distro_features)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022 required_distro_features = d.getVar('REQUIRED_DISTRO_FEATURES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023 if required_distro_features:
24 required_distro_features = required_distro_features.split()
25 for f in required_distro_features:
26 if f in distro_features:
27 continue
28 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040029 raise bb.parse.SkipRecipe("missing required distro feature '%s' (not in DISTRO_FEATURES)" % f)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031 conflict_distro_features = d.getVar('CONFLICT_DISTRO_FEATURES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 if conflict_distro_features:
33 conflict_distro_features = conflict_distro_features.split()
34 for f in conflict_distro_features:
35 if f in distro_features:
Brad Bishop316dfdd2018-06-25 12:45:53 -040036 raise bb.parse.SkipRecipe("conflicting distro feature '%s' (in DISTRO_FEATURES)" % f)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037}