From 6e0475b599217eceb8e01a1e572c2b16319462d9 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 8 Apr 2013 22:36:24 +0200 Subject: [PATCH] gentree: add automatic backports only if needed If the automatic backports aren't selected by any driver then they don't need to be added to the output, so ignore them in that case. Signed-off-by: Johannes Berg --- gentree.py | 11 ++++++++--- lib/kconfig.py | 9 +++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gentree.py b/gentree.py index b1a6be300ed4..a223b4765755 100755 --- a/gentree.py +++ b/gentree.py @@ -178,7 +178,12 @@ def automatic_backport_mangle_c_file(name): def add_automatic_backports(args): export = re.compile(r'^EXPORT_SYMBOL(_GPL)?\((?P[^\)]*)\)') bpi = kconfig.get_backport_info(os.path.join(args.outdir, 'compat', 'Kconfig')) + configtree = kconfig.ConfigTree(os.path.join(args.outdir, 'Kconfig')) + all_selects = configtree.all_selects() for sym, vals in bpi.iteritems(): + if sym.startswith('BACKPORT_BUILD_'): + if not sym[15:] in all_selects: + continue symtype, module_name, c_files, h_files = vals # first copy files @@ -329,9 +334,6 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None, git_debug_init(args) - add_automatic_backports(args) - git_debug_snapshot(args, 'Add automatic backports') - if not args.git_revision: copy_files(args.kerneldir, copy_list, args.outdir) else: @@ -343,6 +345,9 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None, git_debug_snapshot(args, 'Add driver sources') + add_automatic_backports(args) + git_debug_snapshot(args, 'Add automatic backports') + logwrite('Apply patches ...') patches = [] for root, dirs, files in os.walk(os.path.join(source_dir, 'patches')): diff --git a/lib/kconfig.py b/lib/kconfig.py index 406e375b5c5b..880d7c3b25a4 100644 --- a/lib/kconfig.py +++ b/lib/kconfig.py @@ -65,6 +65,15 @@ class ConfigTree(object): syms.append(m.group('sym')) return syms + def all_selects(self): + result = [] + for nf in self._walk(self.rootfile): + for l in open(os.path.join(self.basedir, nf), 'r'): + m = sel_line.match(l) + if m: + result.append(m.group('sym')) + return result + def modify_selects(self): syms = self.symbols() for nf in self._walk(self.rootfile): -- 2.30.2