blob: 9db277c5f91b8289c1eca1159b611405b97652ae [file] [log] [blame]
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -08001#
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
Joe Onorato88155422012-07-23 13:51:44 -070017# the foreach and the if remove the single space entries that creep in because of the evals
18define gather-all-products
19$(sort $(foreach p, \
20 $(eval _all_products_visited := )
Anton Hansson061cbcf2018-05-30 18:24:41 +010021 $(call all-products-inner, $(PARENT_PRODUCT_FILES)) \
Joe Onorato88155422012-07-23 13:51:44 -070022 , $(if $(strip $(p)),$(strip $(p)),)) \
23)
24endef
25
26define all-products-inner
27 $(foreach p,$(1),\
28 $(if $(filter $(p),$(_all_products_visited)),, \
29 $(p) \
30 $(eval _all_products_visited += $(p)) \
31 $(call all-products-inner, $(PRODUCTS.$(strip $(p)).INHERITS_FROM))
32 ) \
33 )
34endef
35
36
Colin Cross6cdc5d22017-10-20 11:37:33 -070037this_makefile := build/make/core/product-graph.mk
Joe Onorato88155422012-07-23 13:51:44 -070038
Joe Onorato88155422012-07-23 13:51:44 -070039products_graph := $(OUT_DIR)/products.dot
Joe Onorato8b46e302012-05-07 17:15:15 -070040ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),)
41products_list := $(INTERNAL_PRODUCT)
42else
43ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),--all)
44products_list := --all
45else
46products_list := $(foreach prod,$(ANDROID_PRODUCT_GRAPH),$(call resolve-short-product-name,$(prod)))
47endif
48endif
49
Anton Hansson061cbcf2018-05-30 18:24:41 +010050all_products := $(call gather-all-products)
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -080051
Ying Wang3670c842013-08-01 17:45:35 -070052open_parethesis := (
53close_parenthesis := )
54
Anton Hansson6ea18292019-05-16 11:09:57 +010055node_color_target := orange
56node_color_common := beige
57node_color_vendor := lavenderblush
58node_color_default := white
59define node-color
60$(if $(filter $(1),$(PRIVATE_PRODUCTS_FILTER)),\
61 $(node_color_target),\
62 $(if $(filter build/make/target/product/%,$(1)),\
63 $(node_color_common),\
64 $(if $(filter vendor/%,$(1)),$(node_color_vendor),$(node_color_default))\
65 )\
66)
67endef
68
Ying Wang3670c842013-08-01 17:45:35 -070069# Emit properties of a product node to a file.
70# $(1) the product
71# $(2) the output file
72define emit-product-node-props
73$(hide) echo \"$(1)\" [ \
74label=\"$(dir $(1))\\n$(notdir $(1))\\n\\n$(subst $(close_parenthesis),,$(subst $(open_parethesis),,$(PRODUCTS.$(strip $(1)).PRODUCT_MODEL)))\\n$(PRODUCTS.$(strip $(1)).PRODUCT_DEVICE)\" \
Anton Hansson6ea18292019-05-16 11:09:57 +010075style=\"filled\" fillcolor=\"$(strip $(call node-color,$(1)))\" \
Marcos Maradoa69822c2014-10-22 14:19:34 +010076colorscheme=\"svg\" fontcolor=\"darkblue\" href=\"products/$(1).html\" \
Ying Wang3670c842013-08-01 17:45:35 -070077] >> $(2)
78
79endef
80
Anton Hansson061cbcf2018-05-30 18:24:41 +010081$(products_graph): PRIVATE_PRODUCTS := $(all_products)
Joe Onorato88155422012-07-23 13:51:44 -070082$(products_graph): PRIVATE_PRODUCTS_FILTER := $(products_list)
83
84$(products_graph): $(this_makefile)
85 @echo Product graph DOT: $@ for $(PRIVATE_PRODUCTS_FILTER)
Ying Wang3670c842013-08-01 17:45:35 -070086 $(hide) echo 'digraph {' > $@.in
87 $(hide) echo 'graph [ ratio=.5 ];' >> $@.in
88 $(hide) $(foreach p,$(PRIVATE_PRODUCTS), \
89 $(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), echo \"$(d)\" -\> \"$(p)\" >> $@.in;))
90 $(foreach p,$(PRIVATE_PRODUCTS),$(call emit-product-node-props,$(p),$@.in))
91 $(hide) echo '}' >> $@.in
Colin Crossfdea8932017-12-06 14:38:40 -080092 $(hide) build/make/tools/filter-product-graph.py $(PRIVATE_PRODUCTS_FILTER) < $@.in > $@
Joe Onorato3366c072009-08-08 12:14:37 -070093
Joe Onorato88155422012-07-23 13:51:44 -070094# Evaluates to the name of the product file
95# $(1) product file
96define product-debug-filename
97$(OUT_DIR)/products/$(strip $(1)).html
98endef
99
100# Makes a rule for the product debug info
101# $(1) product file
102define transform-product-debug
103$(OUT_DIR)/products/$(strip $(1)).txt: $(this_makefile)
104 @echo Product debug info file: $$@
105 $(hide) rm -f $$@
106 $(hide) mkdir -p $$(dir $$@)
107 $(hide) echo 'FILE=$(strip $(1))' >> $$@
108 $(hide) echo 'PRODUCT_NAME=$$(PRODUCTS.$(strip $(1)).PRODUCT_NAME)' >> $$@
109 $(hide) echo 'PRODUCT_MODEL=$$(PRODUCTS.$(strip $(1)).PRODUCT_MODEL)' >> $$@
110 $(hide) echo 'PRODUCT_LOCALES=$$(PRODUCTS.$(strip $(1)).PRODUCT_LOCALES)' >> $$@
111 $(hide) echo 'PRODUCT_AAPT_CONFIG=$$(PRODUCTS.$(strip $(1)).PRODUCT_AAPT_CONFIG)' >> $$@
112 $(hide) echo 'PRODUCT_AAPT_PREF_CONFIG=$$(PRODUCTS.$(strip $(1)).PRODUCT_AAPT_PREF_CONFIG)' >> $$@
113 $(hide) echo 'PRODUCT_PACKAGES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PACKAGES)' >> $$@
114 $(hide) echo 'PRODUCT_DEVICE=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEVICE)' >> $$@
115 $(hide) echo 'PRODUCT_MANUFACTURER=$$(PRODUCTS.$(strip $(1)).PRODUCT_MANUFACTURER)' >> $$@
116 $(hide) echo 'PRODUCT_PROPERTY_OVERRIDES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PROPERTY_OVERRIDES)' >> $$@
117 $(hide) echo 'PRODUCT_DEFAULT_PROPERTY_OVERRIDES=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_PROPERTY_OVERRIDES)' >> $$@
Jaekyun Seokb31b9ba2017-11-03 15:18:55 +0900118 $(hide) echo 'PRODUCT_SYSTEM_DEFAULT_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SYSTEM_DEFAULT_PROPERTIES)' >> $$@
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900119 $(hide) echo 'PRODUCT_PRODUCT_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PRODUCT_PROPERTIES)' >> $$@
Dario Freni5f681e12018-05-29 13:09:01 +0100120 $(hide) echo 'PRODUCT_PRODUCT_SERVICES_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PRODUCT_SERVICES_PROPERTIES)' >> $$@
Bowgo Tsaid624fa62017-11-14 23:42:30 +0800121 $(hide) echo 'PRODUCT_ODM_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_ODM_PROPERTIES)' >> $$@
Joe Onorato88155422012-07-23 13:51:44 -0700122 $(hide) echo 'PRODUCT_CHARACTERISTICS=$$(PRODUCTS.$(strip $(1)).PRODUCT_CHARACTERISTICS)' >> $$@
123 $(hide) echo 'PRODUCT_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_COPY_FILES)' >> $$@
124 $(hide) echo 'PRODUCT_OTA_PUBLIC_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_OTA_PUBLIC_KEYS)' >> $$@
125 $(hide) echo 'PRODUCT_EXTRA_RECOVERY_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_EXTRA_RECOVERY_KEYS)' >> $$@
126 $(hide) echo 'PRODUCT_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_PACKAGE_OVERLAYS)' >> $$@
127 $(hide) echo 'DEVICE_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).DEVICE_PACKAGE_OVERLAYS)' >> $$@
Joe Onorato88155422012-07-23 13:51:44 -0700128 $(hide) echo 'PRODUCT_SDK_ADDON_NAME=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_NAME)' >> $$@
129 $(hide) echo 'PRODUCT_SDK_ADDON_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_FILES)' >> $$@
130 $(hide) echo 'PRODUCT_SDK_ADDON_COPY_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_MODULES)' >> $$@
131 $(hide) echo 'PRODUCT_SDK_ADDON_DOC_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_DOC_MODULES)' >> $$@
132 $(hide) echo 'PRODUCT_DEFAULT_WIFI_CHANNELS=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_WIFI_CHANNELS)' >> $$@
133 $(hide) echo 'PRODUCT_DEFAULT_DEV_CERTIFICATE=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_DEV_CERTIFICATE)' >> $$@
134 $(hide) echo 'PRODUCT_RESTRICT_VENDOR_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_RESTRICT_VENDOR_FILES)' >> $$@
Joe Onorato88155422012-07-23 13:51:44 -0700135 $(hide) echo 'PRODUCT_VENDOR_KERNEL_HEADERS=$$(PRODUCTS.$(strip $(1)).PRODUCT_VENDOR_KERNEL_HEADERS)' >> $$@
136
137$(call product-debug-filename, $(p)): \
138 $(OUT_DIR)/products/$(strip $(1)).txt \
Colin Crossfdea8932017-12-06 14:38:40 -0800139 build/make/tools/product_debug.py \
Joe Onorato88155422012-07-23 13:51:44 -0700140 $(this_makefile)
141 @echo Product debug html file: $$@
142 $(hide) mkdir -p $$(dir $$@)
Colin Crossfdea8932017-12-06 14:38:40 -0800143 $(hide) cat $$< | build/make/tools/product_debug.py > $$@
Joe Onorato88155422012-07-23 13:51:44 -0700144endef
145
146product_debug_files:=
Anton Hansson061cbcf2018-05-30 18:24:41 +0100147$(foreach p,$(all_products), \
Joe Onorato88155422012-07-23 13:51:44 -0700148 $(eval $(call transform-product-debug, $(p))) \
149 $(eval product_debug_files += $(call product-debug-filename, $(p))) \
150 )
The Android Open Source Project6a5f7f02009-03-05 14:34:30 -0800151
Dan Willemsen7a1da0e2018-07-24 01:21:12 -0700152.PHONY: product-graph
Anton Hansson627cf052019-03-19 18:18:42 +0000153product-graph: $(products_graph)
154 @echo Product graph .dot file: $(products_graph)
155 @echo Command to convert to pdf: dot -Tpdf -Nshape=box -o $(OUT_DIR)/products.pdf $(products_graph)
156 @echo Command to convert to svg: dot -Tsvg -Nshape=box -o $(OUT_DIR)/products.svg $(products_graph)