allnoconfig.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 'n'.
  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/allnoconfig.py
  10. """
  11. # See examples/allnoconfig_walk.py for another way to implement this script
  12. import kconfiglib
  13. def main():
  14. kconf = kconfiglib.standard_kconfig(__doc__)
  15. # Avoid warnings that would otherwise get printed by Kconfiglib for the
  16. # following:
  17. #
  18. # 1. Assigning a value to a symbol without a prompt, which never has any
  19. # effect
  20. #
  21. # 2. Assigning values invalid for the type (only bool/tristate symbols
  22. # accept 0/1/2, for n/m/y). The assignments will be ignored for other
  23. # symbol types, which is what we want.
  24. kconf.warn = False
  25. for sym in kconf.unique_defined_syms:
  26. sym.set_value(2 if sym.is_allnoconfig_y else 0)
  27. kconf.warn = True
  28. kconf.load_allconfig("allno.config")
  29. print(kconf.write_config())
  30. if __name__ == "__main__":
  31. main()