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 | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 14 | distro_features = (d.getVar('DISTRO_FEATURES') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 16 | any_of_distro_features = d.getVar('ANY_OF_DISTRO_FEATURES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | raise bb.parse.SkipRecipe("one of '%s' needs to be in DISTRO_FEATURES" % any_of_distro_features) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 22 | required_distro_features = d.getVar('REQUIRED_DISTRO_FEATURES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 29 | raise bb.parse.SkipRecipe("missing required distro feature '%s' (not in DISTRO_FEATURES)" % f) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 31 | conflict_distro_features = d.getVar('CONFLICT_DISTRO_FEATURES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 36 | raise bb.parse.SkipRecipe("conflicting distro feature '%s' (in DISTRO_FEATURES)" % f) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 37 | } |