diff options
Diffstat (limited to 'bitbake/bin/bitbake-layers')
-rwxr-xr-x | bitbake/bin/bitbake-layers | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers index ff085d6744..341ecbcd97 100755 --- a/bitbake/bin/bitbake-layers +++ b/bitbake/bin/bitbake-layers | |||
@@ -14,15 +14,18 @@ import logging | |||
14 | import os | 14 | import os |
15 | import sys | 15 | import sys |
16 | import argparse | 16 | import argparse |
17 | import warnings | ||
18 | warnings.simplefilter("default") | ||
17 | 19 | ||
18 | bindir = os.path.dirname(__file__) | 20 | bindir = os.path.dirname(__file__) |
21 | toolname = os.path.basename(__file__).split(".")[0] | ||
19 | topdir = os.path.dirname(bindir) | 22 | topdir = os.path.dirname(bindir) |
20 | sys.path[0:0] = [os.path.join(topdir, 'lib')] | 23 | sys.path[0:0] = [os.path.join(topdir, 'lib')] |
21 | 24 | ||
22 | import bb.tinfoil | 25 | import bb.tinfoil |
23 | import bb.msg | 26 | import bb.msg |
24 | 27 | ||
25 | logger = bb.msg.logger_create('bitbake-layers', sys.stdout) | 28 | logger = bb.msg.logger_create(toolname, sys.stdout) |
26 | 29 | ||
27 | def main(): | 30 | def main(): |
28 | parser = argparse.ArgumentParser( | 31 | parser = argparse.ArgumentParser( |
@@ -31,7 +34,7 @@ def main(): | |||
31 | add_help=False) | 34 | add_help=False) |
32 | parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') | 35 | parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') |
33 | parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') | 36 | parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') |
34 | parser.add_argument('-F', '--force', help='Force add without recipe parse verification', action='store_true') | 37 | parser.add_argument('-F', '--force', help='Forced execution: can be specified multiple times. -F will force add without recipe parse verification and -FF will additionally force the run withput layer parsing.', action='count', default=0) |
35 | parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') | 38 | parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR') |
36 | 39 | ||
37 | global_args, unparsed_args = parser.parse_known_args() | 40 | global_args, unparsed_args = parser.parse_known_args() |
@@ -55,22 +58,27 @@ def main(): | |||
55 | level=logger.getEffectiveLevel()) | 58 | level=logger.getEffectiveLevel()) |
56 | 59 | ||
57 | plugins = [] | 60 | plugins = [] |
58 | tinfoil = bb.tinfoil.Tinfoil(tracking=True) | 61 | with bb.tinfoil.Tinfoil(tracking=True) as tinfoil: |
59 | tinfoil.logger.setLevel(logger.getEffectiveLevel()) | 62 | tinfoil.logger.setLevel(logger.getEffectiveLevel()) |
60 | try: | 63 | |
61 | tinfoil.prepare(True) | 64 | if global_args.force > 1: |
62 | for path in ([topdir] + | 65 | bbpaths = [] |
63 | tinfoil.config_data.getVar('BBPATH').split(':')): | 66 | else: |
64 | pluginpath = os.path.join(path, 'lib', 'bblayers') | 67 | tinfoil.prepare(True) |
68 | bbpaths = tinfoil.config_data.getVar('BBPATH').split(':') | ||
69 | |||
70 | for path in ([topdir] + bbpaths): | ||
71 | pluginbasepath = {"bitbake-layers":'bblayers', 'bitbake-config-build':'bbconfigbuild'}[toolname] | ||
72 | pluginpath = os.path.join(path, 'lib', pluginbasepath) | ||
65 | bb.utils.load_plugins(logger, plugins, pluginpath) | 73 | bb.utils.load_plugins(logger, plugins, pluginpath) |
66 | 74 | ||
67 | registered = False | 75 | registered = False |
68 | for plugin in plugins: | 76 | for plugin in plugins: |
77 | if hasattr(plugin, 'tinfoil_init') and global_args.force <= 1: | ||
78 | plugin.tinfoil_init(tinfoil) | ||
69 | if hasattr(plugin, 'register_commands'): | 79 | if hasattr(plugin, 'register_commands'): |
70 | registered = True | 80 | registered = True |
71 | plugin.register_commands(subparsers) | 81 | plugin.register_commands(subparsers) |
72 | if hasattr(plugin, 'tinfoil_init'): | ||
73 | plugin.tinfoil_init(tinfoil) | ||
74 | 82 | ||
75 | if not registered: | 83 | if not registered: |
76 | logger.error("No commands registered - missing plugins?") | 84 | logger.error("No commands registered - missing plugins?") |
@@ -84,8 +92,6 @@ def main(): | |||
84 | tinfoil.config_data.enableTracking() | 92 | tinfoil.config_data.enableTracking() |
85 | 93 | ||
86 | return args.func(args) | 94 | return args.func(args) |
87 | finally: | ||
88 | tinfoil.shutdown() | ||
89 | 95 | ||
90 | 96 | ||
91 | if __name__ == "__main__": | 97 | if __name__ == "__main__": |