product_config.mk revision dcc08f073b6873c69ab891d4f69f7c568e282df7
1# 2# Copyright (C) 2008 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# Generic functions 19# TODO: Move these to definitions.make once we're able to include 20# definitions.make before config.make. 21 22########################################################### 23## Return non-empty if $(1) is a C identifier; i.e., if it 24## matches /^[a-zA-Z_][a-zA-Z0-9_]*$/. We do this by first 25## making sure that it isn't empty and doesn't start with 26## a digit, then by removing each valid character. If the 27## final result is empty, then it was a valid C identifier. 28## 29## $(1): word to check 30########################################################### 31 32_ici_digits := 0 1 2 3 4 5 6 7 8 9 33_ici_alphaunderscore := \ 34 a b c d e f g h i j k l m n o p q r s t u v w x y z \ 35 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ 36define is-c-identifier 37$(strip \ 38 $(if $(1), \ 39 $(if $(filter $(addsuffix %,$(_ici_digits)),$(1)), \ 40 , \ 41 $(eval w := $(1)) \ 42 $(foreach c,$(_ici_digits) $(_ici_alphaunderscore), \ 43 $(eval w := $(subst $(c),,$(w))) \ 44 ) \ 45 $(if $(w),,TRUE) \ 46 $(eval w :=) \ 47 ) \ 48 ) \ 49 ) 50endef 51 52 53# --------------------------------------------------------------- 54# Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build 55# a particular configuration without needing to set up the environment. 56# 57product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS))) 58ifdef product_goals 59 # Scrape the product and build names out of the goal, 60 # which should be of the form PRODUCT-<productname>-<buildname>. 61 # 62 ifneq ($(words $(product_goals)),1) 63 $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)") 64 endif 65 goal_name := $(product_goals) 66 product_goals := $(patsubst PRODUCT-%,%,$(product_goals)) 67 product_goals := $(subst -, ,$(product_goals)) 68 ifneq ($(words $(product_goals)),2) 69 $(error Bad PRODUCT-* goal "$(goal_name)") 70 endif 71 72 # The product they want 73 TARGET_PRODUCT := $(word 1,$(product_goals)) 74 75 # The variant they want 76 TARGET_BUILD_VARIANT := $(word 2,$(product_goals)) 77 78 # HACK HACK HACK 79 # The build server wants to do make PRODUCT-dream-installclean 80 # which really means TARGET_PRODUCT=dream make installclean. 81 ifneq ($(filter-out eng user userdebug tests,$(TARGET_BUILD_VARIANT)),) 82 MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT) 83 TARGET_BUILD_VARIANT := eng 84 default_goal_substitution := 85 else 86 default_goal_substitution := $(DEFAULT_GOAL) 87 endif 88 # HACK HACK HACK 89 90 # Hack to make the linux build servers use dexpreopt. 91 # OSX is still a little flaky. Most engineers don't use this 92 # type of target ("make PRODUCT-blah-user"), so this should 93 # only tend to happen when using buildbot. 94 # TODO: remove this and fix the matching lines in build/core/main.mk 95 # once dexpreopt works better on OSX. 96 ifeq ($(TARGET_BUILD_VARIANT),user) 97 WITH_DEXPREOPT_buildbot := true 98 endif 99 100 # Replace the PRODUCT-* goal with the build goal that it refers to. 101 # Note that this will ensure that it appears in the same relative 102 # position, in case it matters. 103 # 104 # Note that modifying this will not affect the goals that make will 105 # attempt to build, but it's important because we inspect this value 106 # in certain situations (like for "make sdk"). 107 # 108 MAKECMDGOALS := $(patsubst $(goal_name),$(default_goal_substitution),$(MAKECMDGOALS)) 109 110 # Define a rule for the PRODUCT-* goal, and make it depend on the 111 # patched-up command-line goals as well as any other goals that we 112 # want to force. 113 # 114.PHONY: $(goal_name) 115$(goal_name): $(MAKECMDGOALS) 116endif 117# else: Use the value set in the environment or buildspec.mk. 118 119# --------------------------------------------------------------- 120# Include the product definitions. 121# We need to do this to translate TARGET_PRODUCT into its 122# underlying TARGET_DEVICE before we start defining any rules. 123# 124include $(BUILD_SYSTEM)/node_fns.mk 125include $(BUILD_SYSTEM)/product.mk 126include $(BUILD_SYSTEM)/device.mk 127 128# Read in all of the product definitions specified by the AndroidProducts.mk 129# files in the tree. 130# 131#TODO: when we start allowing direct pointers to product files, 132# guarantee that they're in this list. 133$(call import-products, $(get-all-product-makefiles)) 134$(check-all-products) 135#$(dump-products) 136#$(error done) 137 138# Convert a short name like "sooner" into the path to the product 139# file defining that product. 140# 141INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT)) 142#$(error TARGET_PRODUCT $(TARGET_PRODUCT) --> $(INTERNAL_PRODUCT)) 143 144# Find the device that this product maps to. 145TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE) 146 147# Figure out which resoure configuration options to use for this 148# product. 149PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES)) 150# TODO: also keep track of things like "port", "land" in product files. 151 152# Assemble the list of options. 153PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) 154 155# Convert spaces to commas. 156comma := , 157PRODUCT_AAPT_CONFIG := \ 158 $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG))) 159 160PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND)) 161 162PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL)) 163ifndef PRODUCT_MODEL 164 PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME)) 165endif 166 167PRODUCT_MANUFACTURER := \ 168 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER)) 169ifndef PRODUCT_MANUFACTURER 170 PRODUCT_MANUFACTURER := unknown 171endif 172 173# Which policy should this product use 174PRODUCT_POLICY := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_POLICY)) 175 176# A list of words like <source path>:<destination path>. The file at 177# the source path should be copied to the destination path when building 178# this product. <destination path> is relative to $(PRODUCT_OUT), so 179# it should look like, e.g., "system/etc/file.xml". The rules 180# for these copy steps are defined in config/Makefile. 181PRODUCT_COPY_FILES := \ 182 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES)) 183 184# A list of property assignments, like "key = value", with zero or more 185# whitespace characters on either side of the '='. 186PRODUCT_PROPERTY_OVERRIDES := \ 187 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES)) 188 189# Add the product-defined properties to the build properties. 190ADDITIONAL_BUILD_PROPERTIES := \ 191 $(ADDITIONAL_BUILD_PROPERTIES) \ 192 $(PRODUCT_PROPERTY_OVERRIDES) 193 194# Get the list of OTA public keys for the product. 195OTA_PUBLIC_KEYS := \ 196 $(sort \ 197 $(OTA_PUBLIC_KEYS) \ 198 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS) \ 199 ) 200 201# HACK: Not all products define OTA keys yet, and the -user build 202# will fail if no keys are defined. 203# TODO: Let a product opt out of needing OTA keys, and stop defaulting to 204# the test key as soon as possible. 205ifeq (,$(strip $(OTA_PUBLIC_KEYS))) 206 ifeq (,$(CALLED_FROM_SETUP)) 207 $(warning WARNING: adding test OTA key) 208 endif 209 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 210endif 211 212# --------------------------------------------------------------- 213# Force the simulator to be the simulator, and make BUILD_TYPE 214# default to debug. 215ifeq ($(TARGET_PRODUCT),sim) 216 TARGET_SIMULATOR := true 217 ifeq (,$(strip $(TARGET_BUILD_TYPE))) 218 TARGET_BUILD_TYPE := debug 219 endif 220 # dexpreopt doesn't work when building the simulator 221 DISABLE_DEXPREOPT := true 222endif 223