diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-10 14:35:29 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 15:27:17 +0100 |
commit | fd1517e2b51a170f2427122c6b95396db251d827 (patch) | |
tree | dabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/features_check.bbclass | |
parent | 10317912ee319ccf7f83605d438b5cbf9663f296 (diff) | |
download | poky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz |
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take
advantage of new bitbake functionality to check class scope/usage.
(From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/features_check.bbclass')
-rw-r--r-- | meta/classes-recipe/features_check.bbclass | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/meta/classes-recipe/features_check.bbclass b/meta/classes-recipe/features_check.bbclass new file mode 100644 index 0000000000..163a7bc3fc --- /dev/null +++ b/meta/classes-recipe/features_check.bbclass | |||
@@ -0,0 +1,57 @@ | |||
1 | # Allow checking of required and conflicting features | ||
2 | # | ||
3 | # xxx = [DISTRO,MACHINE,COMBINED,IMAGE] | ||
4 | # | ||
5 | # ANY_OF_xxx_FEATURES: ensure at least one item on this list is included | ||
6 | # in xxx_FEATURES. | ||
7 | # REQUIRED_xxx_FEATURES: ensure every item on this list is included | ||
8 | # in xxx_FEATURES. | ||
9 | # CONFLICT_xxx_FEATURES: ensure no item in this list is included in | ||
10 | # xxx_FEATURES. | ||
11 | # | ||
12 | # Copyright 2019 (C) Texas Instruments Inc. | ||
13 | # Copyright 2013 (C) O.S. Systems Software LTDA. | ||
14 | # | ||
15 | # SPDX-License-Identifier: MIT | ||
16 | |||
17 | |||
18 | python () { | ||
19 | if d.getVar('PARSE_ALL_RECIPES', False): | ||
20 | return | ||
21 | |||
22 | unused = True | ||
23 | |||
24 | for kind in ['DISTRO', 'MACHINE', 'COMBINED', 'IMAGE']: | ||
25 | if d.getVar('ANY_OF_' + kind + '_FEATURES') is None and not d.hasOverrides('ANY_OF_' + kind + '_FEATURES') and \ | ||
26 | d.getVar('REQUIRED_' + kind + '_FEATURES') is None and not d.hasOverrides('REQUIRED_' + kind + '_FEATURES') and \ | ||
27 | d.getVar('CONFLICT_' + kind + '_FEATURES') is None and not d.hasOverrides('CONFLICT_' + kind + '_FEATURES'): | ||
28 | continue | ||
29 | |||
30 | unused = False | ||
31 | |||
32 | # Assume at least one var is set. | ||
33 | features = set((d.getVar(kind + '_FEATURES') or '').split()) | ||
34 | |||
35 | any_of_features = set((d.getVar('ANY_OF_' + kind + '_FEATURES') or '').split()) | ||
36 | if any_of_features: | ||
37 | if set.isdisjoint(any_of_features, features): | ||
38 | raise bb.parse.SkipRecipe("one of '%s' needs to be in %s_FEATURES" | ||
39 | % (' '.join(any_of_features), kind)) | ||
40 | |||
41 | required_features = set((d.getVar('REQUIRED_' + kind + '_FEATURES') or '').split()) | ||
42 | if required_features: | ||
43 | missing = set.difference(required_features, features) | ||
44 | if missing: | ||
45 | raise bb.parse.SkipRecipe("missing required %s feature%s '%s' (not in %s_FEATURES)" | ||
46 | % (kind.lower(), 's' if len(missing) > 1 else '', ' '.join(missing), kind)) | ||
47 | |||
48 | conflict_features = set((d.getVar('CONFLICT_' + kind + '_FEATURES') or '').split()) | ||
49 | if conflict_features: | ||
50 | conflicts = set.intersection(conflict_features, features) | ||
51 | if conflicts: | ||
52 | raise bb.parse.SkipRecipe("conflicting %s feature%s '%s' (in %s_FEATURES)" | ||
53 | % (kind.lower(), 's' if len(conflicts) > 1 else '', ' '.join(conflicts), kind)) | ||
54 | |||
55 | if unused: | ||
56 | bb.warn("Recipe inherits features_check but doesn't use it") | ||
57 | } | ||