gentree: add automatic backports only if needed
authorJohannes Berg <johannes.berg@intel.com>
Mon, 8 Apr 2013 20:36:24 +0000 (22:36 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 8 Apr 2013 20:36:24 +0000 (22:36 +0200)
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 <johannes.berg@intel.com>
gentree.py
lib/kconfig.py

index b1a6be300ed4f4c28638f7ee6e4a01a0bcbfd61f..a223b4765755a2e188d3b4bbad1c9d37ef7326b4 100755 (executable)
@@ -178,7 +178,12 @@ def automatic_backport_mangle_c_file(name):
 def add_automatic_backports(args):
     export = re.compile(r'^EXPORT_SYMBOL(_GPL)?\((?P<sym>[^\)]*)\)')
     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')):
index 406e375b5c5b724155d2b1f8a91e4a36c486f3a9..880d7c3b25a4c2d75507af926934e79d5585f30b 100644 (file)
@@ -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):