diff options
Diffstat (limited to 'meta/classes')
| -rw-r--r-- | meta/classes/distro_features_check.bbclass | 35 | ||||
| -rw-r--r-- | meta/classes/features_check.bbclass | 85 |
2 files changed, 90 insertions, 30 deletions
diff --git a/meta/classes/distro_features_check.bbclass b/meta/classes/distro_features_check.bbclass index eeaa3b44cb..8124a8ca27 100644 --- a/meta/classes/distro_features_check.bbclass +++ b/meta/classes/distro_features_check.bbclass | |||
| @@ -1,32 +1,7 @@ | |||
| 1 | # Allow checking of required and conflicting DISTRO_FEATURES | 1 | # Temporarily provide fallback to the old name of the class |
| 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 | 2 | ||
| 12 | python () { | 3 | python __anonymous() { |
| 13 | # Assume at least one var is set. | 4 | bb.warn("distro_features_check.bbclass is deprecated, please use features_check.bbclass instead") |
| 14 | distro_features = set((d.getVar('DISTRO_FEATURES') or '').split()) | ||
| 15 | |||
| 16 | any_of_distro_features = set((d.getVar('ANY_OF_DISTRO_FEATURES') or '').split()) | ||
| 17 | if any_of_distro_features: | ||
| 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)) | ||
| 20 | |||
| 21 | required_distro_features = set((d.getVar('REQUIRED_DISTRO_FEATURES') or '').split()) | ||
| 22 | if required_distro_features: | ||
| 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))) | ||
| 26 | |||
| 27 | conflict_distro_features = set((d.getVar('CONFLICT_DISTRO_FEATURES') or '').split()) | ||
| 28 | if conflict_distro_features: | ||
| 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))) | ||
| 32 | } | 5 | } |
| 6 | |||
| 7 | inherit features_check | ||
diff --git a/meta/classes/features_check.bbclass b/meta/classes/features_check.bbclass new file mode 100644 index 0000000000..391fbe1c94 --- /dev/null +++ b/meta/classes/features_check.bbclass | |||
| @@ -0,0 +1,85 @@ | |||
| 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 | # ANY_OF_MACHINE_FEATURES: ensure at least one item on this list is included | ||
| 10 | # in MACHINE_FEATURES. | ||
| 11 | # REQUIRED_MACHINE_FEATURES: ensure every item on this list is included | ||
| 12 | # in MACHINE_FEATURES. | ||
| 13 | # CONFLICT_MACHINE_FEATURES: ensure no item in this list is included in | ||
| 14 | # MACHINE_FEATURES. | ||
| 15 | # ANY_OF_COMBINED_FEATURES: ensure at least one item on this list is included | ||
| 16 | # in COMBINED_FEATURES. | ||
| 17 | # REQUIRED_COMBINED_FEATURES: ensure every item on this list is included | ||
| 18 | # in COMBINED_FEATURES. | ||
| 19 | # CONFLICT_COMBINED_FEATURES: ensure no item in this list is included in | ||
| 20 | # COMBINED_FEATURES. | ||
| 21 | # | ||
| 22 | # Copyright 2019 (C) Texas Instruments Inc. | ||
| 23 | # Copyright 2013 (C) O.S. Systems Software LTDA. | ||
| 24 | |||
| 25 | python () { | ||
| 26 | # Assume at least one var is set. | ||
| 27 | distro_features = set((d.getVar('DISTRO_FEATURES') or '').split()) | ||
| 28 | |||
| 29 | any_of_distro_features = set((d.getVar('ANY_OF_DISTRO_FEATURES') or '').split()) | ||
| 30 | if any_of_distro_features: | ||
| 31 | if set.isdisjoint(any_of_distro_features, distro_features): | ||
| 32 | raise bb.parse.SkipRecipe("one of '%s' needs to be in DISTRO_FEATURES" % ' '.join(any_of_distro_features)) | ||
| 33 | |||
| 34 | required_distro_features = set((d.getVar('REQUIRED_DISTRO_FEATURES') or '').split()) | ||
| 35 | if required_distro_features: | ||
| 36 | missing = set.difference(required_distro_features, distro_features) | ||
| 37 | if missing: | ||
| 38 | raise bb.parse.SkipRecipe("missing required distro feature%s '%s' (not in DISTRO_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing))) | ||
| 39 | |||
| 40 | conflict_distro_features = set((d.getVar('CONFLICT_DISTRO_FEATURES') or '').split()) | ||
| 41 | if conflict_distro_features: | ||
| 42 | conflicts = set.intersection(conflict_distro_features, distro_features) | ||
| 43 | if conflicts: | ||
| 44 | raise bb.parse.SkipRecipe("conflicting distro feature%s '%s' (in DISTRO_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts))) | ||
| 45 | |||
| 46 | # Assume at least one var is set. | ||
| 47 | machine_features = set((d.getVar('MACHINE_FEATURES') or '').split()) | ||
| 48 | |||
| 49 | any_of_machine_features = set((d.getVar('ANY_OF_MACHINE_FEATURES') or '').split()) | ||
| 50 | if any_of_machine_features: | ||
| 51 | if set.isdisjoint(any_of_machine_features, machine_features): | ||
| 52 | raise bb.parse.SkipRecipe("one of '%s' needs to be in MACHINE_FEATURES" % ' '.join(any_of_machine_features)) | ||
| 53 | |||
| 54 | required_machine_features = set((d.getVar('REQUIRED_MACHINE_FEATURES') or '').split()) | ||
| 55 | if required_machine_features: | ||
| 56 | missing = set.difference(required_machine_features, machine_features) | ||
| 57 | if missing: | ||
| 58 | raise bb.parse.SkipRecipe("missing required machine feature%s '%s' (not in MACHINE_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing))) | ||
| 59 | |||
| 60 | conflict_machine_features = set((d.getVar('CONFLICT_MACHINE_FEATURES') or '').split()) | ||
| 61 | if conflict_machine_features: | ||
| 62 | conflicts = set.intersection(conflict_machine_features, machine_features) | ||
| 63 | if conflicts: | ||
| 64 | raise bb.parse.SkipRecipe("conflicting machine feature%s '%s' (in MACHINE_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts))) | ||
| 65 | |||
| 66 | # Assume at least one var is set. | ||
| 67 | combined_features = set((d.getVar('COMBINED_FEATURES') or '').split()) | ||
| 68 | |||
| 69 | any_of_combined_features = set((d.getVar('ANY_OF_COMBINED_FEATURES') or '').split()) | ||
| 70 | if any_of_combined_features: | ||
| 71 | if set.isdisjoint(any_of_combined_features, combined_features): | ||
| 72 | raise bb.parse.SkipRecipe("one of '%s' needs to be in COMBINED_FEATURES" % ' '.join(any_of_combined_features)) | ||
| 73 | |||
| 74 | required_combined_features = set((d.getVar('REQUIRED_COMBINED_FEATURES') or '').split()) | ||
| 75 | if required_combined_features: | ||
| 76 | missing = set.difference(required_combined_features, combined_features) | ||
| 77 | if missing: | ||
| 78 | raise bb.parse.SkipRecipe("missing required machine feature%s '%s' (not in COMBINED_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing))) | ||
| 79 | |||
| 80 | conflict_combined_features = set((d.getVar('CONFLICT_COMBINED_FEATURES') or '').split()) | ||
| 81 | if conflict_combined_features: | ||
| 82 | conflicts = set.intersection(conflict_combined_features, combined_features) | ||
| 83 | if conflicts: | ||
| 84 | raise bb.parse.SkipRecipe("conflicting machine feature%s '%s' (in COMBINED_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts))) | ||
| 85 | } | ||
