summaryrefslogtreecommitdiffstats
path: root/meta/classes/features_check.bbclass
diff options
context:
space:
mode:
authorJacob Kroon <jacob.kroon@gmail.com>2020-05-26 07:36:23 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-09 12:13:59 (GMT)
commit3c5f798c5f84f6d3837ad2d2f93256c6e104e9a3 (patch)
treeb266c1f9a862d078be1f42122a5e709530be9d6e /meta/classes/features_check.bbclass
parent0a8251ccf62b83d0ad2762e5cc24d8dc91a7cccc (diff)
downloadpoky-3c5f798c5f84f6d3837ad2d2f93256c6e104e9a3.tar.gz
features_check: Factorize code for checking features
The DISTRO/MACHINE/COMBINED features should be treated identically, so convert the expanded code to a loop. This fixes some of the COMBINED error messages which were previously referring to MACHINE features. There should be no functional changes. (From OE-Core rev: 051f6efd1b2d5c8c11ab91a75a34f6dc04caf211) Signed-off-by: Jacob Kroon <jacob.kroon@gmail.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.bbclass110
1 files changed, 32 insertions, 78 deletions
diff --git a/meta/classes/features_check.bbclass b/meta/classes/features_check.bbclass
index 876d32e..4ba827d 100644
--- a/meta/classes/features_check.bbclass
+++ b/meta/classes/features_check.bbclass
@@ -1,23 +1,13 @@
1# Allow checking of required and conflicting DISTRO_FEATURES 1# Allow checking of required and conflicting features
2# 2#
3# ANY_OF_DISTRO_FEATURES: ensure at least one item on this list is included 3# xxx = [DISTRO,MACHINE,COMBINED]
4# in DISTRO_FEATURES. 4#
5# REQUIRED_DISTRO_FEATURES: ensure every item on this list is included 5# ANY_OF_xxx_FEATURES: ensure at least one item on this list is included
6# in DISTRO_FEATURES. 6# in xxx_FEATURES.
7# CONFLICT_DISTRO_FEATURES: ensure no item in this list is included in 7# REQUIRED_xxx_FEATURES: ensure every item on this list is included
8# DISTRO_FEATURES. 8# in xxx_FEATURES.
9# ANY_OF_MACHINE_FEATURES: ensure at least one item on this list is included 9# CONFLICT_xxx_FEATURES: ensure no item in this list is included in
10# in MACHINE_FEATURES. 10# xxx_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# 11#
22# Copyright 2019 (C) Texas Instruments Inc. 12# Copyright 2019 (C) Texas Instruments Inc.
23# Copyright 2013 (C) O.S. Systems Software LTDA. 13# Copyright 2013 (C) O.S. Systems Software LTDA.
@@ -26,63 +16,27 @@ python () {
26 if d.getVar('PARSE_ALL_RECIPES', False): 16 if d.getVar('PARSE_ALL_RECIPES', False):
27 return 17 return
28 18
29 # Assume at least one var is set. 19 for kind in ['DISTRO', 'MACHINE', 'COMBINED']:
30 distro_features = set((d.getVar('DISTRO_FEATURES') or '').split()) 20 # Assume at least one var is set.
31 21 features = set((d.getVar(kind + '_FEATURES') or '').split())
32 any_of_distro_features = set((d.getVar('ANY_OF_DISTRO_FEATURES') or '').split()) 22
33 if any_of_distro_features: 23 any_of_features = set((d.getVar('ANY_OF_' + kind + '_FEATURES') or '').split())
34 if set.isdisjoint(any_of_distro_features, distro_features): 24 if any_of_features:
35 raise bb.parse.SkipRecipe("one of '%s' needs to be in DISTRO_FEATURES" % ' '.join(any_of_distro_features)) 25 if set.isdisjoint(any_of_features, features):
36 26 raise bb.parse.SkipRecipe("one of '%s' needs to be in %s_FEATURES"
37 required_distro_features = set((d.getVar('REQUIRED_DISTRO_FEATURES') or '').split()) 27 % (' '.join(any_of_features), kind))
38 if required_distro_features: 28
39 missing = set.difference(required_distro_features, distro_features) 29 required_features = set((d.getVar('REQUIRED_' + kind + '_FEATURES') or '').split())
40 if missing: 30 if required_features:
41 raise bb.parse.SkipRecipe("missing required distro feature%s '%s' (not in DISTRO_FEATURES)" % ('s' if len(missing) > 1 else '', ' '.join(missing))) 31 missing = set.difference(required_features, features)
42 32 if missing:
43 conflict_distro_features = set((d.getVar('CONFLICT_DISTRO_FEATURES') or '').split()) 33 raise bb.parse.SkipRecipe("missing required %s feature%s '%s' (not in %s_FEATURES)"
44 if conflict_distro_features: 34 % (kind.lower(), 's' if len(missing) > 1 else '', ' '.join(missing), kind))
45 conflicts = set.intersection(conflict_distro_features, distro_features) 35
46 if conflicts: 36 conflict_features = set((d.getVar('CONFLICT_' + kind + '_FEATURES') or '').split())
47 raise bb.parse.SkipRecipe("conflicting distro feature%s '%s' (in DISTRO_FEATURES)" % ('s' if len(conflicts) > 1 else '', ' '.join(conflicts))) 37 if conflict_features:
48 38 conflicts = set.intersection(conflict_features, features)
49 # Assume at least one var is set. 39 if conflicts:
50 machine_features = set((d.getVar('MACHINE_FEATURES') or '').split()) 40 raise bb.parse.SkipRecipe("conflicting %s feature%s '%s' (in %s_FEATURES)"
51 41 % (kind.lower(), 's' if len(conflicts) > 1 else '', ' '.join(conflicts), kind))
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} 42}