product-graph.mk revision 3366c07e56cdb6ad7b1184388b5f25cf819de579
1#
2# Copyright (C) 2009 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17products_pdf := $(OUT_DIR)/products.pdf
18products_graph := $(products_pdf:%.pdf=%.dot)
19
20$(products_graph):
21	@echo Product graph DOT: $@
22	$(hide) ( \
23		echo 'digraph {'; \
24		echo 'graph [ ratio=.5 ];'; \
25		$(foreach p,$(ALL_PRODUCTS), \
26			$(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), \
27			echo \"$(d)\" -\> \"$(p)\";)) \
28		$(foreach prod, \
29			$(sort $(foreach p,$(ALL_PRODUCTS), \
30				$(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), \
31					$(d))) \
32				$(foreach p,$(ALL_PRODUCTS),$(p))), \
33			echo \"$(prod)\" [ label=\"$(dir $(prod))\\n$(notdir $(prod))\"];) \
34		echo '}' \
35	) > $@
36
37# This rule doesn't include any nodes that don't inherit from
38# anything or don't have anything inherit from them, to make the
39# graph more readable.  To add that, add this line to the rule
40# below:
41#		$(foreach p,$(ALL_PRODUCTS), echo \"$(p)\";) \
42
43$(products_pdf): $(products_graph)
44	@echo Product graph PDF: $@
45	dot -Tpdf -Nshape=box -o $@ $<
46
47product-graph: $(products_pdf)
48
49