Atlas - print_sym_info.py
Home / ext / kconfiglib / examples Lines: 1 | Size: 1680 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1# Loads a Kconfig and a .config and prints a symbol. 2# 3# Usage: 4# 5# $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/print_sym_info.py SCRIPT_ARG=<name> 6# 7# Example output for SCRIPT_ARG=MODULES: 8# 9# menuconfig MODULES 10# bool 11# prompt "Enable loadable module support" 12# option modules 13# help 14# Kernel modules are small pieces of compiled code which can 15# be inserted in the running kernel, rather than being 16# permanently built into the kernel. You use the "modprobe" 17# tool to add (and sometimes remove) them. If you say Y here, 18# many parts of the kernel can be built as modules (by 19# answering M instead of Y where indicated): this is most 20# useful for infrequently used options which are not required 21# for booting. For more information, see the man pages for 22# modprobe, lsmod, modinfo, insmod and rmmod. 23# 24# If you say Y here, you will need to run "make 25# modules_install" to put the modules under /lib/modules/ 26# where modprobe can find them (you may need to be root to do 27# this). 28# 29# If unsure, say Y. 30# 31# value = n 32# visibility = y 33# currently assignable values: n, y 34# defined at init/Kconfig:1674 35 36import sys 37 38from kconfiglib import Kconfig, TRI_TO_STR 39 40 41if len(sys.argv) < 3: 42 sys.exit('Pass symbol name (without "CONFIG_" prefix) with SCRIPT_ARG=<name>') 43 44kconf = Kconfig(sys.argv[1]) 45sym = kconf.syms[sys.argv[2]] 46 47print(sym) 48print("value = " + sym.str_value) 49print("visibility = " + TRI_TO_STR[sym.visibility]) 50print("currently assignable values: " + 51 ", ".join([TRI_TO_STR[v] for v in sym.assignable])) 52 53for node in sym.nodes: 54 print("defined at {}:{}".format(node.filename, node.linenr)) 55[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.