product.mk revision 64d85d0d827489c514f6aec075482563c80cda73
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# 20 21# 22# Returns the list of all AndroidProducts.mk files. 23# $(call ) isn't necessary. 24# 25define _find-android-products-files 26$(shell test -d vendor && find vendor -maxdepth 6 -name AndroidProducts.mk) \ 27 $(SRC_TARGET_DIR)/product/AndroidProducts.mk 28endef 29 30# 31# Returns the sorted concatenation of all PRODUCT_MAKEFILES 32# variables set in all AndroidProducts.mk files. 33# $(call ) isn't necessary. 34# 35define get-all-product-makefiles 36$(sort \ 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) \ 42 ) \ 43 $(eval PRODUCT_MAKEFILES :=) \ 44 $(eval LOCAL_DIR :=) \ 45 ) 46endef 47 48# 49# Functions for including product makefiles 50# 51 52_product_var_list := \ 53 PRODUCT_NAME \ 54 PRODUCT_MODEL \ 55 PRODUCT_LOCALES \ 56 PRODUCT_PACKAGES \ 57 PRODUCT_DEVICE \ 58 PRODUCT_MANUFACTURER \ 59 PRODUCT_BRAND \ 60 PRODUCT_PROPERTY_OVERRIDES \ 61 PRODUCT_COPY_FILES \ 62 PRODUCT_OTA_PUBLIC_KEYS \ 63 PRODUCT_POLICY \ 64 PRODUCT_PACKAGE_OVERLAYS \ 65 DEVICE_PACKAGE_OVERLAYS \ 66 PRODUCT_CONTRIBUTORS_FILE \ 67 PRODUCT_TAGS \ 68 PRODUCT_SDK_ADDON_NAME \ 69 PRODUCT_SDK_ADDON_COPY_FILES \ 70 PRODUCT_SDK_ADDON_COPY_MODULES \ 71 PRODUCT_SDK_ADDON_DOC_MODULE 72 73define dump-product 74$(info ==== $(1) ====)\ 75$(foreach v,$(_product_var_list),\ 76$(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\ 77$(info --------) 78endef 79 80define dump-products 81$(foreach p,$(PRODUCTS),$(call dump-product,$(p))) 82endef 83 84# 85# $(1): product to inherit 86# 87# Does three things: 88# 1. Inherits all of the variables from $1. 89# 2. Records the inheritance in the .INHERITS_FROM variable 90# 3. Records that we've visited this node, in ALL_PRODUCTS 91# 92define inherit-product 93 $(foreach v,$(_product_var_list), \ 94 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \ 95 $(eval inherit_var := \ 96 PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \ 97 $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \ 98 $(eval inherit_var:=) \ 99 $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack)))) 100endef 101 102# 103# $(1): product makefile list 104# 105#TODO: check to make sure that products have all the necessary vars defined 106define import-products 107$(call import-nodes,PRODUCTS,$(1),$(_product_var_list)) 108endef 109 110 111# 112# Does various consistency checks on all of the known products. 113# Takes no parameters, so $(call ) is not necessary. 114# 115define check-all-products 116$(if ,, \ 117 $(eval _cap_names :=) \ 118 $(foreach p,$(PRODUCTS), \ 119 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \ 120 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \ 121 $(if $(filter $(pn),$(_cap_names)), \ 122 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \ 123 $(foreach \ 124 pp,$(PRODUCTS), 125 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \ 126 $(pp) \ 127 ))) \ 128 ) \ 129 ) \ 130 $(eval _cap_names += $(pn)) \ 131 $(if $(call is-c-identifier,$(pn)),, \ 132 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \ 133 ) \ 134 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \ 135 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \ 136 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \ 137 $(if $(filter 2,$(words $(subst :,$(space),$(cf)))),, \ 138 $(error $(p): malformed COPY_FILE "$(cf)") \ 139 ) \ 140 ) \ 141 ) \ 142) 143endef 144 145 146# 147# Returns the product makefile path for the product with the provided name 148# 149# $(1): short product name like "generic" 150# 151define _resolve-short-product-name 152 $(eval pn := $(strip $(1))) 153 $(eval p := \ 154 $(foreach p,$(PRODUCTS), \ 155 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \ 156 $(p) \ 157 )) \ 158 ) 159 $(eval p := $(sort $(p))) 160 $(if $(filter 1,$(words $(p))), \ 161 $(p), \ 162 $(if $(filter 0,$(words $(p))), \ 163 $(error No matches for product "$(pn)"), \ 164 $(error Product "$(pn)" ambiguous: matches $(p)) \ 165 ) \ 166 ) 167endef 168define resolve-short-product-name 169$(strip $(call _resolve-short-product-name,$(1))) 170endef 171