diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-09 13:47:36 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-10 13:55:33 +0000 |
commit | c665a2c93337fc372207af604c21bdea5babb4e5 (patch) | |
tree | ec5d60d5eb0a28eb3c9002cd81021dc5543a1f45 /bitbake/lib/bb/parse/ast.py | |
parent | 56b1af37dc61e06ef013b8c31248a91c475fffb1 (diff) | |
download | poky-c665a2c93337fc372207af604c21bdea5babb4e5.tar.gz |
bitbake: ast: Fix EXPORT_FUNCTIONS bug
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.
(Bitbake rev: 66306d5151acb0a26a171c338d8f60eb9eb16c6b)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse/ast.py')
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 6441c5cf7c..d30b688965 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -211,10 +211,12 @@ class ExportFuncsNode(AstNode): | |||
211 | 211 | ||
212 | def eval(self, data): | 212 | def eval(self, data): |
213 | 213 | ||
214 | sentinel = " # Export function set\n" | ||
214 | for func in self.n: | 215 | for func in self.n: |
215 | calledfunc = self.classname + "_" + func | 216 | calledfunc = self.classname + "_" + func |
216 | 217 | ||
217 | if data.getVar(func, False) and not data.getVarFlag(func, 'export_func', False): | 218 | basevar = data.getVar(func, False) |
219 | if basevar and sentinel not in basevar: | ||
218 | continue | 220 | continue |
219 | 221 | ||
220 | if data.getVar(func, False): | 222 | if data.getVar(func, False): |
@@ -231,12 +233,11 @@ class ExportFuncsNode(AstNode): | |||
231 | data.setVarFlag(func, "lineno", 1) | 233 | data.setVarFlag(func, "lineno", 1) |
232 | 234 | ||
233 | if data.getVarFlag(calledfunc, "python", False): | 235 | if data.getVarFlag(calledfunc, "python", False): |
234 | data.setVar(func, " bb.build.exec_func('" + calledfunc + "', d)\n", parsing=True) | 236 | data.setVar(func, sentinel + " bb.build.exec_func('" + calledfunc + "', d)\n", parsing=True) |
235 | else: | 237 | else: |
236 | if "-" in self.classname: | 238 | if "-" in self.classname: |
237 | 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)) | 239 | 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)) |
238 | data.setVar(func, " " + calledfunc + "\n", parsing=True) | 240 | data.setVar(func, sentinel + " " + calledfunc + "\n", parsing=True) |
239 | data.setVarFlag(func, 'export_func', '1') | ||
240 | 241 | ||
241 | class AddTaskNode(AstNode): | 242 | class AddTaskNode(AstNode): |
242 | def __init__(self, filename, lineno, func, before, after): | 243 | def __init__(self, filename, lineno, func, before, after): |