diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-09 13:47:36 +0000 |
---|---|---|
committer | Martin Jansa <martin.jansa@gmail.com> | 2024-01-12 16:53:15 +0100 |
commit | 074642af97b1a846ea703a470f7ceeb150f7e089 (patch) | |
tree | e50aa25fa728ce19725bb54c3a1935f985d80ed5 | |
parent | ee090484cc25d760b8c20f18add17b5eff485b40 (diff) | |
download | bitbake-contrib-jansa/test.tar.gz |
ast: Fix EXPORT_FUNCTIONS bugjansa/test
If you have two classes, both of which set EXPORT_FUNCTIONS for the same funciton
and a standard funciton definition for the function that is exported, the export
function can sometimes overwrite the standard one.
The issue is that the internal flag the code uses isn't ovweritten if the variable
is giving a new value. Fix the issue by using a comment in the code that is injected
so that we know if it is ours or not.
Also add some testing for EXPORT_FUNCTIONS, not perfect but a start.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/parse/ast.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py index 9e0a0f5c9..254e6a767 100644 --- a/lib/bb/parse/ast.py +++ b/lib/bb/parse/ast.py @@ -210,10 +210,12 @@ class ExportFuncsNode(AstNode): def eval(self, data): + sentinel = " # Export function set\n" for func in self.n: calledfunc = self.classname + "_" + func - if data.getVar(func, False) and not data.getVarFlag(func, 'export_func', False): + basevar = data.getVar(func, False) + if basevar and sentinel not in basevar: continue if data.getVar(func, False): @@ -230,12 +232,11 @@ class ExportFuncsNode(AstNode): data.setVarFlag(func, "lineno", 1) if data.getVarFlag(calledfunc, "python", False): - data.setVar(func, " bb.build.exec_func('" + calledfunc + "', d)\n", parsing=True) + data.setVar(func, sentinel + " bb.build.exec_func('" + calledfunc + "', d)\n", parsing=True) else: if "-" in self.classname: bb.fatal("The classname %s contains a dash character and is calling an sh function %s using EXPORT_FUNCTIONS. Since a dash is illegal in sh function names, this cannot work, please rename the class or don't use EXPORT_FUNCTIONS." % (self.classname, calledfunc)) - data.setVar(func, " " + calledfunc + "\n", parsing=True) - data.setVarFlag(func, 'export_func', '1') + data.setVar(func, sentinel + " " + calledfunc + "\n", parsing=True) class AddTaskNode(AstNode): def __init__(self, filename, lineno, func, before, after): |