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 17# 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 := ) 21 $(call all-products-inner, $(PARENT_PRODUCT_FILES)) \ 22 , $(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 37this_makefile := build/make/core/product-graph.mk 38 39products_graph := $(OUT_DIR)/products.dot 40ifeq ($(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 50all_products := $(call gather-all-products) 51 52open_parethesis := ( 53close_parenthesis := ) 54 55# Emit properties of a product node to a file. 56# $(1) the product 57# $(2) the output file 58define emit-product-node-props 59$(hide) echo \"$(1)\" [ \ 60label=\"$(dir $(1))\\n$(notdir $(1))\\n\\n$(subst $(close_parenthesis),,$(subst $(open_parethesis),,$(PRODUCTS.$(strip $(1)).PRODUCT_MODEL)))\\n$(PRODUCTS.$(strip $(1)).PRODUCT_DEVICE)\" \ 61$(if $(filter $(1),$(PRIVATE_PRODUCTS_FILTER)), style=\"filled\" fillcolor=\"#FFFDB0\",) \ 62colorscheme=\"svg\" fontcolor=\"darkblue\" href=\"products/$(1).html\" \ 63] >> $(2) 64 65endef 66 67$(products_graph): PRIVATE_PRODUCTS := $(all_products) 68$(products_graph): PRIVATE_PRODUCTS_FILTER := $(products_list) 69 70$(products_graph): $(this_makefile) 71 @echo Product graph DOT: $@ for $(PRIVATE_PRODUCTS_FILTER) 72 $(hide) echo 'digraph {' > $@.in 73 $(hide) echo 'graph [ ratio=.5 ];' >> $@.in 74 $(hide) $(foreach p,$(PRIVATE_PRODUCTS), \ 75 $(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), echo \"$(d)\" -\> \"$(p)\" >> $@.in;)) 76 $(foreach p,$(PRIVATE_PRODUCTS),$(call emit-product-node-props,$(p),$@.in)) 77 $(hide) echo '}' >> $@.in 78 $(hide) build/make/tools/filter-product-graph.py $(PRIVATE_PRODUCTS_FILTER) < $@.in > $@ 79 80# Evaluates to the name of the product file 81# $(1) product file 82define product-debug-filename 83$(OUT_DIR)/products/$(strip $(1)).html 84endef 85 86# Makes a rule for the product debug info 87# $(1) product file 88define transform-product-debug 89$(OUT_DIR)/products/$(strip $(1)).txt: $(this_makefile) 90 @echo Product debug info file: $$@ 91 $(hide) rm -f $$@ 92 $(hide) mkdir -p $$(dir $$@) 93 $(hide) echo 'FILE=$(strip $(1))' >> $$@ 94 $(hide) echo 'PRODUCT_NAME=$$(PRODUCTS.$(strip $(1)).PRODUCT_NAME)' >> $$@ 95 $(hide) echo 'PRODUCT_MODEL=$$(PRODUCTS.$(strip $(1)).PRODUCT_MODEL)' >> $$@ 96 $(hide) echo 'PRODUCT_LOCALES=$$(PRODUCTS.$(strip $(1)).PRODUCT_LOCALES)' >> $$@ 97 $(hide) echo 'PRODUCT_AAPT_CONFIG=$$(PRODUCTS.$(strip $(1)).PRODUCT_AAPT_CONFIG)' >> $$@ 98 $(hide) echo 'PRODUCT_AAPT_PREF_CONFIG=$$(PRODUCTS.$(strip $(1)).PRODUCT_AAPT_PREF_CONFIG)' >> $$@ 99 $(hide) echo 'PRODUCT_PACKAGES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PACKAGES)' >> $$@ 100 $(hide) echo 'PRODUCT_DEVICE=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEVICE)' >> $$@ 101 $(hide) echo 'PRODUCT_MANUFACTURER=$$(PRODUCTS.$(strip $(1)).PRODUCT_MANUFACTURER)' >> $$@ 102 $(hide) echo 'PRODUCT_PROPERTY_OVERRIDES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PROPERTY_OVERRIDES)' >> $$@ 103 $(hide) echo 'PRODUCT_DEFAULT_PROPERTY_OVERRIDES=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_PROPERTY_OVERRIDES)' >> $$@ 104 $(hide) echo 'PRODUCT_SYSTEM_DEFAULT_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SYSTEM_DEFAULT_PROPERTIES)' >> $$@ 105 $(hide) echo 'PRODUCT_PRODUCT_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PRODUCT_PROPERTIES)' >> $$@ 106 $(hide) echo 'PRODUCT_PRODUCT_SERVICES_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PRODUCT_SERVICES_PROPERTIES)' >> $$@ 107 $(hide) echo 'PRODUCT_ODM_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_ODM_PROPERTIES)' >> $$@ 108 $(hide) echo 'PRODUCT_CHARACTERISTICS=$$(PRODUCTS.$(strip $(1)).PRODUCT_CHARACTERISTICS)' >> $$@ 109 $(hide) echo 'PRODUCT_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_COPY_FILES)' >> $$@ 110 $(hide) echo 'PRODUCT_OTA_PUBLIC_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_OTA_PUBLIC_KEYS)' >> $$@ 111 $(hide) echo 'PRODUCT_EXTRA_RECOVERY_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_EXTRA_RECOVERY_KEYS)' >> $$@ 112 $(hide) echo 'PRODUCT_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_PACKAGE_OVERLAYS)' >> $$@ 113 $(hide) echo 'DEVICE_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).DEVICE_PACKAGE_OVERLAYS)' >> $$@ 114 $(hide) echo 'PRODUCT_SDK_ADDON_NAME=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_NAME)' >> $$@ 115 $(hide) echo 'PRODUCT_SDK_ADDON_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_FILES)' >> $$@ 116 $(hide) echo 'PRODUCT_SDK_ADDON_COPY_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_MODULES)' >> $$@ 117 $(hide) echo 'PRODUCT_SDK_ADDON_DOC_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_DOC_MODULES)' >> $$@ 118 $(hide) echo 'PRODUCT_DEFAULT_WIFI_CHANNELS=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_WIFI_CHANNELS)' >> $$@ 119 $(hide) echo 'PRODUCT_DEFAULT_DEV_CERTIFICATE=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_DEV_CERTIFICATE)' >> $$@ 120 $(hide) echo 'PRODUCT_RESTRICT_VENDOR_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_RESTRICT_VENDOR_FILES)' >> $$@ 121 $(hide) echo 'PRODUCT_VENDOR_KERNEL_HEADERS=$$(PRODUCTS.$(strip $(1)).PRODUCT_VENDOR_KERNEL_HEADERS)' >> $$@ 122 123$(call product-debug-filename, $(p)): \ 124 $(OUT_DIR)/products/$(strip $(1)).txt \ 125 build/make/tools/product_debug.py \ 126 $(this_makefile) 127 @echo Product debug html file: $$@ 128 $(hide) mkdir -p $$(dir $$@) 129 $(hide) cat $$< | build/make/tools/product_debug.py > $$@ 130endef 131 132product_debug_files:= 133$(foreach p,$(all_products), \ 134 $(eval $(call transform-product-debug, $(p))) \ 135 $(eval product_debug_files += $(call product-debug-filename, $(p))) \ 136 ) 137 138.PHONY: product-graph 139product-graph: $(products_graph) 140 @echo Product graph .dot file: $(products_graph) 141 @echo Command to convert to pdf: dot -Tpdf -Nshape=box -o $(OUT_DIR)/products.pdf $(products_graph) 142 @echo Command to convert to svg: dot -Tsvg -Nshape=box -o $(OUT_DIR)/products.svg $(products_graph) 143