@@ -392,6 +392,11 @@ MINIKCONF_ARGS = \
MINIKCONF = $(SHELL) $(SRC_PATH)/scripts/minikconf.sh
+.PHONY: allyesconfig allnoconfig defconfig randconfig
+allyesconfig allnoconfig defconfig randconfig:
+ rm */config-devices.mak config-all-devices.mak
+ $(MAKE) MINIKCONF="$(MINIKCONF) --$<" config-all-devices.mak
+
%/config-devices.mak: default-configs/%-softmmu.mak Kconfig.host hw/Kconfig
$(call quiet-command, \
$(MINIKCONF) $@ $*-config-devices.mak.d $^ $(MINIKCONF_ARGS) > $@.tmp, " GEN $@.tmp")
@@ -13,8 +13,10 @@
import os
import sys
import re
+import random
-__all__ = [ 'KconfigParserError', 'KconfigData', 'KconfigParser' ]
+__all__ = [ 'KconfigParserError', 'KconfigData', 'KconfigParser',
+ 'defconfig', 'allyesconfig', 'allnoconfig', 'randconfig' ]
def debug_print(*args):
#print ' '.join(str(x) for x in args)
@@ -30,6 +32,11 @@ def debug_print(*args):
# just its name).
# -------------------------------------------
+allyesconfig = lambda x: True
+allnoconfig = lambda x: False
+defconfig = lambda x: x
+randconfig = lambda x: random.randint(0, 1) == 1
+
class KconfigData:
class Expr:
def __and__(self, rhs):
@@ -178,7 +185,8 @@ class KconfigData:
if self.cond.evaluate():
self.dest.set_value(True)
- def __init__(self):
+ def __init__(self, value_mangler=defconfig):
+ self.value_mangler = value_mangler
self.previously_included = []
self.incl_info = None
self.defined_vars = set()
@@ -256,10 +264,12 @@ class KconfigData:
return var_obj
def do_assignment(self, var, val):
- self.clauses.append(KconfigData.AssignmentClause(var, val))
+ f = self.value_mangler
+ self.clauses.append(KconfigData.AssignmentClause(var, f(val)))
def do_default(self, var, val, cond=None):
- self.clauses.append(KconfigData.DefaultClause(var, val, cond))
+ f = self.value_mangler
+ self.clauses.append(KconfigData.DefaultClause(var, f(val), cond))
def do_depends_on(self, var, expr):
self.clauses.append(KconfigData.DependsOnClause(var, expr))
@@ -309,9 +319,10 @@ class KconfigParserError(Exception):
return "%s: %s" % (self.loc, self.msg)
class KconfigParser:
+
@classmethod
- def parse(self, fp):
- data = KconfigData()
+ def parse(self, fp, mode=None):
+ data = KconfigData(mode or KconfigParser.defconfig)
parser = KconfigParser(data)
parser.parse_file(fp)
return data
@@ -627,11 +638,29 @@ class KconfigParser:
if __name__ == '__main__':
argv = sys.argv
+ mode = defconfig
+ if len(sys.argv) > 1:
+ if argv[1] == '--defconfig':
+ del argv[1]
+ elif argv[1] == '--randconfig':
+ mode = randconfig
+ del argv[1]
+ elif argv[1] == '--allyesconfig':
+ mode = allyesconfig
+ del argv[1]
+ elif argv[1] == '--allnoconfig':
+ mode = allnoconfig
+ del argv[1]
+
if len(argv) == 1:
print >>sys.stderr, "%s: at least one argument is required" % argv[0]
os.exit(1)
- data = KconfigData()
+ if argv[1].startswith('-'):
+ print >>sys.stderr, "%s: invalid option %s" % (argv[0], argv[1])
+ os.exit(1)
+
+ data = KconfigData(mode)
parser = KconfigParser(data)
for arg in argv[3:]:
m = re.match(r'^(CONFIG_[A-Z0-9_]+)=([yn]?)$', arg)