recipetool: also load plugins from BBPATH
This makes it easier to extend, as a layer can add its own sub-commands. The bitbake path setup is moved earlier, as it has to be done before tinfoil_init. [YOCTO #7625] (From OE-Core rev: 5753f20acc31d4d8d93069e3daccce1fad27b7ac) Signed-off-by: Christopher Larson <kergoth@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
89878f5906
commit
71366782d9
|
@ -36,11 +36,8 @@ def tinfoil_init(parserecipes):
|
|||
import logging
|
||||
tinfoil = bb.tinfoil.Tinfoil()
|
||||
tinfoil.prepare(not parserecipes)
|
||||
|
||||
for plugin in plugins:
|
||||
if hasattr(plugin, 'tinfoil_init'):
|
||||
plugin.tinfoil_init(tinfoil)
|
||||
tinfoil.logger.setLevel(logger.getEffectiveLevel())
|
||||
return tinfoil
|
||||
|
||||
def main():
|
||||
|
||||
|
@ -55,12 +52,26 @@ def main():
|
|||
parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR')
|
||||
subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>')
|
||||
|
||||
scriptutils.load_plugins(logger, plugins, os.path.join(scripts_path, 'lib', 'recipetool'))
|
||||
import scriptpath
|
||||
bitbakepath = scriptpath.add_bitbake_lib_path()
|
||||
if not bitbakepath:
|
||||
logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
|
||||
sys.exit(1)
|
||||
logger.debug('Found bitbake path: %s' % bitbakepath)
|
||||
|
||||
tinfoil = tinfoil_init(False)
|
||||
for path in ([scripts_path] +
|
||||
tinfoil.config_data.getVar('BBPATH', True).split(':')):
|
||||
pluginpath = os.path.join(path, 'lib', 'recipetool')
|
||||
scriptutils.load_plugins(logger, plugins, pluginpath)
|
||||
|
||||
registered = False
|
||||
for plugin in plugins:
|
||||
if hasattr(plugin, 'register_command'):
|
||||
registered = True
|
||||
plugin.register_command(subparsers)
|
||||
if hasattr(plugin, 'tinfoil_init'):
|
||||
plugin.tinfoil_init(tinfoil)
|
||||
|
||||
if not registered:
|
||||
logger.error("No commands registered - missing plugins?")
|
||||
|
@ -73,17 +84,11 @@ def main():
|
|||
elif args.quiet:
|
||||
logger.setLevel(logging.ERROR)
|
||||
|
||||
import scriptpath
|
||||
bitbakepath = scriptpath.add_bitbake_lib_path()
|
||||
if not bitbakepath:
|
||||
logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
|
||||
sys.exit(1)
|
||||
logger.debug('Found bitbake path: %s' % bitbakepath)
|
||||
|
||||
scriptutils.logger_setup_color(logger, args.color)
|
||||
|
||||
try:
|
||||
tinfoil_init(getattr(args, 'parserecipes', False))
|
||||
if getattr(args, 'parserecipes', False):
|
||||
tinfoil.parseRecipes()
|
||||
ret = args.func(args)
|
||||
except bb.BBHandledException:
|
||||
ret = 1
|
||||
|
|
Loading…
Reference in New Issue