Atlas - print_tree.py
Home / ext / kconfiglib / examples Lines: 1 | Size: 1844 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1# Prints the menu tree of the configuration. Dependencies between symbols can 2# sometimes implicitly alter the menu structure (see kconfig-language.txt), and 3# that's implemented too. 4# 5# Note: See the Kconfig.node_iter() function as well, which provides a simpler 6# interface for walking the menu tree. 7# 8# Usage: 9# 10# $ make [ARCH=<arch>] scriptconfig SCRIPT=Kconfiglib/examples/print_tree.py 11# 12# Example output: 13# 14# ... 15# config HAVE_KERNEL_LZO 16# config HAVE_KERNEL_LZ4 17# choice 18# config KERNEL_GZIP 19# config KERNEL_BZIP2 20# config KERNEL_LZMA 21# config KERNEL_XZ 22# config KERNEL_LZO 23# config KERNEL_LZ4 24# config DEFAULT_HOSTNAME 25# config SWAP 26# config SYSVIPC 27# config SYSVIPC_SYSCTL 28# config POSIX_MQUEUE 29# config POSIX_MQUEUE_SYSCTL 30# config CROSS_MEMORY_ATTACH 31# config FHANDLE 32# config USELIB 33# config AUDIT 34# config HAVE_ARCH_AUDITSYSCALL 35# config AUDITSYSCALL 36# config AUDIT_WATCH 37# config AUDIT_TREE 38# menu "IRQ subsystem" 39# config MAY_HAVE_SPARSE_IRQ 40# config GENERIC_IRQ_LEGACY 41# config GENERIC_IRQ_PROBE 42# ... 43 44import sys 45 46from kconfiglib import Kconfig, Symbol, Choice, MENU, COMMENT 47 48 49def indent_print(s, indent): 50 print(indent*" " + s) 51 52 53def print_items(node, indent): 54 while node: 55 if isinstance(node.item, Symbol): 56 indent_print("config " + node.item.name, indent) 57 58 elif isinstance(node.item, Choice): 59 indent_print("choice", indent) 60 61 elif node.item == MENU: 62 indent_print('menu "{}"'.format(node.prompt[0]), indent) 63 64 elif node.item == COMMENT: 65 indent_print('comment "{}"'.format(node.prompt[0]), indent) 66 67 68 if node.list: 69 print_items(node.list, indent + 2) 70 71 node = node.next 72 73 74kconf = Kconfig(sys.argv[1]) 75print_items(kconf.top_node, 0) 76[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.