xref: /optee_os/scripts/kconfig/kconfiglib/allyesconfig.py (revision c689edbb2550c76ae81dcecab717d82a564b2d7b)
1#!/usr/bin/env python3
2
3# Copyright (c) 2018-2019, Ulf Magnusson
4# SPDX-License-Identifier: ISC
5
6"""
7Writes a configuration file where as many symbols as possible are set to 'y'.
8
9The default output filename is '.config'. A different filename can be passed
10in the KCONFIG_CONFIG environment variable.
11
12Usage for the Linux kernel:
13
14  $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/allyesconfig.py
15"""
16import kconfiglib
17
18
19def main():
20    kconf = kconfiglib.standard_kconfig(__doc__)
21
22    # See allnoconfig.py
23    kconf.warn = False
24
25    # Try to set all symbols to 'y'. Dependencies might truncate the value down
26    # later, but this will at least give the highest possible value.
27    #
28    # Assigning 0/1/2 to non-bool/tristate symbols has no effect (int/hex
29    # symbols still take a string, because they preserve formatting).
30    for sym in kconf.unique_defined_syms:
31        # Set choice symbols to 'm'. This value will be ignored for choices in
32        # 'y' mode (the "normal" mode), which will instead just get their
33        # default selection, but will set all symbols in m-mode choices to 'm',
34        # which is as high as they can go.
35        #
36        # Here's a convoluted example of how you might get an m-mode choice
37        # even during allyesconfig:
38        #
39        #   choice
40        #           tristate "weird choice"
41        #           depends on m
42        sym.set_value(1 if sym.choice else 2)
43
44    # Set all choices to the highest possible mode
45    for choice in kconf.unique_choices:
46        choice.set_value(2)
47
48    kconf.warn = True
49
50    kconf.load_allconfig("allyes.config")
51
52    print(kconf.write_config())
53
54
55if __name__ == "__main__":
56    main()
57