Skip to contentSkip to conversation

parse/ast: Show errors for append/prepend/remove operators combined with +=/.=

PATCH In review Richard Purdie 4 participants 5 messages Nov 4, 2021 – Nov 5, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parse/ast: Show errors for append/prepend/remove operators combined with +=/.=

Operations like XXX:append += "YYY" are almost always wrong and this is a common mistake made in the metadata. Show warnings for these usages with a view to making it a fatal error eventually.

---
 lib/bb/parse/ast.py | 4 ++++
 1 file changed, 4 insertions(+)
lib/bb/parse/ast.py +4 -0
index 743ea0dfc0..93cbf285ef 100644
@@ -130,6 +130,10 @@ class DataNode(AstNode):
         else:
             val = groupd["value"]
 
+        if ":append" in key or ":remove" in key or ":prepend" in key:
+            if op in ["append", "prepend", "postdot", "predot"]:
+                bb.warn(key + " " + groupd[op] + " is not a recommended operator combination, please replace it.")
+
         flag = None
         if 'flag' in groupd and groupd['flag'] is not None:
             flag = groupd['flag']
Signature · 1 line
2.32.0
#1 lore raw
Quoted 14 lines · Richard Purdie

Operations like XXX:append += "YYY" are almost always wrong and this is a common mistake made in the metadata. Show warnings for these usages with a view to making it a fatal error eventually.

---
  lib/bb/parse/ast.py | 4 ++++
  1 file changed, 4 insertions(+)
lib/bb/parse/ast.py +0 -0
index 743ea0dfc0..93cbf285ef 100644

lib/bb/parse/ast.py class DataNode(AstNode): · line 136

Quoted 7 lines
lib/bb/parse/ast.py +4 -0
@@ -130,6 +130,10 @@ class DataNode(AstNode):
          else:
              val = groupd["value"]
 
+        if ":append" in key or ":remove" in key or ":prepend" in key:
+            if op in ["append", "prepend", "postdot", "predot"]:
+                bb.warn(key + " " + groupd[op] + " is not a recommended operator combination, please replace it.")
+

I've seen also weird combinations like

append:remove

with multiple contradicting override operations out in the wild, might be worth to warn about them as well in a follow-up

Quoted 14 lines
lib/bb/parse/ast.py +0 -1
          flag = None
          if 'flag' in groupd and groupd['flag'] is not None:
              flag = groupd['flag']
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#12877): https://lists.openembedded.org/g/bitbake-devel/message/12877
Mute This Topic: https://lists.openembedded.org/mt/86816155/3647476
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Hi all,

Quoted 26 lines · Konrad Weihmann
Quoted 14 lines · Richard Purdie

Operations like XXX:append += "YYY" are almost always wrong and this is a common mistake made in the metadata. Show warnings for these usages with a view to making it a fatal error eventually.

---
  lib/bb/parse/ast.py | 4 ++++
  1 file changed, 4 insertions(+)
lib/bb/parse/ast.py +0 -0
index 743ea0dfc0..93cbf285ef 100644

lib/bb/parse/ast.py class DataNode(AstNode): · line 135

Quoted 6 lines
lib/bb/parse/ast.py +4 -0
@@ -130,6 +130,10 @@ class DataNode(AstNode):
          else:
              val = groupd["value"]
+        if ":append" in key or ":remove" in key or ":prepend" in key:
+            if op in ["append", "prepend", "postdot", "predot"]:
+                bb.warn(key + " " + groupd[op] + " is not a recommended operator combination, please replace it.")
+

I've seen also weird combinations like

Quoted 5 lines

append:remove

with multiple contradicting override operations out in the wild, might be worth to warn about them as well in a follow-up

I assume :append:.*:append is also something that should be avoided.

And I think we can even go as far as saying that you cannot have any two of append/prepend/remove ?

So...
:append:.*:append
:append:.*:prepend
:append:.*:remove
:prepend:.*:append
:prepend:.*:prepend
:prepend:.*:remove
:remove:.*:remove
:remove:.*:append
:remove:.*:prepend

are no-nos.

Cheers,
Quentin

#3 lore raw
In reply to Richard Purdie

Hi,

this seems to be merged in 1.52 branch now and not in master, was that intentional?

I think this should go only into master branch, right?

Quoted 40 lines · Richard Purdie

Operations like XXX:append += "YYY" are almost always wrong and this is a common mistake made in the metadata. Show warnings for these usages with a view to making it a fatal error eventually.

---
 lib/bb/parse/ast.py | 4 ++++
 1 file changed, 4 insertions(+)
lib/bb/parse/ast.py +4 -0
index 743ea0dfc0..93cbf285ef 100644
@@ -130,6 +130,10 @@ class DataNode(AstNode):
         else:
             val = groupd["value"]
 
+        if ":append" in key or ":remove" in key or ":prepend" in key:
+            if op in ["append", "prepend", "postdot", "predot"]:
+                bb.warn(key + " " + groupd[op] + " is not a recommended
 operator combination, please replace it.")
+
         flag = None
         if 'flag' in groupd and groupd['flag'] is not None:

flag = groupd['flag']
--
2.32.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#12877):
https://lists.openembedded.org/g/bitbake-devel/message/12877
Mute This Topic: https://lists.openembedded.org/mt/86816155/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 6 lines · Martin Jansa

Hi,

this seems to be merged in 1.52 branch now and not in master, was that intentional?

I think this should go only into master branch, right?

Correct, not sure what I did there. I've reverted it as that was not intended and I shouldn't force push now.

Cheers,

Richard