The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | ## Standard rules for building an application package. |
| 19 | ## |
| 20 | ## Additional inputs from base_rules.make: |
| 21 | ## LOCAL_PACKAGE_NAME: The name of the package; the directory |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 22 | ## will be called this. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 23 | ## |
| 24 | ## MODULE, MODULE_PATH, and MODULE_SUFFIX will |
| 25 | ## be set for you. |
| 26 | ########################################################### |
| 27 | |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 28 | |
| 29 | # If this makefile is being read from within an inheritance, |
| 30 | # use the new values. |
| 31 | skip_definition:= |
| 32 | ifdef LOCAL_PACKAGE_OVERRIDES |
| 33 | package_overridden := $(call set-inherited-package-variables) |
| 34 | ifeq ($(strip $(package_overridden)),) |
| 35 | skip_definition := true |
| 36 | endif |
| 37 | endif |
| 38 | |
| 39 | ifndef skip_definition |
| 40 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 41 | LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME)) |
| 42 | ifeq ($(LOCAL_PACKAGE_NAME),) |
| 43 | $(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME) |
| 44 | endif |
| 45 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 46 | ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),) |
| 47 | $(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX) |
| 48 | endif |
| 49 | LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) |
| 50 | |
| 51 | ifneq ($(strip $(LOCAL_MODULE)),) |
| 52 | $(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE) |
| 53 | endif |
| 54 | LOCAL_MODULE := $(LOCAL_PACKAGE_NAME) |
| 55 | |
| 56 | # Android packages should use Android resources or assets. |
| 57 | ifneq (,$(LOCAL_JAVA_RESOURCE_DIRS)) |
| 58 | $(error $(LOCAL_PATH): Package modules may not set LOCAL_JAVA_RESOURCE_DIRS) |
| 59 | endif |
| 60 | ifneq (,$(LOCAL_JAVA_RESOURCE_FILES)) |
| 61 | $(error $(LOCAL_PATH): Package modules may not set LOCAL_JAVA_RESOURCE_FILES) |
| 62 | endif |
| 63 | |
Evan Charlton | 121a787 | 2010-07-23 11:03:29 -0700 | [diff] [blame] | 64 | ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) |
| 65 | LOCAL_MANIFEST_FILE := AndroidManifest.xml |
| 66 | endif |
| 67 | |
Kevin Hester | 6c70362 | 2012-04-12 10:20:53 -0700 | [diff] [blame] | 68 | # If you need to put the MANIFEST_FILE outside of LOCAL_PATH |
| 69 | # you can use FULL_MANIFEST_FILE |
| 70 | ifeq ($(strip $(LOCAL_FULL_MANIFEST_FILE)),) |
| 71 | LOCAL_FULL_MANIFEST_FILE := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) |
| 72 | endif |
| 73 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 74 | ifneq ($(strip $(LOCAL_MODULE_CLASS)),) |
| 75 | $(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS) |
| 76 | endif |
| 77 | LOCAL_MODULE_CLASS := APPS |
| 78 | |
The Android Open Source Project | 2f31293 | 2009-03-09 11:52:11 -0700 | [diff] [blame] | 79 | # Package LOCAL_MODULE_TAGS default to optional |
| 80 | LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS)) |
| 81 | ifeq ($(LOCAL_MODULE_TAGS),) |
| 82 | LOCAL_MODULE_TAGS := optional |
| 83 | endif |
| 84 | |
Ying Wang | c61d593 | 2010-03-10 16:02:42 -0800 | [diff] [blame] | 85 | ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) |
| 86 | # Force localization check if it's not tagged as tests. |
| 87 | LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z |
| 88 | endif |
| 89 | |
Ying Wang | 81f0fd6 | 2012-06-14 15:29:20 -0700 | [diff] [blame] | 90 | # Convert LOCAL_JNI_SHARED_LIBRARIES to LOCAL_REQUIRED_MODULES in full build, |
| 91 | # for preloaded apks don't like embedded jni libraries. |
| 92 | ifndef TARGET_BUILD_APPS |
| 93 | ifdef LOCAL_JNI_SHARED_LIBRARIES |
| 94 | LOCAL_REQUIRED_MODULES += $(LOCAL_JNI_SHARED_LIBRARIES) |
| 95 | LOCAL_JNI_SHARED_LIBRARIES := |
| 96 | endif |
| 97 | endif |
| 98 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 99 | ifeq (,$(LOCAL_ASSET_DIR)) |
| 100 | LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets |
| 101 | endif |
| 102 | |
| 103 | ifeq (,$(LOCAL_RESOURCE_DIR)) |
| 104 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res |
| 105 | endif |
Ying Wang | 71004f8 | 2012-05-24 21:05:19 -0700 | [diff] [blame] | 106 | |
| 107 | package_resource_overlays := $(strip \ |
| 108 | $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \ |
| 109 | $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \ |
| 110 | $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \ |
| 111 | $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR))))) |
| 112 | |
| 113 | LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 114 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 115 | all_assets := $(call find-subdir-assets,$(LOCAL_ASSET_DIR)) |
| 116 | all_assets := $(addprefix $(LOCAL_ASSET_DIR)/,$(patsubst assets/%,%,$(all_assets))) |
| 117 | |
| 118 | all_resources := $(strip \ |
| 119 | $(foreach dir, $(LOCAL_RESOURCE_DIR), \ |
| 120 | $(addprefix $(dir)/, \ |
| 121 | $(patsubst res/%,%, \ |
| 122 | $(call find-subdir-assets,$(dir)) \ |
| 123 | ) \ |
| 124 | ) \ |
| 125 | )) |
| 126 | |
| 127 | all_res_assets := $(strip $(all_assets) $(all_resources)) |
| 128 | |
Ying Wang | 6ef046c | 2009-12-07 18:14:00 -0800 | [diff] [blame] | 129 | package_expected_intermediates_COMMON := $(call local-intermediates-dir,COMMON) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 130 | # If no assets or resources were found, clear the directory variables so |
| 131 | # we don't try to build them. |
| 132 | ifeq (,$(all_assets)) |
| 133 | LOCAL_ASSET_DIR:= |
| 134 | endif |
| 135 | ifeq (,$(all_resources)) |
| 136 | LOCAL_RESOURCE_DIR:= |
| 137 | R_file_stamp := |
| 138 | else |
| 139 | # Make sure that R_file_stamp inherits the proper PRIVATE vars. |
| 140 | # If R.stamp moves, be sure to update the framework makefile, |
| 141 | # which has intimate knowledge of its location. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 142 | R_file_stamp := $(package_expected_intermediates_COMMON)/src/R.stamp |
| 143 | LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) |
| 144 | endif |
| 145 | |
| 146 | LOCAL_BUILT_MODULE_STEM := package.apk |
| 147 | |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 148 | LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED)) |
Ying Wang | 85ab497 | 2010-02-19 18:39:13 -0800 | [diff] [blame] | 149 | ifndef LOCAL_PROGUARD_ENABLED |
| 150 | ifneq ($(filter user userdebug, $(TARGET_BUILD_VARIANT)),) |
| 151 | # turn on Proguard by default for user & userdebug build |
| 152 | LOCAL_PROGUARD_ENABLED :=full |
| 153 | endif |
| 154 | endif |
| 155 | ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) |
| 156 | # the package explicitly request to disable proguard. |
| 157 | LOCAL_PROGUARD_ENABLED := |
| 158 | endif |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 159 | proguard_options_file := |
| 160 | ifneq ($(LOCAL_PROGUARD_ENABLED),custom) |
| 161 | ifneq ($(all_resources),) |
Ying Wang | a17463f | 2010-03-03 14:32:06 -0800 | [diff] [blame] | 162 | proguard_options_file := $(package_expected_intermediates_COMMON)/proguard_options |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 163 | endif # all_resources |
| 164 | endif # !custom |
Ying Wang | a17463f | 2010-03-03 14:32:06 -0800 | [diff] [blame] | 165 | LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 166 | |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 167 | ifneq (true,$(WITH_DEXPREOPT)) |
| 168 | LOCAL_DEX_PREOPT := |
| 169 | else |
Ying Wang | 94978cf | 2011-01-12 11:12:06 -0800 | [diff] [blame] | 170 | ifeq (,$(TARGET_BUILD_APPS)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 171 | ifneq (,$(LOCAL_SRC_FILES)) |
| 172 | ifndef LOCAL_DEX_PREOPT |
| 173 | LOCAL_DEX_PREOPT := true |
| 174 | endif |
| 175 | endif |
| 176 | endif |
Ying Wang | 94978cf | 2011-01-12 11:12:06 -0800 | [diff] [blame] | 177 | endif |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 178 | ifeq (false,$(LOCAL_DEX_PREOPT)) |
| 179 | LOCAL_DEX_PREOPT := |
| 180 | endif |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 181 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 182 | ################################# |
| 183 | include $(BUILD_SYSTEM)/java.mk |
| 184 | ################################# |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 185 | |
Dianne Hackborn | 14169bc | 2011-09-18 17:34:29 -0700 | [diff] [blame] | 186 | LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) |
| 187 | ifeq ($(LOCAL_SDK_RES_VERSION),) |
| 188 | LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) |
| 189 | endif |
| 190 | |
Kevin Hester | 6c70362 | 2012-04-12 10:20:53 -0700 | [diff] [blame] | 191 | full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 192 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 193 | PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) |
| 194 | ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) |
| 195 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 196 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) |
| 197 | else |
| 198 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 199 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) |
| 200 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 201 | |
| 202 | ifneq ($(all_resources),) |
| 203 | |
| 204 | # Since we don't know where the real R.java file is going to end up, |
| 205 | # we need to use another file to stand in its place. We'll just |
| 206 | # copy the generated file to src/R.stamp, which means it will |
| 207 | # have the same contents and timestamp as the actual file. |
| 208 | # |
| 209 | # At the same time, this will copy the R.java file to a central |
| 210 | # 'R' directory to make it easier to add the files to an IDE. |
| 211 | # |
| 212 | #TODO: use PRIVATE_SOURCE_INTERMEDIATES_DIR instead of |
| 213 | # $(intermediates.COMMON)/src |
| 214 | ifneq ($(package_expected_intermediates_COMMON),$(intermediates.COMMON)) |
| 215 | $(error $(LOCAL_MODULE): internal error: expected intermediates.COMMON "$(package_expected_intermediates_COMMON)" != intermediates.COMMON "$(intermediates.COMMON)") |
| 216 | endif |
| 217 | |
| 218 | $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ |
| 219 | $(intermediates.COMMON)/public_resources.xml |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 220 | $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 221 | $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 222 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
| 223 | @rm -f $@ |
| 224 | $(create-resource-java-files) |
| 225 | $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 226 | -name Manifest.java 2> /dev/null`; do \ |
Patrick Scott | fa30f5b | 2010-11-05 15:00:50 -0400 | [diff] [blame] | 227 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 228 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
Ying Wang | d90ff5e | 2011-05-26 13:43:57 -0700 | [diff] [blame] | 229 | $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 230 | done; |
| 231 | $(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 232 | -name R.java 2> /dev/null`; do \ |
Patrick Scott | fa30f5b | 2010-11-05 15:00:50 -0400 | [diff] [blame] | 233 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 234 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
Ying Wang | d90ff5e | 2011-05-26 13:43:57 -0700 | [diff] [blame] | 235 | $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 236 | || exit 31; \ |
Ying Wang | d90ff5e | 2011-05-26 13:43:57 -0700 | [diff] [blame] | 237 | $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 238 | done; \ |
| 239 | |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 240 | $(proguard_options_file): $(R_file_stamp) |
| 241 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 242 | ifdef LOCAL_EXPORT_PACKAGE_RESOURCES |
| 243 | # Put this module's resources into a PRODUCT-agnositc package that |
| 244 | # other packages can use to build their own PRODUCT-agnostic R.java (etc.) |
| 245 | # files. |
| 246 | resource_export_package := $(intermediates.COMMON)/package-export.apk |
| 247 | $(R_file_stamp): $(resource_export_package) |
| 248 | |
| 249 | # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target |
| 250 | # can't know anything about PRODUCT. Clear it out just for this target. |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 251 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := |
Dianne Hackborn | a0f464a | 2011-10-14 19:37:57 -0700 | [diff] [blame] | 252 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
Ying Wang | 035ef06 | 2010-08-18 20:30:52 -0700 | [diff] [blame] | 253 | $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 254 | @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" |
| 255 | $(create-empty-package) |
| 256 | $(add-assets-to-package) |
| 257 | endif |
| 258 | |
| 259 | # Other modules should depend on the BUILT module if |
| 260 | # they want to use this module's R.java file. |
| 261 | $(LOCAL_BUILT_MODULE): $(R_file_stamp) |
| 262 | |
| 263 | ifneq ($(full_classes_jar),) |
| 264 | # If full_classes_jar is non-empty, we're building sources. |
| 265 | # If we're building sources, the initial javac step (which |
| 266 | # produces full_classes_compiled_jar) needs to ensure the |
| 267 | # R.java and Manifest.java files have been generated first. |
| 268 | $(full_classes_compiled_jar): $(R_file_stamp) |
| 269 | endif |
| 270 | |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 271 | endif # all_resources |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 272 | |
| 273 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 274 | # We need to explicitly clear this var so that we don't |
| 275 | # inherit the value from whomever caused us to be built. |
| 276 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := |
| 277 | else |
| 278 | # Most packages should link against the resources defined by framework-res. |
| 279 | # Even if they don't have their own resources, they may use framework |
| 280 | # resources. |
Ying Wang | 0ec188f | 2012-05-10 17:25:51 -0700 | [diff] [blame] | 281 | ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current,$(LOCAL_SDK_RES_VERSION))),) |
Ying Wang | 0f6f4ca | 2010-06-09 10:26:26 -0700 | [diff] [blame] | 282 | # for released sdk versions, the platform resources were built into android.jar. |
| 283 | framework_res_package_export := \ |
Dianne Hackborn | 14169bc | 2011-09-18 17:34:29 -0700 | [diff] [blame] | 284 | $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar |
Ying Wang | 0f6f4ca | 2010-06-09 10:26:26 -0700 | [diff] [blame] | 285 | framework_res_package_export_deps := $(framework_res_package_export) |
Dianne Hackborn | 14169bc | 2011-09-18 17:34:29 -0700 | [diff] [blame] | 286 | else # LOCAL_SDK_RES_VERSION |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 287 | framework_res_package_export := \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 288 | $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 289 | # We can't depend directly on the export.apk file; it won't get its |
| 290 | # PRIVATE_ vars set up correctly if we do. Instead, depend on the |
| 291 | # corresponding R.stamp file, which lists the export.apk as a dependency. |
| 292 | framework_res_package_export_deps := \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 293 | $(dir $(framework_res_package_export))src/R.stamp |
Dianne Hackborn | 14169bc | 2011-09-18 17:34:29 -0700 | [diff] [blame] | 294 | endif # LOCAL_SDK_RES_VERSION |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 295 | $(R_file_stamp): $(framework_res_package_export_deps) |
Ying Wang | 0f6f4ca | 2010-06-09 10:26:26 -0700 | [diff] [blame] | 296 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
Ying Wang | bb9c230 | 2011-04-08 17:27:35 -0700 | [diff] [blame] | 297 | PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) |
Ying Wang | 0f6f4ca | 2010-06-09 10:26:26 -0700 | [diff] [blame] | 298 | endif # LOCAL_NO_STANDARD_LIBRARIES |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 299 | |
| 300 | ifneq ($(full_classes_jar),) |
| 301 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) |
| 302 | $(LOCAL_BUILT_MODULE): $(built_dex) |
| 303 | endif # full_classes_jar |
| 304 | |
| 305 | |
| 306 | # Get the list of jni libraries to be included in the apk file. |
| 307 | |
| 308 | so_suffix := $($(my_prefix)SHLIB_SUFFIX) |
| 309 | |
| 310 | jni_shared_libraries := \ |
| 311 | $(addprefix $($(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 312 | $(addsuffix $(so_suffix), \ |
| 313 | $(LOCAL_JNI_SHARED_LIBRARIES))) |
| 314 | |
Ying Wang | 32fa8a3 | 2011-10-13 17:31:45 -0700 | [diff] [blame] | 315 | # App explicitly requires the prebuilt NDK libstlport_shared.so. |
| 316 | # libstlport_shared.so should never go to the system image. |
| 317 | # Instead it should be packaged into the apk. |
| 318 | ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT)) |
| 319 | ifndef LOCAL_NDK_VERSION |
| 320 | $(error LOCAL_NDK_VERSION has to be defined together with LOCAL_NDK_STL_VARIANT, \ |
| 321 | LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME)) |
| 322 | endif |
| 323 | jni_shared_libraries += \ |
| 324 | $(HISTORICAL_NDK_VERSIONS_ROOT)/android-ndk-r$(LOCAL_NDK_VERSION)/sources/cxx-stl/stlport/libs/$(TARGET_CPU_ABI)/libstlport_shared.so |
| 325 | endif |
| 326 | |
Jack Palevich | a0ab29b | 2010-06-18 15:38:07 +0800 | [diff] [blame] | 327 | # Set the abi directory used by the local JNI shared libraries. |
| 328 | # (Doesn't change how the local shared libraries are compiled, just |
| 329 | # sets where they are stored in the apk.) |
| 330 | |
| 331 | ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),) |
| 332 | jni_shared_libraries_abi := $(TARGET_CPU_ABI) |
| 333 | else |
| 334 | jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI) |
| 335 | endif |
| 336 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 337 | # Pick a key to sign the package with. If this package hasn't specified |
| 338 | # an explicit certificate, use the default. |
| 339 | # Secure release builds will have their packages signed after the fact, |
| 340 | # so it's ok for these private keys to be in the clear. |
| 341 | ifeq ($(LOCAL_CERTIFICATE),) |
Ying Wang | 3c21fe5 | 2011-10-04 10:50:08 -0700 | [diff] [blame] | 342 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 343 | endif |
Doug Zongker | f6a53aa | 2009-12-15 15:06:55 -0800 | [diff] [blame] | 344 | |
| 345 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 346 | # The special value "EXTERNAL" means that we will sign it with the |
Ying Wang | 3c21fe5 | 2011-10-04 10:50:08 -0700 | [diff] [blame] | 347 | # default devkey, apply predexopt, but then expect the final .apk |
Doug Zongker | f6a53aa | 2009-12-15 15:06:55 -0800 | [diff] [blame] | 348 | # (after dexopting) to be signed by an outside tool. |
Ying Wang | 3c21fe5 | 2011-10-04 10:50:08 -0700 | [diff] [blame] | 349 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
Doug Zongker | f6a53aa | 2009-12-15 15:06:55 -0800 | [diff] [blame] | 350 | PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1 |
| 351 | endif |
| 352 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 353 | # If this is not an absolute certificate, assign it to a generic one. |
| 354 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
Ying Wang | 3c21fe5 | 2011-10-04 10:50:08 -0700 | [diff] [blame] | 355 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 356 | endif |
| 357 | private_key := $(LOCAL_CERTIFICATE).pk8 |
| 358 | certificate := $(LOCAL_CERTIFICATE).x509.pem |
| 359 | |
| 360 | $(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR) |
| 361 | $(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key) |
| 362 | $(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate) |
| 363 | |
| 364 | PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key) |
| 365 | PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate) |
| 366 | |
| 367 | # Define the rule to build the actual package. |
| 368 | $(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN) |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 369 | ifdef LOCAL_DEX_PREOPT |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 370 | # Make sure the boot jars get dexpreopt-ed first |
| 371 | $(LOCAL_BUILT_MODULE): $(DEXPREOPT_BOOT_ODEXS) | $(DEXPREOPT) $(DEXOPT) |
| 372 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 373 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries) |
Jack Palevich | a0ab29b | 2010-06-18 15:38:07 +0800 | [diff] [blame] | 374 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abi) |
Joe Onorato | 16fa4b2 | 2010-06-09 16:35:58 -0700 | [diff] [blame] | 375 | ifneq ($(TARGET_BUILD_APPS),) |
Ying Wang | 5291130 | 2010-05-26 13:13:56 -0700 | [diff] [blame] | 376 | # Include all resources for unbundled apps. |
Ying Wang | 8b07ed8 | 2010-12-28 13:14:29 -0800 | [diff] [blame] | 377 | LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true |
| 378 | endif |
| 379 | ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true) |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 380 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := |
Dianne Hackborn | a0f464a | 2011-10-14 19:37:57 -0700 | [diff] [blame] | 381 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
Ying Wang | 4f1ab92 | 2011-03-15 13:19:30 -0700 | [diff] [blame] | 382 | else |
| 383 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG) |
Dianne Hackborn | a0f464a | 2011-10-14 19:37:57 -0700 | [diff] [blame] | 384 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) |
Ying Wang | 5291130 | 2010-05-26 13:13:56 -0700 | [diff] [blame] | 385 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 386 | $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) |
| 387 | @echo "target Package: $(PRIVATE_MODULE) ($@)" |
| 388 | $(create-empty-package) |
| 389 | $(add-assets-to-package) |
| 390 | ifneq ($(jni_shared_libraries),) |
| 391 | $(add-jni-shared-libs-to-package) |
| 392 | endif |
| 393 | ifneq ($(full_classes_jar),) |
| 394 | $(add-dex-to-package) |
| 395 | endif |
| 396 | $(sign-package) |
| 397 | @# Alignment must happen after all other zip operations. |
| 398 | $(align-package) |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 399 | ifdef LOCAL_DEX_PREOPT |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 400 | $(hide) rm -f $(patsubst %.apk,%.odex,$@) |
| 401 | $(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@)) |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 402 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 403 | $(call dexpreopt-remove-classes.dex,$@) |
Ying Wang | 79e3dec | 2011-10-24 12:17:03 -0700 | [diff] [blame] | 404 | endif |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 405 | |
| 406 | built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex |
| 407 | $(built_odex): $(LOCAL_BUILT_MODULE) |
| 408 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 409 | |
| 410 | # Save information about this package |
| 411 | PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 412 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources) |
Ying Wang | 71004f8 | 2012-05-24 21:05:19 -0700 | [diff] [blame] | 413 | ifdef package_resource_overlays |
| 414 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays) |
| 415 | endif |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 416 | |
| 417 | PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME) |
Joe Onorato | 899e62a | 2010-02-04 17:37:21 -0800 | [diff] [blame] | 418 | |
| 419 | endif # skip_definition |