diff --git a/core/definitions.mk b/core/definitions.mk index 07a89488c..94b043694 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -681,7 +681,7 @@ endef # $(1): library name # $(2): Non-empty if IS_HOST_MODULE define _java-lib-full-classes.jar -$(call _java-lib-dir,$(1),$(2))/$(if $(2),javalib,classes)$(COMMON_JAVA_PACKAGE_SUFFIX) +$(call _java-lib-dir,$(1),$(2))/classes.jar endef # Get the jar files (you can pass to "javac -classpath") of static or shared @@ -704,14 +704,6 @@ define java-lib-deps $(call java-lib-files,$(1),$(2)) endef -# Get the jar files (you can pass to "javac -classpath") of host dalvik Java libraries. -# You can also use them as dependency files. -# A host dalvik Java library is different from a host Java library in that -# the java lib file is classes.jar, not javalib.jar. -# $(1): library name list -define host-dex-java-lib-files -$(foreach lib,$(1),$(call _java-lib-dir,$(lib),true)/classes.jar) -endef ########################################################### ## Convert "core ext framework" to "out/.../classes.jack ..." diff --git a/core/host_java_library.mk b/core/host_java_library.mk index 42d3efb1b..3e70eba4e 100644 --- a/core/host_java_library.mk +++ b/core/host_java_library.mk @@ -37,6 +37,7 @@ emma_intermediates_dir := $(intermediates.COMMON)/emma_out # emma is hardcoded to use the leaf name of its input for the output file -- # only the output directory can be changed full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(notdir $(full_classes_jarjar_jar)) +full_classes_jar := $(intermediates.COMMON)/classes.jar LOCAL_INTERMEDIATE_TARGETS += \ $(full_classes_compiled_jar) \ @@ -104,3 +105,4 @@ full_classes_emma_jar := $(full_classes_jarjar_jar) endif # LOCAL_EMMA_INSTRUMENT $(eval $(call copy-one-file,$(full_classes_emma_jar),$(LOCAL_BUILT_MODULE))) +$(eval $(call copy-one-file,$(full_classes_emma_jar),$(full_classes_jar))) diff --git a/core/java.mk b/core/java.mk index affd15fad..009d80792 100644 --- a/core/java.mk +++ b/core/java.mk @@ -640,7 +640,7 @@ $(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) ifeq ($(LOCAL_EMMA_INSTRUMENT),true) $(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals endif -$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX) +$(built_dex_intermediate): $(full_classes_jar) $(DX) $(transform-classes.jar-to-dex) endif # LOCAL_JACK_ENABLED is disabled diff --git a/core/java_common.mk b/core/java_common.mk index cd3d5b98b..67943a451 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -151,7 +151,7 @@ ifdef need_compile_java full_static_java_libs := \ $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ $(call intermediates-dir-for, \ - JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar) + JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jar) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs) @@ -216,11 +216,11 @@ ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true) ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) my_bootclasspath := "" else -my_bootclasspath := $(call normalize-path-list,$(call host-dex-java-lib-files,core-oj-hostdex core-libart-hostdex)) +my_bootclasspath := $(call normalize-path-list,$(call java-lib-files,core-oj-hostdex core-libart-hostdex,true)) endif $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(my_bootclasspath) -full_shared_java_libs := $(call host-dex-java-lib-files,$(LOCAL_JAVA_LIBRARIES)) +full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true) full_java_lib_deps := $(full_shared_java_libs) else # !USE_CORE_LIB_BOOTCLASSPATH $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := diff --git a/core/java_library.mk b/core/java_library.mk index 8f84dc6ad..9db587df4 100644 --- a/core/java_library.mk +++ b/core/java_library.mk @@ -35,9 +35,14 @@ LOCAL_BUILT_MODULE_STEM := classes.jack endif endif +# For non-static java libraries, other modules should depend on +# out/target/common/obj/JAVA_LIBRARIES/.../javalib.jar (for jack) +# or out/target/common/obj/JAVA_LIBRARIES/.../classes.jar (for javac). +# For static java libraries, other modules should depend on +# out/target/common/obj/JAVA_LIBRARIES/.../classes.jar +# There are some dependencies outside the build system that assume static +# java libraries produce javalib.jar, so we will copy classes.jar there too. intermediates.COMMON := $(call local-intermediates-dir,COMMON) - -# This file will be the one that other modules should depend on. common_javalib.jar := $(intermediates.COMMON)/javalib.jar LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar) @@ -65,18 +70,15 @@ include $(BUILD_SYSTEM)/java.mk ################################# ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) -# No dex; all we want are the .class files with resources. -$(common_javalib.jar) : $(java_resource_sources) -$(common_javalib.jar) : $(full_classes_jar) - @echo "target Static Jar: $(PRIVATE_MODULE) ($@)" - $(copy-file-to-target) +# There are some dependencies outside the build system that assume classes.jar +# is available as javalib.jar so copy it there too. +$(eval $(call copy-one-file,$(full_classes_jar),$(common_javalib.jar))) ifdef LOCAL_JACK_ENABLED -$(LOCAL_BUILT_MODULE) : $(full_classes_jack) +$(eval $(call copy-one-file,$(full_classes_jack),$(LOCAL_BUILT_MODULE))) else -$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) +$(eval $(call copy-one-file,$(full_classes_jar),$(LOCAL_BUILT_MODULE))) endif - $(copy-file-to-target) else # !LOCAL_IS_STATIC_JAVA_LIBRARY @@ -100,8 +102,7 @@ ifdef LOCAL_DEX_PREOPT ifneq ($(dexpreopt_boot_jar_module),) # boot jar # boot jar's rules are defined in dex_preopt.mk dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar -$(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) - $(call copy-file-to-target) +$(eval $(call copy-one-file,$(dexpreopted_boot_jar),$(LOCAL_BUILT_MODULE))) # For libart boot jars, we don't have .odex files. else # ! boot jar @@ -111,8 +112,7 @@ $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar) @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" $(call dexpreopt-one-file,$<,$@) -$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) - $(call copy-file-to-target) +$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE))) ifneq (nostripping,$(LOCAL_DEX_PREOPT)) $(call dexpreopt-remove-classes.dex,$@) endif @@ -120,8 +120,7 @@ endif endif # ! boot jar else # LOCAL_DEX_PREOPT -$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) - $(call copy-file-to-target) +$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE))) endif # LOCAL_DEX_PREOPT endif # !LOCAL_IS_STATIC_JAVA_LIBRARY diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk index 77c57ab4b..c53d75501 100644 --- a/core/multi_prebuilt.mk +++ b/core/multi_prebuilt.mk @@ -116,7 +116,7 @@ $(call auto-prebuilt-boilerplate, \ $(prebuilt_module_tags), \ , \ , \ - javalib.jar) + $(if $(prebuilt_is_host),classes.jar,javalib.jar)) $(call auto-prebuilt-boilerplate, \ $(prebuilt_static_java_libraries), \ @@ -125,7 +125,7 @@ $(call auto-prebuilt-boilerplate, \ $(prebuilt_module_tags), \ , \ true, \ - javalib.jar) + classes.jar) prebuilt_static_libs := prebuilt_shared_libs := diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 56f6cf0f6..de443697f 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -433,7 +433,22 @@ endif # LOCAL_MODULE_CLASS != APPS ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) my_src_jar := $(my_prebuilt_src_file) -ifeq ($(LOCAL_IS_HOST_MODULE),) + +ifdef LOCAL_IS_HOST_MODULE +# for host java libraries deps should be in the common dir, so we make a copy in +# the common dir. +common_classes_jar := $(intermediates.COMMON)/classes.jar +common_javalib_jar := $(intermediates.COMMON)/javalib.jar + +$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE) + +$(common_classes_jar) : $(my_src_jar) + $(transform-prebuilt-to-target) + +$(common_javalib_jar) : $(common_classes_jar) + $(transform-prebuilt-to-target) + +else # !LOCAL_IS_HOST_MODULE # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir, # while the deps should be in the common dir, so we make a copy in the common dir. common_classes_jar := $(intermediates.COMMON)/classes.jar @@ -526,6 +541,7 @@ endif # LOCAL_IS_HOST_MODULE is not set ifneq ($(prebuilt_module_is_dex_javalib),true) +ifdef LOCAL_JACK_ENABLED # We may be building classes.jack from a host jar for host dalvik Java library. $(intermediates.COMMON)/classes.jack : PRIVATE_JACK_FLAGS:=$(LOCAL_JACK_FLAGS) $(intermediates.COMMON)/classes.jack : PRIVATE_JACK_MIN_SDK_VERSION := $(if $(strip $(LOCAL_MIN_SDK_VERSION)),$(LOCAL_MIN_SDK_VERSION),1) @@ -540,7 +556,7 @@ $(intermediates.COMMON)/classes.jack : $(LOCAL_JACK_PLUGIN_PATH) $(my_src_jar) \ # always rebuilt. $(intermediates.COMMON)/classes.dex.toc: $(intermediates.COMMON)/classes.jack touch $@ - +endif # LOCAL_JACK_ENABLED endif # ! prebuilt_module_is_dex_javalib endif # JAVA_LIBRARIES