blob: 0d943ccfa0be2efa475c81b8b4091735287da2d6 [file] [log] [blame]
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001#
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$(foreach vendor,$(wildcard vendor/*), \
27 $(if $(wildcard $(vendor)/AndroidProducts.mk), \
28 $(vendor)/AndroidProducts.mk \
29 , \
30 $(wildcard $(vendor)/*/AndroidProducts.mk) \
31 ) \
32 ) \
33 $(wildcard $(SRC_TARGET_DIR)/product/AndroidProducts.mk)
34endef
35
36#
37# Returns the sorted concatenation of all PRODUCT_MAKEFILES
38# variables set in all AndroidProducts.mk files.
39# $(call ) isn't necessary.
40#
41define get-all-product-makefiles
42$(sort \
43 $(foreach f,$(_find-android-products-files), \
44 $(eval PRODUCT_MAKEFILES :=) \
45 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
46 $(eval include $(f)) \
47 $(PRODUCT_MAKEFILES) \
48 ) \
49 $(eval PRODUCT_MAKEFILES :=) \
50 $(eval LOCAL_DIR :=) \
51 )
52endef
53
54#
55# Functions for including product makefiles
56#
57
58_product_var_list := \
59 PRODUCT_NAME \
60 PRODUCT_MODEL \
61 PRODUCT_LOCALES \
62 PRODUCT_PACKAGES \
63 PRODUCT_DEVICE \
64 PRODUCT_MANUFACTURER \
65 PRODUCT_BRAND \
66 PRODUCT_PROPERTY_OVERRIDES \
67 PRODUCT_COPY_FILES \
68 PRODUCT_OTA_PUBLIC_KEYS
69
70define dump-product
71$(info ==== $(1) ====)\
72$(foreach v,$(_product_var_list),\
73$(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
74$(info --------)
75endef
76
77define dump-products
78$(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
79endef
80
81#
82# $(1): product to inherit
83#
84define inherit-product
85 $(foreach v,$(_product_var_list), \
86 $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1))))
87endef
88
89#
90# $(1): product makefile list
91#
92#TODO: check to make sure that products have all the necessary vars defined
93define import-products
94$(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
95endef
96
97
98#
99# Does various consistency checks on all of the known products.
100# Takes no parameters, so $(call ) is not necessary.
101#
102define check-all-products
103$(if ,, \
104 $(eval _cap_names :=) \
105 $(foreach p,$(PRODUCTS), \
106 $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
107 $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
108 $(if $(filter $(pn),$(_cap_names)), \
109 $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
110 $(foreach \
111 pp,$(PRODUCTS),
112 $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
113 $(pp) \
114 ))) \
115 ) \
116 ) \
117 $(eval _cap_names += $(pn)) \
118 $(if $(call is-c-identifier,$(pn)),, \
119 $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
120 ) \
121 $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
122 $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
123 $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
124 $(if $(filter 2,$(words $(subst :,$(space),$(cf)))),, \
125 $(error $(p): malformed COPY_FILE "$(cf)") \
126 ) \
127 ) \
128 ) \
129)
130endef
131
132
133#
134# Returns the product makefile path for the product with the provided name
135#
136# $(1): short product name like "generic"
137#
138define _resolve-short-product-name
139 $(eval pn := $(strip $(1)))
140 $(eval p := \
141 $(foreach p,$(PRODUCTS), \
142 $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
143 $(p) \
144 )) \
145 )
146 $(eval p := $(sort $(p)))
147 $(if $(filter 1,$(words $(p))), \
148 $(p), \
149 $(if $(filter 0,$(words $(p))), \
150 $(error No matches for product "$(pn)"), \
151 $(error Product "$(pn)" ambiguous: matches $(p)) \
152 ) \
153 )
154endef
155define resolve-short-product-name
156$(strip $(call _resolve-short-product-name,$(1)))
157endef