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