github.com/westcoastroms/westcoastroms-build@v0.0.0-20190928114312-2350e5a73030/build/make/core/product-graph.mk (about)

     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
    18  define 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  )
    24  endef
    25  
    26  define 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  	)
    34  endef
    35  
    36  
    37  this_makefile := build/make/core/product-graph.mk
    38  
    39  products_svg := $(OUT_DIR)/products.svg
    40  products_pdf := $(OUT_DIR)/products.pdf
    41  products_graph := $(OUT_DIR)/products.dot
    42  ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),)
    43  products_list := $(INTERNAL_PRODUCT)
    44  else
    45  ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),--all)
    46  products_list := --all
    47  else
    48  products_list := $(foreach prod,$(ANDROID_PRODUCT_GRAPH),$(call resolve-short-product-name,$(prod)))
    49  endif
    50  endif
    51  
    52  really_all_products := $(call gather-all-products)
    53  
    54  open_parethesis := (
    55  close_parenthesis := )
    56  
    57  # Emit properties of a product node to a file.
    58  # $(1) the product
    59  # $(2) the output file
    60  define emit-product-node-props
    61  $(hide) echo \"$(1)\" [ \
    62  label=\"$(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\",) \
    64  colorscheme=\"svg\" fontcolor=\"darkblue\" href=\"products/$(1).html\" \
    65  ] >> $(2)
    66  
    67  endef
    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/make/tools/filter-product-graph.py $(PRIVATE_PRODUCTS_FILTER) < $@.in > $@
    81  
    82  # Evaluates to the name of the product file
    83  # $(1) product file
    84  define product-debug-filename
    85  $(OUT_DIR)/products/$(strip $(1)).html
    86  endef
    87  
    88  # Makes a rule for the product debug info
    89  # $(1) product file
    90  define 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_SYSTEM_DEFAULT_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SYSTEM_DEFAULT_PROPERTIES)' >> $$@
   107  	$(hide) echo 'PRODUCT_PRODUCT_PROPERTIES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PRODUCT_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 > $$@
   130  endef
   131  
   132  product_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  
   146  product-graph: $(products_pdf) $(products_svg)