product_config.mk revision 88b607994a148f4af5bffee163e39ce8296750c6
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# If CUSTOM_LOCALES contains any locales not already included 153# in PRODUCT_LOCALES, add them to PRODUCT_LOCALES. 154extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES)) 155ifneq (,$(extra_locales)) 156 $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)]) 157 PRODUCT_LOCALES += $(extra_locales) 158 extra_locales := 159endif 160 161# Assemble the list of options. 162PRODUCT_AAPT_CONFIG := $(PRODUCT_LOCALES) 163 164# Convert spaces to commas. 165comma := , 166PRODUCT_AAPT_CONFIG := \ 167 $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG))) 168 169PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND)) 170 171PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL)) 172ifndef PRODUCT_MODEL 173 PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME)) 174endif 175 176PRODUCT_MANUFACTURER := \ 177 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER)) 178ifndef PRODUCT_MANUFACTURER 179 PRODUCT_MANUFACTURER := unknown 180endif 181 182# Which policy should this product use 183PRODUCT_POLICY := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_POLICY)) 184 185# A list of words like <source path>:<destination path>. The file at 186# the source path should be copied to the destination path when building 187# this product. <destination path> is relative to $(PRODUCT_OUT), so 188# it should look like, e.g., "system/etc/file.xml". The rules 189# for these copy steps are defined in config/Makefile. 190PRODUCT_COPY_FILES := \ 191 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES)) 192 193# The HTML file containing the contributors to the project. 194PRODUCT_CONTRIBUTORS_FILE := \ 195 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CONTRIBUTORS_FILE)) 196 197# A list of property assignments, like "key = value", with zero or more 198# whitespace characters on either side of the '='. 199PRODUCT_PROPERTY_OVERRIDES := \ 200 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES)) 201 202# Should we use the default resources or add any product specific overlays 203PRODUCT_PACKAGE_OVERLAYS := \ 204 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS)) 205DEVICE_PACKAGE_OVERLAYS := \ 206 $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS)) 207 208# An list of whitespace-separated words. 209PRODUCT_TAGS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_TAGS)) 210 211# Add the product-defined properties to the build properties. 212ADDITIONAL_BUILD_PROPERTIES := \ 213 $(ADDITIONAL_BUILD_PROPERTIES) \ 214 $(PRODUCT_PROPERTY_OVERRIDES) 215 216# Get the list of OTA public keys for the product. 217OTA_PUBLIC_KEYS := \ 218 $(sort \ 219 $(OTA_PUBLIC_KEYS) \ 220 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS) \ 221 ) 222 223# HACK: Not all products define OTA keys yet, and the -user build 224# will fail if no keys are defined. 225# TODO: Let a product opt out of needing OTA keys, and stop defaulting to 226# the test key as soon as possible. 227ifeq (,$(strip $(OTA_PUBLIC_KEYS))) 228 ifeq (,$(CALLED_FROM_SETUP)) 229 $(warning WARNING: adding test OTA key) 230 endif 231 OTA_PUBLIC_KEYS := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 232endif 233 234# --------------------------------------------------------------- 235# Force the simulator to be the simulator, and make BUILD_TYPE 236# default to debug. 237ifeq ($(TARGET_PRODUCT),sim) 238 TARGET_SIMULATOR := true 239 ifeq (,$(strip $(TARGET_BUILD_TYPE))) 240 TARGET_BUILD_TYPE := debug 241 endif 242 # dexpreopt doesn't work when building the simulator 243 DISABLE_DEXPREOPT := true 244endif 245