Atlas - eval_expr.py

Home / ext / kconfiglib / examples Lines: 1 | Size: 643 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1# Evaluates an expression (e.g. "X86_64 || (X86_32 && X86_LOCAL_APIC)") in the 2# context of a configuration. Note that this always yields a tristate value (n, 3# m, or y). 4# 5# Usage: 6# 7# $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/eval_expr.py SCRIPT_ARG=<expr> 8 9import sys 10 11import kconfiglib 12 13 14if len(sys.argv) < 3: 15 sys.exit("Pass the expression to evaluate with SCRIPT_ARG=<expression>") 16 17kconf = kconfiglib.Kconfig(sys.argv[1]) 18expr = sys.argv[2] 19 20# Enable modules so that m doesn't get demoted to n 21kconf.modules.set_value(2) 22 23print("the expression '{}' evaluates to {}" 24 .format(expr, kconf.eval_string(expr))) 25
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.