From 13884e934ec8eda928234c6506ae27f0334ec31b Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 23 Aug 2018 02:43:00 +0200 Subject: Show include paths in menuconfig symbol information Add a MenuNode.include_path attribute that holds a tuple of (filename, linenr) tuples, giving the locations of the 'source' statements via which the node's Kconfig file was included, starting from the top-level Kconfig file. Use MenuNode.include_path to give the include path for symbols and other items in the help display in the menuconfig interface. This is useful for figuring out how Kconfig files are organized, and when reorganizing things. --- menuconfig.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'menuconfig.py') diff --git a/menuconfig.py b/menuconfig.py index 8f5dbe0..8c575b5 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -2075,22 +2075,31 @@ def _select_imply_info(sym): def _kconfig_def_info(item): # Returns a string with the definition of 'item' in Kconfig syntax, - # together with the definition location(s) + # together with the definition location(s) and their include and menu paths nodes = [item] if isinstance(item, MenuNode) else item.nodes s = "Kconfig definition{}, with propagated dependencies\n" \ .format("s" if len(nodes) > 1 else "") - s += (len(s) - 1)*"=" + "\n\n" - - s += "\n\n".join("At {}:{}, in menu {}:\n\n{}".format( - node.filename, node.linenr, _menu_path_info(node), - textwrap.indent(node.custom_str(_name_and_val_str), - " ")) - for node in nodes) + s += (len(s) - 1)*"=" + + for node in nodes: + s += "\n\n" \ + "At {}:{}\n" \ + "Included via {}\n" \ + "Menu path: {}\n\n" \ + "{}" \ + .format(node.filename, node.linenr, + _include_path_info(node), + _menu_path_info(node), + textwrap.indent(node.custom_str(_name_and_val_str), " ")) return s +def _include_path_info(node): + return " -> ".join("{}:{}".format(filename, linenr) + for filename, linenr in node.include_path) + def _menu_path_info(node): # Returns a string describing the menu path leading up to 'node' -- cgit v1.2.3