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