allyesconfig.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 'y'.
  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/allyesconfig.py
  10. """
  11. import kconfiglib
  12. def main():
  13. kconf = kconfiglib.standard_kconfig(__doc__)
  14. # See allnoconfig.py
  15. kconf.warn = False
  16. # Try to set all symbols to 'y'. Dependencies might truncate the value down
  17. # later, but this will at least give the highest possible value.
  18. #
  19. # Assigning 0/1/2 to non-bool/tristate symbols has no effect (int/hex
  20. # symbols still take a string, because they preserve formatting).
  21. for sym in kconf.unique_defined_syms:
  22. # Set choice symbols to 'm'. This value will be ignored for choices in
  23. # 'y' mode (the "normal" mode), which will instead just get their
  24. # default selection, but will set all symbols in m-mode choices to 'm',
  25. # which is as high as they can go.
  26. #
  27. # Here's a convoluted example of how you might get an m-mode choice
  28. # even during allyesconfig:
  29. #
  30. # choice
  31. # tristate "weird choice"
  32. # depends on m
  33. sym.set_value(1 if sym.choice else 2)
  34. # Set all choices to the highest possible mode
  35. for choice in kconf.unique_choices:
  36. choice.set_value(2)
  37. kconf.warn = True
  38. kconf.load_allconfig("allyes.config")
  39. print(kconf.write_config())
  40. if __name__ == "__main__":
  41. main()