Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # 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 | |
| 12 | python () { |
| 13 | # Assume at least one var is set. |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 14 | distro_features = set((d.getVar('DISTRO_FEATURES') or '').split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 16 | any_of_distro_features = set((d.getVar('ANY_OF_DISTRO_FEATURES') or '').split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | if any_of_distro_features: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 18 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | required_distro_features = set((d.getVar('REQUIRED_DISTRO_FEATURES') or '').split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | if required_distro_features: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 23 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 27 | conflict_distro_features = set((d.getVar('CONFLICT_DISTRO_FEATURES') or '').split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | if conflict_distro_features: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 29 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | } |