devtool: refactor bb task execution into a separate class
(From OE-Core rev: bd93a75ec0537fc82ac84ccc5701473d76877bcb) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
6e039bf7c0
commit
f0ab93f177
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue