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 9ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 10 $(call pretty-error,soong_java_prebuilt.mk may only be used from Soong) 11endif 12 13LOCAL_MODULE_SUFFIX := .jar 14LOCAL_BUILT_MODULE_STEM := javalib.jar 15 16intermediates.COMMON := $(call local-intermediates-dir,COMMON) 17 18full_classes_jar := $(intermediates.COMMON)/classes.jar 19full_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar 20full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar 21common_javalib.jar := $(intermediates.COMMON)/javalib.jar 22 23ifdef LOCAL_SOONG_AAR 24 LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_AAR) 25endif 26 27####################################### 28include $(BUILD_SYSTEM)/base_rules.mk 29####################################### 30 31ifdef LOCAL_SOONG_CLASSES_JAR 32 $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_jar))) 33 $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_pre_proguard_jar))) 34 $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(full_classes_jar))) 35 36 ifneq ($(TURBINE_ENABLED),false) 37 ifdef LOCAL_SOONG_HEADER_JAR 38 $(eval $(call copy-one-file,$(LOCAL_SOONG_HEADER_JAR),$(full_classes_header_jar))) 39 else 40 $(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_header_jar))) 41 endif 42 endif # TURBINE_ENABLED != false 43endif 44 45$(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE))) 46 47ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR 48 $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\ 49 $(intermediates.COMMON)/jacoco-report-classes.jar)) 50 $(call add-dependency,$(common_javalib.jar),\ 51 $(intermediates.COMMON)/jacoco-report-classes.jar) 52endif 53 54ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 55 my_res_package := $(intermediates.COMMON)/package-res.apk 56 57 $(my_res_package): $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE) 58 @echo "Copy: $@" 59 $(copy-file-to-target) 60 61 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_res_package)) 62 63 my_proguard_flags := $(intermediates.COMMON)/export_proguard_flags 64 $(my_proguard_flags): $(LOCAL_SOONG_EXPORT_PROGUARD_FLAGS) 65 @echo "Export proguard flags: $@" 66 rm -f $@ 67 touch $@ 68 for f in $+; do \ 69 echo -e "\n# including $$f" >>$@; \ 70 cat $$f >>$@; \ 71 done 72 73 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_proguard_flags)) 74 75 my_static_library_extra_packages := $(intermediates.COMMON)/extra_packages 76 $(eval $(call copy-one-file,$(LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES),$(my_static_library_extra_packages))) 77 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_extra_packages)) 78 79 my_static_library_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml 80 $(eval $(call copy-one-file,$(LOCAL_FULL_MANIFEST_FILE),$(my_static_library_android_manifest))) 81 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_android_manifest)) 82endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 83 84 85ifdef LOCAL_SOONG_DEX_JAR 86 ifndef LOCAL_IS_HOST_MODULE 87 ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),) # is_boot_jar 88 ifeq (true,$(WITH_DEXPREOPT)) 89 # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). 90 # We use this installed_odex trick to get boot.art installed. 91 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 92 # Append the odex for the 2nd arch if we have one. 93 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 94 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex) 95 # Make sure to install the .odex and .vdex when you run "make <module_name>" 96 $(my_all_targets): $(installed_odex) 97 # Copy $(LOCAL_BUILT_MODULE) and its dependencies when installing boot.art 98 $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE): $(LOCAL_BUILT_MODULE) 99 endif 100 endif # is_boot_jar 101 102 $(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(common_javalib.jar))) 103 $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(common_javalib.jar))) 104 $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_jar))) 105 ifneq ($(TURBINE_ENABLED),false) 106 $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_header_jar))) 107 endif 108 endif 109 110 java-dex : $(LOCAL_BUILT_MODULE) 111else # LOCAL_SOONG_DEX_JAR 112 ifndef LOCAL_UNINSTALLABLE_MODULE 113 ifndef LOCAL_IS_HOST_MODULE 114 $(call pretty-error,Installable device module must have LOCAL_SOONG_DEX_JAR set) 115 endif 116 endif 117endif # LOCAL_SOONG_DEX_JAR 118 119my_built_installed := $(foreach f,$(LOCAL_SOONG_BUILT_INSTALLED),\ 120 $(call word-colon,1,$(f)):$(PRODUCT_OUT)$(call word-colon,2,$(f))) 121my_installed := $(call copy-many-files, $(my_built_installed)) 122ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed) 123ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(my_built_installed) 124$(my_register_name): $(my_installed) 125 126ifdef LOCAL_SOONG_AAR 127 ALL_MODULES.$(LOCAL_MODULE).AAR := $(LOCAL_SOONG_AAR) 128endif 129 130javac-check : $(full_classes_jar) 131javac-check-$(LOCAL_MODULE) : $(full_classes_jar) 132.PHONY: javac-check-$(LOCAL_MODULE) 133 134ifndef LOCAL_IS_HOST_MODULE 135ifeq ($(LOCAL_SDK_VERSION),system_current) 136my_link_type := java:system 137else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) 138my_link_type := java:system 139else ifeq ($(LOCAL_SDK_VERSION),core_current) 140my_link_type := java:core 141else ifneq ($(LOCAL_SDK_VERSION),) 142my_link_type := java:sdk 143else 144my_link_type := java:platform 145endif 146# warn/allowed types are both empty because Soong modules can't depend on 147# make-defined modules. 148my_warn_types := 149my_allowed_types := 150 151my_link_deps := 152my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 153my_common := COMMON 154include $(BUILD_SYSTEM)/link_type.mk 155endif # !LOCAL_IS_HOST_MODULE 156 157# LOCAL_EXPORT_SDK_LIBRARIES set by soong is written to exported-sdk-libs file 158my_exported_sdk_libs_file := $(intermediates.COMMON)/exported-sdk-libs 159$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS := $(LOCAL_EXPORT_SDK_LIBRARIES) 160$(my_exported_sdk_libs_file): 161 @echo "Export SDK libs $@" 162 $(hide) mkdir -p $(dir $@) && rm -f $@ 163 $(if $(PRIVATE_EXPORTED_SDK_LIBS),\ 164 $(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\ 165 $(hide) touch $@) 166 167SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE) 168