The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 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 | |
Cole Faust | e23ae98 | 2022-02-28 14:20:48 -0800 | [diff] [blame] | 17 | # the sort also acts as a strip to remove the single space entries that creep in because of the evals |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 18 | define gather-all-makefiles-for-current-product |
Cole Faust | e23ae98 | 2022-02-28 14:20:48 -0800 | [diff] [blame] | 19 | $(eval _all_products_visited := )\ |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 20 | $(sort $(call gather-all-makefiles-for-current-product-inner,$(INTERNAL_PRODUCT))) |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 21 | endef |
| 22 | |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 23 | define gather-all-makefiles-for-current-product-inner |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 24 | $(foreach p,$(1),\ |
| 25 | $(if $(filter $(p),$(_all_products_visited)),, \ |
| 26 | $(p) \ |
| 27 | $(eval _all_products_visited += $(p)) \ |
Cole Faust | 23b94e6 | 2022-04-27 11:55:08 -0700 | [diff] [blame] | 28 | $(call gather-all-makefiles-for-current-product-inner, $(PRODUCTS.$(strip $(p)).INHERITS_FROM)) |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 29 | ) \ |
| 30 | ) |
| 31 | endef |
| 32 | |
Anton Hansson | 6ea1829 | 2019-05-16 11:09:57 +0100 | [diff] [blame] | 33 | node_color_target := orange |
| 34 | node_color_common := beige |
| 35 | node_color_vendor := lavenderblush |
| 36 | node_color_default := white |
| 37 | define node-color |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 38 | $(if $(filter $(1),$(PRIVATE_TOP_LEVEL_MAKEFILE)),\ |
Anton Hansson | 6ea1829 | 2019-05-16 11:09:57 +0100 | [diff] [blame] | 39 | $(node_color_target),\ |
| 40 | $(if $(filter build/make/target/product/%,$(1)),\ |
| 41 | $(node_color_common),\ |
| 42 | $(if $(filter vendor/%,$(1)),$(node_color_vendor),$(node_color_default))\ |
| 43 | )\ |
| 44 | ) |
| 45 | endef |
| 46 | |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 47 | open_parethesis := ( |
| 48 | close_parenthesis := ) |
| 49 | |
Ying Wang | 3670c84 | 2013-08-01 17:45:35 -0700 | [diff] [blame] | 50 | # Emit properties of a product node to a file. |
| 51 | # $(1) the product |
| 52 | # $(2) the output file |
| 53 | define emit-product-node-props |
| 54 | $(hide) echo \"$(1)\" [ \ |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 55 | label=\"$(dir $(1))\\n$(notdir $(1))$(if $(filter $(1),$(PRIVATE_TOP_LEVEL_MAKEFILE)),$(subst $(open_parethesis),,$(subst $(close_parenthesis),,\\n\\n$(PRODUCT_MODEL)\\n$(PRODUCT_DEVICE))))\" \ |
Anton Hansson | 6ea1829 | 2019-05-16 11:09:57 +0100 | [diff] [blame] | 56 | style=\"filled\" fillcolor=\"$(strip $(call node-color,$(1)))\" \ |
Cole Faust | e23ae98 | 2022-02-28 14:20:48 -0800 | [diff] [blame] | 57 | colorscheme=\"svg\" fontcolor=\"darkblue\" \ |
Ying Wang | 3670c84 | 2013-08-01 17:45:35 -0700 | [diff] [blame] | 58 | ] >> $(2) |
| 59 | |
| 60 | endef |
| 61 | |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 62 | products_graph := $(OUT_DIR)/products.dot |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 63 | |
Cole Faust | 81f1e92 | 2022-04-08 11:12:10 -0700 | [diff] [blame] | 64 | $(products_graph): PRIVATE_ALL_MAKEFILES_FOR_THIS_PRODUCT := $(call gather-all-makefiles-for-current-product) |
| 65 | $(products_graph): PRIVATE_TOP_LEVEL_MAKEFILE := $(INTERNAL_PRODUCT) |
| 66 | $(products_graph): |
| 67 | @echo Product graph DOT: $@ for $(PRIVATE_TOP_LEVEL_MAKEFILE) |
| 68 | $(hide) echo 'digraph {' > $@ |
| 69 | $(hide) echo 'graph [ ratio=.5 ];' >> $@ |
| 70 | $(hide) $(foreach p,$(PRIVATE_ALL_MAKEFILES_FOR_THIS_PRODUCT), \ |
| 71 | $(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), echo \"$(d)\" -\> \"$(p)\" >> $@;)) |
| 72 | $(foreach p,$(PRIVATE_ALL_MAKEFILES_FOR_THIS_PRODUCT),$(call emit-product-node-props,$(p),$@)) |
| 73 | $(hide) echo '}' >> $@ |
The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 74 | |
Dan Willemsen | 7a1da0e | 2018-07-24 01:21:12 -0700 | [diff] [blame] | 75 | .PHONY: product-graph |
Anton Hansson | 627cf05 | 2019-03-19 18:18:42 +0000 | [diff] [blame] | 76 | product-graph: $(products_graph) |
| 77 | @echo Product graph .dot file: $(products_graph) |
| 78 | @echo Command to convert to pdf: dot -Tpdf -Nshape=box -o $(OUT_DIR)/products.pdf $(products_graph) |
| 79 | @echo Command to convert to svg: dot -Tsvg -Nshape=box -o $(OUT_DIR)/products.svg $(products_graph) |