1#!/usr/bin/env python3 2 3# note - needs 4# sudo apt-get install python3-networkx python3-matplotlib 5import matplotlib.pyplot as plt 6import networkx as nx 7 8import re 9import fileinput 10 11# okay - not actually using this now 12# groups : 1 -> module name, 2 -> ultimate deps 13RE_highlevel = re.compile("error: [^ ]* module \"([^\"]*)\" variant \"[^\"]*\" .*? depends on multiple versions of the same aidl_interface: (.*)\n") 14 15# groups : 1 -> module name 16RE_dependencyStart = re.compile("error: [^ ]* module \"([^\"]*)\" variant \"[^\"]*\" .*? Dependency path.*\n") 17 18# groups : 1 -> module name 19RE_dependencyCont = re.compile(" *-> ([^{]*){.*\n") 20 21RE_ignore= re.compile(" *via tag.*{.*}.*\n") 22 23# [(module, module)] 24graph = [] 25 26last = None 27 28for i in fileinput.input(): 29 # could validate consistency of this graph based on this 30 if RE_highlevel.fullmatch(i): continue 31 32 m = RE_dependencyStart.fullmatch(i) 33 if m: 34 last = m.groups()[0] 35 continue 36 37 m = RE_dependencyCont.fullmatch(i) 38 if m: 39 curr = m.groups()[0] 40 graph += [(last, curr)] 41 last = curr 42 continue 43 44 if RE_ignore.fullmatch(i): continue 45 46 print("UNRECOGNIZED LINE", i.strip()) 47 48#for a,b in graph: 49# print(a,b) 50 51G = nx.MultiDiGraph() 52G.add_edges_from(graph) 53plt.figure(figsize=(10,10)) 54nx.draw(G, connectionstyle='arc3,rad=0.01', with_labels=True) 55plt.show() 56 57