forked from openkylin/platform_build
Add LOCAL_SRCJARS support
Allow java modules to take jars containing .java files as an input. For turbine, pass them directly to turbine. For javac, extract them to a directory and pass a list of the files to javac. Bug: 73885582 Test: m checkbuild Change-Id: Ib4351a5b4b165a55e5fb02ee2680466db368983a
This commit is contained in:
parent
93d6550c53
commit
11e2d55c0f
|
@ -2228,9 +2228,11 @@ endef
|
||||||
# $(2): classpath_libs
|
# $(2): classpath_libs
|
||||||
define compile-java
|
define compile-java
|
||||||
$(hide) rm -f $@
|
$(hide) rm -f $@
|
||||||
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
|
$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR) $(if $(PRIVATE_SRCJARS),$(PRIVATE_SRCJAR_INTERMEDIATES_DIR))
|
||||||
$(hide) mkdir -p $(dir $@)
|
$(hide) mkdir -p $(dir $@)
|
||||||
$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR)
|
$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_ANNO_INTERMEDIATES_DIR) $(if $(PRIVATE_SRCJARS),$(PRIVATE_SRCJAR_INTERMEDIATES_DIR))
|
||||||
|
$(if $(PRIVATE_SRCJARS),\
|
||||||
|
$(EXTRACT_SRCJARS) $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) $(PRIVATE_SRCJAR_LIST_FILE) $(PRIVATE_SRCJARS))
|
||||||
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
|
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
|
||||||
$(SOONG_JAVAC_WRAPPER) $(JAVAC_WRAPPER) $(1) -encoding UTF-8 \
|
$(SOONG_JAVAC_WRAPPER) $(JAVAC_WRAPPER) $(1) -encoding UTF-8 \
|
||||||
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
$(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
|
||||||
|
@ -2250,6 +2252,7 @@ $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
|
||||||
-d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \
|
-d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \
|
||||||
$(PRIVATE_JAVACFLAGS) \
|
$(PRIVATE_JAVACFLAGS) \
|
||||||
\@$(PRIVATE_JAVA_SOURCE_LIST) \
|
\@$(PRIVATE_JAVA_SOURCE_LIST) \
|
||||||
|
$(if $(PRIVATE_SRCJARS),\@$(PRIVATE_SRCJAR_LIST_FILE)) \
|
||||||
|| ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
|
|| ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
|
||||||
fi
|
fi
|
||||||
$(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/make/tools/java-layers.py \
|
$(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/make/tools/java-layers.py \
|
||||||
|
@ -2278,7 +2281,7 @@ define transform-java-to-header.jar
|
||||||
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
|
$(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \
|
||||||
$(JAVA) -jar $(TURBINE) \
|
$(JAVA) -jar $(TURBINE) \
|
||||||
--output $@.premerged --temp_dir $(dir $@)/classes-turbine \
|
--output $@.premerged --temp_dir $(dir $@)/classes-turbine \
|
||||||
--sources \@$(PRIVATE_JAVA_SOURCE_LIST) \
|
--sources \@$(PRIVATE_JAVA_SOURCE_LIST) --source_jars $(PRIVATE_SRCJARS) \
|
||||||
--javacopts $(PRIVATE_JAVACFLAGS) $(COMMON_JDK_FLAGS) \
|
--javacopts $(PRIVATE_JAVACFLAGS) $(COMMON_JDK_FLAGS) \
|
||||||
$(addprefix --bootclasspath ,$(strip \
|
$(addprefix --bootclasspath ,$(strip \
|
||||||
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
|
$(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \
|
||||||
|
|
|
@ -76,6 +76,7 @@ java_sources_deps := \
|
||||||
$(java_sources) \
|
$(java_sources) \
|
||||||
$(java_resource_sources) \
|
$(java_resource_sources) \
|
||||||
$(proto_java_sources_file_stamp) \
|
$(proto_java_sources_file_stamp) \
|
||||||
|
$(LOCAL_SRCJARS) \
|
||||||
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||||
|
|
||||||
$(java_source_list_file): $(java_sources_deps)
|
$(java_source_list_file): $(java_sources_deps)
|
||||||
|
@ -86,6 +87,9 @@ $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annota
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
|
||||||
$(full_classes_compiled_jar): \
|
$(full_classes_compiled_jar): \
|
||||||
$(java_source_list_file) \
|
$(java_source_list_file) \
|
||||||
$(java_sources_deps) \
|
$(java_sources_deps) \
|
||||||
|
@ -95,6 +99,7 @@ $(full_classes_compiled_jar): \
|
||||||
$(annotation_processor_deps) \
|
$(annotation_processor_deps) \
|
||||||
$(NORMALIZE_PATH) \
|
$(NORMALIZE_PATH) \
|
||||||
$(JAR_ARGS) \
|
$(JAR_ARGS) \
|
||||||
|
$(EXTRACT_SRCJARS) \
|
||||||
| $(SOONG_JAVAC_WRAPPER)
|
| $(SOONG_JAVAC_WRAPPER)
|
||||||
$(transform-host-java-to-dalvik-package)
|
$(transform-host-java-to-dalvik-package)
|
||||||
|
|
||||||
|
@ -102,6 +107,7 @@ ifneq ($(TURBINE_ENABLED),false)
|
||||||
|
|
||||||
$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
|
$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
|
||||||
$(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
|
$(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
|
||||||
|
$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
|
||||||
$(full_classes_turbine_jar): \
|
$(full_classes_turbine_jar): \
|
||||||
$(java_source_list_file) \
|
$(java_source_list_file) \
|
||||||
$(java_sources_deps) \
|
$(java_sources_deps) \
|
||||||
|
|
|
@ -63,6 +63,7 @@ java_sources_deps := \
|
||||||
$(java_sources) \
|
$(java_sources) \
|
||||||
$(java_resource_sources) \
|
$(java_resource_sources) \
|
||||||
$(proto_java_sources_file_stamp) \
|
$(proto_java_sources_file_stamp) \
|
||||||
|
$(LOCAL_SRCJARS) \
|
||||||
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||||
|
|
||||||
$(java_source_list_file): $(java_sources_deps)
|
$(java_source_list_file): $(java_sources_deps)
|
||||||
|
@ -73,6 +74,9 @@ $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annota
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
|
||||||
$(full_classes_compiled_jar): \
|
$(full_classes_compiled_jar): \
|
||||||
$(java_source_list_file) \
|
$(java_source_list_file) \
|
||||||
$(java_sources_deps) \
|
$(java_sources_deps) \
|
||||||
|
@ -82,6 +86,7 @@ $(full_classes_compiled_jar): \
|
||||||
$(NORMALIZE_PATH) \
|
$(NORMALIZE_PATH) \
|
||||||
$(ZIPTIME) \
|
$(ZIPTIME) \
|
||||||
$(JAR_ARGS) \
|
$(JAR_ARGS) \
|
||||||
|
$(EXTRACT_SRCJARS) \
|
||||||
| $(SOONG_JAVAC_WRAPPER)
|
| $(SOONG_JAVAC_WRAPPER)
|
||||||
$(transform-host-java-to-package)
|
$(transform-host-java-to-package)
|
||||||
$(remove-timestamps-from-package)
|
$(remove-timestamps-from-package)
|
||||||
|
|
|
@ -401,6 +401,7 @@ java_sources_deps := \
|
||||||
$(java_resource_sources) \
|
$(java_resource_sources) \
|
||||||
$(RenderScript_file_stamp) \
|
$(RenderScript_file_stamp) \
|
||||||
$(proto_java_sources_file_stamp) \
|
$(proto_java_sources_file_stamp) \
|
||||||
|
$(LOCAL_SRCJARS) \
|
||||||
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
$(LOCAL_ADDITIONAL_DEPENDENCIES)
|
||||||
|
|
||||||
$(java_source_list_file): $(java_sources_deps)
|
$(java_source_list_file): $(java_sources_deps)
|
||||||
|
@ -409,6 +410,7 @@ $(java_source_list_file): $(java_sources_deps)
|
||||||
ifneq ($(TURBINE_ENABLED),false)
|
ifneq ($(TURBINE_ENABLED),false)
|
||||||
|
|
||||||
$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
|
$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
|
||||||
|
$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
|
||||||
$(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
|
$(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
|
||||||
$(full_classes_turbine_jar): \
|
$(full_classes_turbine_jar): \
|
||||||
$(java_source_list_file) \
|
$(java_source_list_file) \
|
||||||
|
@ -446,6 +448,9 @@ $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUD
|
||||||
$(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
|
$(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
|
||||||
$(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file)
|
$(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file)
|
||||||
$(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs)
|
$(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs)
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list
|
||||||
|
$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
|
||||||
$(full_classes_compiled_jar): \
|
$(full_classes_compiled_jar): \
|
||||||
$(java_source_list_file) \
|
$(java_source_list_file) \
|
||||||
$(full_java_header_libs) \
|
$(full_java_header_libs) \
|
||||||
|
@ -456,6 +461,7 @@ $(full_classes_compiled_jar): \
|
||||||
$(annotation_processor_deps) \
|
$(annotation_processor_deps) \
|
||||||
$(NORMALIZE_PATH) \
|
$(NORMALIZE_PATH) \
|
||||||
$(JAR_ARGS) \
|
$(JAR_ARGS) \
|
||||||
|
$(EXTRACT_SRCJARS) \
|
||||||
| $(SOONG_JAVAC_WRAPPER)
|
| $(SOONG_JAVAC_WRAPPER)
|
||||||
@echo "Target Java: $@
|
@echo "Target Java: $@
|
||||||
$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
|
$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
|
||||||
|
|
|
@ -188,7 +188,7 @@ endif
|
||||||
# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
|
# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
|
||||||
# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
|
# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
|
||||||
# You have to set up the dependency in some other way.
|
# You have to set up the dependency in some other way.
|
||||||
need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
|
need_compile_java := $(strip $(all_java_sources)$(LOCAL_SRCJARS)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
|
||||||
ifdef need_compile_java
|
ifdef need_compile_java
|
||||||
|
|
||||||
annotation_processor_flags :=
|
annotation_processor_flags :=
|
||||||
|
|
|
@ -274,7 +274,7 @@ endif # EMMA_INSTRUMENT is true
|
||||||
|
|
||||||
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
||||||
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
|
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
|
||||||
ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
|
ifneq ($(LOCAL_SRC_FILES)$(LOCAL_SRCJARS)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
|
||||||
# Only add jacocoagent if the package contains some java code
|
# Only add jacocoagent if the package contains some java code
|
||||||
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
|
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
|
||||||
# Exclude jacoco classes from proguard
|
# Exclude jacoco classes from proguard
|
||||||
|
|
Loading…
Reference in New Issue