Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 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.items()} |
| 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)) |