1# Java prebuilt coming from Soong. 2# Extra inputs: 3# LOCAL_SOONG_BUILT_INSTALLED 4# LOCAL_SOONG_CLASSES_JAR 5# LOCAL_SOONG_HEADER_JAR 6# LOCAL_SOONG_DEX_JAR 7# LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR 8# LOCAL_SOONG_DEXPREOPT_CONFIG 9 10ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 11 $(call pretty-error,soong_java_prebuilt.mk may only be used from Soong) 12endif 13 14LOCAL_MODULE_SUFFIX := .jar 15LOCAL_BUILT_MODULE_STEM := javalib.jar 16 17intermediates.COMMON := $(call local-intermediates-dir,COMMON) 18 19full_classes_jar := $(intermediates.COMMON)/classes.jar 20full_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar 21full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar 22common_javalib.jar := $(intermediates.COMMON)/javalib.jar 23 24ifdef LOCAL_SOONG_AAR 25 LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_AAR) 26endif 27 28####################################### 29include $(BUILD_SYSTEM)/base_rules.mk 30####################################### 31 32ifdef LOCAL_SOONG_CLASSES_JAR 33 $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_jar))) 34 $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_pre_proguard_jar))) 35 $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(full_classes_jar))) 36 37 ifneq ($(TURBINE_ENABLED),false) 38 ifdef LOCAL_SOONG_HEADER_JAR 39 $(eval $(call copy-one-file,$(LOCAL_SOONG_HEADER_JAR),$(full_classes_header_jar))) 40 else 41 $(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_header_jar))) 42 endif 43 endif # TURBINE_ENABLED != false 44endif 45 46$(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE))) 47 48ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR 49 $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\ 50 $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar)) 51 $(call add-dependency,$(common_javalib.jar),\ 52 $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar) 53endif 54 55ifdef LOCAL_SOONG_PROGUARD_DICT 56 $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\ 57 $(intermediates.COMMON)/proguard_dictionary)) 58 $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\ 59 $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)) 60 $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),\ 61 $(call local-packaging-dir,proguard_dictionary)/classes.jar)) 62 $(call add-dependency,$(common_javalib.jar),\ 63 $(intermediates.COMMON)/proguard_dictionary) 64 $(call add-dependency,$(common_javalib.jar),\ 65 $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary) 66 $(call add-dependency,$(common_javalib.jar),\ 67 $(call local-packaging-dir,proguard_dictionary)/classes.jar) 68endif 69 70ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP 71 $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_USAGE_ZIP),\ 72 $(call local-packaging-dir,proguard_usage)/proguard_usage.zip)) 73 $(call add-dependency,$(common_javalib.jar),\ 74 $(call local-packaging-dir,proguard_usage)/proguard_usage.zip) 75endif 76 77 78ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 79 my_res_package := $(intermediates.COMMON)/package-res.apk 80 81 $(my_res_package): $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE) 82 @echo "Copy: $@" 83 $(copy-file-to-target) 84 85 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_res_package)) 86 87 my_proguard_flags := $(intermediates.COMMON)/export_proguard_flags 88 $(my_proguard_flags): $(LOCAL_SOONG_EXPORT_PROGUARD_FLAGS) 89 @echo "Export proguard flags: $@" 90 rm -f $@ 91 touch $@ 92 for f in $+; do \ 93 echo -e "\n# including $$f" >>$@; \ 94 cat $$f >>$@; \ 95 done 96 97 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_proguard_flags)) 98 99 my_static_library_extra_packages := $(intermediates.COMMON)/extra_packages 100 $(eval $(call copy-one-file,$(LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES),$(my_static_library_extra_packages))) 101 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_extra_packages)) 102 103 my_static_library_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml 104 $(eval $(call copy-one-file,$(LOCAL_FULL_MANIFEST_FILE),$(my_static_library_android_manifest))) 105 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_android_manifest)) 106endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 107 108 109ifdef LOCAL_SOONG_DEX_JAR 110 ifndef LOCAL_IS_HOST_MODULE 111 boot_jars := $(foreach pair,$(PRODUCT_BOOT_JARS), $(call word-colon,2,$(pair))) 112 ifneq ($(filter $(LOCAL_MODULE),$(boot_jars)),) # is_boot_jar 113 ifeq (true,$(WITH_DEXPREOPT)) 114 # $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE) contains modules that installs 115 # all of bootjars' dexpreopt files (.art, .oat, .vdex, ...) 116 # Add them to the required list so they are installed alongside this module. 117 ALL_MODULES.$(my_register_name).REQUIRED_FROM_TARGET += \ 118 $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE) \ 119 $(2ND_DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE) 120 # Copy $(LOCAL_BUILT_MODULE) and its dependencies when installing boot.art 121 # so that dependencies of $(LOCAL_BUILT_MODULE) (which may include 122 # jacoco-report-classes.jar) are copied for every build. 123 $(foreach m,$(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE) $(2ND_DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE), \ 124 $(eval $(call add-dependency,$(firstword $(call module-installed-files,$(m))),$(LOCAL_BUILT_MODULE))) \ 125 ) 126 endif 127 endif # is_boot_jar 128 129 $(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(common_javalib.jar))) 130 $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(common_javalib.jar))) 131 ifdef LOCAL_SOONG_CLASSES_JAR 132 $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_jar))) 133 ifneq ($(TURBINE_ENABLED),false) 134 $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_header_jar))) 135 endif 136 endif 137 endif 138 139 java-dex : $(LOCAL_BUILT_MODULE) 140else # LOCAL_SOONG_DEX_JAR 141 ifndef LOCAL_UNINSTALLABLE_MODULE 142 ifndef LOCAL_IS_HOST_MODULE 143 $(call pretty-error,Installable device module must have LOCAL_SOONG_DEX_JAR set) 144 endif 145 endif 146endif # LOCAL_SOONG_DEX_JAR 147 148my_built_installed := $(foreach f,$(LOCAL_SOONG_BUILT_INSTALLED),\ 149 $(call word-colon,1,$(f)):$(PRODUCT_OUT)$(call word-colon,2,$(f))) 150my_installed := $(call copy-many-files, $(my_built_installed)) 151ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed) 152ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(my_built_installed) 153ALL_MODULES.$(my_register_name).CLASSES_JAR := $(full_classes_jar) 154$(my_register_name): $(my_installed) 155 156ifdef LOCAL_SOONG_AAR 157 ALL_MODULES.$(my_register_name).AAR := $(LOCAL_SOONG_AAR) 158endif 159 160# Copy dexpreopt.config files from Soong libraries to the location where Make 161# modules can find them. 162ifdef LOCAL_SOONG_DEXPREOPT_CONFIG 163 $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(call local-intermediates-dir,)/dexpreopt.config)) 164 my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config 165 $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config))) 166 $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config) 167endif 168 169ifdef LOCAL_SOONG_CLASSES_JAR 170javac-check : $(full_classes_jar) 171javac-check-$(LOCAL_MODULE) : $(full_classes_jar) 172endif 173.PHONY: javac-check-$(LOCAL_MODULE) 174 175ifndef LOCAL_IS_HOST_MODULE 176ifeq ($(LOCAL_SDK_VERSION),system_current) 177my_link_type := java:system 178else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) 179my_link_type := java:system 180else ifeq ($(LOCAL_SDK_VERSION),core_current) 181my_link_type := java:core 182else ifneq ($(LOCAL_SDK_VERSION),) 183my_link_type := java:sdk 184else 185my_link_type := java:platform 186endif 187# warn/allowed types are both empty because Soong modules can't depend on 188# make-defined modules. 189my_warn_types := 190my_allowed_types := 191 192my_link_deps := 193my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 194my_common := COMMON 195include $(BUILD_SYSTEM)/link_type.mk 196endif # !LOCAL_IS_HOST_MODULE 197 198# LOCAL_EXPORT_SDK_LIBRARIES set by soong is written to exported-sdk-libs file 199my_exported_sdk_libs_file := $(intermediates.COMMON)/exported-sdk-libs 200$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS := $(LOCAL_EXPORT_SDK_LIBRARIES) 201$(my_exported_sdk_libs_file): 202 @echo "Export SDK libs $@" 203 $(hide) mkdir -p $(dir $@) && rm -f $@ 204 $(if $(PRIVATE_EXPORTED_SDK_LIBS),\ 205 $(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\ 206 $(hide) touch $@) 207 208SOONG_ALREADY_CONV += $(LOCAL_MODULE) 209