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