From 35a60b786c646c846d9bad6a5f15711acc9a62c6 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 15 Sep 2018 02:19:34 +0200 Subject: Update some examples to use node_iter() Simplifies the code. Should promote new APIs. Also fix list_undefined.py for recent kernels. More environment variables are referenced now. --- examples/list_undefined.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'examples/list_undefined.py') diff --git a/examples/list_undefined.py b/examples/list_undefined.py index 0207975..4a3bc9b 100644 --- a/examples/list_undefined.py +++ b/examples/list_undefined.py @@ -70,9 +70,6 @@ def all_arch_srcarch_pairs(): yield ("sh64", "sh") - yield ("tilepro", "tile") - yield ("tilegx", "tile") - yield ("um", "um") @@ -80,6 +77,13 @@ def all_arch_srcarch_kconfigs(): """ Generates Kconfig instances for all the architectures in the kernel """ + + os.environ["srctree"] = "." + os.environ["HOSTCC"] = "gcc" + os.environ["HOSTCXX"] = "g++" + os.environ["CC"] = "gcc" + os.environ["LD"] = "ld" + for arch, srcarch in all_arch_srcarch_pairs(): print(" Processing " + arch) @@ -118,21 +122,16 @@ for kconf in all_arch_srcarch_kconfigs(): print("\nFinding references to each undefined symbol") -def referencing_nodes(node, name): +def referencing_nodes(kconf, name): # Returns a list of all menu nodes that reference a symbol named 'name' in # any of their properties or property conditions res = [] - while node: + for node in kconf.node_iter(): for ref in node.referenced: if ref.name == name: res.append(node) - if node.list: - res.extend(referencing_nodes(node.list, name)) - - node = node.next - return res @@ -145,7 +144,7 @@ for kconf in all_arch_srcarch_kconfigs(): # undefined symbol, which is terribly inefficient. We could speed # things up by tweaking referencing_nodes() to compare each symbol to # multiple symbols while walking the configuration tree. - for node in referencing_nodes(kconf.top_node, name): + for node in referencing_nodes(kconf, name): refs.add("{}:{}".format(node.filename, node.linenr)) -- cgit v1.2.3