blob: f7b9cee371793b35a1e627a8f34c1d85c94b3ce2 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright BitBake Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: GPL-2.0-only
5#
6
Patrick Williamsc0f7c042017-02-23 20:41:17 -06007import argparse
8import logging
9import os
10
11logger = logging.getLogger('bitbake-layers')
12
13
14class LayerPlugin():
15 def __init__(self):
16 self.tinfoil = None
17 self.bblayers = []
18
19 def tinfoil_init(self, tinfoil):
20 self.tinfoil = tinfoil
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021 self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS') or "").split()
Andrew Geissler82c905d2020-04-13 13:39:40 -050022 layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060023 self.bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()}
24
25 @staticmethod
26 def add_command(subparsers, cmdname, function, parserecipes=True, *args, **kwargs):
27 """Convert docstring for function to help."""
28 docsplit = function.__doc__.splitlines()
29 help = docsplit[0]
30 if len(docsplit) > 1:
31 desc = '\n'.join(docsplit[1:])
32 else:
33 desc = help
34 subparser = subparsers.add_parser(cmdname, *args, help=help, description=desc, formatter_class=argparse.RawTextHelpFormatter, **kwargs)
35 subparser.set_defaults(func=function, parserecipes=parserecipes)
36 return subparser
37
38 def get_layer_name(self, layerdir):
39 return os.path.basename(layerdir.rstrip(os.sep))