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 | |
Yohann Roussel | d2a76c1 | 2015-02-05 16:10:58 +0100 | [diff] [blame] | 60 | ################################# |
| 61 | include $(BUILD_SYSTEM)/configure_local_jack.mk |
| 62 | ################################# |
Yohann Roussel | 37822c4 | 2015-01-09 10:36:40 +0100 | [diff] [blame] | 63 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 64 | # Package LOCAL_MODULE_TAGS default to optional |
| 65 | LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS)) |
| 66 | ifeq ($(LOCAL_MODULE_TAGS),) |
| 67 | LOCAL_MODULE_TAGS := optional |
| 68 | endif |
| 69 | |
| 70 | ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) |
| 71 | # Force localization check if it's not tagged as tests. |
| 72 | LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z |
| 73 | endif |
| 74 | |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 75 | ifdef LOCAL_PACKAGE_SPLITS |
| 76 | LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS)) |
| 77 | endif |
| 78 | |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 79 | need_compile_asset := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 80 | ifeq (,$(LOCAL_ASSET_DIR)) |
| 81 | LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 82 | else |
| 83 | need_compile_asset := true |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 84 | endif |
| 85 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 86 | # LOCAL_RESOURCE_DIR may point to resource generated during the build |
| 87 | need_compile_res := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 88 | ifeq (,$(LOCAL_RESOURCE_DIR)) |
| 89 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 90 | else |
| 91 | need_compile_res := true |
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 | |
| 100 | LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR) |
| 101 | |
Colin Cross | 2c32144 | 2014-02-12 13:06:30 -0800 | [diff] [blame] | 102 | all_assets := $(strip \ |
| 103 | $(foreach dir, $(LOCAL_ASSET_DIR), \ |
| 104 | $(addprefix $(dir)/, \ |
| 105 | $(patsubst assets/%,%, \ |
| 106 | $(call find-subdir-assets, $(dir)) \ |
| 107 | ) \ |
| 108 | ) \ |
| 109 | )) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 110 | |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 111 | ifneq ($(all_assets),) |
| 112 | need_compile_asset := true |
| 113 | endif |
| 114 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 115 | all_resources := $(strip \ |
| 116 | $(foreach dir, $(LOCAL_RESOURCE_DIR), \ |
| 117 | $(addprefix $(dir)/, \ |
| 118 | $(patsubst res/%,%, \ |
| 119 | $(call find-subdir-assets,$(dir)) \ |
| 120 | ) \ |
| 121 | ) \ |
| 122 | )) |
| 123 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 124 | ifneq ($(all_resources),) |
| 125 | need_compile_res := true |
| 126 | endif |
| 127 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 128 | all_res_assets := $(strip $(all_assets) $(all_resources)) |
| 129 | |
Ying Wang | 98ae798 | 2014-12-18 14:53:52 -0800 | [diff] [blame] | 130 | intermediates.COMMON := $(call local-intermediates-dir,COMMON) |
| 131 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 132 | # If no assets or resources were found, clear the directory variables so |
| 133 | # we don't try to build them. |
Ying Wang | 4cb0499 | 2014-07-29 10:34:30 -0700 | [diff] [blame] | 134 | ifneq (true,$(need_compile_asset)) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 135 | LOCAL_ASSET_DIR:= |
| 136 | endif |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 137 | ifneq (true,$(need_compile_res)) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 138 | LOCAL_RESOURCE_DIR:= |
| 139 | R_file_stamp := |
| 140 | else |
| 141 | # Make sure that R_file_stamp inherits the proper PRIVATE vars. |
| 142 | # If R.stamp moves, be sure to update the framework makefile, |
| 143 | # which has intimate knowledge of its location. |
Ying Wang | 98ae798 | 2014-12-18 14:53:52 -0800 | [diff] [blame] | 144 | R_file_stamp := $(intermediates.COMMON)/src/R.stamp |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 145 | LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) |
| 146 | endif |
| 147 | |
| 148 | LOCAL_BUILT_MODULE_STEM := package.apk |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 149 | LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 150 | |
| 151 | LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED)) |
| 152 | ifndef LOCAL_PROGUARD_ENABLED |
| 153 | ifneq ($(DISABLE_PROGUARD),true) |
| 154 | LOCAL_PROGUARD_ENABLED :=full |
| 155 | endif |
| 156 | endif |
| 157 | ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) |
| 158 | # the package explicitly request to disable proguard. |
| 159 | LOCAL_PROGUARD_ENABLED := |
| 160 | endif |
| 161 | proguard_options_file := |
| 162 | ifneq ($(LOCAL_PROGUARD_ENABLED),custom) |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 163 | ifeq ($(need_compile_res),true) |
Ying Wang | 98ae798 | 2014-12-18 14:53:52 -0800 | [diff] [blame] | 164 | proguard_options_file := $(intermediates.COMMON)/proguard_options |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 165 | endif # need_compile_res |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 166 | endif # !custom |
| 167 | LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) |
| 168 | |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 169 | ifndef LOCAL_JACK_PROGUARD_FLAGS |
| 170 | LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS) |
| 171 | endif |
| 172 | LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 173 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 174 | ifeq (true,$(EMMA_INSTRUMENT)) |
| 175 | ifndef LOCAL_EMMA_INSTRUMENT |
| 176 | # No emma for test apks. |
Ying Wang | 324ffb2 | 2015-11-06 11:22:28 -0800 | [diff] [blame] | 177 | ifeq (,$(LOCAL_INSTRUMENTATION_FOR)) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 178 | LOCAL_EMMA_INSTRUMENT := true |
| 179 | endif # No test apk |
| 180 | endif # LOCAL_EMMA_INSTRUMENT is not set |
| 181 | else |
| 182 | LOCAL_EMMA_INSTRUMENT := false |
| 183 | endif # EMMA_INSTRUMENT is true |
| 184 | |
Ying Wang | 8586573 | 2016-03-28 18:39:42 -0700 | [diff] [blame] | 185 | ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),) |
| 186 | # Only add jacocoagent if the package contains some java code |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 187 | ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) |
| 188 | ifeq (true,$(EMMA_INSTRUMENT_STATIC)) |
Sebastien Hertz | dfce8ad | 2015-11-19 17:53:00 +0100 | [diff] [blame] | 189 | # Jack supports coverage with Jacoco |
| 190 | LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent |
Ying Wang | 8586573 | 2016-03-28 18:39:42 -0700 | [diff] [blame] | 191 | else # ! EMMA_INSTRUMENT_STATIC |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 192 | ifdef LOCAL_SDK_VERSION |
| 193 | ifdef TARGET_BUILD_APPS |
Sebastien Hertz | 2319e56 | 2016-03-31 16:48:26 +0200 | [diff] [blame] | 194 | # In unbundled build, merge the coverage library into the apk. |
Sebastien Hertz | dfce8ad | 2015-11-19 17:53:00 +0100 | [diff] [blame] | 195 | # Jack supports coverage with Jacoco |
| 196 | LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent |
Sebastien Hertz | 2319e56 | 2016-03-31 16:48:26 +0200 | [diff] [blame] | 197 | # Exclude jacoco classes from proguard |
| 198 | LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags |
| 199 | LOCAL_JACK_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags |
| 200 | else # ! TARGET_BUILD_APPS |
| 201 | # If build against the SDK in full build, core.jar is not used |
| 202 | # so coverage classes are not present. |
| 203 | # Jack needs jacoco on the classpath but we do not want it to be in |
| 204 | # the final apk. While it is a static library, we add it to the |
| 205 | # LOCAL_JAVA_LIBRARIES which are only present on the classpath. |
| 206 | # Note: we have nothing to do for proguard since jacoco will be |
| 207 | # on the classpath only, thus not modified during the compilation. |
| 208 | LOCAL_JAVA_LIBRARIES += jacocoagent |
Ying Wang | 8586573 | 2016-03-28 18:39:42 -0700 | [diff] [blame] | 209 | endif # TARGET_BUILD_APPS |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 210 | endif # LOCAL_SDK_VERSION |
Ying Wang | 8586573 | 2016-03-28 18:39:42 -0700 | [diff] [blame] | 211 | endif # ! EMMA_INSTRUMENT_STATIC |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 212 | endif # LOCAL_EMMA_INSTRUMENT |
Ying Wang | 8586573 | 2016-03-28 18:39:42 -0700 | [diff] [blame] | 213 | endif # Contains java code |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 214 | |
| 215 | rs_compatibility_jni_libs := |
| 216 | |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 217 | include $(BUILD_SYSTEM)/android_manifest.mk |
| 218 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 219 | ################################# |
| 220 | include $(BUILD_SYSTEM)/java.mk |
| 221 | ################################# |
| 222 | |
| 223 | LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) |
| 224 | ifeq ($(LOCAL_SDK_RES_VERSION),) |
| 225 | LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) |
| 226 | endif |
| 227 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 228 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 229 | PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) |
Ying Wang | efb9358 | 2014-07-19 17:00:50 -0700 | [diff] [blame] | 230 | ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 231 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 232 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) |
| 233 | else |
| 234 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 235 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) |
| 236 | endif |
| 237 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 238 | ifeq ($(need_compile_res),true) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 239 | |
| 240 | # Since we don't know where the real R.java file is going to end up, |
| 241 | # we need to use another file to stand in its place. We'll just |
| 242 | # copy the generated file to src/R.stamp, which means it will |
| 243 | # have the same contents and timestamp as the actual file. |
| 244 | # |
| 245 | # At the same time, this will copy the R.java file to a central |
| 246 | # 'R' directory to make it easier to add the files to an IDE. |
| 247 | # |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 248 | |
| 249 | $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ |
| 250 | $(intermediates.COMMON)/public_resources.xml |
| 251 | $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) |
| 252 | $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP) |
| 253 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
Martin Arenlind | fb6985e | 2015-09-15 15:52:56 +0200 | [diff] [blame] | 254 | @rm -rf $@ && mkdir -p $(dir $@) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 255 | $(create-resource-java-files) |
| 256 | $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 257 | -name Manifest.java 2> /dev/null`; do \ |
| 258 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \ |
| 259 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 260 | $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 261 | done; |
| 262 | $(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 263 | -name R.java 2> /dev/null`; do \ |
| 264 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \ |
| 265 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 266 | $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \ |
| 267 | || exit 31; \ |
| 268 | $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \ |
Martin Arenlind | fb6985e | 2015-09-15 15:52:56 +0200 | [diff] [blame] | 269 | done; |
| 270 | @# Ensure that the target file is always created, i.e. also in case we did not |
| 271 | @# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding. |
| 272 | $(hide) touch $@ |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 273 | |
| 274 | $(proguard_options_file): $(R_file_stamp) |
| 275 | |
Ying Wang | dbe23f5 | 2014-03-25 14:42:46 -0700 | [diff] [blame] | 276 | resource_export_package := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 277 | ifdef LOCAL_EXPORT_PACKAGE_RESOURCES |
| 278 | # Put this module's resources into a PRODUCT-agnositc package that |
| 279 | # other packages can use to build their own PRODUCT-agnostic R.java (etc.) |
| 280 | # files. |
| 281 | resource_export_package := $(intermediates.COMMON)/package-export.apk |
| 282 | $(R_file_stamp): $(resource_export_package) |
| 283 | |
| 284 | # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target |
| 285 | # can't know anything about PRODUCT. Clear it out just for this target. |
| 286 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := |
| 287 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 288 | $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) |
| 289 | @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" |
| 290 | $(create-empty-package) |
| 291 | $(add-assets-to-package) |
| 292 | endif |
| 293 | |
Ying Wang | 8586573 | 2016-03-28 18:39:42 -0700 | [diff] [blame] | 294 | # Make sure to generate R.java before compiling. |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 295 | # Other modules should depend on the BUILT module if |
| 296 | # they want to use this module's R.java file. |
Ying Wang | 8586573 | 2016-03-28 18:39:42 -0700 | [diff] [blame] | 297 | $(LOCAL_BUILT_MODULE) \ |
| 298 | $(full_classes_compiled_jar) \ |
| 299 | $(built_dex_intermediate) $(noshrob_classes_jack) $(full_classes_jack) $(jack_check_timestamp) \ |
| 300 | : $(R_file_stamp) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 301 | |
Ying Wang | 6129192 | 2014-06-25 13:23:58 -0700 | [diff] [blame] | 302 | endif # need_compile_res |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 303 | |
| 304 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 305 | # We need to explicitly clear this var so that we don't |
| 306 | # inherit the value from whomever caused us to be built. |
| 307 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := |
| 308 | else |
| 309 | # Most packages should link against the resources defined by framework-res. |
| 310 | # Even if they don't have their own resources, they may use framework |
| 311 | # resources. |
Ying Wang | efb9358 | 2014-07-19 17:00:50 -0700 | [diff] [blame] | 312 | ifneq ($(filter-out current system_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current,$(LOCAL_SDK_RES_VERSION))),) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 313 | # for released sdk versions, the platform resources were built into android.jar. |
| 314 | framework_res_package_export := \ |
| 315 | $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar |
| 316 | framework_res_package_export_deps := $(framework_res_package_export) |
| 317 | else # LOCAL_SDK_RES_VERSION |
| 318 | framework_res_package_export := \ |
| 319 | $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk |
| 320 | # We can't depend directly on the export.apk file; it won't get its |
| 321 | # PRIVATE_ vars set up correctly if we do. Instead, depend on the |
| 322 | # corresponding R.stamp file, which lists the export.apk as a dependency. |
| 323 | framework_res_package_export_deps := \ |
| 324 | $(dir $(framework_res_package_export))src/R.stamp |
| 325 | endif # LOCAL_SDK_RES_VERSION |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 326 | all_library_res_package_exports := \ |
| 327 | $(framework_res_package_export) \ |
Adam Lesinski | 5eebe0f | 2014-03-25 15:45:34 -0700 | [diff] [blame] | 328 | $(foreach lib,$(LOCAL_RES_LIBRARIES),\ |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 329 | $(call intermediates-dir-for,APPS,$(lib),,COMMON)/package-export.apk) |
| 330 | |
| 331 | all_library_res_package_export_deps := \ |
| 332 | $(framework_res_package_export_deps) \ |
Adam Lesinski | 5eebe0f | 2014-03-25 15:45:34 -0700 | [diff] [blame] | 333 | $(foreach lib,$(LOCAL_RES_LIBRARIES),\ |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 334 | $(call intermediates-dir-for,APPS,$(lib),,COMMON)/src/R.stamp) |
| 335 | |
Ying Wang | b574564 | 2014-06-19 16:07:30 -0700 | [diff] [blame] | 336 | $(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] | 337 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
Adam Lesinski | de057c3 | 2014-03-13 18:48:27 -0700 | [diff] [blame] | 338 | PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 339 | endif # LOCAL_NO_STANDARD_LIBRARIES |
| 340 | |
| 341 | ifneq ($(full_classes_jar),) |
| 342 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) |
| 343 | $(LOCAL_BUILT_MODULE): $(built_dex) |
Ying Wang | 33360dd | 2015-01-14 14:23:56 -0800 | [diff] [blame] | 344 | else |
| 345 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 346 | endif # full_classes_jar |
| 347 | |
Ying Wang | 96bcad4 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 348 | include $(BUILD_SYSTEM)/install_jni_libs.mk |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 349 | |
| 350 | # Pick a key to sign the package with. If this package hasn't specified |
| 351 | # an explicit certificate, use the default. |
| 352 | # Secure release builds will have their packages signed after the fact, |
| 353 | # so it's ok for these private keys to be in the clear. |
| 354 | ifeq ($(LOCAL_CERTIFICATE),) |
| 355 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 356 | endif |
| 357 | |
| 358 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 359 | # The special value "EXTERNAL" means that we will sign it with the |
| 360 | # default devkey, apply predexopt, but then expect the final .apk |
| 361 | # (after dexopting) to be signed by an outside tool. |
| 362 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 363 | PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1 |
| 364 | endif |
| 365 | |
| 366 | # If this is not an absolute certificate, assign it to a generic one. |
| 367 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
| 368 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
| 369 | endif |
| 370 | private_key := $(LOCAL_CERTIFICATE).pk8 |
| 371 | certificate := $(LOCAL_CERTIFICATE).x509.pem |
Shinichiro Hamaji | 641e61c | 2016-05-13 16:03:24 +0900 | [diff] [blame^] | 372 | additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 373 | |
| 374 | $(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR) |
| 375 | $(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key) |
| 376 | $(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate) |
| 377 | |
| 378 | PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key) |
| 379 | PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate) |
| 380 | |
Shinichiro Hamaji | 641e61c | 2016-05-13 16:03:24 +0900 | [diff] [blame^] | 381 | $(LOCAL_BUILT_MODULE): $(additional_certificates) |
| 382 | $(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 383 | |
| 384 | # Define the rule to build the actual package. |
Alex Klyubin | 5b826ac | 2015-12-04 10:07:41 -0800 | [diff] [blame] | 385 | $(LOCAL_BUILT_MODULE): $(AAPT) |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 386 | # PRIVATE_JNI_SHARED_LIBRARIES is a list of <abi>:<path_of_built_lib>. |
| 387 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis) |
| 388 | # PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names. |
| 389 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 390 | ifneq ($(TARGET_BUILD_APPS),) |
| 391 | # Include all resources for unbundled apps. |
| 392 | LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true |
| 393 | endif |
| 394 | ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true) |
| 395 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := |
| 396 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 397 | else |
| 398 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG) |
Ying Wang | 934008f | 2014-07-30 13:40:14 -0700 | [diff] [blame] | 399 | ifdef LOCAL_PACKAGE_SPLITS |
| 400 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 401 | else |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 402 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) |
| 403 | endif |
Ying Wang | 934008f | 2014-07-30 13:40:14 -0700 | [diff] [blame] | 404 | endif |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 405 | $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) |
| 406 | @echo "target Package: $(PRIVATE_MODULE) ($@)" |
| 407 | $(create-empty-package) |
| 408 | $(add-assets-to-package) |
| 409 | ifneq ($(jni_shared_libraries),) |
| 410 | $(add-jni-shared-libs-to-package) |
| 411 | endif |
Ying Wang | 8b27d18 | 2015-03-27 11:07:17 -0700 | [diff] [blame] | 412 | ifeq ($(full_classes_jar),) |
| 413 | # We don't build jar, need to add the Java resources here. |
| 414 | $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 415 | else # full_classes_jar |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 416 | $(add-dex-to-package) |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 417 | endif # full_classes_jar |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 418 | $(add-carried-jack-resources) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 419 | ifdef LOCAL_DEX_PREOPT |
Ying Wang | fbc5b9f | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 420 | ifneq ($(BUILD_PLATFORM_ZIP),) |
| 421 | @# Keep a copy of apk with classes.dex unstripped |
| 422 | $(hide) cp -f $@ $(dir $@)package.dex.apk |
| 423 | endif # BUILD_PLATFORM_ZIP |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 424 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 425 | $(call dexpreopt-remove-classes.dex,$@) |
| 426 | endif |
| 427 | endif |
Kenny Root | dff3755 | 2015-04-15 12:09:32 -0700 | [diff] [blame] | 428 | $(sign-package) |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 429 | |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 430 | ############################### |
Ying Wang | 8070b20 | 2014-12-01 17:46:56 -0800 | [diff] [blame] | 431 | ## Build dpi-specific apks, if it's apps_only build. |
| 432 | ifdef TARGET_BUILD_APPS |
| 433 | ifdef LOCAL_DPI_VARIANTS |
| 434 | $(foreach d, $(LOCAL_DPI_VARIANTS), \ |
| 435 | $(eval my_dpi := $(d)) \ |
| 436 | $(eval include $(BUILD_SYSTEM)/dpi_specific_apk.mk)) |
| 437 | endif |
| 438 | endif |
| 439 | |
| 440 | ############################### |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 441 | ## Rule to build the odex file |
| 442 | ifdef LOCAL_DEX_PREOPT |
| 443 | $(built_odex): PRIVATE_DEX_FILE := $(built_dex) |
Ying Wang | db48da7 | 2014-09-13 11:26:39 -0700 | [diff] [blame] | 444 | # Use pattern rule - we may have multiple built odex files. |
| 445 | $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex) |
Ying Wang | 994c226 | 2014-05-28 13:34:59 -0700 | [diff] [blame] | 446 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 447 | $(add-dex-to-package) |
| 448 | $(hide) mv $@ $@.input |
| 449 | $(call dexpreopt-one-file,$@.input,$@) |
| 450 | $(hide) rm $@.input |
| 451 | endif |
| 452 | |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 453 | ############################### |
| 454 | ## APK splits |
| 455 | ifdef LOCAL_PACKAGE_SPLITS |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 456 | # LOCAL_PACKAGE_SPLITS is a list of resource labels. |
Ying Wang | 114a0fc | 2014-10-01 12:01:04 -0700 | [diff] [blame] | 457 | # aapt will convert comma inside resource lable to underscore in the file names. |
| 458 | my_split_suffixes := $(subst $(comma),_,$(LOCAL_PACKAGE_SPLITS)) |
| 459 | built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk) |
| 460 | installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 461 | |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 462 | # 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] | 463 | # This rule just runs signing. |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 464 | # Note that we explicily check the existence of the split apk and remove the |
| 465 | # built base apk if the split apk isn't there. |
| 466 | # 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] | 467 | $(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key) |
| 468 | $(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate) |
Ying Wang | 7f625aa | 2014-07-23 10:27:57 -0700 | [diff] [blame] | 469 | $(built_apk_splits) : $(built_module_path)/%.apk : $(LOCAL_BUILT_MODULE) |
| 470 | $(hide) if [ ! -f $@ ]; then \ |
| 471 | echo 'No $@ generated, check your apk splitting parameters.' 1>&2; \ |
| 472 | rm $<; exit 1; \ |
| 473 | fi |
| 474 | $(sign-package) |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 475 | |
| 476 | # Rules to install the splits |
Dan Willemsen | 7f01615 | 2016-02-29 17:52:39 -0800 | [diff] [blame] | 477 | $(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] | 478 | @echo "Install: $@" |
| 479 | $(copy-file-to-new-target) |
Ying Wang | 1425e2d | 2014-07-22 15:42:11 -0700 | [diff] [blame] | 480 | |
| 481 | # Register the additional built and installed files. |
| 482 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) |
| 483 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ |
Ying Wang | 114a0fc | 2014-10-01 12:01:04 -0700 | [diff] [blame] | 484 | $(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] | 485 | |
| 486 | # Make sure to install the splits when you run "make <module_name>". |
| 487 | $(my_register_name): $(installed_apk_splits) |
| 488 | endif # LOCAL_PACKAGE_SPLITS |
| 489 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 490 | # Save information about this package |
| 491 | PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 492 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources) |
| 493 | ifdef package_resource_overlays |
| 494 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays) |
| 495 | endif |
| 496 | |
| 497 | PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME) |
| 498 | |
Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame] | 499 | endif # skip_definition |
| 500 | |
| 501 | # Reset internal variables. |
| 502 | all_res_assets := |