OSDN Git Service

Merge "[DO NOT MERGE] Updating security string to 2017-07-05 on lmp-dev bug:38342695...
[android-x86/build.git] / core / product.mk
1 #
2 # Copyright (C) 2007 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 #
18 # Functions for including AndroidProducts.mk files
19 # PRODUCT_MAKEFILES is set up in AndroidProducts.mks.
20 # Format of PRODUCT_MAKEFILES:
21 # <product_name>:<path_to_the_product_makefile>
22 # If the <product_name> is the same as the base file name (without dir
23 # and the .mk suffix) of the product makefile, "<product_name>:" can be
24 # omitted.
25
26 # Search for AndroidProducts.mks in the given dir.
27 # $(1): the path to the dir
28 define _search-android-products-files-in-dir
29 $(sort $(shell test -d $(1) && find -L $(1) \
30   -maxdepth 6 \
31   -name .git -prune \
32   -o -name AndroidProducts.mk -print))
33 endef
34
35 #
36 # Returns the list of all AndroidProducts.mk files.
37 # $(call ) isn't necessary.
38 #
39 define _find-android-products-files
40 $(foreach d, device vendor product,$(call _search-android-products-files-in-dir,$(d))) \
41   $(SRC_TARGET_DIR)/product/AndroidProducts.mk
42 endef
43
44 #
45 # Returns the sorted concatenation of PRODUCT_MAKEFILES
46 # variables set in the given AndroidProducts.mk files.
47 # $(1): the list of AndroidProducts.mk files.
48 #
49 define get-product-makefiles
50 $(sort \
51   $(foreach f,$(1), \
52     $(eval PRODUCT_MAKEFILES :=) \
53     $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
54     $(eval include $(f)) \
55     $(PRODUCT_MAKEFILES) \
56    ) \
57   $(eval PRODUCT_MAKEFILES :=) \
58   $(eval LOCAL_DIR :=) \
59  )
60 endef
61
62 #
63 # Returns the sorted concatenation of all PRODUCT_MAKEFILES
64 # variables set in all AndroidProducts.mk files.
65 # $(call ) isn't necessary.
66 #
67 define get-all-product-makefiles
68 $(call get-product-makefiles,$(_find-android-products-files))
69 endef
70
71 #
72 # Functions for including product makefiles
73 #
74
75 _product_var_list := \
76     PRODUCT_NAME \
77     PRODUCT_MODEL \
78     PRODUCT_LOCALES \
79     PRODUCT_AAPT_CONFIG \
80     PRODUCT_AAPT_PREF_CONFIG \
81     PRODUCT_AAPT_PREBUILT_DPI \
82     PRODUCT_PACKAGES \
83     PRODUCT_PACKAGES_DEBUG \
84     PRODUCT_PACKAGES_ENG \
85     PRODUCT_PACKAGES_TESTS \
86     PRODUCT_DEVICE \
87     PRODUCT_MANUFACTURER \
88     PRODUCT_BRAND \
89     PRODUCT_PROPERTY_OVERRIDES \
90     PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
91     PRODUCT_CHARACTERISTICS \
92     PRODUCT_COPY_FILES \
93     PRODUCT_OTA_PUBLIC_KEYS \
94     PRODUCT_EXTRA_RECOVERY_KEYS \
95     PRODUCT_PACKAGE_OVERLAYS \
96     DEVICE_PACKAGE_OVERLAYS \
97     PRODUCT_ENFORCE_RRO_TARGETS \
98     PRODUCT_SDK_ATREE_FILES \
99     PRODUCT_SDK_ADDON_NAME \
100     PRODUCT_SDK_ADDON_COPY_FILES \
101     PRODUCT_SDK_ADDON_COPY_MODULES \
102     PRODUCT_SDK_ADDON_DOC_MODULES \
103     PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
104     PRODUCT_DEFAULT_WIFI_CHANNELS \
105     PRODUCT_DEFAULT_DEV_CERTIFICATE \
106     PRODUCT_RESTRICT_VENDOR_FILES \
107     PRODUCT_VENDOR_KERNEL_HEADERS \
108     PRODUCT_BOOT_JARS \
109     PRODUCT_SUPPORTS_BOOT_SIGNER \
110     PRODUCT_SUPPORTS_VBOOT \
111     PRODUCT_SUPPORTS_VERITY \
112     PRODUCT_SUPPORTS_VERITY_FEC \
113     PRODUCT_OEM_PROPERTIES \
114     PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
115     PRODUCT_SYSTEM_SERVER_APPS \
116     PRODUCT_SYSTEM_SERVER_JARS \
117     PRODUCT_VBOOT_SIGNING_KEY \
118     PRODUCT_VBOOT_SIGNING_SUBKEY \
119     PRODUCT_VERITY_SIGNING_KEY \
120     PRODUCT_SYSTEM_VERITY_PARTITION \
121     PRODUCT_VENDOR_VERITY_PARTITION \
122     PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
123     PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
124     PRODUCT_DEX_PREOPT_BOOT_FLAGS \
125     PRODUCT_SANITIZER_MODULE_CONFIGS \
126     PRODUCT_SYSTEM_BASE_FS_PATH \
127     PRODUCT_VENDOR_BASE_FS_PATH \
128     PRODUCT_SHIPPING_API_LEVEL \
129     VENDOR_PRODUCT_RESTRICT_VENDOR_FILES \
130     VENDOR_EXCEPTION_MODULES \
131     VENDOR_EXCEPTION_PATHS \
132     PRODUCT_ART_USE_READ_BARRIER \
133     PRODUCT_IOT \
134
135
136
137 define dump-product
138 $(info ==== $(1) ====)\
139 $(foreach v,$(_product_var_list),\
140 $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
141 $(info --------)
142 endef
143
144 define dump-products
145 $(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
146 endef
147
148 #
149 # $(1): product to inherit
150 #
151 # Does three things:
152 #  1. Inherits all of the variables from $1.
153 #  2. Records the inheritance in the .INHERITS_FROM variable
154 #  3. Records that we've visited this node, in ALL_PRODUCTS
155 #
156 define inherit-product
157   $(if $(findstring ../,$(1)),\
158     $(eval np := $(call normalize-paths,$(1))),\
159     $(eval np := $(strip $(1))))\
160   $(foreach v,$(_product_var_list), \
161       $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
162   $(eval inherit_var := \
163       PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
164   $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
165   $(eval inherit_var:=) \
166   $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
167 endef
168
169
170 #
171 # Do inherit-product only if $(1) exists
172 #
173 define inherit-product-if-exists
174   $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
175 endef
176
177 #
178 # $(1): product makefile list
179 #
180 #TODO: check to make sure that products have all the necessary vars defined
181 define import-products
182 $(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
183 endef
184
185
186 #
187 # Does various consistency checks on all of the known products.
188 # Takes no parameters, so $(call ) is not necessary.
189 #
190 define check-all-products
191 $(if ,, \
192   $(eval _cap_names :=) \
193   $(foreach p,$(PRODUCTS), \
194     $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
195     $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
196     $(if $(filter $(pn),$(_cap_names)), \
197       $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
198           $(foreach \
199             pp,$(PRODUCTS),
200               $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
201                 $(pp) \
202                ))) \
203        ) \
204      ) \
205     $(eval _cap_names += $(pn)) \
206     $(if $(call is-c-identifier,$(pn)),, \
207       $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
208      ) \
209     $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
210     $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
211     $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
212       $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
213         $(error $(p): malformed COPY_FILE "$(cf)") \
214        ) \
215      ) \
216    ) \
217 )
218 endef
219
220
221 #
222 # Returns the product makefile path for the product with the provided name
223 #
224 # $(1): short product name like "generic"
225 #
226 define _resolve-short-product-name
227   $(eval pn := $(strip $(1)))
228   $(eval p := \
229       $(foreach p,$(PRODUCTS), \
230           $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
231             $(p) \
232        )) \
233    )
234   $(eval p := $(sort $(p)))
235   $(if $(filter 1,$(words $(p))), \
236     $(p), \
237     $(if $(filter 0,$(words $(p))), \
238       $(error No matches for product "$(pn)"), \
239       $(error Product "$(pn)" ambiguous: matches $(p)) \
240     ) \
241   )
242 endef
243 define resolve-short-product-name
244 $(strip $(call _resolve-short-product-name,$(1)))
245 endef
246
247
248 _product_stash_var_list := $(_product_var_list) \
249         PRODUCT_BOOTCLASSPATH \
250         PRODUCT_SYSTEM_SERVER_CLASSPATH \
251         TARGET_ARCH \
252         TARGET_ARCH_VARIANT \
253         TARGET_CPU_VARIANT \
254         TARGET_BOARD_PLATFORM \
255         TARGET_BOARD_PLATFORM_GPU \
256         TARGET_BOARD_KERNEL_HEADERS \
257         TARGET_DEVICE_KERNEL_HEADERS \
258         TARGET_PRODUCT_KERNEL_HEADERS \
259         TARGET_BOOTLOADER_BOARD_NAME \
260         TARGET_NO_BOOTLOADER \
261         TARGET_NO_KERNEL \
262         TARGET_NO_RECOVERY \
263         TARGET_NO_RADIOIMAGE \
264         TARGET_HARDWARE_3D \
265         TARGET_CPU_ABI \
266         TARGET_CPU_ABI2 \
267
268
269 _product_stash_var_list += \
270         BOARD_WPA_SUPPLICANT_DRIVER \
271         BOARD_WLAN_DEVICE \
272         BOARD_USES_GENERIC_AUDIO \
273         BOARD_KERNEL_CMDLINE \
274         BOARD_KERNEL_BASE \
275         BOARD_HAVE_BLUETOOTH \
276         BOARD_VENDOR_USE_AKMD \
277         BOARD_EGL_CFG \
278         BOARD_BOOTIMAGE_PARTITION_SIZE \
279         BOARD_RECOVERYIMAGE_PARTITION_SIZE \
280         BOARD_SYSTEMIMAGE_PARTITION_SIZE \
281         BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
282         BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
283         BOARD_USERDATAIMAGE_PARTITION_SIZE \
284         BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
285         BOARD_CACHEIMAGE_PARTITION_SIZE \
286         BOARD_FLASH_BLOCK_SIZE \
287         BOARD_VENDORIMAGE_PARTITION_SIZE \
288         BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
289         BOARD_INSTALLER_CMDLINE \
290
291
292 _product_stash_var_list += \
293         DEFAULT_SYSTEM_DEV_CERTIFICATE \
294         WITH_DEXPREOPT \
295         WITH_DEXPREOPT_BOOT_IMG_ONLY \
296         WITH_DEXPREOPT_APP_IMAGE
297
298 #
299 # Mark the variables in _product_stash_var_list as readonly
300 #
301 define readonly-product-vars
302 $(foreach v,$(_product_stash_var_list), \
303         $(eval $(v) ?=) \
304         $(eval .KATI_READONLY := $(v)) \
305  )
306 endef
307
308 define add-to-product-copy-files-if-exists
309 $(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
310 endef
311
312 # whitespace placeholder when we record module's dex-preopt config.
313 _PDPMC_SP_PLACE_HOLDER := |@SP@|
314 # Set up dex-preopt config for a module.
315 # $(1) list of module names
316 # $(2) the modules' dex-preopt config
317 define add-product-dex-preopt-module-config
318 $(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
319 $(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
320   $(foreach m,$(1),$(m)=$(_c)))
321 endef
322
323 # whitespace placeholder when we record module's sanitizer config.
324 _PSMC_SP_PLACE_HOLDER := |@SP@|
325 # Set up sanitizer config for a module.
326 # $(1) list of module names
327 # $(2) the modules' sanitizer config
328 define add-product-sanitizer-module-config
329 $(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
330 $(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
331   $(foreach m,$(1),$(m)=$(_c)))
332 endef