Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: GPL-2.0-only |
| 3 | # |
| 4 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 5 | import argparse |
| 6 | import logging |
| 7 | import os |
| 8 | |
| 9 | logger = logging.getLogger('bitbake-layers') |
| 10 | |
| 11 | |
| 12 | class LayerPlugin(): |
| 13 | def __init__(self): |
| 14 | self.tinfoil = None |
| 15 | self.bblayers = [] |
| 16 | |
| 17 | def tinfoil_init(self, tinfoil): |
| 18 | self.tinfoil = tinfoil |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 19 | self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS') or "").split() |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 20 | layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 21 | self.bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()} |
| 22 | |
| 23 | @staticmethod |
| 24 | def add_command(subparsers, cmdname, function, parserecipes=True, *args, **kwargs): |
| 25 | """Convert docstring for function to help.""" |
| 26 | docsplit = function.__doc__.splitlines() |
| 27 | help = docsplit[0] |
| 28 | if len(docsplit) > 1: |
| 29 | desc = '\n'.join(docsplit[1:]) |
| 30 | else: |
| 31 | desc = help |
| 32 | subparser = subparsers.add_parser(cmdname, *args, help=help, description=desc, formatter_class=argparse.RawTextHelpFormatter, **kwargs) |
| 33 | subparser.set_defaults(func=function, parserecipes=parserecipes) |
| 34 | return subparser |
| 35 | |
| 36 | def get_layer_name(self, layerdir): |
| 37 | return os.path.basename(layerdir.rstrip(os.sep)) |