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 32# Use the Soong output as the checkbuild target instead of LOCAL_BUILT_MODULE 33# to avoid checkbuilds making an extra copy of every module. 34LOCAL_CHECKED_MODULE := $(LOCAL_PREBUILT_MODULE_FILE) 35LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_CLASSES_JAR) 36LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_HEADER_JAR) 37LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_FULL_MANIFEST_FILE) 38LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_DEXPREOPT_CONFIG) 39LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE) 40LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_DEX_JAR) 41 42####################################### 43include $(BUILD_SYSTEM)/base_rules.mk 44####################################### 45 46ifdef LOCAL_SOONG_CLASSES_JAR 47 $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_jar))) 48 $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_pre_proguard_jar))) 49 $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(full_classes_jar))) 50 51 ifneq ($(TURBINE_ENABLED),false) 52 ifdef LOCAL_SOONG_HEADER_JAR 53 $(eval $(call copy-one-file,$(LOCAL_SOONG_HEADER_JAR),$(full_classes_header_jar))) 54 else 55 $(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_header_jar))) 56 endif 57 endif # TURBINE_ENABLED != false 58 59 javac-check : $(full_classes_jar) 60 javac-check-$(LOCAL_MODULE) : $(full_classes_jar) 61 .PHONY: javac-check-$(LOCAL_MODULE) 62endif 63 64ifdef LOCAL_SOONG_DEXPREOPT_CONFIG 65 my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config 66 $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config))) 67 $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config) 68endif 69 70 71 72# Run veridex on product, system_ext and vendor modules. 73# We skip it for unbundled app builds where we cannot build veridex. 74module_run_appcompat := 75ifeq (true,$(non_system_module)) 76ifeq (,$(TARGET_BUILD_APPS)) # not unbundled app build 77ifeq (,$(filter sdk,$(MAKECMDGOALS))) # not sdk build (which is another form of unbundled build) 78ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true) 79 module_run_appcompat := true 80endif 81endif 82endif 83endif 84 85ifeq ($(module_run_appcompat),true) 86 $(LOCAL_BUILT_MODULE): $(appcompat-files) 87 $(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE) 88 $(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE) 89 @echo "Copy: $@" 90 $(copy-file-to-target) 91 $(appcompat-header) 92 $(run-appcompat) 93else 94 $(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE))) 95endif 96 97ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR 98 $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\ 99 $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar)) 100 $(call add-dependency,$(LOCAL_BUILT_MODULE),\ 101 $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar) 102endif 103 104ifdef LOCAL_SOONG_PROGUARD_DICT 105 $(eval $(call copy-r8-dictionary-file-with-mapping,\ 106 $(LOCAL_SOONG_PROGUARD_DICT),\ 107 $(intermediates.COMMON)/proguard_dictionary,\ 108 $(intermediates.COMMON)/proguard_dictionary.textproto)) 109 110 ALL_MODULES.$(my_register_name).PROGUARD_DICTIONARY_FILES := \ 111 $(intermediates.COMMON)/proguard_dictionary \ 112 $(LOCAL_SOONG_CLASSES_JAR) 113 ALL_MODULES.$(my_register_name).PROGUARD_DICTIONARY_SOONG_ZIP_ARGUMENTS := \ 114 -e out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates/proguard_dictionary \ 115 -f $(intermediates.COMMON)/proguard_dictionary \ 116 -e out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates/classes.jar \ 117 -f $(LOCAL_SOONG_CLASSES_JAR) 118 ALL_MODULES.$(my_register_name).PROGUARD_DICTIONARY_MAPPING := $(intermediates.COMMON)/proguard_dictionary.textproto 119endif 120 121ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP 122 ALL_MODULES.$(my_register_name).PROGUARD_USAGE_ZIP := $(LOCAL_SOONG_PROGUARD_USAGE_ZIP) 123endif 124 125ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 126resource_export_package := $(intermediates.COMMON)/package-export.apk 127resource_export_stamp := $(intermediates.COMMON)/src/R.stamp 128 129$(resource_export_package): PRIVATE_STAMP := $(resource_export_stamp) 130$(resource_export_package): .KATI_IMPLICIT_OUTPUTS := $(resource_export_stamp) 131$(resource_export_package): $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE) 132 @echo "Copy: $@" 133 $(copy-file-to-target) 134 touch $(PRIVATE_STAMP) 135$(call add-dependency,$(LOCAL_BUILT_MODULE),$(resource_export_package)) 136 137endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 138 139java-dex: $(LOCAL_SOONG_DEX_JAR) 140 141 142# Copy test suite files. 143ifdef LOCAL_COMPATIBILITY_SUITE 144my_apks_to_install := $(foreach f,$(filter %.apk %.idsig,$(LOCAL_SOONG_BUILT_INSTALLED)),$(call word-colon,1,$(f))) 145$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 146 $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \ 147 $(foreach a,$(my_apks_to_install),\ 148 $(call compat-copy-pair,$(a),$(dir)/$(notdir $(a))))))) 149$(call create-suite-dependencies) 150endif 151 152# install symbol files of JNI libraries 153my_jni_lib_symbols_copy_files := $(foreach f,$(LOCAL_SOONG_JNI_LIBS_SYMBOLS),\ 154 $(call word-colon,1,$(f)):$(patsubst $(PRODUCT_OUT)/%,$(TARGET_OUT_UNSTRIPPED)/%,$(call word-colon,2,$(f)))) 155$(LOCAL_BUILT_MODULE): | $(call copy-many-files, $(my_jni_lib_symbols_copy_files)) 156 157# embedded JNI will already have been handled by soong 158my_embed_jni := 159my_prebuilt_jni_libs := 160ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 161 ifdef LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH) 162 my_2nd_arch_prefix := 163 LOCAL_JNI_SHARED_LIBRARIES := $(LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH)) 164 partition_lib_pairs := $(LOCAL_SOONG_JNI_LIBS_PARTITION_$(TARGET_ARCH)) 165 include $(BUILD_SYSTEM)/install_jni_libs_internal.mk 166 endif 167 ifdef TARGET_2ND_ARCH 168 ifdef LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH) 169 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 170 LOCAL_JNI_SHARED_LIBRARIES := $(LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH)) 171 partition_lib_pairs := $(LOCAL_SOONG_JNI_LIBS_PARTITION_$(TARGET_2ND_ARCH)) 172 include $(BUILD_SYSTEM)/install_jni_libs_internal.mk 173 endif 174 endif 175endif 176LOCAL_SHARED_JNI_LIBRARIES := 177my_embed_jni := 178my_prebuilt_jni_libs := 179my_2nd_arch_prefix := 180partition_lib_pairs := 181 182PACKAGES := $(PACKAGES) $(LOCAL_MODULE) 183ifndef LOCAL_CERTIFICATE 184 $(call pretty-error,LOCAL_CERTIFICATE must be set for soong_app_prebuilt.mk) 185endif 186ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) 187 # The magic string "PRESIGNED" means this package is already checked 188 # signed with its release key. 189 # 190 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be 191 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED") 192 # but the dexpreopt process will not try to re-sign the app. 193 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED 194else ifneq ($(LOCAL_CERTIFICATE),) 195 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE) 196 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(patsubst %.x509.pem,%.pk8,$(LOCAL_CERTIFICATE)) 197endif 198include $(BUILD_SYSTEM)/app_certificate_validate.mk 199PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) 200 201ifneq ($(LOCAL_MODULE_STEM),) 202 PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE_STEM) 203else 204 PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE) 205endif 206 207# Set a actual_partition_tag (calculated in base_rules.mk) for the package. 208PACKAGES.$(LOCAL_MODULE).PARTITION := $(actual_partition_tag) 209 210ifdef LOCAL_SOONG_BUNDLE 211 ALL_MODULES.$(my_register_name).BUNDLE := $(LOCAL_SOONG_BUNDLE) 212endif 213 214ifdef LOCAL_SOONG_LINT_REPORTS 215 ALL_MODULES.$(my_register_name).LINT_REPORTS := $(LOCAL_SOONG_LINT_REPORTS) 216endif 217 218ifndef LOCAL_IS_HOST_MODULE 219ifeq ($(LOCAL_SDK_VERSION),system_current) 220my_link_type := java:system 221else ifneq ($(LOCAL_SDK_VERSION),) 222my_link_type := java:sdk 223else 224my_link_type := java:platform 225endif 226# warn/allowed types are both empty because Soong modules can't depend on 227# make-defined modules. 228my_warn_types := 229my_allowed_types := 230 231my_link_deps := 232my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 233my_common := COMMON 234include $(BUILD_SYSTEM)/link_type.mk 235endif # !LOCAL_IS_HOST_MODULE 236 237ifeq (,$(filter tests,$(LOCAL_MODULE_TAGS))) 238 ifdef LOCAL_SOONG_DEVICE_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_DEVICE_RRO_DIRS), \ 245 vendor \ 246 ) 247 endif 248 249 ifdef LOCAL_SOONG_PRODUCT_RRO_DIRS 250 $(call append_enforce_rro_sources, \ 251 $(my_register_name), \ 252 false, \ 253 $(LOCAL_FULL_MANIFEST_FILE), \ 254 $(if $(LOCAL_EXPORT_PACKAGE_RESOURCES),true,false), \ 255 $(LOCAL_SOONG_PRODUCT_RRO_DIRS), \ 256 product \ 257 ) 258 endif 259endif 260 261ifdef LOCAL_PREBUILT_COVERAGE_ARCHIVE 262 my_coverage_dir := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path)) 263 my_coverage_copy_pairs := $(foreach f,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(f):$(my_coverage_dir)/$(notdir $(f))) 264 my_coverage_files := $(call copy-many-files,$(my_coverage_copy_pairs)) 265 $(LOCAL_INSTALLED_MODULE): $(my_coverage_files) 266endif 267 268SOONG_ALREADY_CONV += $(LOCAL_MODULE) 269 270########################################################### 271## SBOM generation 272########################################################### 273include $(BUILD_SBOM_GEN) 274