summaryrefslogtreecommitdiffstats
path: root/scripts/recipetool
diff options
context:
space:
mode:
authorChristopher Larson <kergoth@gmail.com>2015-06-25 11:35:41 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-27 23:29:12 +0100
commit71366782d9b8c52222eed68a0be76bdfc6f1038c (patch)
tree552dd742b040950808c5bafa93dbd13c08a3b3f2 /scripts/recipetool
parent89878f590694a4c2452c92fbc7f4e85b63bd2288 (diff)
downloadpoky-71366782d9b8c52222eed68a0be76bdfc6f1038c.tar.gz
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>
Diffstat (limited to 'scripts/recipetool')
-rwxr-xr-xscripts/recipetool31
1 files changed, 18 insertions, 13 deletions
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):
36 import logging 36 import logging
37 tinfoil = bb.tinfoil.Tinfoil() 37 tinfoil = bb.tinfoil.Tinfoil()
38 tinfoil.prepare(not parserecipes) 38 tinfoil.prepare(not parserecipes)
39
40 for plugin in plugins:
41 if hasattr(plugin, 'tinfoil_init'):
42 plugin.tinfoil_init(tinfoil)
43 tinfoil.logger.setLevel(logger.getEffectiveLevel()) 39 tinfoil.logger.setLevel(logger.getEffectiveLevel())
40 return tinfoil
44 41
45def main(): 42def main():
46 43
@@ -55,12 +52,26 @@ def main():
55 parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') 52 parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR')
56 subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>') 53 subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>')
57 54
58 scriptutils.load_plugins(logger, plugins, os.path.join(scripts_path, 'lib', 'recipetool')) 55 import scriptpath
56 bitbakepath = scriptpath.add_bitbake_lib_path()
57 if not bitbakepath:
58 logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
59 sys.exit(1)
60 logger.debug('Found bitbake path: %s' % bitbakepath)
61
62 tinfoil = tinfoil_init(False)
63 for path in ([scripts_path] +
64 tinfoil.config_data.getVar('BBPATH', True).split(':')):
65 pluginpath = os.path.join(path, 'lib', 'recipetool')
66 scriptutils.load_plugins(logger, plugins, pluginpath)
67
59 registered = False 68 registered = False
60 for plugin in plugins: 69 for plugin in plugins:
61 if hasattr(plugin, 'register_command'): 70 if hasattr(plugin, 'register_command'):
62 registered = True 71 registered = True
63 plugin.register_command(subparsers) 72 plugin.register_command(subparsers)
73 if hasattr(plugin, 'tinfoil_init'):
74 plugin.tinfoil_init(tinfoil)
64 75
65 if not registered: 76 if not registered:
66 logger.error("No commands registered - missing plugins?") 77 logger.error("No commands registered - missing plugins?")
@@ -73,17 +84,11 @@ def main():
73 elif args.quiet: 84 elif args.quiet:
74 logger.setLevel(logging.ERROR) 85 logger.setLevel(logging.ERROR)
75 86
76 import scriptpath
77 bitbakepath = scriptpath.add_bitbake_lib_path()
78 if not bitbakepath:
79 logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
80 sys.exit(1)
81 logger.debug('Found bitbake path: %s' % bitbakepath)
82
83 scriptutils.logger_setup_color(logger, args.color) 87 scriptutils.logger_setup_color(logger, args.color)
84 88
85 try: 89 try:
86 tinfoil_init(getattr(args, 'parserecipes', False)) 90 if getattr(args, 'parserecipes', False):
91 tinfoil.parseRecipes()
87 ret = args.func(args) 92 ret = args.func(args)
88 except bb.BBHandledException: 93 except bb.BBHandledException:
89 ret = 1 94 ret = 1