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