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 |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 18 | define gather-all-products |
Cole Faust | e23ae98 | 2022-02-28 14:20:48 -0800 | [diff] [blame^] | 19 | $(eval _all_products_visited := )\ |
| 20 | $(sort $(call all-products-inner, $(PARENT_PRODUCT_FILES))) |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 21 | endef |
| 22 | |
| 23 | define all-products-inner |
| 24 | $(foreach p,$(1),\ |
| 25 | $(if $(filter $(p),$(_all_products_visited)),, \ |
| 26 | $(p) \ |
| 27 | $(eval _all_products_visited += $(p)) \ |
| 28 | $(call all-products-inner, $(PRODUCTS.$(strip $(p)).INHERITS_FROM)) |
| 29 | ) \ |
| 30 | ) |
| 31 | endef |
| 32 | |
Colin Cross | 6cdc5d2 | 2017-10-20 11:37:33 -0700 | [diff] [blame] | 33 | this_makefile := build/make/core/product-graph.mk |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 34 | |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 35 | products_graph := $(OUT_DIR)/products.dot |
Joe Onorato | 8b46e30 | 2012-05-07 17:15:15 -0700 | [diff] [blame] | 36 | ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),) |
| 37 | products_list := $(INTERNAL_PRODUCT) |
| 38 | else |
| 39 | ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),--all) |
| 40 | products_list := --all |
| 41 | else |
| 42 | products_list := $(foreach prod,$(ANDROID_PRODUCT_GRAPH),$(call resolve-short-product-name,$(prod))) |
| 43 | endif |
| 44 | endif |
| 45 | |
Anton Hansson | 061cbcf | 2018-05-30 18:24:41 +0100 | [diff] [blame] | 46 | all_products := $(call gather-all-products) |
The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 47 | |
Ying Wang | 3670c84 | 2013-08-01 17:45:35 -0700 | [diff] [blame] | 48 | open_parethesis := ( |
| 49 | close_parenthesis := ) |
| 50 | |
Anton Hansson | 6ea1829 | 2019-05-16 11:09:57 +0100 | [diff] [blame] | 51 | node_color_target := orange |
| 52 | node_color_common := beige |
| 53 | node_color_vendor := lavenderblush |
| 54 | node_color_default := white |
| 55 | define node-color |
| 56 | $(if $(filter $(1),$(PRIVATE_PRODUCTS_FILTER)),\ |
| 57 | $(node_color_target),\ |
| 58 | $(if $(filter build/make/target/product/%,$(1)),\ |
| 59 | $(node_color_common),\ |
| 60 | $(if $(filter vendor/%,$(1)),$(node_color_vendor),$(node_color_default))\ |
| 61 | )\ |
| 62 | ) |
| 63 | endef |
| 64 | |
Ying Wang | 3670c84 | 2013-08-01 17:45:35 -0700 | [diff] [blame] | 65 | # Emit properties of a product node to a file. |
| 66 | # $(1) the product |
| 67 | # $(2) the output file |
| 68 | define emit-product-node-props |
| 69 | $(hide) echo \"$(1)\" [ \ |
Anton Hansson | cca8cdb | 2019-10-28 11:30:40 +0000 | [diff] [blame] | 70 | label=\"$(dir $(1))\\n$(notdir $(1))\\n\\n$(subst $(close_parenthesis),,$(subst $(open_parethesis),,$(call get-product-var,$(1),PRODUCT_MODEL)))\\n$(call get-product-var,$(1),PRODUCT_DEVICE)\" \ |
Anton Hansson | 6ea1829 | 2019-05-16 11:09:57 +0100 | [diff] [blame] | 71 | style=\"filled\" fillcolor=\"$(strip $(call node-color,$(1)))\" \ |
Cole Faust | e23ae98 | 2022-02-28 14:20:48 -0800 | [diff] [blame^] | 72 | colorscheme=\"svg\" fontcolor=\"darkblue\" \ |
Ying Wang | 3670c84 | 2013-08-01 17:45:35 -0700 | [diff] [blame] | 73 | ] >> $(2) |
| 74 | |
| 75 | endef |
| 76 | |
Anton Hansson | 061cbcf | 2018-05-30 18:24:41 +0100 | [diff] [blame] | 77 | $(products_graph): PRIVATE_PRODUCTS := $(all_products) |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 78 | $(products_graph): PRIVATE_PRODUCTS_FILTER := $(products_list) |
| 79 | |
| 80 | $(products_graph): $(this_makefile) |
Cole Faust | 985fa48 | 2021-10-07 17:14:23 -0700 | [diff] [blame] | 81 | ifeq (,$(RBC_PRODUCT_CONFIG)$(RBC_NO_PRODUCT_GRAPH)$(RBC_BOARD_CONFIG)) |
Joe Onorato | 8815542 | 2012-07-23 13:51:44 -0700 | [diff] [blame] | 82 | @echo Product graph DOT: $@ for $(PRIVATE_PRODUCTS_FILTER) |
Ying Wang | 3670c84 | 2013-08-01 17:45:35 -0700 | [diff] [blame] | 83 | $(hide) echo 'digraph {' > $@.in |
| 84 | $(hide) echo 'graph [ ratio=.5 ];' >> $@.in |
| 85 | $(hide) $(foreach p,$(PRIVATE_PRODUCTS), \ |
| 86 | $(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), echo \"$(d)\" -\> \"$(p)\" >> $@.in;)) |
| 87 | $(foreach p,$(PRIVATE_PRODUCTS),$(call emit-product-node-props,$(p),$@.in)) |
| 88 | $(hide) echo '}' >> $@.in |
Colin Cross | fdea893 | 2017-12-06 14:38:40 -0800 | [diff] [blame] | 89 | $(hide) build/make/tools/filter-product-graph.py $(PRIVATE_PRODUCTS_FILTER) < $@.in > $@ |
Sasha Smundak | 8d97bf5 | 2021-05-04 09:58:38 -0700 | [diff] [blame] | 90 | else |
| 91 | @echo RBC_PRODUCT_CONFIG and RBC_NO_PRODUCT_GRAPH should be unset to generate product graph |
| 92 | false |
| 93 | endif |
Joe Onorato | 3366c07 | 2009-08-08 12:14:37 -0700 | [diff] [blame] | 94 | |
Cole Faust | 985fa48 | 2021-10-07 17:14:23 -0700 | [diff] [blame] | 95 | ifeq (,$(RBC_PRODUCT_CONFIG)$(RBC_NO_PRODUCT_GRAPH)$(RBC_BOARD_CONFIG)) |
The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 96 | |
Dan Willemsen | 7a1da0e | 2018-07-24 01:21:12 -0700 | [diff] [blame] | 97 | .PHONY: product-graph |
Anton Hansson | 627cf05 | 2019-03-19 18:18:42 +0000 | [diff] [blame] | 98 | product-graph: $(products_graph) |
| 99 | @echo Product graph .dot file: $(products_graph) |
| 100 | @echo Command to convert to pdf: dot -Tpdf -Nshape=box -o $(OUT_DIR)/products.pdf $(products_graph) |
| 101 | @echo Command to convert to svg: dot -Tsvg -Nshape=box -o $(OUT_DIR)/products.svg $(products_graph) |
Sasha Smundak | 8d97bf5 | 2021-05-04 09:58:38 -0700 | [diff] [blame] | 102 | else |
| 103 | .PHONY: product-graph |
| 104 | @echo RBC_PRODUCT_CONFIG and RBC_NO_PRODUCT_GRAPH should be unset to generate product graph |
| 105 | false |
Cole Faust | 985fa48 | 2021-10-07 17:14:23 -0700 | [diff] [blame] | 106 | endif |