xref: /optee_os/scripts/kconfig/kconfiglib/allmodconfig.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 'm'.
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/allmodconfig.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    for sym in kconf.unique_defined_syms:
26        if sym.orig_type == kconfiglib.BOOL:
27            # 'bool' choice symbols get their default value, as determined by
28            # e.g. 'default's on the choice
29            if not sym.choice:
30                # All other bool symbols get set to 'y', like for allyesconfig
31                sym.set_value(2)
32        elif sym.orig_type == kconfiglib.TRISTATE:
33            sym.set_value(1)
34
35    for choice in kconf.unique_choices:
36        choice.set_value(2 if choice.orig_type == kconfiglib.BOOL else 1)
37
38    kconf.warn = True
39
40    kconf.load_allconfig("allmod.config")
41
42    print(kconf.write_config())
43
44
45if __name__ == "__main__":
46    main()
47