From f0ab93f17721e0f0a213f0260b9c7fbf9fbc6853 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 12 May 2015 16:39:31 +0300 Subject: devtool: refactor bb task execution into a separate class (From OE-Core rev: bd93a75ec0537fc82ac84ccc5701473d76877bcb) Signed-off-by: Markus Lehtonen Signed-off-by: Richard Purdie --- scripts/lib/devtool/standard.py | 50 ++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'scripts') diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 1e99413365..aed76ea621 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py @@ -213,6 +213,32 @@ def extract(args, config, basepath, workspace): else: return -1 +class BbTaskExecutor(object): + """Class for executing bitbake tasks for a recipe + + FIXME: This is very awkward. Unfortunately it's not currently easy to + properly execute tasks outside of bitbake itself, until then this has to + suffice if we are to handle e.g. linux-yocto's extra tasks + """ + + def __init__(self, rdata): + self.rdata = rdata + self.executed = [] + + def exec_func(self, func, report): + """Run bitbake task function""" + if not func in self.executed: + deps = self.rdata.getVarFlag(func, 'deps') + if deps: + for taskdepfunc in deps: + self.exec_func(taskdepfunc, True) + if report: + logger.info('Executing %s...' % func) + fn = self.rdata.getVar('FILE', True) + localdata = bb.build._task_data(fn, func, self.rdata) + bb.build.exec_func(func, localdata) + self.executed.append(func) + def _extract_source(srctree, keep_temp, devbranch, d): """Extract sources of a recipe""" @@ -270,28 +296,12 @@ def _extract_source(srctree, keep_temp, devbranch, d): # We don't want to move the source to STAGING_KERNEL_DIR here crd.setVar('STAGING_KERNEL_DIR', '${S}') - # FIXME: This is very awkward. Unfortunately it's not currently easy to properly - # execute tasks outside of bitbake itself, until then this has to suffice if we - # are to handle e.g. linux-yocto's extra tasks - executed = [] - def exec_task_func(func, report): - """Run specific bitbake task for a recipe""" - if not func in executed: - deps = crd.getVarFlag(func, 'deps') - if deps: - for taskdepfunc in deps: - exec_task_func(taskdepfunc, True) - if report: - logger.info('Executing %s...' % func) - fn = d.getVar('FILE', True) - localdata = bb.build._task_data(fn, func, crd) - bb.build.exec_func(func, localdata) - executed.append(func) + task_executor = BbTaskExecutor(crd) logger.info('Fetching %s...' % pn) - exec_task_func('do_fetch', False) + task_executor.exec_func('do_fetch', False) logger.info('Unpacking...') - exec_task_func('do_unpack', False) + task_executor.exec_func('do_unpack', False) srcsubdir = crd.getVar('S', True) if srcsubdir == workdir: # Find non-patch sources that were "unpacked" to srctree directory @@ -343,7 +353,7 @@ def _extract_source(srctree, keep_temp, devbranch, d): crd.setVar('PATCHTOOL', 'git') logger.info('Patching...') - exec_task_func('do_patch', False) + task_executor.exec_func('do_patch', False) bb.process.run('git tag -f devtool-patched', cwd=srcsubdir) -- cgit v1.2.3-54-g00ecf