blob: 391fbe1c9465c423d2e9d80cbbe3ddc009ae72f9 [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 () {
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}