blob: 12dc19e0be7d5bee4a3a159086aa755fd54f311f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# Works like allyesconfig. This is a bit more involved than allnoconfig as we
# need to handle choices in two different modes:
#
# "y": One symbol is "y", the rest are "n".
# "m": Any number of symbols are "m", the rest are "n".
#
# Only tristate choices can be in "m" mode. It is safe since the code for two
# conflicting options will appear as separate modules instead of simultaneously
# in the kernel.
#
# If a choice can be in "y" mode, it will be. If it can only be in "m" mode
# (due to dependencies), then all the options will be set to "m".
#
# The looping is in case setting one symbol to "y" (or "m") allows the value of
# other symbols to be raised.
import kconfiglib
import sys
conf = kconfiglib.Config(sys.argv[1])
# 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_item()]
while True:
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.calc_value(), upper_bound):
sym.set_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_value("y")
done = False
# Handle choices whose visibility only allow them to be in "m" mode
elif choice.get_visibility() == "m":
for sym in choice.get_items():
if sym.calc_value() != "m" and \
sym.get_upper_bound() != "n":
sym.set_value("m")
done = False
if done:
break
conf.write_config(".config")
|