blob: cdc4958b1c50f5a516903b3bbff2ed8f01a8cf4e [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
90package_resource_overlays := $(strip \
91 $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
92 $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
93 $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
94 $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
95
Jaekyun Seok30706102017-02-02 00:44:58 +090096enforce_rro_enabled :=
Jaekyun Seok2a209992017-03-30 11:25:02 +090097ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
98 ifneq ($(package_resource_overlays),)
99 ifeq ($(PRODUCT_ENFORCE_RRO_TARGETS),*)
100 enforce_rro_enabled := true
101 else ifneq (,$(filter $(LOCAL_PACKAGE_NAME), $(PRODUCT_ENFORCE_RRO_TARGETS)))
Jaekyun Seok30706102017-02-02 00:44:58 +0900102 enforce_rro_enabled := true
103 endif
104 endif
105
106 ifdef enforce_rro_enabled
107 ifeq (,$(LOCAL_MODULE_PATH))
108 ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
109 enforce_rro_enabled :=
110 else ifeq (true,$(LOCAL_OEM_MODULE))
111 enforce_rro_enabled :=
112 else ifeq (true,$(LOCAL_ODM_MODULE))
113 enforce_rro_enabled :=
114 endif
115 else ifeq ($(filter $(TARGET_OUT)/%,$(LOCAL_MODULE_PATH)),)
116 enforce_rro_enabled :=
117 endif
118 endif
119endif
120
Jaekyun Seokccee95e2017-09-01 17:23:25 +0900121ifdef enforce_rro_enabled
122 ifneq ($(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS),)
123 static_only_resource_overlays := $(filter $(addsuffix %,$(PRODUCT_ENFORCE_RRO_EXCLUDED_OVERLAYS)),$(package_resource_overlays))
124 ifneq ($(static_only_resource_overlays),)
125 package_resource_overlays := $(filter-out $(static_only_resource_overlays),$(package_resource_overlays))
126 LOCAL_RESOURCE_DIR := $(static_only_resource_overlays) $(LOCAL_RESOURCE_DIR)
127 ifeq ($(package_resource_overlays),)
128 enforce_rro_enabled :=
129 endif
130 endif
131 endif
132else
Colin Cross8e404122014-02-06 14:45:37 -0800133LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
Jaekyun Seok30706102017-02-02 00:44:58 +0900134endif
Colin Cross8e404122014-02-06 14:45:37 -0800135
Colin Cross2c321442014-02-12 13:06:30 -0800136all_assets := $(strip \
137 $(foreach dir, $(LOCAL_ASSET_DIR), \
138 $(addprefix $(dir)/, \
139 $(patsubst assets/%,%, \
140 $(call find-subdir-assets, $(dir)) \
141 ) \
142 ) \
143 ))
Colin Cross8e404122014-02-06 14:45:37 -0800144
Ying Wang4cb04992014-07-29 10:34:30 -0700145ifneq ($(all_assets),)
146need_compile_asset := true
147endif
148
Dan Willemsenbb6393c2017-11-17 15:39:52 -0800149ifdef LOCAL_AAPT2_ONLY
150LOCAL_USE_AAPT2 := true
151endif
152
Adam Lesinskie758f932016-02-26 11:13:43 -0800153my_res_package :=
Ying Wange295c3d2016-02-24 14:11:55 -0800154ifdef LOCAL_USE_AAPT2
Ying Wangdd71c852015-12-04 13:59:18 -0800155# In aapt2 the last takes precedence.
156my_resource_dirs := $(call reverse-list,$(LOCAL_RESOURCE_DIR))
Adam Lesinskie758f932016-02-26 11:13:43 -0800157my_res_dir :=
158my_overlay_res_dirs :=
159
160ifneq ($(LOCAL_STATIC_ANDROID_LIBRARIES),)
161# If we are using static android libraries, every source file becomes an overlay.
162# This is to emulate old AAPT behavior which simulated library support.
163my_res_dir :=
164my_overlay_res_dirs := $(my_resource_dirs)
165else
166# Without static libraries, the first directory is our directory, which can then be
167# overlaid by the rest. (First directory in my_resource_dirs is last directory in
168# $(LOCAL_RESOURCE_DIR) due to it being reversed.
169my_res_dir := $(firstword $(my_resource_dirs))
170my_overlay_res_dirs := $(wordlist 2,999,$(my_resource_dirs))
171endif
172
Ying Wangdd71c852015-12-04 13:59:18 -0800173my_overlay_resources := $(strip \
Adam Lesinskie758f932016-02-26 11:13:43 -0800174 $(foreach d,$(my_overlay_res_dirs),\
Ying Wangdd71c852015-12-04 13:59:18 -0800175 $(addprefix $(d)/, \
176 $(call find-subdir-assets,$(d)))))
177
Colin Crossfe109632016-11-29 11:12:56 -0800178my_res_resources := $(if $(my_res_dir),$(strip \
Ying Wangdd71c852015-12-04 13:59:18 -0800179 $(addprefix $(my_res_dir)/, \
Colin Crossfe109632016-11-29 11:12:56 -0800180 $(call find-subdir-assets,$(my_res_dir)))))
Ying Wangdd71c852015-12-04 13:59:18 -0800181
182all_resources := $(strip $(my_res_resources) $(my_overlay_resources))
183
184# The linked resource package.
185my_res_package := $(intermediates)/package-res.apk
186LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
187
Ying Wange5853972016-03-01 12:06:47 -0800188# Always run aapt2, because we need to at least compile the AndroidManifest.xml.
Ying Wangdd71c852015-12-04 13:59:18 -0800189need_compile_res := true
190
Ying Wange295c3d2016-02-24 14:11:55 -0800191else # LOCAL_USE_AAPT2
Colin Cross8e404122014-02-06 14:45:37 -0800192all_resources := $(strip \
193 $(foreach dir, $(LOCAL_RESOURCE_DIR), \
194 $(addprefix $(dir)/, \
195 $(patsubst res/%,%, \
196 $(call find-subdir-assets,$(dir)) \
197 ) \
198 ) \
199 ))
200
Adam Lesinski4c452052016-08-12 12:57:17 -0700201ifdef LOCAL_PACKAGE_SPLITS
202LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
203endif
204
Ying Wange295c3d2016-02-24 14:11:55 -0800205endif # LOCAL_USE_AAPT2
Ying Wangdd71c852015-12-04 13:59:18 -0800206
Ying Wang61291922014-06-25 13:23:58 -0700207ifneq ($(all_resources),)
208 need_compile_res := true
209endif
210
Colin Cross8e404122014-02-06 14:45:37 -0800211all_res_assets := $(strip $(all_assets) $(all_resources))
212
Colin Cross8e404122014-02-06 14:45:37 -0800213# If no assets or resources were found, clear the directory variables so
214# we don't try to build them.
Ying Wang4cb04992014-07-29 10:34:30 -0700215ifneq (true,$(need_compile_asset))
Colin Cross8e404122014-02-06 14:45:37 -0800216LOCAL_ASSET_DIR:=
217endif
Ying Wang61291922014-06-25 13:23:58 -0700218ifneq (true,$(need_compile_res))
Colin Cross8e404122014-02-06 14:45:37 -0800219LOCAL_RESOURCE_DIR:=
220R_file_stamp :=
221else
222# Make sure that R_file_stamp inherits the proper PRIVATE vars.
223# If R.stamp moves, be sure to update the framework makefile,
224# which has intimate knowledge of its location.
Ying Wang98ae7982014-12-18 14:53:52 -0800225R_file_stamp := $(intermediates.COMMON)/src/R.stamp
Colin Cross8e404122014-02-06 14:45:37 -0800226LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
227endif
228
Narayan Kamath7c205102017-08-07 12:31:17 +0100229ifdef LOCAL_COMPRESSED_MODULE
230ifneq (true,$(LOCAL_COMPRESSED_MODULE))
231$(call pretty-error, Unknown value for LOCAL_COMPRESSED_MODULE $(LOCAL_COMPRESSED_MODULE))
232endif
233endif
234
235ifdef LOCAL_COMPRESSED_MODULE
Narayan Kamath6a4bd692017-08-14 10:53:50 +0100236PACKAGES.$(LOCAL_PACKAGE_NAME).COMPRESSED := gz
Narayan Kamath7c205102017-08-07 12:31:17 +0100237LOCAL_BUILT_MODULE_STEM := package.apk.gz
238LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk.gz
239else # !LOCAL_COMPRESSED_MODULE
Colin Cross8e404122014-02-06 14:45:37 -0800240LOCAL_BUILT_MODULE_STEM := package.apk
Ying Wangaf9757e2014-07-17 21:24:42 -0700241LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
Narayan Kamath7c205102017-08-07 12:31:17 +0100242endif
Colin Cross8e404122014-02-06 14:45:37 -0800243
244LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
245ifndef LOCAL_PROGUARD_ENABLED
246ifneq ($(DISABLE_PROGUARD),true)
247 LOCAL_PROGUARD_ENABLED :=full
248endif
249endif
250ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
251 # the package explicitly request to disable proguard.
252 LOCAL_PROGUARD_ENABLED :=
253endif
254proguard_options_file :=
255ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
Ying Wang61291922014-06-25 13:23:58 -0700256ifeq ($(need_compile_res),true)
Ying Wang98ae7982014-12-18 14:53:52 -0800257 proguard_options_file := $(intermediates.COMMON)/proguard_options
Ying Wang61291922014-06-25 13:23:58 -0700258endif # need_compile_res
Colin Cross8e404122014-02-06 14:45:37 -0800259endif # !custom
260LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
261
262ifeq (true,$(EMMA_INSTRUMENT))
263ifndef LOCAL_EMMA_INSTRUMENT
Jeff Gastonaaae43c2017-04-11 16:36:46 -0700264# No jacoco for test apks.
Ying Wang324ffb22015-11-06 11:22:28 -0800265ifeq (,$(LOCAL_INSTRUMENTATION_FOR))
Colin Cross8e404122014-02-06 14:45:37 -0800266LOCAL_EMMA_INSTRUMENT := true
267endif # No test apk
268endif # LOCAL_EMMA_INSTRUMENT is not set
269else
270LOCAL_EMMA_INSTRUMENT := false
271endif # EMMA_INSTRUMENT is true
272
273ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
274ifeq (true,$(EMMA_INSTRUMENT_STATIC))
Colin Cross79e2f732016-12-21 14:29:13 -0800275ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
276# Only add jacocoagent if the package contains some java code
Sebastien Hertzdfce8ad2015-11-19 17:53:00 +0100277LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
Colin Crossdc4a6b82018-01-03 12:39:11 -0800278# Exclude jacoco classes from proguard
279LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
Colin Cross79e2f732016-12-21 14:29:13 -0800280endif # Contains java code
281else
Colin Cross8e404122014-02-06 14:45:37 -0800282ifdef LOCAL_SDK_VERSION
283ifdef TARGET_BUILD_APPS
Sebastien Hertz2319e562016-03-31 16:48:26 +0200284# In unbundled build, merge the coverage library into the apk.
Colin Cross79e2f732016-12-21 14:29:13 -0800285ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
286# Only add jacocoagent if the package contains some java code
Sebastien Hertzdfce8ad2015-11-19 17:53:00 +0100287LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
Sebastien Hertz2319e562016-03-31 16:48:26 +0200288# Exclude jacoco classes from proguard
289LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
Colin Cross79e2f732016-12-21 14:29:13 -0800290endif # Contains java code
Colin Crosse673deb2017-09-27 14:28:41 -0700291endif # TARGET_BUILD_APPS
Colin Cross8e404122014-02-06 14:45:37 -0800292endif # LOCAL_SDK_VERSION
Colin Cross79e2f732016-12-21 14:29:13 -0800293endif # EMMA_INSTRUMENT_STATIC
Colin Cross8e404122014-02-06 14:45:37 -0800294endif # LOCAL_EMMA_INSTRUMENT
295
296rs_compatibility_jni_libs :=
297
Ying Wanged0361f2015-04-19 09:55:39 -0700298ifeq ($(LOCAL_DATA_BINDING),true)
299data_binding_intermediates := $(intermediates.COMMON)/data-binding
300
301LOCAL_JAVACFLAGS += -processorpath $(DATA_BINDING_COMPILER) -s $(data_binding_intermediates)/anno-src
Ying Wanged0361f2015-04-19 09:55:39 -0700302
303LOCAL_STATIC_JAVA_LIBRARIES += databinding-baselibrary
304LOCAL_STATIC_JAVA_AAR_LIBRARIES += databinding-library databinding-adapters
305
306data_binding_res_in := $(LOCAL_RESOURCE_DIR)
307data_binding_res_out := $(data_binding_intermediates)/res
308
309# Replace with the processed merged res dir.
310LOCAL_RESOURCE_DIR := $(data_binding_res_out)
311
312LOCAL_AAPT_FLAGS += --auto-add-overlay --extra-packages com.android.databinding.library
313endif # LOCAL_DATA_BINDING
314
Narayan Kamath7c205102017-08-07 12:31:17 +0100315# If the module is a compressed module, we don't pre-opt it because its final
316# installation location will be the data partition.
317ifdef LOCAL_COMPRESSED_MODULE
318LOCAL_DEX_PREOPT := false
319endif
320
Ying Wange9dd9f22014-10-29 15:48:32 -0700321include $(BUILD_SYSTEM)/android_manifest.mk
322
Narayan Kamathbbcdc072017-08-22 15:47:08 +0100323called_from_package_internal := true
Colin Cross8e404122014-02-06 14:45:37 -0800324#################################
325include $(BUILD_SYSTEM)/java.mk
326#################################
Narayan Kamathbbcdc072017-08-22 15:47:08 +0100327called_from_package_internal :=
Colin Cross8e404122014-02-06 14:45:37 -0800328
329LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
330ifeq ($(LOCAL_SDK_RES_VERSION),)
331 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
332endif
333
Colin Cross8e404122014-02-06 14:45:37 -0800334$(LOCAL_INTERMEDIATE_TARGETS): \
335 PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
Colin Cross8e404122014-02-06 14:45:37 -0800336
Ying Wanged0361f2015-04-19 09:55:39 -0700337ifeq ($(LOCAL_DATA_BINDING),true)
338data_binding_stamp := $(data_binding_intermediates)/data-binding.stamp
339$(data_binding_stamp): PRIVATE_INTERMEDIATES := $(data_binding_intermediates)
340$(data_binding_stamp): PRIVATE_MANIFEST := $(full_android_manifest)
341# Generate code into $(LOCAL_INTERMEDIATE_SOURCE_DIR) so that the generated .java files
342# will be automatically picked up by function compile-java.
343$(data_binding_stamp): PRIVATE_SRC_OUT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/data-binding
344$(data_binding_stamp): PRIVATE_XML_OUT := $(data_binding_intermediates)/xml
345$(data_binding_stamp): PRIVATE_RES_OUT := $(data_binding_res_out)
346$(data_binding_stamp): PRIVATE_RES_IN := $(data_binding_res_in)
347$(data_binding_stamp): PRIVATE_ANNO_SRC_DIR := $(data_binding_intermediates)/anno-src
348
349$(data_binding_stamp) : $(all_res_assets) $(full_android_manifest) \
350 $(DATA_BINDING_COMPILER)
351 @echo "Data-binding process: $@"
352 @rm -rf $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) && \
353 mkdir -p $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) \
354 $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_ANNO_SRC_DIR)
Colin Cross0851df82017-06-30 13:55:38 -0700355 $(hide) $(JAVA) -classpath $(DATA_BINDING_COMPILER) android.databinding.tool.MakeCopy \
Ying Wanged0361f2015-04-19 09:55:39 -0700356 $(PRIVATE_MANIFEST) $(PRIVATE_SRC_OUT) $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_RES_IN)
357 $(hide) touch $@
358
359# Make sure the data-binding process happens before javac and generation of R.java.
Colin Crossdfc45ec2017-05-26 15:22:02 -0700360$(R_file_stamp): $(data_binding_stamp)
361$(java_source_list_file): $(data_binding_stamp)
Nan Zhangad818dc2017-10-04 09:26:06 -0700362$(foreach x,$(sharded_java_source_list_files),$(eval $(x): $(data_binding_stamp)))
Colin Crossdfc45ec2017-05-26 15:22:02 -0700363$(full_classes_compiled_jar): $(data_binding_stamp)
Ying Wanged0361f2015-04-19 09:55:39 -0700364endif # LOCAL_DATA_BINDING
365
Colin Crossab61f212018-01-04 14:27:36 -0800366resource_export_package :=
367
Ying Wang61291922014-06-25 13:23:58 -0700368ifeq ($(need_compile_res),true)
Adam Lesinski4c452052016-08-12 12:57:17 -0700369
370###############################
371## APK splits
372built_apk_splits :=
373installed_apk_splits :=
374my_apk_split_configs :=
375
376ifdef LOCAL_PACKAGE_SPLITS
Narayan Kamath7c205102017-08-07 12:31:17 +0100377ifdef LOCAL_COMPRESSED_MODULE
378$(error $(LOCAL_MODULE): LOCAL_COMPRESSED_MODULE is not currently supported for split installs)
379endif # LOCAL_COMPRESSED_MODULE
380
Adam Lesinski4c452052016-08-12 12:57:17 -0700381my_apk_split_configs := $(LOCAL_PACKAGE_SPLITS)
382my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs))
Dan Willemsenf72308a2017-05-15 23:38:04 -0700383built_apk_splits := $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk)
Adam Lesinski4c452052016-08-12 12:57:17 -0700384installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
385endif
386
Ying Wange295c3d2016-02-24 14:11:55 -0800387ifdef LOCAL_USE_AAPT2
Colin Crossd5cce4c2017-10-27 16:10:18 -0700388my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res
Yang Nie2c09012017-04-26 16:15:42 -0700389renderscript_target_api :=
390ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
391renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
392else
393ifneq (,$(LOCAL_SDK_VERSION))
394# Set target-api for LOCAL_SDK_VERSIONs other than current.
395ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
Sundong Ahn5a44d1f2017-10-16 19:20:34 +0900396renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
Yang Nie2c09012017-04-26 16:15:42 -0700397endif
398endif # LOCAL_SDK_VERSION is set
399endif # LOCAL_RENDERSCRIPT_TARGET_API is set
400ifneq (,$(renderscript_target_api))
401ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true)
Ying Wange295c3d2016-02-24 14:11:55 -0800402my_generated_res_dirs := $(rs_generated_res_dir)
403my_generated_res_dirs_deps := $(RenderScript_file_stamp)
Yang Nie2c09012017-04-26 16:15:42 -0700404endif # renderscript_target_api < 21
405endif # renderscript_target_api is set
Adam Lesinski981de832017-03-16 04:53:05 +0000406my_asset_dirs := $(LOCAL_ASSET_DIR)
407my_full_asset_paths := $(all_assets)
Adam Lesinskie758f932016-02-26 11:13:43 -0800408# Add AAPT2 link specific flags.
409$(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --no-static-lib-packages
Ying Wangdd71c852015-12-04 13:59:18 -0800410include $(BUILD_SYSTEM)/aapt2.mk
Ying Wange295c3d2016-02-24 14:11:55 -0800411else # LOCAL_USE_AAPT2
Colin Cross8e404122014-02-06 14:45:37 -0800412
413# Since we don't know where the real R.java file is going to end up,
414# we need to use another file to stand in its place. We'll just
415# copy the generated file to src/R.stamp, which means it will
416# have the same contents and timestamp as the actual file.
417#
418# At the same time, this will copy the R.java file to a central
419# 'R' directory to make it easier to add the files to an IDE.
420#
Colin Cross8e404122014-02-06 14:45:37 -0800421
422$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \
423 $(intermediates.COMMON)/public_resources.xml
424$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
Dan Willemsenf439c332017-10-02 14:22:02 -0700425$(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_res_assets)
Colin Cross8e404122014-02-06 14:45:37 -0800426$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP)
427 @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
Martin Arenlindfb6985e2015-09-15 15:52:56 +0200428 @rm -rf $@ && mkdir -p $(dir $@)
Colin Cross8e404122014-02-06 14:45:37 -0800429 $(create-resource-java-files)
Dan Willemsenba9b0fb2017-09-29 19:18:21 -0700430 $(call find-generated-R.java,$@)
Colin Cross8e404122014-02-06 14:45:37 -0800431
432$(proguard_options_file): $(R_file_stamp)
433
434ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
435# Put this module's resources into a PRODUCT-agnositc package that
436# other packages can use to build their own PRODUCT-agnostic R.java (etc.)
437# files.
438resource_export_package := $(intermediates.COMMON)/package-export.apk
439$(R_file_stamp): $(resource_export_package)
440
441# add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target
442# can't know anything about PRODUCT. Clear it out just for this target.
443$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
444$(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
Dan Willemsenf439c332017-10-02 14:22:02 -0700445$(resource_export_package): PRIVATE_RESOURCE_LIST := $(all_res_assets)
Colin Cross8e404122014-02-06 14:45:37 -0800446$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT)
447 @echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
448 $(create-empty-package)
449 $(add-assets-to-package)
450endif
451
Ying Wange295c3d2016-02-24 14:11:55 -0800452endif # LOCAL_USE_AAPT2
Ying Wangdd71c852015-12-04 13:59:18 -0800453
Colin Cross8e404122014-02-06 14:45:37 -0800454# Other modules should depend on the BUILT module if
455# they want to use this module's R.java file.
Colin Cross79e2f732016-12-21 14:29:13 -0800456$(LOCAL_BUILT_MODULE): $(R_file_stamp)
457
Colin Crossdfc45ec2017-05-26 15:22:02 -0700458# The R.java file must exist by the time the java source
459# list is generated
460$(java_source_list_file): $(R_file_stamp)
Nan Zhangad818dc2017-10-04 09:26:06 -0700461$(foreach x,$(sharded_java_source_list_files),$(eval $(x): $(R_file_stamp)))
Colin Cross8e404122014-02-06 14:45:37 -0800462
Ying Wang61291922014-06-25 13:23:58 -0700463endif # need_compile_res
Colin Cross8e404122014-02-06 14:45:37 -0800464
465ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
466# We need to explicitly clear this var so that we don't
467# inherit the value from whomever caused us to be built.
468$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES :=
469else
470# Most packages should link against the resources defined by framework-res.
471# Even if they don't have their own resources, they may use framework
472# resources.
Michael Wright0fb087f2015-11-06 15:20:51 +0000473ifneq ($(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 -0800474# for released sdk versions, the platform resources were built into android.jar.
475framework_res_package_export := \
476 $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
477framework_res_package_export_deps := $(framework_res_package_export)
478else # LOCAL_SDK_RES_VERSION
479framework_res_package_export := \
480 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
481# We can't depend directly on the export.apk file; it won't get its
482# PRIVATE_ vars set up correctly if we do. Instead, depend on the
483# corresponding R.stamp file, which lists the export.apk as a dependency.
484framework_res_package_export_deps := \
485 $(dir $(framework_res_package_export))src/R.stamp
486endif # LOCAL_SDK_RES_VERSION
Adam Lesinskide057c32014-03-13 18:48:27 -0700487all_library_res_package_exports := \
488 $(framework_res_package_export) \
Adam Lesinski5eebe0f2014-03-25 15:45:34 -0700489 $(foreach lib,$(LOCAL_RES_LIBRARIES),\
Adam Lesinskide057c32014-03-13 18:48:27 -0700490 $(call intermediates-dir-for,APPS,$(lib),,COMMON)/package-export.apk)
491
492all_library_res_package_export_deps := \
493 $(framework_res_package_export_deps) \
Adam Lesinski5eebe0f2014-03-25 15:45:34 -0700494 $(foreach lib,$(LOCAL_RES_LIBRARIES),\
Adam Lesinskide057c32014-03-13 18:48:27 -0700495 $(call intermediates-dir-for,APPS,$(lib),,COMMON)/src/R.stamp)
Ying Wangb5745642014-06-19 16:07:30 -0700496$(resource_export_package) $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(all_library_res_package_export_deps)
Colin Cross8e404122014-02-06 14:45:37 -0800497$(LOCAL_INTERMEDIATE_TARGETS): \
Adam Lesinskide057c32014-03-13 18:48:27 -0700498 PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
Ying Wangdd71c852015-12-04 13:59:18 -0800499
Ying Wange295c3d2016-02-24 14:11:55 -0800500ifdef LOCAL_USE_AAPT2
Ying Wangdd71c852015-12-04 13:59:18 -0800501$(my_res_package) : $(all_library_res_package_export_deps)
502endif
Colin Cross8e404122014-02-06 14:45:37 -0800503endif # LOCAL_NO_STANDARD_LIBRARIES
504
505ifneq ($(full_classes_jar),)
506$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
Colin Cross79e2f732016-12-21 14:29:13 -0800507# Use the jarjar processed arhive as the initial package file.
Colin Crossffbf0a62017-03-29 12:58:15 -0700508$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
Colin Cross8e404122014-02-06 14:45:37 -0800509$(LOCAL_BUILT_MODULE): $(built_dex)
Ying Wang33360dd2015-01-14 14:23:56 -0800510else
511$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE :=
Colin Cross79e2f732016-12-21 14:29:13 -0800512$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE :=
Colin Cross8e404122014-02-06 14:45:37 -0800513endif # full_classes_jar
514
Ying Wang96bcad42014-04-17 13:38:04 -0700515include $(BUILD_SYSTEM)/install_jni_libs.mk
Colin Cross8e404122014-02-06 14:45:37 -0800516
517# Pick a key to sign the package with. If this package hasn't specified
518# an explicit certificate, use the default.
519# Secure release builds will have their packages signed after the fact,
520# so it's ok for these private keys to be in the clear.
521ifeq ($(LOCAL_CERTIFICATE),)
522 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
523endif
524
525ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
526 # The special value "EXTERNAL" means that we will sign it with the
527 # default devkey, apply predexopt, but then expect the final .apk
528 # (after dexopting) to be signed by an outside tool.
529 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
530 PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1
531endif
532
533# If this is not an absolute certificate, assign it to a generic one.
534ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
535 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
536endif
537private_key := $(LOCAL_CERTIFICATE).pk8
538certificate := $(LOCAL_CERTIFICATE).x509.pem
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900539additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
Colin Cross8e404122014-02-06 14:45:37 -0800540
541$(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR)
542$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key)
543$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate)
544
545PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key)
546PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate)
547
Shinichiro Hamaji641e61c2016-05-13 16:03:24 +0900548$(LOCAL_BUILT_MODULE): $(additional_certificates)
549$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates)
Colin Cross8e404122014-02-06 14:45:37 -0800550
551# Define the rule to build the actual package.
Ying Wang8e20ef62014-06-24 20:01:52 -0700552# PRIVATE_JNI_SHARED_LIBRARIES is a list of <abi>:<path_of_built_lib>.
553$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
554# PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names.
555$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
Colin Cross8e404122014-02-06 14:45:37 -0800556ifneq ($(TARGET_BUILD_APPS),)
557 # Include all resources for unbundled apps.
558 LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
559endif
560ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
Adam Lesinskie758f932016-02-26 11:13:43 -0800561 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
562 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
Colin Cross8e404122014-02-06 14:45:37 -0800563else
Adam Lesinskie758f932016-02-26 11:13:43 -0800564 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
Ying Wang934008f2014-07-30 13:40:14 -0700565ifdef LOCAL_PACKAGE_SPLITS
Adam Lesinskie758f932016-02-26 11:13:43 -0800566 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
Ying Wang934008f2014-07-30 13:40:14 -0700567else
Adam Lesinskie758f932016-02-26 11:13:43 -0800568 $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG)
Colin Cross8e404122014-02-06 14:45:37 -0800569endif
Ying Wang934008f2014-07-30 13:40:14 -0700570endif
Colin Cross303567c2017-08-03 03:17:34 +0000571
Colin Cross79e2f732016-12-21 14:29:13 -0800572$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
Colin Cross303567c2017-08-03 03:17:34 +0000573$(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/resources
574$(LOCAL_BUILT_MODULE): PRIVATE_FULL_CLASSES_JAR := $(full_classes_jar)
Ying Wangdd71c852015-12-04 13:59:18 -0800575$(LOCAL_BUILT_MODULE) : $(jni_shared_libraries)
Colin Cross128800f2017-08-10 15:24:10 -0700576$(LOCAL_BUILT_MODULE) : $(JAR_ARGS)
Ying Wange295c3d2016-02-24 14:11:55 -0800577ifdef LOCAL_USE_AAPT2
Ying Wangdd71c852015-12-04 13:59:18 -0800578$(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package)
579$(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP)
580else
Dan Willemsenf439c332017-10-02 14:22:02 -0700581$(LOCAL_BUILT_MODULE): PRIVATE_RESOURCE_LIST := $(all_res_assets)
Nicolas Geoffraya95fbd12017-09-19 13:10:31 +0100582$(LOCAL_BUILT_MODULE) : $(all_res_assets) $(full_android_manifest) $(AAPT) $(ZIPALIGN)
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000583endif # LOCAL_USE_AAPT2
Narayan Kamath7c205102017-08-07 12:31:17 +0100584ifdef LOCAL_COMPRESSED_MODULE
585$(LOCAL_BUILT_MODULE) : $(MINIGZIP)
586endif
Colin Cross8e404122014-02-06 14:45:37 -0800587 @echo "target Package: $(PRIVATE_MODULE) ($@)"
Ying Wange295c3d2016-02-24 14:11:55 -0800588ifdef LOCAL_USE_AAPT2
Ying Wangdd71c852015-12-04 13:59:18 -0800589 $(call copy-file-to-new-target)
Ying Wang81ef4712016-03-31 10:10:42 -0700590else # ! LOCAL_USE_AAPT2
Colin Cross79e2f732016-12-21 14:29:13 -0800591 $(if $(PRIVATE_SOURCE_ARCHIVE),\
592 $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
593 $(create-empty-package))
Colin Cross8e404122014-02-06 14:45:37 -0800594 $(add-assets-to-package)
Ying Wange295c3d2016-02-24 14:11:55 -0800595endif # LOCAL_USE_AAPT2
Colin Cross8e404122014-02-06 14:45:37 -0800596ifneq ($(jni_shared_libraries),)
597 $(add-jni-shared-libs-to-package)
598endif
Ying Wang8b27d182015-03-27 11:07:17 -0700599ifeq ($(full_classes_jar),)
600# We don't build jar, need to add the Java resources here.
601 $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
Ying Wang3a61eeb2016-03-11 10:32:01 -0800602else # full_classes_jar
Colin Cross8e404122014-02-06 14:45:37 -0800603 $(add-dex-to-package)
Colin Cross303567c2017-08-03 03:17:34 +0000604ifdef LOCAL_USE_AAPT2
Colin Cross303567c2017-08-03 03:17:34 +0000605 $(call add-jar-resources-to-package,$@,$(PRIVATE_FULL_CLASSES_JAR),$(PRIVATE_RESOURCE_INTERMEDIATES_DIR))
606endif
Ying Wang3a61eeb2016-03-11 10:32:01 -0800607endif # full_classes_jar
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000608ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
609 @# No need to align, sign-package below will do it.
610 $(uncompress-dexs)
611endif
Colin Cross8e404122014-02-06 14:45:37 -0800612ifdef LOCAL_DEX_PREOPT
Ying Wang3a61eeb2016-03-11 10:32:01 -0800613ifneq ($(BUILD_PLATFORM_ZIP),)
614 @# Keep a copy of apk with classes.dex unstripped
615 $(hide) cp -f $@ $(dir $@)package.dex.apk
616endif # BUILD_PLATFORM_ZIP
Colin Cross8e404122014-02-06 14:45:37 -0800617ifneq (nostripping,$(LOCAL_DEX_PREOPT))
618 $(call dexpreopt-remove-classes.dex,$@)
619endif
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000620endif # LOCAL_DEX_PREOPT
Kenny Rootdff37552015-04-15 12:09:32 -0700621 $(sign-package)
Narayan Kamath7c205102017-08-07 12:31:17 +0100622ifdef LOCAL_COMPRESSED_MODULE
623 $(compress-package)
624endif # LOCAL_COMPRESSED_MODULE
Colin Cross8e404122014-02-06 14:45:37 -0800625
Ying Wang36142f62014-05-21 16:13:33 -0700626###############################
Ying Wang8070b202014-12-01 17:46:56 -0800627## Build dpi-specific apks, if it's apps_only build.
628ifdef TARGET_BUILD_APPS
629ifdef LOCAL_DPI_VARIANTS
630$(foreach d, $(LOCAL_DPI_VARIANTS), \
631 $(eval my_dpi := $(d)) \
632 $(eval include $(BUILD_SYSTEM)/dpi_specific_apk.mk))
633endif
634endif
635
636###############################
Ying Wang36142f62014-05-21 16:13:33 -0700637## Rule to build the odex file
638ifdef LOCAL_DEX_PREOPT
639$(built_odex): PRIVATE_DEX_FILE := $(built_dex)
Ying Wangdb48da72014-09-13 11:26:39 -0700640# Use pattern rule - we may have multiple built odex files.
641$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex)
Ying Wang994c2262014-05-28 13:34:59 -0700642 $(hide) mkdir -p $(dir $@) && rm -f $@
Ying Wang36142f62014-05-21 16:13:33 -0700643 $(add-dex-to-package)
Nicolas Geoffray3972a472018-01-09 11:46:30 +0000644ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
645 $(uncompress-dexs)
646 $(align-package)
647endif
Ying Wang36142f62014-05-21 16:13:33 -0700648 $(hide) mv $@ $@.input
649 $(call dexpreopt-one-file,$@.input,$@)
650 $(hide) rm $@.input
651endif
652
Ying Wang1425e2d2014-07-22 15:42:11 -0700653###############################
654## APK splits
655ifdef LOCAL_PACKAGE_SPLITS
Ying Wang7f625aa2014-07-23 10:27:57 -0700656# The splits should have been built in the same command building the base apk.
Alex Klyubin5b826ac2015-12-04 10:07:41 -0800657# This rule just runs signing.
Ying Wang7f625aa2014-07-23 10:27:57 -0700658# Note that we explicily check the existence of the split apk and remove the
659# built base apk if the split apk isn't there.
660# That way the build system will rerun the aapt after the user changes the splitting parameters.
Ying Wang1425e2d2014-07-22 15:42:11 -0700661$(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key)
662$(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate)
Dan Willemsenf72308a2017-05-15 23:38:04 -0700663$(built_apk_splits) : $(intermediates)/%.apk : $(LOCAL_BUILT_MODULE)
Ying Wang7f625aa2014-07-23 10:27:57 -0700664 $(hide) if [ ! -f $@ ]; then \
665 echo 'No $@ generated, check your apk splitting parameters.' 1>&2; \
666 rm $<; exit 1; \
667 fi
668 $(sign-package)
Ying Wang1425e2d2014-07-22 15:42:11 -0700669
670# Rules to install the splits
Dan Willemsenf72308a2017-05-15 23:38:04 -0700671$(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(intermediates)/package_%.apk
Ying Wang7f625aa2014-07-23 10:27:57 -0700672 @echo "Install: $@"
673 $(copy-file-to-new-target)
Ying Wang1425e2d2014-07-22 15:42:11 -0700674
675# Register the additional built and installed files.
676ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
677ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
Dan Willemsenf72308a2017-05-15 23:38:04 -0700678 $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
Ying Wang1425e2d2014-07-22 15:42:11 -0700679
680# Make sure to install the splits when you run "make <module_name>".
Colin Cross33886702016-09-20 16:01:28 -0700681$(my_all_targets): $(installed_apk_splits)
Ying Wang16243612015-06-03 12:43:50 -0700682
683ifdef LOCAL_COMPATIBILITY_SUITE
Ying Wang16243612015-06-03 12:43:50 -0700684
Simran Basi6bea37c2017-02-16 18:04:10 -0800685$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
686 $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
687 $(foreach s,$(my_split_suffixes),\
Dan Willemsenf72308a2017-05-15 23:38:04 -0700688 $(intermediates)/package_$(s).apk:$(dir)/$(LOCAL_MODULE)_$(s).apk))))
Ying Wang16243612015-06-03 12:43:50 -0700689
Simran Basi6bea37c2017-02-16 18:04:10 -0800690$(call create-suite-dependencies)
691
Ying Wang16243612015-06-03 12:43:50 -0700692endif # LOCAL_COMPATIBILITY_SUITE
Ying Wang1425e2d2014-07-22 15:42:11 -0700693endif # LOCAL_PACKAGE_SPLITS
694
Colin Cross8e404122014-02-06 14:45:37 -0800695# Save information about this package
696PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
697PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
Colin Cross8e404122014-02-06 14:45:37 -0800698
699PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
700
Colin Cross8e404122014-02-06 14:45:37 -0800701endif # skip_definition
702
703# Reset internal variables.
704all_res_assets :=
Jaekyun Seok30706102017-02-02 00:44:58 +0900705
706ifdef enforce_rro_enabled
707 ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
708 enforce_rro_use_res_lib := true
709 else
710 enforce_rro_use_res_lib := false
711 endif
712
713 ifdef LOCAL_MANIFEST_PACKAGE_NAME
714 enforce_rro_is_manifest_package_name := true
715 enforce_rro_manifest_package_info := $(LOCAL_MANIFEST_PACKAGE_NAME)
716 else
717 enforce_rro_is_manifest_package_name := false
718 enforce_rro_manifest_package_info := $(full_android_manifest)
719 endif
720
721$(call append_enforce_rro_sources, \
722 $(my_register_name), \
723 $(enforce_rro_is_manifest_package_name), \
724 $(enforce_rro_manifest_package_info), \
725 $(enforce_rro_use_res_lib), \
726 $(package_resource_overlays) \
727 )
Jaekyun Seok2a209992017-03-30 11:25:02 +0900728endif # enforce_rro_enabled