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_PROGUARD_DICT 55 $(eval $(call copy-one-file,$(LOCAL_SOONG_PROGUARD_DICT),\ 56 $(intermediates.COMMON)/proguard_dictionary)) 57 $(call add-dependency,$(LOCAL_BUILT_MODULE),\ 58 $(intermediates.COMMON)/proguard_dictionary) 59endif 60 61ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 62 my_res_package := $(intermediates.COMMON)/package-res.apk 63 64 $(my_res_package): $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE) 65 @echo "Copy: $@" 66 $(copy-file-to-target) 67 68 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_res_package)) 69 70 my_proguard_flags := $(intermediates.COMMON)/export_proguard_flags 71 $(my_proguard_flags): $(LOCAL_SOONG_EXPORT_PROGUARD_FLAGS) 72 @echo "Export proguard flags: $@" 73 rm -f $@ 74 touch $@ 75 for f in $+; do \ 76 echo -e "\n# including $$f" >>$@; \ 77 cat $$f >>$@; \ 78 done 79 80 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_proguard_flags)) 81 82 my_static_library_extra_packages := $(intermediates.COMMON)/extra_packages 83 $(eval $(call copy-one-file,$(LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES),$(my_static_library_extra_packages))) 84 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_extra_packages)) 85 86 my_static_library_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml 87 $(eval $(call copy-one-file,$(LOCAL_FULL_MANIFEST_FILE),$(my_static_library_android_manifest))) 88 $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_android_manifest)) 89endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE 90 91 92ifdef LOCAL_SOONG_DEX_JAR 93 ifndef LOCAL_IS_HOST_MODULE 94 ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),) # is_boot_jar 95 ifeq (true,$(WITH_DEXPREOPT)) 96 # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). 97 # We use this installed_odex trick to get boot.art installed. 98 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 99 # Append the odex for the 2nd arch if we have one. 100 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) 101 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex) 102 # Make sure to install the .odex and .vdex when you run "make <module_name>" 103 $(my_all_targets): $(installed_odex) 104 # Copy $(LOCAL_BUILT_MODULE) and its dependencies when installing boot.art 105 $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE): $(LOCAL_BUILT_MODULE) 106 endif 107 endif # is_boot_jar 108 109 $(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(common_javalib.jar))) 110 $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(common_javalib.jar))) 111 $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_jar))) 112 ifneq ($(TURBINE_ENABLED),false) 113 $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_header_jar))) 114 endif 115 endif 116 117 java-dex : $(LOCAL_BUILT_MODULE) 118else # LOCAL_SOONG_DEX_JAR 119 ifndef LOCAL_UNINSTALLABLE_MODULE 120 ifndef LOCAL_IS_HOST_MODULE 121 $(call pretty-error,Installable device module must have LOCAL_SOONG_DEX_JAR set) 122 endif 123 endif 124endif # LOCAL_SOONG_DEX_JAR 125 126my_built_installed := $(foreach f,$(LOCAL_SOONG_BUILT_INSTALLED),\ 127 $(call word-colon,1,$(f)):$(PRODUCT_OUT)$(call word-colon,2,$(f))) 128my_installed := $(call copy-many-files, $(my_built_installed)) 129ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed) 130ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(my_built_installed) 131ALL_MODULES.$(my_register_name).CLASSES_JAR := $(full_classes_jar) 132$(my_register_name): $(my_installed) 133 134ifdef LOCAL_SOONG_AAR 135 ALL_MODULES.$(LOCAL_MODULE).AAR := $(LOCAL_SOONG_AAR) 136endif 137 138javac-check : $(full_classes_jar) 139javac-check-$(LOCAL_MODULE) : $(full_classes_jar) 140.PHONY: javac-check-$(LOCAL_MODULE) 141 142ifndef LOCAL_IS_HOST_MODULE 143ifeq ($(LOCAL_SDK_VERSION),system_current) 144my_link_type := java:system 145else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) 146my_link_type := java:system 147else ifeq ($(LOCAL_SDK_VERSION),core_current) 148my_link_type := java:core 149else ifneq ($(LOCAL_SDK_VERSION),) 150my_link_type := java:sdk 151else 152my_link_type := java:platform 153endif 154# warn/allowed types are both empty because Soong modules can't depend on 155# make-defined modules. 156my_warn_types := 157my_allowed_types := 158 159my_link_deps := 160my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 161my_common := COMMON 162include $(BUILD_SYSTEM)/link_type.mk 163endif # !LOCAL_IS_HOST_MODULE 164 165# LOCAL_EXPORT_SDK_LIBRARIES set by soong is written to exported-sdk-libs file 166my_exported_sdk_libs_file := $(intermediates.COMMON)/exported-sdk-libs 167$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS := $(LOCAL_EXPORT_SDK_LIBRARIES) 168$(my_exported_sdk_libs_file): 169 @echo "Export SDK libs $@" 170 $(hide) mkdir -p $(dir $@) && rm -f $@ 171 $(if $(PRIVATE_EXPORTED_SDK_LIBS),\ 172 $(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\ 173 $(hide) touch $@) 174 175SOONG_ALREADY_CONV += $(LOCAL_MODULE) 176