add kernel version dependencies
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 2 Apr 2013 08:33:20 +0000 (10:33 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 2 Apr 2013 08:33:20 +0000 (10:33 +0200)
Some drivers/subsystems/... can only build on certain newer
kernels, or were never tested elsewhere. Insert their version
dependencies into the output Kconfig.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
gentree.py
lib/kconfig.py

index 4a2849a498a7888fc85d09404ee95d054b35494e..68990b829538f5a95a3a5ab45636409de051d34f 100755 (executable)
@@ -39,6 +39,20 @@ def read_copy_list(kerneldir, copyfile):
         ret.append((kerneldir, srcitem, dstitem))
     return ret
 
+def read_dependencies(depfilename):
+    ret = {}
+    depfile = open(depfilename)
+    for item in depfile:
+        item = item.strip()
+        if not item or item[0] == '#':
+            continue
+        sym, dep = item.split()
+        if not sym in ret:
+            ret[sym] = [dep, ]
+        else:
+            raise Exception("Listing the same symbol (%s) multiple times is pointless" % sym)
+    return ret
+
 def check_output_dir(d, clean):
     if clean:
         shutil.rmtree(d, ignore_errors=True)
@@ -156,6 +170,8 @@ def main():
     copy_list.append((os.path.join(source_dir, 'compat'), 'compat/', 'compat/'))
     copy_list.append((os.path.join(source_dir, 'compat'), 'include/', 'include/'))
 
+    deplist = read_dependencies(os.path.join(source_dir, 'dependencies'))
+
     # validate output directory
     check_output_dir(args.outdir, args.clean)
 
@@ -300,6 +316,14 @@ def main():
     configtree.disable_symbols(disable_kconfig)
     git_debug_snapshot(args, "disable impossible kconfig symbols")
 
+    for sym in tuple(deplist.keys()):
+        new = []
+        for dep in deplist[sym]:
+            new.append('!BACKPORT_KERNEL_%s' % dep.replace('.', '_'))
+        deplist[sym] = new
+    configtree.add_dependencies(deplist)
+    git_debug_snapshot(args, "add kernel version dependencies")
+
     regexes = []
     for some_symbols in [disable_makefile[i:i + 50] for i in range(0, len(disable_makefile), 50)]:
         r = '(CONFIG_(' + '|'.join([s for s in some_symbols]) + '))'
index c2c55860e20ce23b304a756e05c240127386604f..48226361932b817720a152ff7f47fcb8aebfbee4 100644 (file)
@@ -91,3 +91,16 @@ class ConfigTree(object):
             outf = open(os.path.join(self.basedir, nf), 'w')
             outf.write(out)
             outf.close()
+
+    def add_dependencies(self, deps):
+        for nf in self._walk(self.rootfile):
+            out = ''
+            for l in open(os.path.join(self.basedir, nf), 'r'):
+                m = cfg_line.match(l)
+                out += l
+                if m:
+                    for dep in deps.get(m.group('sym'), []):
+                        out += "\tdepends on %s\n" % dep
+            outf = open(os.path.join(self.basedir, nf), 'w')
+            outf.write(out)
+            outf.close()