From dd0e227216e247d2040cdd40bf7397702880cdc4 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 9 Oct 2017 23:05:00 +0200 Subject: Kconfiglib 2 backup WIP --- examples/eval_expr.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'examples/eval_expr.py') 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=] scriptconfig SCRIPT=Kconfiglib/examples/eval_expr.py SCRIPT_ARG= 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]))) -- cgit v1.2.3