allmodconfig.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2018-2019, Ulf Magnusson
  3. # SPDX-License-Identifier: ISC
  4. """
  5. Writes a configuration file where as many symbols as possible are set to 'm'.
  6. The default output filename is '.config'. A different filename can be passed
  7. in the KCONFIG_CONFIG environment variable.
  8. Usage for the Linux kernel:
  9. $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/allmodconfig.py
  10. """
  11. import kconfiglib
  12. def main():
  13. kconf = kconfiglib.standard_kconfig(__doc__)
  14. # See allnoconfig.py
  15. kconf.warn = False
  16. for sym in kconf.unique_defined_syms:
  17. if sym.orig_type == kconfiglib.BOOL:
  18. # 'bool' choice symbols get their default value, as determined by
  19. # e.g. 'default's on the choice
  20. if not sym.choice:
  21. # All other bool symbols get set to 'y', like for allyesconfig
  22. sym.set_value(2)
  23. elif sym.orig_type == kconfiglib.TRISTATE:
  24. sym.set_value(1)
  25. for choice in kconf.unique_choices:
  26. choice.set_value(2 if choice.orig_type == kconfiglib.BOOL else 1)
  27. kconf.warn = True
  28. kconf.load_allconfig("allmod.config")
  29. print(kconf.write_config())
  30. if __name__ == "__main__":
  31. main()