diff options
author | Christopher Larson <chris_larson@mentor.com> | 2016-04-30 12:41:00 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-17 21:16:35 +0100 |
commit | 6bbe4fe48c93d1e2b67a36aa82d2ea5e289a219c (patch) | |
tree | 802427823189e16ffcd6560acfda961303873adc /bitbake/lib/bblayers/common.py | |
parent | 07eebc66898b423ea2e04e96c57d3b2b5eabbb26 (diff) | |
download | poky-6bbe4fe48c93d1e2b67a36aa82d2ea5e289a219c.tar.gz |
bitbake: bitbake-layers: convert to plugin-based
This uses bb.utils.load_plugins, based on the plugin handling in recipetool
and devtool in oe-core.
(Bitbake rev: 5e542df9b966a99b5a5b8aa7cf6100174aff54b2)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bblayers/common.py')
-rw-r--r-- | bitbake/lib/bblayers/common.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bitbake/lib/bblayers/common.py b/bitbake/lib/bblayers/common.py new file mode 100644 index 0000000000..360b9d764f --- /dev/null +++ b/bitbake/lib/bblayers/common.py | |||
@@ -0,0 +1,33 @@ | |||
1 | import argparse | ||
2 | import logging | ||
3 | import os | ||
4 | |||
5 | logger = logging.getLogger('bitbake-layers') | ||
6 | |||
7 | |||
8 | class LayerPlugin(): | ||
9 | def __init__(self): | ||
10 | self.tinfoil = None | ||
11 | self.bblayers = [] | ||
12 | |||
13 | def tinfoil_init(self, tinfoil): | ||
14 | self.tinfoil = tinfoil | ||
15 | self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS', True) or "").split() | ||
16 | layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS', self.tinfoil.config_data) | ||
17 | self.bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.iteritems()} | ||
18 | |||
19 | @staticmethod | ||
20 | def add_command(subparsers, cmdname, function, parserecipes=True, *args, **kwargs): | ||
21 | """Convert docstring for function to help.""" | ||
22 | docsplit = function.__doc__.splitlines() | ||
23 | help = docsplit[0] | ||
24 | if len(docsplit) > 1: | ||
25 | desc = '\n'.join(docsplit[1:]) | ||
26 | else: | ||
27 | desc = help | ||
28 | subparser = subparsers.add_parser(cmdname, *args, help=help, description=desc, formatter_class=argparse.RawTextHelpFormatter, **kwargs) | ||
29 | subparser.set_defaults(func=function, parserecipes=parserecipes) | ||
30 | return subparser | ||
31 | |||
32 | def get_layer_name(self, layerdir): | ||
33 | return os.path.basename(layerdir.rstrip(os.sep)) | ||