1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

bitbake: BBHandler/ast: Improve addtask handling

The recent addtask improvement to handle comments complicated the regex significantly
and there are already a number of corner cases in that code which aren't handled well.

Instead of trying to complicate the regex further, switch to code logic instead. This
means the following cases are now handled:

* addtask with multiple task names
* addtask with multiple before constraints
* addtask with multiple after constraints

The testcase is updated to match the improvements.

(Bitbake rev: 417016b83c21fca7616b2ee768d5d08e1edd1e06)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2024-08-12 15:53:06 +01:00
parent 36f98fc1f2
commit 5226f46342
3 changed files with 37 additions and 43 deletions
+9 -17
View File
@@ -240,14 +240,16 @@ class ExportFuncsNode(AstNode):
data.setVar(func, sentinel + " " + calledfunc + "\n", parsing=True)
class AddTaskNode(AstNode):
def __init__(self, filename, lineno, func, before, after):
def __init__(self, filename, lineno, tasks, before, after):
AstNode.__init__(self, filename, lineno)
self.func = func
self.tasks = tasks
self.before = before
self.after = after
def eval(self, data):
bb.build.addtask(self.func, self.before, self.after, data)
tasks = self.tasks.split()
for task in tasks:
bb.build.addtask(task, self.before, self.after, data)
class DelTaskNode(AstNode):
def __init__(self, filename, lineno, tasks):
@@ -348,21 +350,11 @@ def handlePythonMethod(statements, filename, lineno, funcname, modulename, body)
def handleExportFuncs(statements, filename, lineno, m, classname):
statements.append(ExportFuncsNode(filename, lineno, m.group(1), classname))
def handleAddTask(statements, filename, lineno, m):
func = m.group("func")
before = m.group("before")
after = m.group("after")
if func is None:
return
def handleAddTask(statements, filename, lineno, tasks, before, after):
statements.append(AddTaskNode(filename, lineno, tasks, before, after))
statements.append(AddTaskNode(filename, lineno, func, before, after))
def handleDelTask(statements, filename, lineno, m):
func = m.group(1)
if func is None:
return
statements.append(DelTaskNode(filename, lineno, func))
def handleDelTask(statements, filename, lineno, tasks):
statements.append(DelTaskNode(filename, lineno, tasks))
def handleBBHandlers(statements, filename, lineno, m):
statements.append(BBHandlerNode(filename, lineno, m.group(1)))