blob: bc56e125d9a72d3acdc4ccc07b281744f5647180 [file] [log] [blame]
#!/usr/bin/env python
"""See this page for more details:
http://dev.chromium.org/chromium-os/how-tos-and-troubleshooting/kernel-configuration
"""
import os
import re
import sys
allconfigs = {}
# Parse config files
for config in os.listdir("."):
# Only config.*
if not config.endswith(".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["common.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()