mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
65 lines
1.6 KiB
Python
Executable File
65 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import os
|
|
import fnmatch
|
|
import re
|
|
import sys
|
|
|
|
allconfigs = {}
|
|
|
|
def find(pattern, path):
|
|
result = []
|
|
print os.getcwd()
|
|
print path
|
|
for root, dirs, files in os.walk(path):
|
|
for name in files:
|
|
if fnmatch.fnmatch(name, pattern):
|
|
result.append(os.path.join(root, name))
|
|
return result
|
|
|
|
root = os.getcwd()
|
|
configs = find("config*", os.path.join(root, "armhf"))
|
|
configs += find("config*", os.path.join(root, "arm64"))
|
|
|
|
# Parse config files
|
|
for config in configs:
|
|
print (config)
|
|
|
|
# Ignore emacs backups
|
|
if config.endswith("~"):
|
|
continue
|
|
|
|
# Nothing that is disabled, or remnant
|
|
if re.search("\.(default|disabled|stub)$", config):
|
|
continue
|
|
|
|
allconfigs[config] = set()
|
|
|
|
for line in open(config):
|
|
m = re.match("#*\s*CONFIG_(\w+)[\s=](.*)$", line)
|
|
if not m:
|
|
continue
|
|
option, value = m.groups()
|
|
allconfigs[config].add((option, value))
|
|
|
|
# Split out common config options
|
|
common = allconfigs.values()[0].copy()
|
|
for config in allconfigs.keys():
|
|
common &= allconfigs[config]
|
|
for config in allconfigs.keys():
|
|
allconfigs[config] -= common
|
|
allconfigs["config"] = common
|
|
|
|
# Generate new splitconfigs
|
|
for config in allconfigs.keys():
|
|
f = open(config, "w")
|
|
command = os.path.basename(sys.argv[0])
|
|
print >>f, "#\n# Config options generated by %s\n#" % command
|
|
for option, value in sorted(list(allconfigs[config])):
|
|
if value == "is not set":
|
|
print >>f, "# CONFIG_%s %s" % (option, value)
|
|
else:
|
|
print >>f, "CONFIG_%s=%s" % (option, value)
|
|
|
|
f.close()
|