blob: 98515ced4f8999ed180c15f11909ae91e4e80076 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001import argparse
2import logging
3import os
4
5logger = logging.getLogger('bitbake-layers')
6
7
8class LayerPlugin():
9 def __init__(self):
10 self.tinfoil = None
11 self.bblayers = []
12
13 def tinfoil_init(self, tinfoil):
14 self.tinfoil = tinfoil
Brad Bishop6e60e8b2018-02-01 10:27:11 -050015 self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS') or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -060016 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))