make product-graph now filtered
Change-Id: I6bd93a87902e20a24c1c58152fb578ef1f4cb208
This commit is contained in:
parent
6020d698f5
commit
f5debbfee6
|
@ -16,9 +16,20 @@
|
|||
|
||||
products_pdf := $(OUT_DIR)/products.pdf
|
||||
products_graph := $(products_pdf:%.pdf=%.dot)
|
||||
ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),)
|
||||
products_list := $(INTERNAL_PRODUCT)
|
||||
else
|
||||
ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),--all)
|
||||
products_list := --all
|
||||
else
|
||||
products_list := $(foreach prod,$(ANDROID_PRODUCT_GRAPH),$(call resolve-short-product-name,$(prod)))
|
||||
endif
|
||||
endif
|
||||
|
||||
$(products_graph): PRIVATE_PRODUCTS := $(products_list)
|
||||
|
||||
$(products_graph):
|
||||
@echo Product graph DOT: $@
|
||||
@echo Product graph DOT: $@ for $(PRIVATE_PRODUCTS)
|
||||
$(hide) ( \
|
||||
echo 'digraph {'; \
|
||||
echo 'graph [ ratio=.5 ];'; \
|
||||
|
@ -27,12 +38,17 @@ $(products_graph):
|
|||
echo \"$(d)\" -\> \"$(p)\";)) \
|
||||
$(foreach prod, \
|
||||
$(sort $(foreach p,$(ALL_PRODUCTS), \
|
||||
$(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), \
|
||||
$(d))) \
|
||||
$(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), $(d))) \
|
||||
$(foreach p,$(ALL_PRODUCTS),$(p))), \
|
||||
echo \"$(prod)\" [ label=\"$(dir $(prod))\\n$(notdir $(prod))\"];) \
|
||||
echo \"$(prod)\" [ \
|
||||
label=\"$(dir $(prod))\\n$(notdir $(prod))\\n\\n$(PRODUCTS.$(strip $(prod)).PRODUCT_MODEL)\\n$(PRODUCTS.$(strip $(prod)).PRODUCT_DEVICE)\" \
|
||||
$(if $(filter $(prod),$(PRIVATE_PRODUCTS)), \
|
||||
style=\"filled\" fillcolor=\"#FFFDB0\",) \
|
||||
];) \
|
||||
echo '}' \
|
||||
) > $@
|
||||
) \
|
||||
| ./build/tools/filter-product-graph.py $(PRIVATE_PRODUCTS) \
|
||||
> $@
|
||||
|
||||
# This rule doesn't include any nodes that don't inherit from
|
||||
# anything or don't have anything inherit from them, to make the
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python
|
||||
# vim: ts=2 sw=2 nocindent
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
def choose_regex(regs, line):
|
||||
for func,reg in regs:
|
||||
m = reg.match(line)
|
||||
if m:
|
||||
return (func,m)
|
||||
return (None,None)
|
||||
|
||||
def gather(included, deps):
|
||||
result = set()
|
||||
for inc in included:
|
||||
result.add(inc)
|
||||
for d in deps:
|
||||
if inc == d[1]:
|
||||
result.add(d[0])
|
||||
return result
|
||||
|
||||
def main():
|
||||
deps = []
|
||||
infos = []
|
||||
def dependency(m):
|
||||
deps.append((m.group(1), m.group(2)))
|
||||
def info(m):
|
||||
infos.append((m.group(1), m.group(2)))
|
||||
|
||||
REGS = [
|
||||
(dependency, re.compile(r'"(.*)"\s*->\s*"(.*)"')),
|
||||
(info, re.compile(r'"(.*)"(\s*\[.*\])')),
|
||||
]
|
||||
|
||||
lines = sys.stdin.readlines()
|
||||
lines = [line.strip() for line in lines]
|
||||
|
||||
for line in lines:
|
||||
func,m = choose_regex(REGS, line)
|
||||
if func:
|
||||
func(m)
|
||||
|
||||
# filter
|
||||
sys.stderr.write("argv: " + str(sys.argv) + "\n")
|
||||
if not (len(sys.argv) == 2 and sys.argv[1] == "--all"):
|
||||
targets = sys.argv[1:]
|
||||
|
||||
included = set(targets)
|
||||
prevLen = -1
|
||||
while prevLen != len(included):
|
||||
prevLen = len(included)
|
||||
included = gather(included, deps)
|
||||
|
||||
deps = [dep for dep in deps if dep[1] in included]
|
||||
infos = [info for info in infos if info[0] in included]
|
||||
|
||||
print "digraph {"
|
||||
print "graph [ ratio=.5 ];"
|
||||
for dep in deps:
|
||||
print '"%s" -> "%s"' % dep
|
||||
for info in infos:
|
||||
print '"%s"%s' % info
|
||||
print "}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue