diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-12-18 10:45:02 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-12-18 17:08:07 +0000 |
commit | ba82035412d5dec2ce6f8a459ee52da48b1afe32 (patch) | |
tree | 2669fa096510cb8bfb691843c47ce96222538219 /bitbake | |
parent | 8a82a3835cb5b38812da720914d5f47a7cd443e8 (diff) | |
download | poky-ba82035412d5dec2ce6f8a459ee52da48b1afe32.tar.gz |
bitbake: build/ast: Create strong task add/del API in bb.build
Currently its near impossible to control task addition/deletion from
metadata context. This adds stong add/deltask API to bb.build
which is traditionally where it resided. The rather broken
remove_tasks function was removed, it didn't appear to do anything
useful or have any users.
This allows us to clean up hacks currently in use in metadata and use
standard API for it instead.
(Bitbake rev: bf7138dd38fc1f8efca80891198e3422fef64093)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/build.py | 37 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 33 |
2 files changed, 34 insertions, 36 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 6b395264b6..1524da0049 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -668,9 +668,36 @@ def add_tasks(tasklist, deltasklist, d): | |||
668 | # don't assume holding a reference | 668 | # don't assume holding a reference |
669 | d.setVar('_task_deps', task_deps) | 669 | d.setVar('_task_deps', task_deps) |
670 | 670 | ||
671 | def remove_task(task, kill, d): | 671 | def addtask(task, before, after, d): |
672 | """Remove an BB 'task'. | 672 | if task[:3] != "do_": |
673 | task = "do_" + task | ||
674 | |||
675 | d.setVarFlag(task, "task", 1) | ||
676 | bbtasks = d.getVar('__BBTASKS') or [] | ||
677 | if not task in bbtasks: | ||
678 | bbtasks.append(task) | ||
679 | d.setVar('__BBTASKS', bbtasks) | ||
680 | |||
681 | existing = d.getVarFlag(task, "deps") or [] | ||
682 | if after is not None: | ||
683 | # set up deps for function | ||
684 | for entry in after.split(): | ||
685 | if entry not in existing: | ||
686 | existing.append(entry) | ||
687 | d.setVarFlag(task, "deps", existing) | ||
688 | if before is not None: | ||
689 | # set up things that depend on this func | ||
690 | for entry in before.split(): | ||
691 | existing = d.getVarFlag(entry, "deps") or [] | ||
692 | if task not in existing: | ||
693 | d.setVarFlag(entry, "deps", [task] + existing) | ||
694 | |||
695 | def deltask(task, d): | ||
696 | if task[:3] != "do_": | ||
697 | task = "do_" + task | ||
698 | |||
699 | bbtasks = d.getVar('__BBDELTASKS') or [] | ||
700 | if not task in bbtasks: | ||
701 | bbtasks.append(task) | ||
702 | d.setVar('__BBDELTASKS', bbtasks) | ||
673 | 703 | ||
674 | If kill is 1, also remove tasks that depend on this task.""" | ||
675 | |||
676 | d.delVarFlag(task, 'task') | ||
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 2036cd43fe..a2020532ea 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -235,29 +235,7 @@ class AddTaskNode(AstNode): | |||
235 | self.after = after | 235 | self.after = after |
236 | 236 | ||
237 | def eval(self, data): | 237 | def eval(self, data): |
238 | var = self.func | 238 | bb.build.addtask(self.func, self.before, self.after, data) |
239 | if self.func[:3] != "do_": | ||
240 | var = "do_" + self.func | ||
241 | |||
242 | data.setVarFlag(var, "task", 1) | ||
243 | bbtasks = data.getVar('__BBTASKS') or [] | ||
244 | if not var in bbtasks: | ||
245 | bbtasks.append(var) | ||
246 | data.setVar('__BBTASKS', bbtasks) | ||
247 | |||
248 | existing = data.getVarFlag(var, "deps") or [] | ||
249 | if self.after is not None: | ||
250 | # set up deps for function | ||
251 | for entry in self.after.split(): | ||
252 | if entry not in existing: | ||
253 | existing.append(entry) | ||
254 | data.setVarFlag(var, "deps", existing) | ||
255 | if self.before is not None: | ||
256 | # set up things that depend on this func | ||
257 | for entry in self.before.split(): | ||
258 | existing = data.getVarFlag(entry, "deps") or [] | ||
259 | if var not in existing: | ||
260 | data.setVarFlag(entry, "deps", [var] + existing) | ||
261 | 239 | ||
262 | class DelTaskNode(AstNode): | 240 | class DelTaskNode(AstNode): |
263 | def __init__(self, filename, lineno, func): | 241 | def __init__(self, filename, lineno, func): |
@@ -265,14 +243,7 @@ class DelTaskNode(AstNode): | |||
265 | self.func = func | 243 | self.func = func |
266 | 244 | ||
267 | def eval(self, data): | 245 | def eval(self, data): |
268 | var = self.func | 246 | bb.build.deltask(self.func, data) |
269 | if self.func[:3] != "do_": | ||
270 | var = "do_" + self.func | ||
271 | |||
272 | bbtasks = data.getVar('__BBDELTASKS') or [] | ||
273 | if not var in bbtasks: | ||
274 | bbtasks.append(var) | ||
275 | data.setVar('__BBDELTASKS', bbtasks) | ||
276 | 247 | ||
277 | class BBHandlerNode(AstNode): | 248 | class BBHandlerNode(AstNode): |
278 | def __init__(self, filename, lineno, fns): | 249 | def __init__(self, filename, lineno, fns): |