blob: 6c76ef3505f3c70938e89269a84eab756edf02dc [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: GPL-2.0-only
3#
4
Patrick Williamsc0f7c042017-02-23 20:41:17 -06005import argparse
6import logging
7import os
8
9logger = logging.getLogger('bitbake-layers')
10
11
12class LayerPlugin():
13 def __init__(self):
14 self.tinfoil = None
15 self.bblayers = []
16
17 def tinfoil_init(self, tinfoil):
18 self.tinfoil = tinfoil
Brad Bishop6e60e8b2018-02-01 10:27:11 -050019 self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS') or "").split()
Andrew Geissler82c905d2020-04-13 13:39:40 -050020 layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021 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))