• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2
3#
4# Run from the root of the tree, after product-config has been run to see
5# the product inheritance hierarchy for the current lunch target.
6#
7
8import csv
9import sys
10
11def PrintNodes(graph, node, prefix):
12  sys.stdout.write("%s%s" % (prefix, node))
13  children = graph.get(node, [])
14  if children:
15    sys.stdout.write(" {\n")
16    for child in sorted(graph.get(node, [])):
17      PrintNodes(graph, child, prefix + "  ")
18    sys.stdout.write("%s}\n" % prefix);
19  else:
20    sys.stdout.write("\n")
21
22def main(argv):
23  if len(argv) != 2:
24    print("usage: inherit_tree.py out/$TARGET_PRODUCT-$TARGET_BUILD_VARIANT/dumpconfig.csv")
25    sys.exit(1)
26
27  root = None
28  graph = {}
29  with open(argv[1], newline='') as csvfile:
30    for line in csv.reader(csvfile):
31      if not root:
32        # Look for PRODUCTS
33        if len(line) < 3 or line[0] != "phase" or line[1] != "PRODUCTS":
34          continue
35        root = line[2]
36      else:
37        # Everything else
38        if len(line) < 3 or line[0] != "inherit":
39          continue
40        graph.setdefault(line[1], list()).append(line[2])
41
42  PrintNodes(graph, root, "")
43
44
45if __name__ == "__main__":
46  main(sys.argv)
47
48# vim: set expandtab ts=2 sw=2 sts=2:
49
50