Colin Cross | 8e40412 | 2014-02-06 14:45:37 -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 |
| 22 | ## will be called this. |
| 23 | ## |
| 24 | ## MODULE, MODULE_PATH, and MODULE_SUFFIX will |
| 25 | ## be set for you. |
| 26 | ########################################################### |
| 27 | |
| 28 | # If this makefile is being read from within an inheritance, |
| 29 | # use the new values. |
| 30 | skip_definition:= |
| 31 | ifdef LOCAL_PACKAGE_OVERRIDES |
| 32 | package_overridden := $(call set-inherited-package-variables) |
| 33 | ifeq ($(strip $(package_overridden)),) |
| 34 | skip_definition := true |
| 35 | endif |
| 36 | endif |
| 37 | |
| 38 | ifndef skip_definition |
| 39 | |
| 40 | LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME)) |
| 41 | ifeq ($(LOCAL_PACKAGE_NAME),) |
| 42 | $(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME) |
| 43 | endif |
| 44 | |
| 45 | ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),) |
| 46 | $(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX) |
| 47 | endif |
| 48 | LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) |
| 49 | |
| 50 | ifneq ($(strip $(LOCAL_MODULE)),) |
| 51 | $(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE) |
| 52 | endif |
| 53 | LOCAL_MODULE := $(LOCAL_PACKAGE_NAME) |
| 54 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 55 | ifneq ($(strip $(LOCAL_MODULE_CLASS)),) |
| 56 | $(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS) |
| 57 | endif |
| 58 | LOCAL_MODULE_CLASS := APPS |
| 59 | |
Yohann Roussel | d2a76c1 | 2015-02-05 16:10:58 +0100 | [diff] [blame] | 60 | ################################# |
| 61 | include $(BUILD_SYSTEM)/configure_local_jack.mk |
| 62 | ################################# |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 63 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 64 | # Package LOCAL_MODULE_TAGS default to optional |
| 65 | LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS)) |
| 66 | ifeq ($(LOCAL_MODULE_TAGS),) |
| 67 | LOCAL_MODULE_TAGS := optional |
| 68 | endif |
| 69 | |
| 70 | ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) |
| 71 | # Force localization check if it's not tagged as tests. |
| 72 | LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z |
| 73 | endif |
| 74 | |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 75 | ifdef LOCAL_PACKAGE_SPLITS |
| 76 | LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS)) |
| 77 | endif |
| 78 | |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 79 | need_compile_asset := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 80 | ifeq (,$(LOCAL_ASSET_DIR)) |
| 81 | LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 82 | else |
| 83 | need_compile_asset := true |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 84 | endif |
| 85 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 86 | # LOCAL_RESOURCE_DIR may point to resource generated during the build |
| 87 | need_compile_res := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 88 | ifeq (,$(LOCAL_RESOURCE_DIR)) |
| 89 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 90 | else |
| 91 | need_compile_res := true |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 92 | endif |
| 93 | |
| 94 | package_resource_overlays := $(strip \ |
| 95 | $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \ |
| 96 | $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \ |
| 97 | $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \ |
| 98 | $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR))))) |
| 99 | |
| 100 | LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR) |
| 101 | |
Colin Cross | 2c32144 | 2014-02-12 13:06:30 -0800 | [diff] [blame] | 102 | all_assets := $(strip \ |
| 103 | $(foreach dir, $(LOCAL_ASSET_DIR), \ |
| 104 | $(addprefix $(dir)/, \ |
| 105 | $(patsubst assets/%,%, \ |
| 106 | $(call find-subdir-assets, $(dir)) \ |
| 107 | ) \ |
| 108 | ) \ |
| 109 | )) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 110 | |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 111 | ifneq ($(all_assets),) |
| 112 | need_compile_asset := true |
| 113 | endif |
| 114 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 115 | all_resources := $(strip \ |
| 116 | $(foreach dir, $(LOCAL_RESOURCE_DIR), \ |
| 117 | $(addprefix $(dir)/, \ |
| 118 | $(patsubst res/%,%, \ |
| 119 | $(call find-subdir-assets,$(dir)) \ |
| 120 | ) \ |
| 121 | ) \ |
| 122 | )) |
| 123 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 124 | ifneq ($(all_resources),) |
| 125 | need_compile_res := true |
| 126 | endif |
| 127 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 128 | all_res_assets := $(strip $(all_assets) $(all_resources)) |
| 129 | |
Ying Wang | 98ae798 | 2014-12-18 14:53:52 -0800 | [diff] [blame] | 130 | intermediates.COMMON := $(call local-intermediates-dir,COMMON) |
| 131 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 132 | # If no assets or resources were found, clear the directory variables so |
| 133 | # we don't try to build them. |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 134 | ifneq (true,$(need_compile_asset)) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 135 | LOCAL_ASSET_DIR:= |
| 136 | endif |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 137 | ifneq (true,$(need_compile_res)) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 138 | LOCAL_RESOURCE_DIR:= |
| 139 | R_file_stamp := |
| 140 | else |
| 141 | # Make sure that R_file_stamp inherits the proper PRIVATE vars. |
| 142 | # If R.stamp moves, be sure to update the framework makefile, |
| 143 | # which has intimate knowledge of its location. |
Ying Wang | 98ae798 | 2014-12-18 14:53:52 -0800 | [diff] [blame] | 144 | R_file_stamp := $(intermediates.COMMON)/src/R.stamp |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 145 | LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) |
| 146 | endif |
| 147 | |
| 148 | LOCAL_BUILT_MODULE_STEM := package.apk |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 149 | LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 150 | |
| 151 | LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED)) |
| 152 | ifndef LOCAL_PROGUARD_ENABLED |
| 153 | ifneq ($(DISABLE_PROGUARD),true) |
| 154 | LOCAL_PROGUARD_ENABLED :=full |
| 155 | endif |
| 156 | endif |
| 157 | ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) |
| 158 | # the package explicitly request to disable proguard. |
| 159 | LOCAL_PROGUARD_ENABLED := |
| 160 | endif |
| 161 | proguard_options_file := |
| 162 | ifneq ($(LOCAL_PROGUARD_ENABLED),custom) |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 163 | ifeq ($(need_compile_res),true) |
Ying Wang | 98ae798 | 2014-12-18 14:53:52 -0800 | [diff] [blame] | 164 | proguard_options_file := $(intermediates.COMMON)/proguard_options |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 165 | endif # need_compile_res |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 166 | endif # !custom |
| 167 | LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) |
| 168 | |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 169 | ifdef LOCAL_JACK_ENABLED |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 170 | ifndef LOCAL_JACK_PROGUARD_FLAGS |
| 171 | LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS) |
| 172 | endif |
| 173 | LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS) |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 174 | endif # LOCAL_JACK_ENABLED |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 175 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 176 | ifeq (true,$(EMMA_INSTRUMENT)) |
| 177 | ifndef LOCAL_EMMA_INSTRUMENT |
| 178 | # No emma for test apks. |
| 179 | ifeq (,$(filer tests,$(LOCAL_MODULE_TAGS))$(LOCAL_INSTRUMENTATION_FOR)) |
| 180 | LOCAL_EMMA_INSTRUMENT := true |
| 181 | endif # No test apk |
| 182 | endif # LOCAL_EMMA_INSTRUMENT is not set |
| 183 | else |
| 184 | LOCAL_EMMA_INSTRUMENT := false |
| 185 | endif # EMMA_INSTRUMENT is true |
| 186 | |
| 187 | ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) |
| 188 | ifeq (true,$(EMMA_INSTRUMENT_STATIC)) |
| 189 | LOCAL_STATIC_JAVA_LIBRARIES += emma |
| 190 | else |
| 191 | ifdef LOCAL_SDK_VERSION |
| 192 | ifdef TARGET_BUILD_APPS |
| 193 | # In unbundled build merge the emma library into the apk. |
| 194 | LOCAL_STATIC_JAVA_LIBRARIES += emma |
| 195 | else |
| 196 | # If build against the SDK in full build, core.jar is not used, |
| 197 | # we have to use prebiult emma.jar to make Proguard happy; |
| 198 | # Otherwise emma classes are included in core.jar. |
| 199 | LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR) |
| 200 | endif # full build |
| 201 | endif # LOCAL_SDK_VERSION |
| 202 | endif # EMMA_INSTRUMENT_STATIC |
| 203 | endif # LOCAL_EMMA_INSTRUMENT |
| 204 | |
| 205 | rs_compatibility_jni_libs := |
| 206 | |
Ying Wang | ed0361f | 2015-04-19 09:55:39 -0700 | [diff] [blame] | 207 | ifeq ($(LOCAL_DATA_BINDING),true) |
| 208 | data_binding_intermediates := $(intermediates.COMMON)/data-binding |
| 209 | |
| 210 | LOCAL_JAVACFLAGS += -processorpath $(DATA_BINDING_COMPILER) -s $(data_binding_intermediates)/anno-src |
| 211 | LOCAL_JACK_FLAGS += --processorpath $(DATA_BINDING_COMPILER) |
| 212 | |
| 213 | LOCAL_STATIC_JAVA_LIBRARIES += databinding-baselibrary |
| 214 | LOCAL_STATIC_JAVA_AAR_LIBRARIES += databinding-library databinding-adapters |
| 215 | |
| 216 | data_binding_res_in := $(LOCAL_RESOURCE_DIR) |
| 217 | data_binding_res_out := $(data_binding_intermediates)/res |
| 218 | |
| 219 | # Replace with the processed merged res dir. |
| 220 | LOCAL_RESOURCE_DIR := $(data_binding_res_out) |
| 221 | |
| 222 | LOCAL_AAPT_FLAGS += --auto-add-overlay --extra-packages com.android.databinding.library |
| 223 | endif # LOCAL_DATA_BINDING |
| 224 | |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 225 | include $(BUILD_SYSTEM)/android_manifest.mk |
| 226 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 227 | ################################# |
| 228 | include $(BUILD_SYSTEM)/java.mk |
| 229 | ################################# |
| 230 | |
| 231 | LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) |
| 232 | ifeq ($(LOCAL_SDK_RES_VERSION),) |
| 233 | LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) |
| 234 | endif |
| 235 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 236 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 237 | PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) |
Ying Wang | efb9358 | 2014-07-19 17:00:50 -0700 | [diff] [blame] | 238 | ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 239 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 240 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) |
| 241 | else |
| 242 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 243 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) |
| 244 | endif |
| 245 | |
Ying Wang | ed0361f | 2015-04-19 09:55:39 -0700 | [diff] [blame] | 246 | ifeq ($(LOCAL_DATA_BINDING),true) |
| 247 | data_binding_stamp := $(data_binding_intermediates)/data-binding.stamp |
| 248 | $(data_binding_stamp): PRIVATE_INTERMEDIATES := $(data_binding_intermediates) |
| 249 | $(data_binding_stamp): PRIVATE_MANIFEST := $(full_android_manifest) |
| 250 | # Generate code into $(LOCAL_INTERMEDIATE_SOURCE_DIR) so that the generated .java files |
| 251 | # will be automatically picked up by function compile-java. |
| 252 | $(data_binding_stamp): PRIVATE_SRC_OUT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/data-binding |
| 253 | $(data_binding_stamp): PRIVATE_XML_OUT := $(data_binding_intermediates)/xml |
| 254 | $(data_binding_stamp): PRIVATE_RES_OUT := $(data_binding_res_out) |
| 255 | $(data_binding_stamp): PRIVATE_RES_IN := $(data_binding_res_in) |
| 256 | $(data_binding_stamp): PRIVATE_ANNO_SRC_DIR := $(data_binding_intermediates)/anno-src |
| 257 | |
| 258 | $(data_binding_stamp) : $(all_res_assets) $(full_android_manifest) \ |
| 259 | $(DATA_BINDING_COMPILER) |
| 260 | @echo "Data-binding process: $@" |
| 261 | @rm -rf $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) && \ |
| 262 | mkdir -p $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) \ |
| 263 | $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_ANNO_SRC_DIR) |
| 264 | $(hide) java -classpath $(DATA_BINDING_COMPILER) android.databinding.tool.MakeCopy \ |
| 265 | $(PRIVATE_MANIFEST) $(PRIVATE_SRC_OUT) $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_RES_IN) |
| 266 | $(hide) touch $@ |
| 267 | |
| 268 | # Make sure the data-binding process happens before javac and generation of R.java. |
| 269 | $(R_file_stamp) $(full_classes_compiled_jar) : $(data_binding_stamp) |
| 270 | # The dependency path when jack is enabled |
| 271 | $(built_dex_intermediate) : $(data_binding_stamp) |
| 272 | endif # LOCAL_DATA_BINDING |
| 273 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 274 | ifeq ($(need_compile_res),true) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 275 | |
| 276 | # Since we don't know where the real R.java file is going to end up, |
| 277 | # we need to use another file to stand in its place. We'll just |
| 278 | # copy the generated file to src/R.stamp, which means it will |
| 279 | # have the same contents and timestamp as the actual file. |
| 280 | # |
| 281 | # At the same time, this will copy the R.java file to a central |
| 282 | # 'R' directory to make it easier to add the files to an IDE. |
| 283 | # |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 284 | |
| 285 | $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ |
| 286 | $(intermediates.COMMON)/public_resources.xml |
| 287 | $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) |
| 288 | $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP) |
| 289 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
| 290 | @rm -f $@ |
| 291 | $(create-resource-java-files) |
| 292 | $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 293 | -name Manifest.java 2> /dev/null`; do \ |
| 294 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \ |
| 295 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 296 | $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 297 | done; |
| 298 | $(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 299 | -name R.java 2> /dev/null`; do \ |
| 300 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \ |
| 301 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 302 | $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \ |
| 303 | || exit 31; \ |
| 304 | $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \ |
| 305 | done; \ |
| 306 | |
| 307 | $(proguard_options_file): $(R_file_stamp) |
| 308 | |
Ying Wang | dbe23f5 | 2014-03-25 14:42:46 -0700 | [diff] [blame] | 309 | resource_export_package := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 310 | ifdef LOCAL_EXPORT_PACKAGE_RESOURCES |
| 311 | # Put this module's resources into a PRODUCT-agnositc package that |
| 312 | # other packages can use to build their own PRODUCT-agnostic R.java (etc.) |
| 313 | # files. |
| 314 | resource_export_package := $(intermediates.COMMON)/package-export.apk |
| 315 | $(R_file_stamp): $(resource_export_package) |
| 316 | |
| 317 | # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target |
| 318 | # can't know anything about PRODUCT. Clear it out just for this target. |
| 319 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := |
| 320 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 321 | $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) |
| 322 | @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" |
| 323 | $(create-empty-package) |
| 324 | $(add-assets-to-package) |
| 325 | endif |
| 326 | |
| 327 | # Other modules should depend on the BUILT module if |
| 328 | # they want to use this module's R.java file. |
| 329 | $(LOCAL_BUILT_MODULE): $(R_file_stamp) |
| 330 | |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 331 | ifdef LOCAL_JACK_ENABLED |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 332 | ifneq ($(built_dex_intermediate),) |
| 333 | $(built_dex_intermediate): $(R_file_stamp) |
| 334 | endif |
| 335 | ifneq ($(noshrob_classes_jack),) |
| 336 | $(noshrob_classes_jack): $(R_file_stamp) |
| 337 | endif |
| 338 | ifneq ($(full_classes_jack),) |
| 339 | $(full_classes_jack): $(R_file_stamp) |
| 340 | endif |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 341 | endif # LOCAL_JACK_ENABLED |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 342 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 343 | ifneq ($(full_classes_jar),) |
| 344 | # If full_classes_jar is non-empty, we're building sources. |
| 345 | # If we're building sources, the initial javac step (which |
| 346 | # produces full_classes_compiled_jar) needs to ensure the |
| 347 | # R.java and Manifest.java files have been generated first. |
| 348 | $(full_classes_compiled_jar): $(R_file_stamp) |
| 349 | endif |
| 350 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 351 | endif # need_compile_res |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 352 | |
| 353 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 354 | # We need to explicitly clear this var so that we don't |
| 355 | # inherit the value from whomever caused us to be built. |
| 356 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := |
| 357 | else |
| 358 | # Most packages should link against the resources defined by framework-res. |
| 359 | # Even if they don't have their own resources, they may use framework |
| 360 | # resources. |
Ying Wang | efb9358 | 2014-07-19 17:00:50 -0700 | [diff] [blame] | 361 | ifneq ($(filter-out current system_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current,$(LOCAL_SDK_RES_VERSION))),) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 362 | # for released sdk versions, the platform resources were built into android.jar. |
| 363 | framework_res_package_export := \ |
| 364 | $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar |
| 365 | framework_res_package_export_deps := $(framework_res_package_export) |
| 366 | else # LOCAL_SDK_RES_VERSION |
| 367 | framework_res_package_export := \ |
| 368 | $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk |
| 369 | # We can't depend directly on the export.apk file; it won't get its |
| 370 | # PRIVATE_ vars set up correctly if we do. Instead, depend on the |
| 371 | # corresponding R.stamp file, which lists the export.apk as a dependency. |
| 372 | framework_res_package_export_deps := \ |
| 373 | $(dir $(framework_res_package_export))src/R.stamp |
| 374 | endif # LOCAL_SDK_RES_VERSION |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 375 | all_library_res_package_exports := \ |
| 376 | $(framework_res_package_export) \ |
Adam Lesinski | 5eebe0f | 2014-03-25 15:45:34 -0700 | [diff] [blame] | 377 | $(foreach lib,$(LOCAL_RES_LIBRARIES),\ |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 378 | $(call intermediates-dir-for,APPS,$(lib),,COMMON)/package-export.apk) |
| 379 | |
| 380 | all_library_res_package_export_deps := \ |
| 381 | $(framework_res_package_export_deps) \ |
Adam Lesinski | 5eebe0f | 2014-03-25 15:45:34 -0700 | [diff] [blame] | 382 | $(foreach lib,$(LOCAL_RES_LIBRARIES),\ |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 383 | $(call intermediates-dir-for,APPS,$(lib),,COMMON)/src/R.stamp) |
| 384 | |
Ying Wang | b574564 | 2014-06-19 16:07:30 -0700 | [diff] [blame] | 385 | $(resource_export_package) $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(all_library_res_package_export_deps) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 386 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 387 | PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 388 | endif # LOCAL_NO_STANDARD_LIBRARIES |
| 389 | |
| 390 | ifneq ($(full_classes_jar),) |
| 391 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 392 | # Use the jarjar processed arhive as the initial package file. |
| 393 | $(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 394 | $(LOCAL_BUILT_MODULE): $(built_dex) |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 395 | else |
| 396 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := |
| 397 | $(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 398 | endif # full_classes_jar |
| 399 | |
Ying Wang | 96bcad4 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 400 | include $(BUILD_SYSTEM)/install_jni_libs.mk |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 401 | |
| 402 | # Pick a key to sign the package with. If this package hasn't specified |
| 403 | # an explicit certificate, use the default. |
| 404 | # Secure release builds will have their packages signed after the fact, |
| 405 | # so it's ok for these private keys to be in the clear. |
| 406 | ifeq ($(LOCAL_CERTIFICATE),) |
| 407 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 408 | endif |
| 409 | |
| 410 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 411 | # The special value "EXTERNAL" means that we will sign it with the |
| 412 | # default devkey, apply predexopt, but then expect the final .apk |
| 413 | # (after dexopting) to be signed by an outside tool. |
| 414 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 415 | PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1 |
| 416 | endif |
| 417 | |
| 418 | # If this is not an absolute certificate, assign it to a generic one. |
| 419 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
| 420 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
| 421 | endif |
| 422 | private_key := $(LOCAL_CERTIFICATE).pk8 |
| 423 | certificate := $(LOCAL_CERTIFICATE).x509.pem |
| 424 | |
| 425 | $(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR) |
| 426 | $(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key) |
| 427 | $(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate) |
| 428 | |
| 429 | PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key) |
| 430 | PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate) |
| 431 | |
| 432 | $(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\ |
| 433 | $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8) |
| 434 | |
| 435 | # Define the rule to build the actual package. |
| 436 | $(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN) |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 437 | # PRIVATE_JNI_SHARED_LIBRARIES is a list of <abi>:<path_of_built_lib>. |
| 438 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis) |
| 439 | # PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names. |
| 440 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 441 | ifneq ($(TARGET_BUILD_APPS),) |
| 442 | # Include all resources for unbundled apps. |
| 443 | LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true |
| 444 | endif |
| 445 | ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true) |
| 446 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := |
| 447 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 448 | else |
| 449 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG) |
Ying Wang | 934008f | 2014-07-30 13:40:14 -0700 | [diff] [blame] | 450 | ifdef LOCAL_PACKAGE_SPLITS |
| 451 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 452 | else |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 453 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) |
| 454 | endif |
Ying Wang | 934008f | 2014-07-30 13:40:14 -0700 | [diff] [blame] | 455 | endif |
Fredrik Roubert | cc93f0c | 2015-01-28 21:29:38 +0100 | [diff] [blame] | 456 | $(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 457 | $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) |
| 458 | @echo "target Package: $(PRIVATE_MODULE) ($@)" |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 459 | ifdef LOCAL_JACK_ENABLED |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 460 | $(create-empty-package) |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 461 | else |
| 462 | $(if $(PRIVATE_SOURCE_ARCHIVE),\ |
| 463 | $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\ |
| 464 | $(create-empty-package)) |
| 465 | endif |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 466 | $(add-assets-to-package) |
| 467 | ifneq ($(jni_shared_libraries),) |
| 468 | $(add-jni-shared-libs-to-package) |
| 469 | endif |
Ying Wang | 8b27d18 | 2015-03-27 11:07:17 -0700 | [diff] [blame] | 470 | ifeq ($(full_classes_jar),) |
| 471 | # We don't build jar, need to add the Java resources here. |
| 472 | $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) |
| 473 | else |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 474 | $(add-dex-to-package) |
| 475 | endif |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 476 | ifdef LOCAL_JACK_ENABLED |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 477 | $(add-carried-jack-resources) |
| 478 | endif |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 479 | ifdef LOCAL_DEX_PREOPT |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 480 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 481 | $(call dexpreopt-remove-classes.dex,$@) |
| 482 | endif |
| 483 | endif |
Kenny Root | dff3755 | 2015-04-15 12:09:32 -0700 | [diff] [blame] | 484 | $(sign-package) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 485 | @# Alignment must happen after all other zip operations. |
| 486 | $(align-package) |
| 487 | |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 488 | ############################### |
Ying Wang | 8070b20 | 2014-12-01 17:46:56 -0800 | [diff] [blame] | 489 | ## Build dpi-specific apks, if it's apps_only build. |
| 490 | ifdef TARGET_BUILD_APPS |
| 491 | ifdef LOCAL_DPI_VARIANTS |
| 492 | $(foreach d, $(LOCAL_DPI_VARIANTS), \ |
| 493 | $(eval my_dpi := $(d)) \ |
| 494 | $(eval include $(BUILD_SYSTEM)/dpi_specific_apk.mk)) |
| 495 | endif |
| 496 | endif |
| 497 | |
| 498 | ############################### |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 499 | ## Rule to build the odex file |
| 500 | ifdef LOCAL_DEX_PREOPT |
| 501 | $(built_odex): PRIVATE_DEX_FILE := $(built_dex) |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 502 | # Use pattern rule - we may have multiple built odex files. |
| 503 | $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex) |
Ying Wang | 994c226 | 2014-05-28 13:34:59 -0700 | [diff] [blame] | 504 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 505 | $(add-dex-to-package) |
| 506 | $(hide) mv $@ $@.input |
| 507 | $(call dexpreopt-one-file,$@.input,$@) |
| 508 | $(hide) rm $@.input |
| 509 | endif |
| 510 | |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 511 | ############################### |
| 512 | ## APK splits |
| 513 | ifdef LOCAL_PACKAGE_SPLITS |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 514 | # LOCAL_PACKAGE_SPLITS is a list of resource labels. |
Ying Wang | 114a0fc | 2014-10-01 12:01:04 -0700 | [diff] [blame] | 515 | # aapt will convert comma inside resource lable to underscore in the file names. |
| 516 | my_split_suffixes := $(subst $(comma),_,$(LOCAL_PACKAGE_SPLITS)) |
| 517 | built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk) |
| 518 | installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 519 | |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 520 | # The splits should have been built in the same command building the base apk. |
| 521 | # This rule just runs signing and zipalign etc. |
| 522 | # Note that we explicily check the existence of the split apk and remove the |
| 523 | # built base apk if the split apk isn't there. |
| 524 | # That way the build system will rerun the aapt after the user changes the splitting parameters. |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 525 | $(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key) |
| 526 | $(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate) |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 527 | $(built_apk_splits) : $(built_module_path)/%.apk : $(LOCAL_BUILT_MODULE) |
| 528 | $(hide) if [ ! -f $@ ]; then \ |
| 529 | echo 'No $@ generated, check your apk splitting parameters.' 1>&2; \ |
| 530 | rm $<; exit 1; \ |
| 531 | fi |
| 532 | $(sign-package) |
| 533 | $(align-package) |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 534 | |
| 535 | # Rules to install the splits |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 536 | $(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk | $(ACP) |
| 537 | @echo "Install: $@" |
| 538 | $(copy-file-to-new-target) |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 539 | |
| 540 | # Register the additional built and installed files. |
| 541 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) |
| 542 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ |
Ying Wang | 114a0fc | 2014-10-01 12:01:04 -0700 | [diff] [blame] | 543 | $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 544 | |
| 545 | # Make sure to install the splits when you run "make <module_name>". |
| 546 | $(my_register_name): $(installed_apk_splits) |
Ying Wang | 1624361 | 2015-06-03 12:43:50 -0700 | [diff] [blame] | 547 | |
| 548 | ifdef LOCAL_COMPATIBILITY_SUITE |
| 549 | cts_testcase_file := $(foreach s,$(my_split_suffixes),$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE)_$(s).apk) |
Ying Wang | 9d8a062 | 2015-10-21 14:14:50 -0700 | [diff] [blame^] | 550 | $(cts_testcase_file) : $(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk | $(ACP) |
Ying Wang | 1624361 | 2015-06-03 12:43:50 -0700 | [diff] [blame] | 551 | $(copy-file-to-new-target) |
| 552 | |
| 553 | COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES := \ |
| 554 | $(COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES) \ |
| 555 | $(cts_testcase_file) |
| 556 | |
| 557 | $(my_register_name) : $(cts_testcase_file) |
| 558 | endif # LOCAL_COMPATIBILITY_SUITE |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 559 | endif # LOCAL_PACKAGE_SPLITS |
| 560 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 561 | # Save information about this package |
| 562 | PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 563 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources) |
| 564 | ifdef package_resource_overlays |
| 565 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays) |
| 566 | endif |
| 567 | |
| 568 | PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME) |
| 569 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 570 | endif # skip_definition |
| 571 | |
| 572 | # Reset internal variables. |
| 573 | all_res_assets := |