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