• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# App prebuilt coming from Soong.
2# Extra inputs:
3# LOCAL_SOONG_BUILT_INSTALLED
4# LOCAL_SOONG_BUNDLE
5# LOCAL_SOONG_CLASSES_JAR
6# LOCAL_SOONG_DEX_JAR
7# LOCAL_SOONG_HEADER_JAR
8# LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
9# LOCAL_SOONG_PROGUARD_DICT
10# LOCAL_SOONG_PROGUARD_USAGE_ZIP
11# LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
12# LOCAL_SOONG_RRO_DIRS
13# LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH)
14# LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH)
15# LOCAL_SOONG_JNI_LIBS_SYMBOLS
16# LOCAL_SOONG_DEXPREOPT_CONFIG
17
18ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
19  $(call pretty-error,soong_app_prebuilt.mk may only be used from Soong)
20endif
21
22LOCAL_MODULE_SUFFIX := .apk
23LOCAL_BUILT_MODULE_STEM := package.apk
24
25intermediates.COMMON := $(call local-intermediates-dir,COMMON)
26
27full_classes_jar := $(intermediates.COMMON)/classes.jar
28full_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar
29full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar
30
31#######################################
32include $(BUILD_SYSTEM)/base_rules.mk
33#######################################
34
35ifdef LOCAL_SOONG_CLASSES_JAR
36  $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_jar)))
37  $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_pre_proguard_jar)))
38  $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(full_classes_jar)))
39
40  ifneq ($(TURBINE_ENABLED),false)
41    ifdef LOCAL_SOONG_HEADER_JAR
42      $(eval $(call copy-one-file,$(LOCAL_SOONG_HEADER_JAR),$(full_classes_header_jar)))
43    else
44      $(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_header_jar)))
45    endif
46  endif # TURBINE_ENABLED != false
47
48  javac-check : $(full_classes_jar)
49  javac-check-$(LOCAL_MODULE) : $(full_classes_jar)
50  .PHONY: javac-check-$(LOCAL_MODULE)
51endif
52
53ifdef LOCAL_SOONG_DEXPREOPT_CONFIG
54  my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
55  $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config)))
56  $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config)
57endif
58
59
60
61# Run veridex on product, system_ext and vendor modules.
62# We skip it for unbundled app builds where we cannot build veridex.
63module_run_appcompat :=
64ifeq (true,$(non_system_module))
65ifeq (,$(TARGET_BUILD_APPS))  # ! unbundled app build
66ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true)
67  module_run_appcompat := true
68endif
69endif
70endif
71
72ifeq ($(module_run_appcompat),true)
73  $(LOCAL_BUILT_MODULE): $(appcompat-files)
74  $(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
75  $(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE)
76	@echo "Copy: $@"
77	$(copy-file-to-target)
78	$(appcompat-header)
79	$(run-appcompat)
80else
81  $(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE)))
82endif
83
84ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
85  $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\
86    $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar))
87  $(call add-dependency,$(LOCAL_BUILT_MODULE),\
88    $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar)
89endif
90
91ifdef LOCAL_SOONG_PROGUARD_DICT
92  $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
93    $(intermediates.COMMON)/proguard_dictionary))
94  $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\
95    $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary))
96  $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),\
97    $(call local-packaging-dir,proguard_dictionary)/classes.jar))
98  $(call add-dependency,$(LOCAL_BUILT_MODULE),\
99    $(intermediates.COMMON)/proguard_dictionary)
100  $(call add-dependency,$(LOCAL_BUILT_MODULE),\
101    $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)
102  $(call add-dependency,$(LOCAL_BUILT_MODULE),\
103    $(call local-packaging-dir,proguard_dictionary)/classes.jar)
104endif
105
106ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP
107  $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_USAGE_ZIP),\
108    $(call local-packaging-dir,proguard_usage)/proguard_usage.zip))
109  $(call add-dependency,$(LOCAL_BUILT_MODULE),\
110    $(call local-packaging-dir,proguard_usage)/proguard_usage.zip)
111endif
112
113ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
114resource_export_package := $(intermediates.COMMON)/package-export.apk
115resource_export_stamp := $(intermediates.COMMON)/src/R.stamp
116
117$(resource_export_package): PRIVATE_STAMP := $(resource_export_stamp)
118$(resource_export_package): .KATI_IMPLICIT_OUTPUTS := $(resource_export_stamp)
119$(resource_export_package): $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE)
120	@echo "Copy: $@"
121	$(copy-file-to-target)
122	touch $(PRIVATE_STAMP)
123$(call add-dependency,$(LOCAL_BUILT_MODULE),$(resource_export_package))
124
125endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
126
127java-dex: $(LOCAL_SOONG_DEX_JAR)
128
129
130my_built_installed := $(foreach f,$(LOCAL_SOONG_BUILT_INSTALLED),\
131  $(call word-colon,1,$(f)):$(PRODUCT_OUT)$(call word-colon,2,$(f)))
132my_installed := $(call copy-many-files, $(my_built_installed))
133ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed)
134ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(my_built_installed)
135$(my_all_targets): $(my_installed)
136
137# Copy test suite files.
138ifdef LOCAL_COMPATIBILITY_SUITE
139my_apks_to_install := $(foreach f,$(filter %.apk %.idsig,$(LOCAL_SOONG_BUILT_INSTALLED)),$(call word-colon,1,$(f)))
140$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
141  $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
142    $(foreach a,$(my_apks_to_install),\
143      $(call compat-copy-pair,$(a),$(dir)/$(notdir $(a)))))))
144$(call create-suite-dependencies)
145endif
146
147# install symbol files of JNI libraries
148my_jni_lib_symbols_copy_files := $(foreach f,$(LOCAL_SOONG_JNI_LIBS_SYMBOLS),\
149  $(call word-colon,1,$(f)):$(patsubst $(PRODUCT_OUT)/%,$(TARGET_OUT_UNSTRIPPED)/%,$(call word-colon,2,$(f))))
150$(LOCAL_BUILT_MODULE): | $(call copy-many-files, $(my_jni_lib_symbols_copy_files))
151
152# embedded JNI will already have been handled by soong
153my_embed_jni :=
154my_prebuilt_jni_libs :=
155ifdef LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH)
156  my_2nd_arch_prefix :=
157  LOCAL_JNI_SHARED_LIBRARIES := $(LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH))
158  include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
159endif
160ifdef TARGET_2ND_ARCH
161  ifdef LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH)
162    my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
163    LOCAL_JNI_SHARED_LIBRARIES := $(LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH))
164    include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
165  endif
166endif
167LOCAL_SHARED_JNI_LIBRARIES :=
168my_embed_jni :=
169my_prebuilt_jni_libs :=
170my_2nd_arch_prefix :=
171
172PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
173ifndef LOCAL_CERTIFICATE
174  $(call pretty-error,LOCAL_CERTIFICATE must be set for soong_app_prebuilt.mk)
175endif
176ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
177  # The magic string "PRESIGNED" means this package is already checked
178  # signed with its release key.
179  #
180  # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
181  # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
182  # but the dexpreopt process will not try to re-sign the app.
183  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
184else ifneq ($(LOCAL_CERTIFICATE),)
185  PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE)
186  PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(patsubst %.x509.pem,%.pk8,$(LOCAL_CERTIFICATE))
187endif
188include $(BUILD_SYSTEM)/app_certificate_validate.mk
189PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
190
191ifneq ($(LOCAL_MODULE_STEM),)
192  PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE_STEM)
193else
194  PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE)
195endif
196
197# Set a actual_partition_tag (calculated in base_rules.mk) for the package.
198PACKAGES.$(LOCAL_MODULE).PARTITION := $(actual_partition_tag)
199
200ifdef LOCAL_SOONG_BUNDLE
201  ALL_MODULES.$(my_register_name).BUNDLE := $(LOCAL_SOONG_BUNDLE)
202endif
203
204ifdef LOCAL_SOONG_LINT_REPORTS
205  ALL_MODULES.$(my_register_name).LINT_REPORTS := $(LOCAL_SOONG_LINT_REPORTS)
206endif
207
208ifndef LOCAL_IS_HOST_MODULE
209ifeq ($(LOCAL_SDK_VERSION),system_current)
210my_link_type := java:system
211else ifneq ($(LOCAL_SDK_VERSION),)
212my_link_type := java:sdk
213else
214my_link_type := java:platform
215endif
216# warn/allowed types are both empty because Soong modules can't depend on
217# make-defined modules.
218my_warn_types :=
219my_allowed_types :=
220
221my_link_deps :=
222my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
223my_common := COMMON
224include $(BUILD_SYSTEM)/link_type.mk
225endif # !LOCAL_IS_HOST_MODULE
226
227ifdef LOCAL_SOONG_DEVICE_RRO_DIRS
228  $(call append_enforce_rro_sources, \
229      $(my_register_name), \
230      false, \
231      $(LOCAL_FULL_MANIFEST_FILE), \
232      $(if $(LOCAL_EXPORT_PACKAGE_RESOURCES),true,false), \
233      $(LOCAL_SOONG_DEVICE_RRO_DIRS), \
234      vendor \
235  )
236endif
237
238ifdef LOCAL_SOONG_PRODUCT_RRO_DIRS
239  $(call append_enforce_rro_sources, \
240      $(my_register_name), \
241      false, \
242      $(LOCAL_FULL_MANIFEST_FILE), \
243      $(if $(LOCAL_EXPORT_PACKAGE_RESOURCES),true,false), \
244      $(LOCAL_SOONG_PRODUCT_RRO_DIRS), \
245      product \
246  )
247endif
248
249ifdef LOCAL_PREBUILT_COVERAGE_ARCHIVE
250  my_coverage_dir := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
251  my_coverage_copy_pairs := $(foreach f,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(f):$(my_coverage_dir)/$(notdir  $(f)))
252  my_coverage_files := $(call copy-many-files,$(my_coverage_copy_pairs))
253  $(LOCAL_INSTALLED_MODULE): $(my_coverage_files)
254endif
255
256SOONG_ALREADY_CONV += $(LOCAL_MODULE)
257