Add JarJar support to BUILD_HOST_JAVA_LIBRARY
This will allow us to convert icu4j-icudata / icu4j-icutzdata
targets to "host" targets rather than "target" targets.
Right now they are forcing Jack off just so they can use
javac + jarjar (even though the resulting file is used on
host).
Bug: 27218410
(cherry picked from commit 30b21ad579fab9669ec00845bfa092e4318eed10)
Change-Id: I4f16896606bcfdd00164078eeb142d05b29bb832
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 052c571..97079fd 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -30,13 +30,15 @@
endif
full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
+full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
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_compiled_jar))
+full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(notdir $(full_classes_jarjar_jar))
LOCAL_INTERMEDIATE_TARGETS += \
$(full_classes_compiled_jar) \
+ $(full_classes_jarjar_jar) \
$(full_classes_emma_jar)
#######################################
@@ -49,30 +51,6 @@
include $(BUILD_SYSTEM)/java_common.mk
-ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
-$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
-$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
-ifdef LOCAL_EMMA_COVERAGE_FILTER
-$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER)
-else
-# by default, avoid applying emma instrumentation onto emma classes itself,
-# otherwise there will be exceptions thrown
-$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.*
-endif
-# this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and
-# $(full_classes_emma_jar)
-$(full_classes_emma_jar) : $(full_classes_compiled_jar) | $(EMMA_JAR)
- $(transform-classes.jar-to-emma)
-
-$(built_javalib_jar) : $(full_classes_emma_jar)
- @echo Copying: $@
- $(hide) $(ACP) -fp $< $@
-
-else # LOCAL_EMMA_INSTRUMENT
-# Directly build into $(built_javalib_jar).
-full_classes_compiled_jar := $(built_javalib_jar)
-endif # LOCAL_EMMA_INSTRUMENT
-
# The layers file allows you to enforce a layering between java packages.
# Run build/tools/java-layers.py for more details.
layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
@@ -91,3 +69,41 @@
$(LOCAL_MODULE_MAKEFILE_DEP) \
$(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-host-java-to-package)
+
+# Run jarjar if necessary, otherwise just copy the file.
+ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
+$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+ @echo JarJar: $@
+ $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+else
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+endif
+
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
+$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
+ifdef LOCAL_EMMA_COVERAGE_FILTER
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER)
+else
+# by default, avoid applying emma instrumentation onto emma classes itself,
+# otherwise there will be exceptions thrown
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.*
+endif
+# this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and
+# $(full_classes_emma_jar)
+$(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR)
+ $(transform-classes.jar-to-emma)
+
+$(built_javalib_jar) : $(full_classes_emma_jar)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+
+else # LOCAL_EMMA_INSTRUMENT
+$(built_javalib_jar): $(full_classes_jarjar_jar) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+endif # LOCAL_EMMA_INSTRUMENT
+