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