blob: 876d32e3155666e960e643e6941f0d95a514fbea [file] [log] [blame]
Brad Bishop6dbb3162019-11-25 09:41:34 -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# 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
25python () {
Andrew Geissler82c905d2020-04-13 13:39:40 -050026 if d.getVar('PARSE_ALL_RECIPES', False):
27 return
28
Brad Bishop6dbb3162019-11-25 09:41:34 -050029 # Assume at least one var is set.
30 distro_features = set((d.getVar('DISTRO_FEATURES') or '').split())
31
32 any_of_distro_features = set((d.getVar('ANY_OF_DISTRO_FEATURES') or '').split())
33 if any_of_distro_features:
34 if set.isdisjoint(any_of_distro_features, distro_features):
35 raise bb.parse.SkipRecipe("one of '%s' needs to be in DISTRO_FEATURES" % ' '.join(any_of_distro_features))
36
37 required_distro_features = set((d.getVar('REQUIRED_DISTRO_FEATURES') or '').split())
38 if required_distro_features:
39 missing = set.difference(required_distro_features, distro_features)
40 if missing:
41 raise bb.parse.SkipRecipe("missing required distro feature%s '%s' (not in DISTRO_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing)))
42
43 conflict_distro_features = set((d.getVar('CONFLICT_DISTRO_FEATURES') or '').split())
44 if conflict_distro_features:
45 conflicts = set.intersection(conflict_distro_features, distro_features)
46 if conflicts:
47 raise bb.parse.SkipRecipe("conflicting distro feature%s '%s' (in DISTRO_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts)))
48
49 # Assume at least one var is set.
50 machine_features = set((d.getVar('MACHINE_FEATURES') or '').split())
51
52 any_of_machine_features = set((d.getVar('ANY_OF_MACHINE_FEATURES') or '').split())
53 if any_of_machine_features:
54 if set.isdisjoint(any_of_machine_features, machine_features):
55 raise bb.parse.SkipRecipe("one of '%s' needs to be in MACHINE_FEATURES" % ' '.join(any_of_machine_features))
56
57 required_machine_features = set((d.getVar('REQUIRED_MACHINE_FEATURES') or '').split())
58 if required_machine_features:
59 missing = set.difference(required_machine_features, machine_features)
60 if missing:
61 raise bb.parse.SkipRecipe("missing required machine feature%s '%s' (not in MACHINE_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing)))
62
63 conflict_machine_features = set((d.getVar('CONFLICT_MACHINE_FEATURES') or '').split())
64 if conflict_machine_features:
65 conflicts = set.intersection(conflict_machine_features, machine_features)
66 if conflicts:
67 raise bb.parse.SkipRecipe("conflicting machine feature%s '%s' (in MACHINE_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts)))
68
69 # Assume at least one var is set.
70 combined_features = set((d.getVar('COMBINED_FEATURES') or '').split())
71
72 any_of_combined_features = set((d.getVar('ANY_OF_COMBINED_FEATURES') or '').split())
73 if any_of_combined_features:
74 if set.isdisjoint(any_of_combined_features, combined_features):
75 raise bb.parse.SkipRecipe("one of '%s' needs to be in COMBINED_FEATURES" % ' '.join(any_of_combined_features))
76
77 required_combined_features = set((d.getVar('REQUIRED_COMBINED_FEATURES') or '').split())
78 if required_combined_features:
79 missing = set.difference(required_combined_features, combined_features)
80 if missing:
81 raise bb.parse.SkipRecipe("missing required machine feature%s '%s' (not in COMBINED_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing)))
82
83 conflict_combined_features = set((d.getVar('CONFLICT_COMBINED_FEATURES') or '').split())
84 if conflict_combined_features:
85 conflicts = set.intersection(conflict_combined_features, combined_features)
86 if conflicts:
87 raise bb.parse.SkipRecipe("conflicting machine feature%s '%s' (in COMBINED_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts)))
88}