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