Skip to contentSkip to conversation

Add variable-key quality checker

PATCH In review Javier Tia 2 participants 3 messages Nov 24, 2020

lore
Share & tools
lore

Javier Tia

author
#0 lore raw

PATCH 1/1 Add variable-key quality checker

Allow to select between a warning or error message when variable key replace the original key.

---
 lib/bb/data.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
lib/bb/data.py +10 -1
index 0d75d0c1..ca14d64a 100644
@@ -100,7 +100,16 @@ def expandKeys(alterdata, readdata = None):
         if newval is not None:
             val = alterdata.getVar(key, False)
             if val is not None:
-                bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
+                msg = "Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval)
+                error_qa = alterdata.getVar('ERROR_QA', False)
+                warn_qa = alterdata.getVar('WARN_QA', False)
+                if error_qa and 'variable-key' in error_qa:
+                    bb.error(msg)
+                elif warn_qa and 'variable-key' in warn_qa:
+                    bb.warn(msg)
+                else:
+                    bb.warn(msg)
+
         alterdata.renameVar(key, ekey)
 
 def inheritFromOS(d, savedenv, permitted):
Signature · 1 line
2.29.2
#1 lore raw

ERROR_QA and WARN_QA are OE variables, not bitbake ones, and they are space separated lists of words, so would need to be split to be used.

Quoted 39 lines · Javier Tia

Allow to select between a warning or error message when variable key replace the original key.

---
 lib/bb/data.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
lib/bb/data.py +10 -1
index 0d75d0c1..ca14d64a 100644
@@ -100,7 +100,16 @@ def expandKeys(alterdata, readdata = None):
         if newval is not None:
             val = alterdata.getVar(key, False)
             if val is not None:
-                bb.warn("Variable key %s (%s) replaces original key %s
 (%s)." % (key, val, ekey, newval))
+                msg = "Variable key %s (%s) replaces original key %s
 (%s)." % (key, val, ekey, newval)
+                error_qa = alterdata.getVar('ERROR_QA', False)
+                warn_qa = alterdata.getVar('WARN_QA', False)
+                if error_qa and 'variable-key' in error_qa:
+                    bb.error(msg)
+                elif warn_qa and 'variable-key' in warn_qa:
+                    bb.warn(msg)
+                else:
+                    bb.warn(msg)
+
         alterdata.renameVar(key, ekey)

def inheritFromOS(d, savedenv, permitted):
--
2.29.2

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics
author
#2 lore raw

Sorry I don't follow. Should I submit the patch to the [email protected] mailing list?

I have a new modification that works as it's expected:

msg = "Variable key %s (%s) replaces original key %s (%s)." % (key,
val, ekey, newval)
error_qa = alterdata.expand(alterdata.getVar('ERROR_QA', False)) warn_qa = alterdata.expand(alterdata.getVar('WARN_QA', False)) if error_qa is not None and 'variable-key' in error_qa:
bb.error(msg)
elif warn_qa is not None and 'variable-key' in warn_qa:
bb.warn(msg)
else:
bb.warn(msg)

Thanks for considering the patch,
▷ Javier's 🖊

Quoted 48 lines · Christopher Larson

ERROR_QA and WARN_QA are OE variables, not bitbake ones, and they are space separated lists of words, so would need to be split to be used.

On Tue, Nov 24, 2020 at 1:36 PM Javier Tia <[email protected] <mailto:[email protected]>> wrote:

Allow to select between a warning or error message when variable key replace the original key.

<mailto:[email protected]>>
---
 lib/bb/data.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/bb/data.py b/lib/bb/data.py
index 0d75d0c1..ca14d64a 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -100,7 +100,16 @@ def expandKeys(alterdata, readdata = None):
         if newval is not None:
             val = alterdata.getVar(key, False)
             if val is not None:
-                bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
+                msg = "Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval)
+                error_qa = alterdata.getVar('ERROR_QA', False) +                warn_qa = alterdata.getVar('WARN_QA', False) +                if error_qa and 'variable-key' in error_qa:
+                    bb.error(msg)
+                elif warn_qa and 'variable-key' in warn_qa:
+                    bb.warn(msg)
+                else:
+                    bb.warn(msg)
+
         alterdata.renameVar(key, ekey)

 def inheritFromOS(d, savedenv, permitted):
--
2.29.2

Signature · 4 lines
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics