2 # Copyright (C) 2007 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # Functions for including AndroidProducts.mk files
22 # Returns the list of all AndroidProducts.mk files.
23 # $(call ) isn't necessary.
25 define _find-android-products-files
26 $(shell test -d vendor && find vendor -maxdepth 6 -name AndroidProducts.mk) \
27 $(SRC_TARGET_DIR)/product/AndroidProducts.mk
31 # Returns the sorted concatenation of all PRODUCT_MAKEFILES
32 # variables set in all AndroidProducts.mk files.
33 # $(call ) isn't necessary.
35 define get-all-product-makefiles
37 $(foreach f,$(_find-android-products-files), \
38 $(eval PRODUCT_MAKEFILES :=) \
39 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
40 $(eval include $(f)) \
41 $(PRODUCT_MAKEFILES) \
43 $(eval PRODUCT_MAKEFILES :=) \
44 $(eval LOCAL_DIR :=) \
49 # Functions for including product makefiles
52 _product_var_list := \
58 PRODUCT_MANUFACTURER \
60 PRODUCT_PROPERTY_OVERRIDES \
62 PRODUCT_OTA_PUBLIC_KEYS \
64 PRODUCT_PACKAGE_OVERLAYS \
65 DEVICE_PACKAGE_OVERLAYS \
66 PRODUCT_CONTRIBUTORS_FILE \
68 PRODUCT_SDK_ADDON_NAME \
69 PRODUCT_SDK_ADDON_COPY_FILES \
70 PRODUCT_SDK_ADDON_COPY_MODULES \
71 PRODUCT_SDK_ADDON_DOC_MODULE \
72 PRODUCT_DEFAULT_WIFI_CHANNELS
75 $(info ==== $(1) ====)\
76 $(foreach v,$(_product_var_list),\
77 $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
82 $(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
86 # $(1): product to inherit
89 # 1. Inherits all of the variables from $1.
90 # 2. Records the inheritance in the .INHERITS_FROM variable
91 # 3. Records that we've visited this node, in ALL_PRODUCTS
93 define inherit-product
94 $(foreach v,$(_product_var_list), \
95 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \
96 $(eval inherit_var := \
97 PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
98 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \
99 $(eval inherit_var:=) \
100 $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
104 # $(1): product makefile list
106 #TODO: check to make sure that products have all the necessary vars defined
107 define import-products
108 $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
113 # Does various consistency checks on all of the known products.
114 # Takes no parameters, so $(call ) is not necessary.
116 define check-all-products
118 $(eval _cap_names :=) \
119 $(foreach p,$(PRODUCTS), \
120 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
121 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
122 $(if $(filter $(pn),$(_cap_names)), \
123 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
126 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
131 $(eval _cap_names += $(pn)) \
132 $(if $(call is-c-identifier,$(pn)),, \
133 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
135 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
136 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
137 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
138 $(if $(filter 2,$(words $(subst :,$(space),$(cf)))),, \
139 $(error $(p): malformed COPY_FILE "$(cf)") \
148 # Returns the product makefile path for the product with the provided name
150 # $(1): short product name like "generic"
152 define _resolve-short-product-name
153 $(eval pn := $(strip $(1)))
155 $(foreach p,$(PRODUCTS), \
156 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
160 $(eval p := $(sort $(p)))
161 $(if $(filter 1,$(words $(p))), \
163 $(if $(filter 0,$(words $(p))), \
164 $(error No matches for product "$(pn)"), \
165 $(error Product "$(pn)" ambiguous: matches $(p)) \
169 define resolve-short-product-name
170 $(strip $(call _resolve-short-product-name,$(1)))