2009-03-05 23:34:30 +01:00
|
|
|
#
|
|
|
|
# Copyright (C) 2009 The Android Open Source Project
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
2022-02-28 23:20:48 +01:00
|
|
|
# the sort also acts as a strip to remove the single space entries that creep in because of the evals
|
2012-07-23 22:51:44 +02:00
|
|
|
define gather-all-products
|
2022-02-28 23:20:48 +01:00
|
|
|
$(eval _all_products_visited := )\
|
|
|
|
$(sort $(call all-products-inner, $(PARENT_PRODUCT_FILES)))
|
2012-07-23 22:51:44 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
define all-products-inner
|
|
|
|
$(foreach p,$(1),\
|
|
|
|
$(if $(filter $(p),$(_all_products_visited)),, \
|
|
|
|
$(p) \
|
|
|
|
$(eval _all_products_visited += $(p)) \
|
|
|
|
$(call all-products-inner, $(PRODUCTS.$(strip $(p)).INHERITS_FROM))
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2017-10-20 20:37:33 +02:00
|
|
|
this_makefile := build/make/core/product-graph.mk
|
2012-07-23 22:51:44 +02:00
|
|
|
|
|
|
|
products_graph := $(OUT_DIR)/products.dot
|
2012-05-08 02:15:15 +02:00
|
|
|
ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),)
|
|
|
|
products_list := $(INTERNAL_PRODUCT)
|
|
|
|
else
|
|
|
|
ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),--all)
|
|
|
|
products_list := --all
|
|
|
|
else
|
|
|
|
products_list := $(foreach prod,$(ANDROID_PRODUCT_GRAPH),$(call resolve-short-product-name,$(prod)))
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-05-30 19:24:41 +02:00
|
|
|
all_products := $(call gather-all-products)
|
2012-07-23 22:51:44 +02:00
|
|
|
|
2013-08-02 02:45:35 +02:00
|
|
|
open_parethesis := (
|
|
|
|
close_parenthesis := )
|
|
|
|
|
2019-05-16 12:09:57 +02:00
|
|
|
node_color_target := orange
|
|
|
|
node_color_common := beige
|
|
|
|
node_color_vendor := lavenderblush
|
|
|
|
node_color_default := white
|
|
|
|
define node-color
|
|
|
|
$(if $(filter $(1),$(PRIVATE_PRODUCTS_FILTER)),\
|
|
|
|
$(node_color_target),\
|
|
|
|
$(if $(filter build/make/target/product/%,$(1)),\
|
|
|
|
$(node_color_common),\
|
|
|
|
$(if $(filter vendor/%,$(1)),$(node_color_vendor),$(node_color_default))\
|
|
|
|
)\
|
|
|
|
)
|
|
|
|
endef
|
|
|
|
|
2013-08-02 02:45:35 +02:00
|
|
|
# Emit properties of a product node to a file.
|
|
|
|
# $(1) the product
|
|
|
|
# $(2) the output file
|
|
|
|
define emit-product-node-props
|
|
|
|
$(hide) echo \"$(1)\" [ \
|
2019-10-28 12:30:40 +01:00
|
|
|
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)\" \
|
2019-05-16 12:09:57 +02:00
|
|
|
style=\"filled\" fillcolor=\"$(strip $(call node-color,$(1)))\" \
|
2022-02-28 23:20:48 +01:00
|
|
|
colorscheme=\"svg\" fontcolor=\"darkblue\" \
|
2013-08-02 02:45:35 +02:00
|
|
|
] >> $(2)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
2018-05-30 19:24:41 +02:00
|
|
|
$(products_graph): PRIVATE_PRODUCTS := $(all_products)
|
2012-07-23 22:51:44 +02:00
|
|
|
$(products_graph): PRIVATE_PRODUCTS_FILTER := $(products_list)
|
2009-03-05 23:34:30 +01:00
|
|
|
|
2012-07-23 22:51:44 +02:00
|
|
|
$(products_graph): $(this_makefile)
|
2021-10-08 02:14:23 +02:00
|
|
|
ifeq (,$(RBC_PRODUCT_CONFIG)$(RBC_NO_PRODUCT_GRAPH)$(RBC_BOARD_CONFIG))
|
2012-07-23 22:51:44 +02:00
|
|
|
@echo Product graph DOT: $@ for $(PRIVATE_PRODUCTS_FILTER)
|
2013-08-02 02:45:35 +02:00
|
|
|
$(hide) echo 'digraph {' > $@.in
|
|
|
|
$(hide) echo 'graph [ ratio=.5 ];' >> $@.in
|
|
|
|
$(hide) $(foreach p,$(PRIVATE_PRODUCTS), \
|
|
|
|
$(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), echo \"$(d)\" -\> \"$(p)\" >> $@.in;))
|
|
|
|
$(foreach p,$(PRIVATE_PRODUCTS),$(call emit-product-node-props,$(p),$@.in))
|
|
|
|
$(hide) echo '}' >> $@.in
|
2017-12-06 23:38:40 +01:00
|
|
|
$(hide) build/make/tools/filter-product-graph.py $(PRIVATE_PRODUCTS_FILTER) < $@.in > $@
|
2021-05-04 18:58:38 +02:00
|
|
|
else
|
|
|
|
@echo RBC_PRODUCT_CONFIG and RBC_NO_PRODUCT_GRAPH should be unset to generate product graph
|
|
|
|
false
|
|
|
|
endif
|
2009-08-08 21:14:37 +02:00
|
|
|
|
2021-10-08 02:14:23 +02:00
|
|
|
ifeq (,$(RBC_PRODUCT_CONFIG)$(RBC_NO_PRODUCT_GRAPH)$(RBC_BOARD_CONFIG))
|
2009-08-08 21:14:37 +02:00
|
|
|
|
2018-07-24 10:21:12 +02:00
|
|
|
.PHONY: product-graph
|
2019-03-19 19:18:42 +01:00
|
|
|
product-graph: $(products_graph)
|
|
|
|
@echo Product graph .dot file: $(products_graph)
|
|
|
|
@echo Command to convert to pdf: dot -Tpdf -Nshape=box -o $(OUT_DIR)/products.pdf $(products_graph)
|
|
|
|
@echo Command to convert to svg: dot -Tsvg -Nshape=box -o $(OUT_DIR)/products.svg $(products_graph)
|
2021-05-04 18:58:38 +02:00
|
|
|
else
|
|
|
|
.PHONY: product-graph
|
|
|
|
@echo RBC_PRODUCT_CONFIG and RBC_NO_PRODUCT_GRAPH should be unset to generate product graph
|
|
|
|
false
|
2021-10-08 02:14:23 +02:00
|
|
|
endif
|