Openembedded Core Discussions
 help / color / mirror / Atom feed
* [RFC][PATCH 1/2] features_check: Warn if not used
@ 2020-06-09 14:11 Jacob Kroon
  2020-06-09 14:11 ` [RFC][PATCH 2/2] Don't inherit 'features_check' in recipes that don't utilize it Jacob Kroon
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Jacob Kroon @ 2020-06-09 14:11 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com>
---
 meta/classes/features_check.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/meta/classes/features_check.bbclass b/meta/classes/features_check.bbclass
index 4ba827d4ab..31ce600374 100644
--- a/meta/classes/features_check.bbclass
+++ b/meta/classes/features_check.bbclass
@@ -12,11 +12,25 @@
 # Copyright 2019 (C) Texas Instruments Inc.
 # Copyright 2013 (C) O.S. Systems Software LTDA.
 
+FEATURES_CHECK_INCLUDE_STACK := "${BBINCLUDESTACK}"
+
 python () {
     if d.getVar('PARSE_ALL_RECIPES', False):
         return
 
+    unused = True
+
     for kind in ['DISTRO', 'MACHINE', 'COMBINED']:
+        if d.getVar('ANY_OF_' + kind + '_FEATURES') is None and \
+           d.overridedata.get('ANY_OF_' + kind + '_FEATURES') is None and \
+           d.getVar('REQUIRED_' + kind + '_FEATURES') is None and \
+           d.overridedata.get('REQUIRED_' + kind + '_FEATURES') is None and \
+           d.getVar('CONFLICT_' + kind + '_FEATURES') is None and \
+           d.overridedata.get('CONFLICT_' + kind + '_FEATURES') is None:
+            continue
+
+        unused = False
+
         # Assume at least one var is set.
         features = set((d.getVar(kind + '_FEATURES') or '').split())
 
@@ -39,4 +53,10 @@ python () {
             if conflicts:
                 raise bb.parse.SkipRecipe("conflicting %s feature%s '%s' (in %s_FEATURES)"
                     % (kind.lower(), 's' if len(conflicts) > 1 else '', ' '.join(conflicts), kind))
+
+    # Only warn if inherited directly in a .bb-file; if the class is inherited
+    # via an .inc/.bbclass it could be a false positive
+    inherited_from_bb = d.getVar('FEATURES_CHECK_INCLUDE_STACK').split()[-1].endswith('.bb')
+    if unused and inherited_from_bb:
+        bb.warn("Recipe inherits features_check but doesn't use it")
 }

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-09 16:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-09 14:11 [RFC][PATCH 1/2] features_check: Warn if not used Jacob Kroon
2020-06-09 14:11 ` [RFC][PATCH 2/2] Don't inherit 'features_check' in recipes that don't utilize it Jacob Kroon
2020-06-09 14:31 ` ✗ patchtest: failure for "[RFC] features_check: Warn if ..." and 1 more Patchwork
2020-06-09 14:34 ` [OE-core] [RFC][PATCH 1/2] features_check: Warn if not used Martin Jansa
2020-06-09 15:54   ` Jacob Kroon
2020-06-09 15:44 ` Richard Purdie
2020-06-09 16:00   ` Jacob Kroon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox