From 5753f20acc31d4d8d93069e3daccce1fad27b7ac Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Thu, 25 Jun 2015 11:35:41 -0700 Subject: 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] Signed-off-by: Christopher Larson Signed-off-by: Ross Burton --- scripts/recipetool | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/recipetool b/scripts/recipetool index 3063cf7c43..37c2dd31f4 100755 --- a/scripts/recipetool +++ b/scripts/recipetool @@ -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='') - 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 -- cgit 1.2.3-korg