The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | # |
| 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 |
| 28 | endef |
| 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 | # |
| 35 | define 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 | ) |
| 46 | endef |
| 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 | |
| 69 | define dump-product |
| 70 | $(info ==== $(1) ====)\ |
| 71 | $(foreach v,$(_product_var_list),\ |
| 72 | $(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\ |
| 73 | $(info --------) |
| 74 | endef |
| 75 | |
| 76 | define dump-products |
| 77 | $(foreach p,$(PRODUCTS),$(call dump-product,$(p))) |
| 78 | endef |
| 79 | |
| 80 | # |
| 81 | # $(1): product to inherit |
| 82 | # |
The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 83 | # Does three things: |
| 84 | # 1. Inherits all of the variables from $1. |
| 85 | # 2. Records the inheritance in the .INHERITS_FROM variable |
| 86 | # 3. Records that we've visited this node, in ALL_PRODUCTS |
| 87 | # |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 88 | define inherit-product |
| 89 | $(foreach v,$(_product_var_list), \ |
The Android Open Source Project | 6a5f7f0 | 2009-03-05 14:34:30 -0800 | [diff] [blame] | 90 | $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \ |
| 91 | $(eval inherit_var := \ |
| 92 | PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \ |
| 93 | $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \ |
| 94 | $(eval inherit_var:=) \ |
| 95 | $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack)))) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 96 | endef |
| 97 | |
| 98 | # |
| 99 | # $(1): product makefile list |
| 100 | # |
| 101 | #TODO: check to make sure that products have all the necessary vars defined |
| 102 | define import-products |
| 103 | $(call import-nodes,PRODUCTS,$(1),$(_product_var_list)) |
| 104 | endef |
| 105 | |
| 106 | |
| 107 | # |
| 108 | # Does various consistency checks on all of the known products. |
| 109 | # Takes no parameters, so $(call ) is not necessary. |
| 110 | # |
| 111 | define check-all-products |
| 112 | $(if ,, \ |
| 113 | $(eval _cap_names :=) \ |
| 114 | $(foreach p,$(PRODUCTS), \ |
| 115 | $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \ |
| 116 | $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \ |
| 117 | $(if $(filter $(pn),$(_cap_names)), \ |
| 118 | $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \ |
| 119 | $(foreach \ |
| 120 | pp,$(PRODUCTS), |
| 121 | $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \ |
| 122 | $(pp) \ |
| 123 | ))) \ |
| 124 | ) \ |
| 125 | ) \ |
| 126 | $(eval _cap_names += $(pn)) \ |
| 127 | $(if $(call is-c-identifier,$(pn)),, \ |
| 128 | $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \ |
| 129 | ) \ |
| 130 | $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \ |
| 131 | $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \ |
| 132 | $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \ |
| 133 | $(if $(filter 2,$(words $(subst :,$(space),$(cf)))),, \ |
| 134 | $(error $(p): malformed COPY_FILE "$(cf)") \ |
| 135 | ) \ |
| 136 | ) \ |
| 137 | ) \ |
| 138 | ) |
| 139 | endef |
| 140 | |
| 141 | |
| 142 | # |
| 143 | # Returns the product makefile path for the product with the provided name |
| 144 | # |
| 145 | # $(1): short product name like "generic" |
| 146 | # |
| 147 | define _resolve-short-product-name |
| 148 | $(eval pn := $(strip $(1))) |
| 149 | $(eval p := \ |
| 150 | $(foreach p,$(PRODUCTS), \ |
| 151 | $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \ |
| 152 | $(p) \ |
| 153 | )) \ |
| 154 | ) |
| 155 | $(eval p := $(sort $(p))) |
| 156 | $(if $(filter 1,$(words $(p))), \ |
| 157 | $(p), \ |
| 158 | $(if $(filter 0,$(words $(p))), \ |
| 159 | $(error No matches for product "$(pn)"), \ |
| 160 | $(error Product "$(pn)" ambiguous: matches $(p)) \ |
| 161 | ) \ |
| 162 | ) |
| 163 | endef |
| 164 | define resolve-short-product-name |
| 165 | $(strip $(call _resolve-short-product-name,$(1))) |
| 166 | endef |