From: Johannes Berg Date: Tue, 2 Apr 2013 08:33:20 +0000 (+0200) Subject: add kernel version dependencies X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=be3ec52dae8beff6052c8aff517c97b30418f0c4;p=openwrt%2Fstaging%2Fblogic.git add kernel version dependencies 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 --- diff --git a/gentree.py b/gentree.py index 4a2849a498a7..68990b829538 100755 --- a/gentree.py +++ b/gentree.py @@ -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]) + '))' diff --git a/lib/kconfig.py b/lib/kconfig.py index c2c55860e20c..48226361932b 100644 --- a/lib/kconfig.py +++ b/lib/kconfig.py @@ -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()