blob: 637a13564e384ba6abefa1657268aa4c55b71d8a [file] [log] [blame]
Colin Cross8e404122014-02-06 14:45:37 -08001#
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.
30skip_definition:=
31ifdef LOCAL_PACKAGE_OVERRIDES
32 package_overridden := $(call set-inherited-package-variables)
33 ifeq ($(strip $(package_overridden)),)
34 skip_definition := true
35 endif
36endif
37
38ifndef skip_definition
39
40LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME))
41ifeq ($(LOCAL_PACKAGE_NAME),)
42$(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME)
43endif
44
45ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),)
46$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX)
47endif
48LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
49
50ifneq ($(strip $(LOCAL_MODULE)),)
51$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE)
52endif
53LOCAL_MODULE := $(LOCAL_PACKAGE_NAME)
54
Colin Cross8e404122014-02-06 14:45:37 -080055ifneq ($(strip $(LOCAL_MODULE_CLASS)),)
56$(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
57endif
58LOCAL_MODULE_CLASS := APPS
59
Ying Wangdd71c852015-12-04 13:59:18 -080060intermediates := $(call local-intermediates-dir)
61intermediates.COMMON := $(call local-intermediates-dir,COMMON)
62
Colin Cross8e404122014-02-06 14:45:37 -080063# Package LOCAL_MODULE_TAGS default to optional
64LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS))
65ifeq ($(LOCAL_MODULE_TAGS),)
66LOCAL_MODULE_TAGS := optional
67endif
68
69ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),)
70# Force localization check if it's not tagged as tests.
71LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
72endif
73
Ying Wang4cb04992014-07-29 10:34:30 -070074need_compile_asset :=
Colin Cross8e404122014-02-06 14:45:37 -080075ifeq (,$(LOCAL_ASSET_DIR))
76LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
Ying Wang4cb04992014-07-29 10:34:30 -070077else
78need_compile_asset := true
Colin Cross8e404122014-02-06 14:45:37 -080079endif
80
Ying Wang61291922014-06-25 13:23:58 -070081# LOCAL_RESOURCE_DIR may point to resource generated during the build
82need_compile_res :=
Colin Cross8e404122014-02-06 14:45:37 -080083ifeq (,$(LOCAL_RESOURCE_DIR))
84 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
Ying Wang61291922014-06-25 13:23:58 -070085else
86 need_compile_res := true
Dan Willemsenfa7ecfb2017-05-02 23:55:44 -070087 LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d)))
Colin Cross8e404122014-02-06 14:45:37 -080088endif
89
Colin Cross20299032018-05-09 13:29:51 -070090include $(BUILD_SYSTEM)/force_aapt2.mk
91
Colin Cross7bc6cab2018-05-17 15:05:47 -070092# Process Support Library dependencies.
93include $(BUILD_SYSTEM)/support_libraries.mk
94
Colin Cross8e404122014-02-06 14:45:37 -080095package_resource_overlays := $(strip \
96 $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
97 $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
98 $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
99 $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
100
Jaekyun Seok30706102017-02-02 00:44:58 +0900101enforce_rro_enabled :=
Jaekyun Seok2a209992017-03-30 11:25:02 +0900102ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
103 ifneq ($(package_resource_overlays),)
104 ifeq ($(PRODUCT_ENFORCE_RRO_TARGETS),*)
105 enforce_rro_enabled := true
106 else ifneq (,$(filter $(LOCAL_PACKAGE_NAME), $(PRODUCT_ENFORCE_RRO_TARGETS)))
Jaekyun Seok30706102017-02-02 00:44:58 +0900107 enforce_rro_enabled := true
108 endif
109 endif
110
111 ifdef enforce_rro_enabled
112 ifeq (,$(LOCAL_MODULE_PATH))
113 ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
114 enforce_rro_enabled :=
115 else ifeq (true,$(LOCAL_OEM_MODULE))
116 enforce_rro_enabled :=
117 else ifeq (true,$(LOCAL_ODM_MODULE))
118 enforce_rro_enabled :=
Jaekyun Seokb7735d82017-11-27 17:04:47 +0900119 else ifeq (true,$(LOCAL_PRODUCT_MODULE))
120 enforce_rro_enabled :=
Jaekyun Seok30706102017-02-02 00:44:58 +0900121 endif
122 else ifeq ($(filter $(TARGET_OUT)/%,$(LOCAL_MODULE_PATH)),)
123 enforce_rro_enabled :=
124 endif
125 endif
126endif
127
Jaekyun Seokccee95e2017-09-01 17:23:25 +0900128ifdef enforce_rro_enabled
129 ifneq ($(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS),)
130 static_only_resource_overlays := $(filter $(addsuffix %,$(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)),$(package_resource_overlays))
131 ifneq ($(static_only_resource_overlays),)
132 package_resource_overlays := $(filter-out $(static_only_resource_overlays),$(package_resource_overlays))
133 LOCAL_RESOURCE_DIR := $(static_only_resource_overlays) $(LOCAL_RESOURCE_DIR)
134 ifeq ($(package_resource_overlays),)
135 enforce_rro_enabled :=
136 endif
137 endif
138 endif
139else
Colin Cross8e404122014-02-06 14:45:37 -0800140LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
Jaekyun Seok30706102017-02-02 00:44:58 +0900141endif
Colin Cross8e404122014-02-06 14:45:37 -0800142
Colin Cross2c321442014-02-12 13:06:30 -0800143all_assets := $(strip \
144 $(foreach dir, $(LOCAL_ASSET_DIR), \
145 $(addprefix $(dir)/, \
146 $(patsubst assets/%,%, \
147 $(call find-subdir-assets, $(dir)) \
148 ) \
149 ) \
150 ))
Colin Cross8e404122014-02-06 14:45:37 -0800151
Ying Wang4cb04992014-07-29 10:34:30 -0700152ifneq ($(all_assets),)
153need_compile_asset := true
154endif
155
Dan Willemsenbb6393c2017-11-17 15:39:52 -0800156ifdef LOCAL_AAPT2_ONLY
157LOCAL_USE_AAPT2 := true
158endif
159
Adam Lesinskie758f932016-02-26 11:13:43 -0800160my_res_package :=
Colin Cross20299032018-05-09 13:29:51 -0700161ifeq ($(LOCAL_USE_AAPT2),true)
Ying Wangdd71c852015-12-04 13:59:18 -0800162# In aapt2 the last takes precedence.
163my_resource_dirs := $(call reverse-list,$(LOCAL_RESOURCE_DIR))
Adam Lesinskie758f932016-02-26 11:13:43 -0800164my_res_dir :=
165my_overlay_res_dirs :=
166
Colin Cross71c5b952018-05-23 13:35:53 -0700167ifneq ($(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),)
Adam Lesinskie758f932016-02-26 11:13:43 -0800168# If we are using static android libraries, every source file becomes an overlay.
169# This is to emulate old AAPT behavior which simulated library support.
170my_res_dir :=
171my_overlay_res_dirs := $(my_resource_dirs)
172else
173# Without static libraries, the first directory is our directory, which can then be
174# overlaid by the rest. (First directory in my_resource_dirs is last directory in
175# $(LOCAL_RESOURCE_DIR) due to it being reversed.
176my_res_dir := $(firstword $(my_resource_dirs))
177my_overlay_res_dirs := $(wordlist 2,999,$(my_resource_dirs))
178endif
179
Ying Wangdd71c852015-12-04 13:59:18 -0800180my_overlay_resources := $(strip \
Adam Lesinskie758f932016-02-26 11:13:43 -0800181 $(foreach d,$(my_overlay_res_dirs),\
Ying Wangdd71c852015-12-04 13:59:18 -0800182 $(addprefix $(d)/, \
183 $(call find-subdir-assets,$(d)))))
184
Colin Crossfe109632016-11-29 11:12:56 -0800185my_res_resources := $(if $(my_res_dir),$(strip \
Ying Wangdd71c852015-12-04 13:59:18 -0800186 $(addprefix $(my_res_dir)/, \
Colin Crossfe109632016-11-29 11:12:56 -0800187 $(call find-subdir-assets,$(my_res_dir)))))
Ying Wangdd71c852015-12-04 13:59:18 -0800188
189all_resources := $(strip $(my_res_resources) $(my_overlay_resources))
190
191# The linked resource package.
192my_res_package := $(intermediates)/package-res.apk
193LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
194
Ying Wange5853972016-03-01 12:06:47 -0800195# Always run aapt2, because we need to at least compile the AndroidManifest.xml.
Ying Wangdd71c852015-12-04 13:59:18 -0800196need_compile_res := true
197
Ying Wange295c3d2016-02-24 14:11:55 -0800198else # LOCAL_USE_AAPT2
Colin Cross8e404122014-02-06 14:45:37 -0800199all_resources := $(strip \
200 $(foreach dir, $(LOCAL_RESOURCE_DIR), \
201 $(addprefix $(dir)/, \
202 $(patsubst res/%,%, \
203 $(call find-subdir-assets,$(dir)) \
204 ) \
205 ) \
206 ))
207
Adam Lesinski4c452052016-08-12 12:57:17 -0700208ifdef LOCAL_PACKAGE_SPLITS
209LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
210endif
211
Ying Wange295c3d2016-02-24 14:11:55 -0800212endif # LOCAL_USE_AAPT2
Ying Wangdd71c852015-12-04 13:59:18 -0800213
Ying Wang61291922014-06-25 13:23:58 -0700214ifneq ($(all_resources),)
215 need_compile_res := true
216endif
217
Colin Cross8e404122014-02-06 14:45:37 -0800218all_res_assets := $(strip $(all_assets) $(all_resources))
219
Colin Cross8e404122014-02-06 14:45:37 -0800220# If no assets or resources were found, clear the directory variables so
221# we don't try to build them.
Ying Wang4cb04992014-07-29 10:34:30 -0700222ifneq (true,$(need_compile_asset))
Colin Cross8e404122014-02-06 14:45:37 -0800223LOCAL_ASSET_DIR:=
224endif
Ying Wang61291922014-06-25 13:23:58 -0700225ifneq (true,$(need_compile_res))
Colin Cross8e404122014-02-06 14:45:37 -0800226LOCAL_RESOURCE_DIR:=
227R_file_stamp :=
228else
229# Make sure that R_file_stamp inherits the proper PRIVATE vars.
230# If R.stamp moves, be sure to update the framework makefile,
231# which has intimate knowledge of its location.
Ying Wang98ae7982014-12-18 14:53:52 -0800232R_file_stamp := $(intermediates.COMMON)/src/R.stamp
Colin Cross8e404122014-02-06 14:45:37 -0800233LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
234endif
235
Narayan Kamath7c205102017-08-07 12:31:17 +0100236ifdef LOCAL_COMPRESSED_MODULE
237ifneq (true,$(LOCAL_COMPRESSED_MODULE))
238$(call pretty-error, Unknown value for LOCAL_COMPRESSED_MODULE $(LOCAL_COMPRESSED_MODULE))
239endif
240endif
241
242ifdef LOCAL_COMPRESSED_MODULE
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100243PACKAGES.$(LOCAL_PACKAGE_NAME).COMPRESSED := gz
Narayan Kamath7c205102017-08-07 12:31:17 +0100244LOCAL_BUILT_MODULE_STEM := package.apk.gz
245LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk.gz
246else # !LOCAL_COMPRESSED_MODULE
Colin Cross8e404122014-02-06 14:45:37 -0800247LOCAL_BUILT_MODULE_STEM := package.apk
Ying Wangaf9757e2014-07-17 21:24:42 -0700248LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
Narayan Kamath7c205102017-08-07 12:31:17 +0100249endif
Colin Cross8e404122014-02-06 14:45:37 -0800250
251LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
252ifndef LOCAL_PROGUARD_ENABLED
253ifneq ($(DISABLE_PROGUARD),true)
254 LOCAL_PROGUARD_ENABLED :=full
255endif
256endif
257ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
258 # the package explicitly request to disable proguard.
259 LOCAL_PROGUARD_ENABLED :=
260endif
261proguard_options_file :=
262ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
Ying Wang61291922014-06-25 13:23:58 -0700263ifeq ($(need_compile_res),true)
Ying Wang98ae7982014-12-18 14:53:52 -0800264 proguard_options_file := $(intermediates.COMMON)/proguard_options
Ying Wang61291922014-06-25 13:23:58 -0700265endif # need_compile_res
Colin Cross8e404122014-02-06 14:45:37 -0800266endif # !custom
267LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
268
269ifeq (true,$(EMMA_INSTRUMENT))
270ifndef LOCAL_EMMA_INSTRUMENT
Jeff Gastonaaae43c2017-04-11 16:36:46 -0700271# No jacoco for test apks.
Ying Wang324ffb22015-11-06 11:22:28 -0800272ifeq (,$(LOCAL_INSTRUMENTATION_FOR))
Colin Cross8e404122014-02-06 14:45:37 -0800273LOCAL_EMMA_INSTRUMENT := true
274endif # No test apk
275endif # LOCAL_EMMA_INSTRUMENT is not set
276else
277LOCAL_EMMA_INSTRUMENT := false
278endif # EMMA_INSTRUMENT is true
279
280ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
281ifeq (true,$(EMMA_INSTRUMENT_STATIC))
Colin Cross11e2d552018-03-07 15:44:54 -0800282ifneq ($(LOCAL_SRC_FILES)$(LOCAL_SRCJARS)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
Colin Cross79e2f732016-12-21 14:29:13 -0800283# Only add jacocoagent if the package contains some java code
Sebastien Hertzdfce8ad2015-11-19 17:53:00 +0100284LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
Colin Crossdc4a6b82018-01-03 12:39:11 -0800285# Exclude jacoco classes from proguard
286LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
Colin Cross79e2f732016-12-21 14:29:13 -0800287endif # Contains java code
288else
Colin Cross8e404122014-02-06 14:45:37 -0800289ifdef LOCAL_SDK_VERSION
290ifdef TARGET_BUILD_APPS
Sebastien Hertz2319e562016-03-31 16:48:26 +0200291# In unbundled build, merge the coverage library into the apk.
Colin Cross79e2f732016-12-21 14:29:13 -0800292ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
293# Only add jacocoagent if the package contains some java code
Sebastien Hertzdfce8ad2015-11-19 17:53:00 +0100294LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
Sebastien Hertz2319e562016-03-31 16:48:26 +0200295# Exclude jacoco classes from proguard
296LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
Colin Cross79e2f732016-12-21 14:29:13 -0800297endif # Contains java code
Colin Crosse673deb2017-09-27 14:28:41 -0700298endif # TARGET_BUILD_APPS
Colin Cross8e404122014-02-06 14:45:37 -0800299endif # LOCAL_SDK_VERSION
Colin Cross79e2f732016-12-21 14:29:13 -0800300endif # EMMA_INSTRUMENT_STATIC
Colin Cross8e404122014-02-06 14:45:37 -0800301endif # LOCAL_EMMA_INSTRUMENT
302
303rs_compatibility_jni_libs :=
304
Ying Wanged0361f2015-04-19 09:55:39 -0700305ifeq ($(LOCAL_DATA_BINDING),true)
306data_binding_intermediates := $(intermediates.COMMON)/data-binding
307
308LOCAL_JAVACFLAGS += -processorpath $(DATA_BINDING_COMPILER) -s $(data_binding_intermediates)/anno-src
Ying Wanged0361f2015-04-19 09:55:39 -0700309
310LOCAL_STATIC_JAVA_LIBRARIES += databinding-baselibrary
311LOCAL_STATIC_JAVA_AAR_LIBRARIES += databinding-library databinding-adapters
312
313data_binding_res_in := $(LOCAL_RESOURCE_DIR)
314data_binding_res_out := $(data_binding_intermediates)/res
315
316# Replace with the processed merged res dir.
317LOCAL_RESOURCE_DIR := $(data_binding_res_out)
318
319LOCAL_AAPT_FLAGS += --auto-add-overlay --extra-packages com.android.databinding.library
320endif # LOCAL_DATA_BINDING
321
Narayan Kamath7c205102017-08-07 12:31:17 +0100322# If the module is a compressed module, we don't pre-opt it because its final
323# installation location will be the data partition.
324ifdef LOCAL_COMPRESSED_MODULE
325LOCAL_DEX_PREOPT := false
326endif
327
Ying Wange9dd9f22014-10-29 15:48:32 -0700328include $(BUILD_SYSTEM)/android_manifest.mk
329
Colin Cross7a281582018-03-06 16:21:36 -0800330resource_export_package :=
331
332include $(BUILD_SYSTEM)/java_renderscript.mk
333
334include $(BUILD_SYSTEM)/aapt_flags.mk
335
336ifeq ($(need_compile_res),true)
337
338###############################
339## APK splits
340built_apk_splits :=
341installed_apk_splits :=
342my_apk_split_configs :=
343
344ifdef LOCAL_PACKAGE_SPLITS
345ifdef LOCAL_COMPRESSED_MODULE
346$(error $(LOCAL_MODULE): LOCAL_COMPRESSED_MODULE is not currently supported for split installs)
347endif # LOCAL_COMPRESSED_MODULE
348
349my_apk_split_configs := $(LOCAL_PACKAGE_SPLITS)
350my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs))
351built_apk_splits := $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk)
352endif
353
354$(R_file_stamp) $(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS)
355$(R_file_stamp) $(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS)
356$(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
357$(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
358
359###############################
360## AAPT/AAPT2
361
Colin Cross20299032018-05-09 13:29:51 -0700362ifeq ($(LOCAL_USE_AAPT2),true)
Colin Cross7a281582018-03-06 16:21:36 -0800363 my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res
Colin Cross532ae3b2018-05-15 15:15:38 -0700364 ifneq (,$(filter-out current,$(renderscript_target_api)))
Colin Cross7a281582018-03-06 16:21:36 -0800365 ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true)
366 my_generated_res_zips := $(rs_generated_res_zip)
367 endif # renderscript_target_api < 21
368 endif # renderscript_target_api is set
369 my_asset_dirs := $(LOCAL_ASSET_DIR)
370 my_full_asset_paths := $(all_assets)
371
372 # Add AAPT2 link specific flags.
373 $(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS)
374 ifndef LOCAL_AAPT_NAMESPACES
375 $(my_res_package): PRIVATE_AAPT_FLAGS += --no-static-lib-packages
376 endif
377
378 include $(BUILD_SYSTEM)/aapt2.mk
379else # LOCAL_USE_AAPT2
380
Colin Crossf6d68cf2018-03-08 16:49:16 -0800381 my_srcjar := $(intermediates.COMMON)/aapt.srcjar
382 LOCAL_SRCJARS += $(my_srcjar)
383 $(R_file_stamp): PRIVATE_SRCJAR := $(my_srcjar)
384 $(R_file_stamp): PRIVATE_JAVA_GEN_DIR := $(intermediates.COMMON)/aapt
385 $(R_file_stamp): .KATI_IMPLICIT_OUTPUTS := $(my_srcjar)
Colin Cross7a281582018-03-06 16:21:36 -0800386 # Since we don't know where the real R.java file is going to end up,
387 # we need to use another file to stand in its place. We'll just
388 # copy the generated file to src/R.stamp, which means it will
389 # have the same contents and timestamp as the actual file.
390 #
391 # At the same time, this will copy the R.java file to a central
392 # 'R' directory to make it easier to add the files to an IDE.
393 #
394
395 $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \
396 $(intermediates.COMMON)/public_resources.xml
397 $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
398 $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_res_assets)
Colin Crossf6d68cf2018-03-08 16:49:16 -0800399 $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) $(SOONG_ZIP) | $(ACP)
Colin Cross7a281582018-03-06 16:21:36 -0800400 @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
401 @rm -rf $@ && mkdir -p $(dir $@)
402 $(create-resource-java-files)
Colin Crossf6d68cf2018-03-08 16:49:16 -0800403 $(call find-generated-R.java,$(PRIVATE_JAVA_GEN_DIR),$@)
Colin Cross7a281582018-03-06 16:21:36 -0800404
405 $(proguard_options_file): $(R_file_stamp)
406
407 ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
408 # Put this module's resources into a PRODUCT-agnositc package that
409 # other packages can use to build their own PRODUCT-agnostic R.java (etc.)
410 # files.
411 resource_export_package := $(intermediates.COMMON)/package-export.apk
412 $(R_file_stamp): $(resource_export_package)
413
414 # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target
415 # can't know anything about PRODUCT. Clear it out just for this target.
416 $(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
417 $(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
418 $(resource_export_package): PRIVATE_RESOURCE_LIST := $(all_res_assets)
Colin Cross14658062018-05-15 16:04:47 -0700419 $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT)
Colin Cross7a281582018-03-06 16:21:36 -0800420 @echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
421 $(create-empty-package)
422 $(add-assets-to-package)
423 endif
424
425endif # LOCAL_USE_AAPT2
426
427endif # need_compile_res
428
Narayan Kamathbbcdc072017-08-22 15:47:08 +0100429called_from_package_internal := true
Colin Cross8e404122014-02-06 14:45:37 -0800430#################################
431include $(BUILD_SYSTEM)/java.mk
432#################################
Narayan Kamathbbcdc072017-08-22 15:47:08 +0100433called_from_package_internal :=
Colin Cross8e404122014-02-06 14:45:37 -0800434
Colin Cross7a281582018-03-06 16:21:36 -0800435ifeq ($(need_compile_res),true)
436
437# Other modules should depend on the BUILT module if
438# they want to use this module's R.java file.
439$(LOCAL_BUILT_MODULE): $(R_file_stamp)
440
441# The R.java file must exist by the time the java source
442# list is generated
443$(java_source_list_file): $(R_file_stamp)
444
445endif # need_compile_res
446
Colin Cross8e404122014-02-06 14:45:37 -0800447LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
448ifeq ($(LOCAL_SDK_RES_VERSION),)
449 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
450endif
451
Colin Cross8e404122014-02-06 14:45:37 -0800452$(LOCAL_INTERMEDIATE_TARGETS): \
453 PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
Colin Cross8e404122014-02-06 14:45:37 -0800454
Ying Wanged0361f2015-04-19 09:55:39 -0700455ifeq ($(LOCAL_DATA_BINDING),true)
456data_binding_stamp := $(data_binding_intermediates)/data-binding.stamp
457$(data_binding_stamp): PRIVATE_INTERMEDIATES := $(data_binding_intermediates)
458$(data_binding_stamp): PRIVATE_MANIFEST := $(full_android_manifest)
459# Generate code into $(LOCAL_INTERMEDIATE_SOURCE_DIR) so that the generated .java files
460# will be automatically picked up by function compile-java.
461$(data_binding_stamp): PRIVATE_SRC_OUT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/data-binding
462$(data_binding_stamp): PRIVATE_XML_OUT := $(data_binding_intermediates)/xml
463$(data_binding_stamp): PRIVATE_RES_OUT := $(data_binding_res_out)
464$(data_binding_stamp): PRIVATE_RES_IN := $(data_binding_res_in)
465$(data_binding_stamp): PRIVATE_ANNO_SRC_DIR := $(data_binding_intermediates)/anno-src
466
467$(data_binding_stamp) : $(all_res_assets) $(full_android_manifest) \
468 $(DATA_BINDING_COMPILER)
469 @echo "Data-binding process: $@"
470 @rm -rf $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) && \
471 mkdir -p $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) \
472 $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_ANNO_SRC_DIR)
Colin Cross0851df82017-06-30 13:55:38 -0700473 $(hide) $(JAVA) -classpath $(DATA_BINDING_COMPILER) android.databinding.tool.MakeCopy \
Ying Wanged0361f2015-04-19 09:55:39 -0700474 $(PRIVATE_MANIFEST) $(PRIVATE_SRC_OUT) $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_RES_IN)
475 $(hide) touch $@
476
477# Make sure the data-binding process happens before javac and generation of R.java.
Colin Crossdfc45ec2017-05-26 15:22:02 -0700478$(R_file_stamp): $(data_binding_stamp)
479$(java_source_list_file): $(data_binding_stamp)
480$(full_classes_compiled_jar): $(data_binding_stamp)
Ying Wanged0361f2015-04-19 09:55:39 -0700481endif # LOCAL_DATA_BINDING
482
Adam Lesinski6b6283a2018-02-14 16:18:12 -0800483framework_res_package_export :=
Adam Lesinski6b6283a2018-02-14 16:18:12 -0800484
485ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
Colin Cross8e404122014-02-06 14:45:37 -0800486# Most packages should link against the resources defined by framework-res.
487# Even if they don't have their own resources, they may use framework
488# resources.
Dan Willemsenc51b7b02018-02-16 13:31:17 -0800489ifeq ($(LOCAL_SDK_RES_VERSION),core_current)
490# core_current doesn't contain any framework resources.
491else 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 Cross8e404122014-02-06 14:45:37 -0800492# for released sdk versions, the platform resources were built into android.jar.
493framework_res_package_export := \
Anton Hansson66d47b82018-04-27 14:11:17 +0100494 $(call resolve-prebuilt-sdk-jar-path,$(LOCAL_SDK_RES_VERSION))
Colin Cross8e404122014-02-06 14:45:37 -0800495else # LOCAL_SDK_RES_VERSION
496framework_res_package_export := \
497 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
Colin Cross8e404122014-02-06 14:45:37 -0800498endif # LOCAL_SDK_RES_VERSION
Adam Lesinski6b6283a2018-02-14 16:18:12 -0800499endif # LOCAL_NO_STANDARD_LIBRARIES
500
Adam Lesinskide057c32014-03-13 18:48:27 -0700501all_library_res_package_exports := \
502 $(framework_res_package_export) \
Adam Lesinski5eebe0f2014-03-25 15:45:34 -0700503 $(foreach lib,$(LOCAL_RES_LIBRARIES),\
Adam Lesinskide057c32014-03-13 18:48:27 -0700504 $(call intermediates-dir-for,APPS,$(lib),,COMMON)/package-export.apk)
505
506all_library_res_package_export_deps := \
Colin Cross6e136922018-02-20 14:31:33 -0800507 $(framework_res_package_export) \
Adam Lesinski5eebe0f2014-03-25 15:45:34 -0700508 $(foreach lib,$(LOCAL_RES_LIBRARIES),\
Adam Lesinskide057c32014-03-13 18:48:27 -0700509 $(call intermediates-dir-for,APPS,$(lib),,COMMON)/src/R.stamp)
Ying Wangb5745642014-06-19 16:07:30 -0700510$(resource_export_package) $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(all_library_res_package_export_deps)
Colin Cross8e404122014-02-06 14:45:37 -0800511$(LOCAL_INTERMEDIATE_TARGETS): \
Adam Lesinskide057c32014-03-13 18:48:27 -0700512 PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
Ying Wangdd71c852015-12-04 13:59:18 -0800513
Colin Cross20299032018-05-09 13:29:51 -0700514ifeq ($(LOCAL_USE_AAPT2),true)
Ying Wangdd71c852015-12-04 13:59:18 -0800515$(my_res_package) : $(all_library_res_package_export_deps)
516endif
Colin Cross8e404122014-02-06 14:45:37 -0800517
Colin Cross7a281582018-03-06 16:21:36 -0800518# These four are set above for $(R_stamp_file) and $(my_res_package), but
519# $(LOCAL_BUILT_MODULE) is not set before java.mk, so they have to be set again
520# here.
521$(LOCAL_BUILT_MODULE): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS)
522$(LOCAL_BUILT_MODULE): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS)
523$(LOCAL_BUILT_MODULE): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
524$(LOCAL_BUILT_MODULE): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
525
Colin Cross8e404122014-02-06 14:45:37 -0800526ifneq ($(full_classes_jar),)
527$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
Colin Cross79e2f732016-12-21 14:29:13 -0800528# Use the jarjar processed arhive as the initial package file.
Colin Crossffbf0a62017-03-29 12:58:15 -0700529$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
Colin Cross8e404122014-02-06 14:45:37 -0800530$(LOCAL_BUILT_MODULE): $(built_dex)
Ying Wang33360dd2015-01-14 14:23:56 -0800531else
532$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE :=
Colin Cross79e2f732016-12-21 14:29:13 -0800533$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE :=
Colin Cross8e404122014-02-06 14:45:37 -0800534endif # full_classes_jar
535
Ying Wang96bcad42014-04-17 13:38:04 -0700536include $(BUILD_SYSTEM)/install_jni_libs.mk
Colin Cross8e404122014-02-06 14:45:37 -0800537
538# Pick a key to sign the package with. If this package hasn't specified
539# an explicit certificate, use the default.
540# Secure release builds will have their packages signed after the fact,
541# so it's ok for these private keys to be in the clear.
542ifeq ($(LOCAL_CERTIFICATE),)
543 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
544endif
545
546ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
547 # The special value "EXTERNAL" means that we will sign it with the
548 # default devkey, apply predexopt, but then expect the final .apk
549 # (after dexopting) to be signed by an outside tool.
550 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
551 PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1
552endif
553
554# If this is not an absolute certificate, assign it to a generic one.
555ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
556 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
557endif
558private_key := $(LOCAL_CERTIFICATE).pk8
559certificate := $(LOCAL_CERTIFICATE).x509.pem
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900560additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
Colin Cross8e404122014-02-06 14:45:37 -0800561
562$(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR)
563$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key)
564$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate)
565
566PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key)
567PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate)
568
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900569$(LOCAL_BUILT_MODULE): $(additional_certificates)
570$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates)
Colin Cross8e404122014-02-06 14:45:37 -0800571
572# Define the rule to build the actual package.
Ying Wang8e20ef62014-06-24 20:01:52 -0700573# PRIVATE_JNI_SHARED_LIBRARIES is a list of <abi>:<path_of_built_lib>.
574$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
575# PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names.
576$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
Colin Cross8e404122014-02-06 14:45:37 -0800577ifneq ($(TARGET_BUILD_APPS),)
578 # Include all resources for unbundled apps.
579 LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
580endif
581ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
Adam Lesinskie758f932016-02-26 11:13:43 -0800582 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
583 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
Colin Cross8e404122014-02-06 14:45:37 -0800584else
Adam Lesinskie758f932016-02-26 11:13:43 -0800585 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
Ying Wang934008f2014-07-30 13:40:14 -0700586ifdef LOCAL_PACKAGE_SPLITS
Adam Lesinskie758f932016-02-26 11:13:43 -0800587 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
Ying Wang934008f2014-07-30 13:40:14 -0700588else
Adam Lesinskie758f932016-02-26 11:13:43 -0800589 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG)
Colin Cross8e404122014-02-06 14:45:37 -0800590endif
Ying Wang934008f2014-07-30 13:40:14 -0700591endif
Colin Cross303567c2017-08-03 03:17:34 +0000592
Colin Cross79e2f732016-12-21 14:29:13 -0800593$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
Colin Cross303567c2017-08-03 03:17:34 +0000594$(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/resources
595$(LOCAL_BUILT_MODULE): PRIVATE_FULL_CLASSES_JAR := $(full_classes_jar)
Ying Wangdd71c852015-12-04 13:59:18 -0800596$(LOCAL_BUILT_MODULE) : $(jni_shared_libraries)
Colin Cross128800f2017-08-10 15:24:10 -0700597$(LOCAL_BUILT_MODULE) : $(JAR_ARGS)
Colin Cross20299032018-05-09 13:29:51 -0700598ifeq ($(LOCAL_USE_AAPT2),true)
Ying Wangdd71c852015-12-04 13:59:18 -0800599$(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package)
600$(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP)
601else
Dan Willemsenf439c332017-10-02 14:22:02 -0700602$(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_LIST := $(all_res_assets)
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +0100603$(LOCAL_BUILT_MODULE) : $(all_res_assets) $(full_android_manifest) $(AAPT) $(ZIPALIGN)
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000604endif # LOCAL_USE_AAPT2
Narayan Kamath7c205102017-08-07 12:31:17 +0100605ifdef LOCAL_COMPRESSED_MODULE
606$(LOCAL_BUILT_MODULE) : $(MINIGZIP)
607endif
Colin Cross8e404122014-02-06 14:45:37 -0800608 @echo "target Package: $(PRIVATE_MODULE) ($@)"
Colin Cross20299032018-05-09 13:29:51 -0700609ifeq ($(LOCAL_USE_AAPT2),true)
Ying Wangdd71c852015-12-04 13:59:18 -0800610 $(call copy-file-to-new-target)
Ying Wang81ef4712016-03-31 10:10:42 -0700611else # ! LOCAL_USE_AAPT2
Colin Cross79e2f732016-12-21 14:29:13 -0800612 $(if $(PRIVATE_SOURCE_ARCHIVE),\
613 $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
614 $(create-empty-package))
Colin Cross8e404122014-02-06 14:45:37 -0800615 $(add-assets-to-package)
Ying Wange295c3d2016-02-24 14:11:55 -0800616endif # LOCAL_USE_AAPT2
Colin Cross8e404122014-02-06 14:45:37 -0800617ifneq ($(jni_shared_libraries),)
618 $(add-jni-shared-libs-to-package)
619endif
Ying Wang8b27d182015-03-27 11:07:17 -0700620ifeq ($(full_classes_jar),)
621# We don't build jar, need to add the Java resources here.
622 $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
Ying Wang3a61eeb2016-03-11 10:32:01 -0800623else # full_classes_jar
Colin Cross8e404122014-02-06 14:45:37 -0800624 $(add-dex-to-package)
Colin Cross20299032018-05-09 13:29:51 -0700625ifeq ($(LOCAL_USE_AAPT2),true)
Colin Cross303567c2017-08-03 03:17:34 +0000626 $(call add-jar-resources-to-package,$@,$(PRIVATE_FULL_CLASSES_JAR),$(PRIVATE_RESOURCE_INTERMEDIATES_DIR))
627endif
Ying Wang3a61eeb2016-03-11 10:32:01 -0800628endif # full_classes_jar
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000629ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
630 @# No need to align, sign-package below will do it.
631 $(uncompress-dexs)
632endif
Colin Cross8e404122014-02-06 14:45:37 -0800633ifdef LOCAL_DEX_PREOPT
Ying Wang3a61eeb2016-03-11 10:32:01 -0800634ifneq ($(BUILD_PLATFORM_ZIP),)
635 @# Keep a copy of apk with classes.dex unstripped
636 $(hide) cp -f $@ $(dir $@)package.dex.apk
637endif # BUILD_PLATFORM_ZIP
Colin Cross8e404122014-02-06 14:45:37 -0800638ifneq (nostripping,$(LOCAL_DEX_PREOPT))
639 $(call dexpreopt-remove-classes.dex,$@)
640endif
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000641endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700642 $(sign-package)
Narayan Kamath7c205102017-08-07 12:31:17 +0100643ifdef LOCAL_COMPRESSED_MODULE
644 $(compress-package)
645endif # LOCAL_COMPRESSED_MODULE
Colin Cross8e404122014-02-06 14:45:37 -0800646
Ying Wang36142f62014-05-21 16:13:33 -0700647###############################
Ying Wang8070b202014-12-01 17:46:56 -0800648## Build dpi-specific apks, if it's apps_only build.
649ifdef TARGET_BUILD_APPS
650ifdef LOCAL_DPI_VARIANTS
651$(foreach d, $(LOCAL_DPI_VARIANTS), \
652 $(eval my_dpi := $(d)) \
653 $(eval include $(BUILD_SYSTEM)/dpi_specific_apk.mk))
654endif
655endif
656
657###############################
Ying Wang36142f62014-05-21 16:13:33 -0700658## Rule to build the odex file
659ifdef LOCAL_DEX_PREOPT
660$(built_odex): PRIVATE_DEX_FILE := $(built_dex)
Ying Wangdb48da72014-09-13 11:26:39 -0700661# Use pattern rule - we may have multiple built odex files.
662$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex)
Ying Wang994c2262014-05-28 13:34:59 -0700663 $(hide) mkdir -p $(dir $@) && rm -f $@
Ying Wang36142f62014-05-21 16:13:33 -0700664 $(add-dex-to-package)
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000665ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
666 $(uncompress-dexs)
667 $(align-package)
668endif
Ying Wang36142f62014-05-21 16:13:33 -0700669 $(hide) mv $@ $@.input
670 $(call dexpreopt-one-file,$@.input,$@)
671 $(hide) rm $@.input
672endif
673
Ying Wang1425e2d2014-07-22 15:42:11 -0700674###############################
675## APK splits
676ifdef LOCAL_PACKAGE_SPLITS
Ying Wang7f625aa2014-07-23 10:27:57 -0700677# The splits should have been built in the same command building the base apk.
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800678# This rule just runs signing.
Ying Wang7f625aa2014-07-23 10:27:57 -0700679# Note that we explicily check the existence of the split apk and remove the
680# built base apk if the split apk isn't there.
681# That way the build system will rerun the aapt after the user changes the splitting parameters.
Ying Wang1425e2d2014-07-22 15:42:11 -0700682$(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key)
683$(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate)
Dan Willemsenf72308a2017-05-15 23:38:04 -0700684$(built_apk_splits) : $(intermediates)/%.apk : $(LOCAL_BUILT_MODULE)
Ying Wang7f625aa2014-07-23 10:27:57 -0700685 $(hide) if [ ! -f $@ ]; then \
686 echo 'No $@ generated, check your apk splitting parameters.' 1>&2; \
687 rm $<; exit 1; \
688 fi
689 $(sign-package)
Ying Wang1425e2d2014-07-22 15:42:11 -0700690
691# Rules to install the splits
Colin Cross7a281582018-03-06 16:21:36 -0800692installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
Dan Willemsenf72308a2017-05-15 23:38:04 -0700693$(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(intermediates)/package_%.apk
Ying Wang7f625aa2014-07-23 10:27:57 -0700694 @echo "Install: $@"
695 $(copy-file-to-new-target)
Ying Wang1425e2d2014-07-22 15:42:11 -0700696
697# Register the additional built and installed files.
698ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
699ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
Dan Willemsenf72308a2017-05-15 23:38:04 -0700700 $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
Ying Wang1425e2d2014-07-22 15:42:11 -0700701
702# Make sure to install the splits when you run "make <module_name>".
Colin Cross33886702016-09-20 16:01:28 -0700703$(my_all_targets): $(installed_apk_splits)
Ying Wang16243612015-06-03 12:43:50 -0700704
705ifdef LOCAL_COMPATIBILITY_SUITE
Ying Wang16243612015-06-03 12:43:50 -0700706
Simran Basi6bea37c2017-02-16 18:04:10 -0800707$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
708 $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
709 $(foreach s,$(my_split_suffixes),\
Dan Willemsenf72308a2017-05-15 23:38:04 -0700710 $(intermediates)/package_$(s).apk:$(dir)/$(LOCAL_MODULE)_$(s).apk))))
Ying Wang16243612015-06-03 12:43:50 -0700711
Simran Basi6bea37c2017-02-16 18:04:10 -0800712$(call create-suite-dependencies)
713
Ying Wang16243612015-06-03 12:43:50 -0700714endif # LOCAL_COMPATIBILITY_SUITE
Ying Wang1425e2d2014-07-22 15:42:11 -0700715endif # LOCAL_PACKAGE_SPLITS
716
Colin Cross8e404122014-02-06 14:45:37 -0800717# Save information about this package
718PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
719PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
Colin Cross8e404122014-02-06 14:45:37 -0800720
721PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
722
Colin Cross8e404122014-02-06 14:45:37 -0800723endif # skip_definition
724
725# Reset internal variables.
726all_res_assets :=
Jaekyun Seok30706102017-02-02 00:44:58 +0900727
728ifdef enforce_rro_enabled
729 ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
730 enforce_rro_use_res_lib := true
731 else
732 enforce_rro_use_res_lib := false
733 endif
734
735 ifdef LOCAL_MANIFEST_PACKAGE_NAME
736 enforce_rro_is_manifest_package_name := true
737 enforce_rro_manifest_package_info := $(LOCAL_MANIFEST_PACKAGE_NAME)
738 else
739 enforce_rro_is_manifest_package_name := false
740 enforce_rro_manifest_package_info := $(full_android_manifest)
741 endif
742
743$(call append_enforce_rro_sources, \
744 $(my_register_name), \
745 $(enforce_rro_is_manifest_package_name), \
746 $(enforce_rro_manifest_package_info), \
747 $(enforce_rro_use_res_lib), \
748 $(package_resource_overlays) \
749 )
Jaekyun Seok2a209992017-03-30 11:25:02 +0900750endif # enforce_rro_enabled