diff options
-rwxr-xr-x | gentree.py | 18 | ||||
-rw-r--r-- | lib/kconfig.py | 18 | ||||
-rw-r--r-- | patches/backport-adjustments/dma-buf.patch | 4 |
3 files changed, 26 insertions, 14 deletions
@@ -171,17 +171,20 @@ def copy_git_files(srcpath, copy_list, rev, outdir): outf.close() os.chmod(f, int(m, 8)) +def automatic_backport_mangle_c_file(name): + return name.replace('/', '-') + 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')) for sym, vals in bpi.iteritems(): - symtype, c_files, h_files = vals + symtype, module_name, c_files, h_files = vals # first copy files files = [] for f in c_files: - files.append((f, os.path.join('compat', os.path.basename(f)))) + files.append((f, os.path.join('compat', automatic_backport_mangle_c_file(f)))) for f in h_files: files.append((os.path.join('include', f), os.path.join('include', os.path.dirname(f), 'backport-' + os.path.basename(f)))) @@ -192,16 +195,21 @@ def add_automatic_backports(args): # now add the Makefile line mf = open(os.path.join(args.outdir, 'compat', 'Makefile'), 'a+') - o_files = [os.path.basename(f)[:-1] + 'o' for f in c_files] + o_files = [automatic_backport_mangle_c_file(f)[:-1] + 'o' for f in c_files] if symtype == 'tristate': - mf.write('obj-$(CPTCFG_%s) += %s\n' % (sym, ' '.join(o_files))) + if not module_name: + raise Exception('backporting a module requires a #module-name') + for of in o_files: + mf.write('%s-objs += %s\n' % (module_name, of)) + mf.write('obj-$(CPTCFG_%s) += %s.o\n' % (sym, module_name)) elif symtype == 'bool': mf.write('compat-$(CPTCFG_%s) += %s\n' % (sym, ' '.join(o_files))) # finally create the include file syms = [] for f in c_files: - for l in open(os.path.join(args.outdir, 'compat', os.path.basename(f)), 'r'): + for l in open(os.path.join(args.outdir, 'compat', + automatic_backport_mangle_c_file(f)), 'r'): m = export.match(l) if m: syms.append(m.group('sym')) diff --git a/lib/kconfig.py b/lib/kconfig.py index b971c205..406e375b 100644 --- a/lib/kconfig.py +++ b/lib/kconfig.py @@ -9,7 +9,7 @@ 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>.*)') +backport_line = re.compile(r'^\s+#(?P<key>[ch]-file|module-name)\s*(?P<name>.*)') class ConfigTree(object): def __init__(self, rootfile): @@ -118,6 +118,7 @@ def get_backport_info(filename): f = open(filename, 'r') result = {} conf = None + module_name = None # trick to always have an empty line last def append_empty(f): @@ -129,9 +130,10 @@ def get_backport_info(filename): 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) + result[conf] = (conf_type, module_name, c_files, h_files) conf = None conf_type = None + module_name = None c_files = [] h_files = [] if m: @@ -147,10 +149,12 @@ def get_backport_info(filename): if m: conf_type = 'bool' continue - m = ch_line.match(line) + m = backport_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')) + if m.group('key') == 'c-file': + c_files.append(m.group('name')) + elif m.group('key') == 'h-file': + h_files.append(m.group('name')) + elif m.group('key') == 'module-name': + module_name = m.group('name') return result diff --git a/patches/backport-adjustments/dma-buf.patch b/patches/backport-adjustments/dma-buf.patch index cec56269..06ed9f65 100644 --- a/patches/backport-adjustments/dma-buf.patch +++ b/patches/backport-adjustments/dma-buf.patch @@ -1,5 +1,5 @@ ---- a/compat/dma-buf.c -+++ b/compat/dma-buf.c +--- a/compat/drivers-base-dma-buf.c ++++ b/compat/drivers-base-dma-buf.c @@ -27,6 +27,9 @@ #include <linux/dma-buf.h> #include <linux/anon_inodes.h> |