aboutsummaryrefslogtreecommitdiff
path: root/scripts/Kconfiglib/allyesconfig.py
diff options
context:
space:
mode:
authorAnup Patel <apatel@ventanamicro.com>2022-08-08 09:33:03 +0530
committerAnup Patel <anup@brainfault.org>2022-08-08 09:33:03 +0530
commit422f0e0486dd30196c11e43763510410c8632bcb (patch)
treeb01d5d29ef273035cc9b1004669c49adc52980ce /scripts/Kconfiglib/allyesconfig.py
parentb9edf49b67a1b5e47b1c35dcd7c75efccaf22ea3 (diff)
downloadopensbi-422f0e0486dd30196c11e43763510410c8632bcb.zip
opensbi-422f0e0486dd30196c11e43763510410c8632bcb.tar.gz
opensbi-422f0e0486dd30196c11e43763510410c8632bcb.tar.bz2
scripts: Add Kconfiglib v14.1.0 under scripts directory
We adopt Kconfiglib v14.1.0 sources under scripts directory so that top-level OpenSBI makefile can directly use Kconfiglib scripts without expecting users to install a particular version of Kconfiglib on their build system. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Tested-by: Andrew Jones <ajones@ventanamicro.com> Acked-by: Atish Patra <atishp@rivosinc.com> Tested-by: Atish Patra <atishp@rivosinc.com>
Diffstat (limited to 'scripts/Kconfiglib/allyesconfig.py')
-rwxr-xr-xscripts/Kconfiglib/allyesconfig.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/Kconfiglib/allyesconfig.py b/scripts/Kconfiglib/allyesconfig.py
new file mode 100755
index 0000000..90eb9b8
--- /dev/null
+++ b/scripts/Kconfiglib/allyesconfig.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+
+# Copyright (c) 2018-2019, Ulf Magnusson
+# SPDX-License-Identifier: ISC
+
+"""
+Writes a configuration file where as many symbols as possible are set to 'y'.
+
+The default output filename is '.config'. A different filename can be passed
+in the KCONFIG_CONFIG environment variable.
+
+Usage for the Linux kernel:
+
+ $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/allyesconfig.py
+"""
+import kconfiglib
+
+
+def main():
+ kconf = kconfiglib.standard_kconfig(__doc__)
+
+ # See allnoconfig.py
+ kconf.warn = False
+
+ # Try to set all symbols to 'y'. Dependencies might truncate the value down
+ # later, but this will at least give the highest possible value.
+ #
+ # Assigning 0/1/2 to non-bool/tristate symbols has no effect (int/hex
+ # symbols still take a string, because they preserve formatting).
+ for sym in kconf.unique_defined_syms:
+ # Set choice symbols to 'm'. This value will be ignored for choices in
+ # 'y' mode (the "normal" mode), which will instead just get their
+ # default selection, but will set all symbols in m-mode choices to 'm',
+ # which is as high as they can go.
+ #
+ # Here's a convoluted example of how you might get an m-mode choice
+ # even during allyesconfig:
+ #
+ # choice
+ # tristate "weird choice"
+ # depends on m
+ sym.set_value(1 if sym.choice else 2)
+
+ # Set all choices to the highest possible mode
+ for choice in kconf.unique_choices:
+ choice.set_value(2)
+
+ kconf.warn = True
+
+ kconf.load_allconfig("allyes.config")
+
+ print(kconf.write_config())
+
+
+if __name__ == "__main__":
+ main()