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