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