summaryrefslogtreecommitdiff
path: root/examples/eval_expr.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/eval_expr.py')
-rw-r--r--examples/eval_expr.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/examples/eval_expr.py b/examples/eval_expr.py
index edb33e6..a907f35 100644
--- a/examples/eval_expr.py
+++ b/examples/eval_expr.py
@@ -1,8 +1,22 @@
-# Evaluates an expression in the context of a configuration. (Here we could
-# load a .config as well.)
+# Evaluates an expression (e.g. "X86_64 || (X86_32 && X86_LOCAL_APIC)") in the
+# context of a configuration. Note that this always yields a tristate value (n,
+# m, or y).
+#
+# Usage:
+#
+# $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/eval_expr.py SCRIPT_ARG=<expr>
import kconfiglib
import sys
+if len(sys.argv) < 3:
+ print('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=NAME')
+ sys.exit(1)
+
conf = kconfiglib.Config(sys.argv[1])
-print(conf.eval("(TRACE_IRQFLAGS_SUPPORT || PPC32) && STACKTRACE_SUPPORT"))
+
+# Enable modules so that 'm' doesn't get demoted to 'n'
+conf.syms["MODULES"].set_value("y")
+
+print("the expression '{}' evaluates to {}"
+ .format(sys.argv[2], conf.eval_string(sys.argv[2])))