diff options
author | Johannes Berg <johannes.berg@intel.com> | 2013-04-05 20:59:02 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-04-05 21:19:32 +0200 |
commit | 4e133e70121b5ad4a8b58ede85bdf4ab66990f84 (patch) | |
tree | 26c5aa0f4cb4a230792ebc31ed253b2685923f6f /lib | |
parent | c0a09343c255709705e3e6d381c2b6121b14df74 (diff) |
gentree: add ability to create automatic backports
Instead of manually copying code like HDMI and dma-buf,
add the ability to just specify such backports in the
Kconfig file for compat. This will then always update
to the lastest code as well.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kconfig.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/kconfig.py b/lib/kconfig.py index 2369f746..b971c205 100644 --- a/lib/kconfig.py +++ b/lib/kconfig.py @@ -6,8 +6,10 @@ import os, re src_line = re.compile(r'^source\s+"?(?P<src>[^\s"]*)"?\s*$') tri_line = re.compile(r'^(?P<spc>\s+)tristate') +bool_line = re.compile(r'^(?P<spc>\s+)bool') cfg_line = re.compile(r'^(config|menuconfig)\s+(?P<sym>[^\s]*)') sel_line = re.compile(r'^(?P<spc>\s+)select\s+(?P<sym>[^\s]*)\s*$') +ch_line = re.compile(r'^\s+#(?P<ch>[ch])-file\s*(?P<file>.*)') class ConfigTree(object): def __init__(self, rootfile): @@ -104,3 +106,51 @@ class ConfigTree(object): outf = open(os.path.join(self.basedir, nf), 'w') outf.write(out) outf.close() + +def get_backport_info(filename): + """ + Return a dictionary of + + CONFIG_SYMBOL => (type, C-files, H-files) + + where type is 'bool' or 'tristate' and the C-files/H-files are lists + """ + f = open(filename, 'r') + result = {} + conf = None + + # trick to always have an empty line last + def append_empty(f): + for l in f: + yield l + yield '' + + for line in append_empty(f): + m = cfg_line.match(line) + if not line.strip() or m: + if conf and conf_type and (c_files or h_files): + result[conf] = (conf_type, c_files, h_files) + conf = None + conf_type = None + c_files = [] + h_files = [] + if m: + conf = m.group('sym') + continue + if not conf: + continue + m = tri_line.match(line) + if m: + conf_type = 'tristate' + continue + m = bool_line.match(line) + if m: + conf_type = 'bool' + continue + m = ch_line.match(line) + if m: + if m.group('ch') == 'c': + c_files.append(m.group('file')) + elif m.group('ch') == 'h': + h_files.append(m.group('file')) + return result |