# case setting one symbol to "n" allows other symbols to be set to "n" (due to # dependencies). import kconfiglib import sys conf = kconfiglib.Config(sys.argv[1]) done = False while not done: done = True for sym in conf: # Choices take care of themselves for allnoconfig, so we only need to # worry about non-choice symbols if not sym.is_choice_symbol(): # If we can assign a value to the symbol (where "n", "m" and "y" # are ordered from lowest to highest), then assign the lowest # value. lower_bound() returns None for symbols whose values cannot # (currently) be changed, as well as for non-bool/tristate symbols. lower_bound = sym.get_lower_bound() if lower_bound is not None and \ kconfiglib.tri_less(lower_bound, sym.get_value()): sym.set_user_value(lower_bound) # We just changed the value of some symbol. As this may affect # other symbols, keep going. done = False conf.write_config(".config")
# Get a list of all symbols that are not in choices non_choice_syms = [sym for sym in conf.get_symbols() if not sym.is_choice_symbol()] done = False while not done: done = True # Handle symbols outside of choices for sym in non_choice_syms: upper_bound = sym.get_upper_bound() # See corresponding comment for allnoconfig implementation if upper_bound is not None and \ kconfiglib.tri_less(sym.get_value(), upper_bound): sym.set_user_value(upper_bound) done = False # Handle symbols within choices for choice in conf.get_choices(): # Handle choices whose visibility allow them to be in "y" mode if choice.get_visibility() == "y": selection = choice.get_selection_from_defaults() if selection is not None and \ selection is not choice.get_user_selection(): selection.set_user_value("y") done = False
break # Search for symbol to disable for sym in conf: if not sym.is_choice_item() and \ not sym.get_name() in req and \ sym.get_type() in (kconfiglib.BOOL, kconfiglib.TRISTATE) and \ sym.calc_value() == "y": val = sym.calc_value() # Get the lowerst value the symbol can be assigned, with "n", # "m", and "y" being arranged from lowest to highest lower_bound = sym.get_lower_bound() if lower_bound is not None and \ kconfiglib.tri_less(lower_bound, val): print "Lowering the value of {0} from '{1}' to '{2}'" \ .format(sym.get_name(), val, lower_bound) sym.set_value(lower_bound) break else: print "Done - no more symbols can be disabled" break # Test the kernel write_config(conf, ".config") print "Compiling kernel" run_cmd(compile_cmd)
non_choice_syms = [ sym for sym in conf.get_symbols() if not sym.is_choice_symbol() ] done = False while not done: done = True # Handle symbols outside of choices for sym in non_choice_syms: upper_bound = sym.get_upper_bound() # See corresponding comment for allnoconfig implementation if upper_bound is not None and \ kconfiglib.tri_less(sym.get_value(), upper_bound): sym.set_user_value(upper_bound) done = False # Handle symbols within choices for choice in conf.get_choices(): # Handle choices whose visibility allow them to be in "y" mode if choice.get_visibility() == "y": selection = choice.get_selection_from_defaults() if selection is not None and \ selection is not choice.get_user_selection(): selection.set_user_value("y") done = False