Use the correct jars to host gtests.

Before this change, host gtests use the host variant of boot jars, while
they also use the boot images generated from the APEX variant of boot
jars, causing checksum mismatches.

Actually, `dexpreopt_bootjars` uses a single source of input, which is
`out/soong/$(PRODUCT_DEVICE)/dex_*jars_input` (copied from the APEX
variant), to generate boot images, regardless of the variant. Therefore,
host gtests should use the same jars.

Bug: 210410981
Test: Patch aosp/1915157 and run `art/test.py --host -g`.
Change-Id: I1f3078906dc3f962c2b490862f109e04682da7ce
diff --git a/build/Android.common_path.mk b/build/Android.common_path.mk
index 3d04763..345a869 100644
--- a/build/Android.common_path.mk
+++ b/build/Android.common_path.mk
@@ -64,10 +64,15 @@
 TARGET_CORE_IMG_DEX_FILES := $(foreach jar,$(TARGET_CORE_IMG_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar).com.android.art.testing, ,COMMON)/javalib.jar)
 
 # Also copy the jar files next to host boot.art image.
+# `dexpreopt_bootjars.go` uses a single source of input regardless of variants, so we should use the
+# same source for `CORE_IMG_JARS` to avoid checksum mismatches on the oat files.
 HOST_BOOT_IMAGE_JARS := $(foreach jar,$(CORE_IMG_JARS),$(HOST_OUT)/apex/com.android.art/javalib/$(jar).jar)
-$(HOST_BOOT_IMAGE_JARS): $(HOST_OUT)/apex/com.android.art/javalib/%.jar : $(HOST_OUT_JAVA_LIBRARIES)/%-hostdex.jar
+CORE_IMG_JAR_DIR := $(OUT_DIR)/soong/$(PRODUCT_DEVICE)/dex_artjars_input
+$(HOST_BOOT_IMAGE_JARS): $(HOST_OUT)/apex/com.android.art/javalib/%.jar : $(CORE_IMG_JAR_DIR)/%.jar
 	$(copy-file-to-target)
 
+# We can still use the host variant of `conscrypt` and `core-icu4j` because they don't go into the
+# primary boot image that is used in host gtests, and hence can't lead to checksum mismatches.
 HOST_BOOT_IMAGE_JARS += $(HOST_OUT)/apex/com.android.conscrypt/javalib/conscrypt.jar
 $(HOST_OUT)/apex/com.android.conscrypt/javalib/conscrypt.jar : $(HOST_OUT_JAVA_LIBRARIES)/conscrypt-hostdex.jar
 	$(copy-file-to-target)
@@ -77,8 +82,8 @@
 
 HOST_CORE_IMG_OUTS += $(HOST_BOOT_IMAGE_JARS) $(HOST_BOOT_IMAGE) $(2ND_HOST_BOOT_IMAGE)
 
-HOST_TEST_CORE_JARS   := $(addsuffix -hostdex,$(CORE_IMG_JARS) core-icu4j conscrypt)
-ART_HOST_DEX_DEPENDENCIES := $(foreach jar,$(HOST_TEST_CORE_JARS),$(HOST_OUT_JAVA_LIBRARIES)/$(jar).jar)
+HOST_TEST_ADDITIONAL_JARS := core-icu4j conscrypt
+ART_HOST_DEX_DEPENDENCIES := $(foreach jar,$(CORE_IMG_JARS),$(CORE_IMG_JAR_DIR)/$(jar).jar) $(foreach jar,$(HOST_TEST_ADDITIONAL_JARS),$(HOST_OUT_JAVA_LIBRARIES)/$(jar)-hostdex.jar)
 ART_TARGET_DEX_DEPENDENCIES := com.android.art.testing com.android.conscrypt com.android.i18n
 
 ART_CORE_SHARED_LIBRARIES := libjavacore libopenjdk libopenjdkjvm libopenjdkjvmti