summaryrefslogtreecommitdiffstats
path: root/meta/classes/features_check.bbclass
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denys@ti.com>2019-11-14 19:40:07 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-11-21 23:08:19 +0000
commit9702544b3e75d761d86cae7e8b36f3f2625b68ce (patch)
treeb8db1573283245d3f7d7c8d9fc32b9bd67c76f14 /meta/classes/features_check.bbclass
parenta616ffebdc6f761635f351432461010de1890b7d (diff)
downloadpoky-9702544b3e75d761d86cae7e8b36f3f2625b68ce.tar.gz
distro_features_check: expand with MACHINE_FEATURES and COMBINED_FEATURES, rename
Besides checking DISTRO_FEATURES for required or conflicting features, being able to check MACHINE_FEATURES and/or COMBINED_FEATURES may also be useful at times. Temporarily support the old class name with a warning about future deprecation. (From OE-Core rev: 5f4875b950ce199e91f99c8e945a0c709166dc14) Signed-off-by: Denys Dmytriyenko <denys@ti.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/features_check.bbclass')
-rw-r--r--meta/classes/features_check.bbclass85
1 files changed, 85 insertions, 0 deletions
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
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}