Finish move of jar compilation rules from makefile to soong.

The rules have already been previously ported to soong, but they were
only used for atest.  Always use them to simplify the makefile.

This makes the gtest modules in .bp files depend on the needed jars,
which ensures that they will be copied next to the test binary.
This is needed as atest can not access them in the current location.

It also simplifies the tradefed xml since the manual copying
can be removed for the apex-based device testing.

Test: test-art-host-gtest
Test: atest ArtGtestsTarget
Bug: 147819342
Change-Id: I54d92eca88fc04c949209d490e838d0a92ce8f87
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 2397a09..dc5015f 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -24,239 +24,6 @@
 include art/build/Android.common_path.mk
 include art/build/Android.common_build.mk
 
-# Subdirectories in art/test which contain dex files used as inputs for gtests.
-GTEST_DEX_DIRECTORIES := \
-  AbstractMethod \
-  AllFields \
-  DefaultMethods \
-  DexToDexDecompiler \
-  ErroneousA \
-  ErroneousB \
-  ErroneousInit \
-  Extension1 \
-  Extension2 \
-  ForClassLoaderA \
-  ForClassLoaderB \
-  ForClassLoaderC \
-  ForClassLoaderD \
-  ExceptionHandle \
-  GetMethodSignature \
-  HiddenApi \
-  HiddenApiSignatures \
-  HiddenApiStubs \
-  ImageLayoutA \
-  ImageLayoutB \
-  IMTA \
-  IMTB \
-  Instrumentation \
-  Interfaces \
-  Lookup \
-  Main \
-  ManyMethods \
-  MethodTypes \
-  MultiDex \
-  MultiDexModifiedSecondary \
-  MyClass \
-  MyClassNatives \
-  Nested \
-  NonStaticLeafMethods \
-  Packages \
-  ProtoCompare \
-  ProtoCompare2 \
-  ProfileTestMultiDex \
-  StaticLeafMethods \
-  Statics \
-  StaticsFromCode \
-  StringLiterals \
-  Transaction \
-  XandY
-
-# Create build rules for each dex file recording the dependency.
-$(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-gtest,$(dir), \
-  $(ART_TARGET_NATIVETEST_OUT),art/build/Android.gtest.mk,ART_TEST_TARGET_GTEST_$(dir)_DEX, \
-  ART_TEST_HOST_GTEST_$(dir)_DEX)))
-
-# Create rules for MainStripped, a copy of Main with the classes.dex stripped
-# for the oat file assistant tests.
-ART_TEST_HOST_GTEST_MainStripped_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-ART_TEST_TARGET_GTEST_MainStripped_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
-
-# Create rules for MainUncompressedAligned, a copy of Main with the classes.dex uncompressed
-# for the dex2oat tests.
-ART_TEST_HOST_GTEST_MainUncompressedAligned_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))UncompressedAligned$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-ART_TEST_TARGET_GTEST_MainUncompressedAligned_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))UncompressedAligned$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
-
-# Create rules for UncompressedEmpty, a classes.dex that is empty and uncompressed
-# for the dex2oat tests.
-ART_TEST_HOST_GTEST_EmptyUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))EmptyUncompressed$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))EmptyUncompressed$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
-
-# Create rules for UncompressedEmptyAligned, a classes.dex that is empty, uncompressed,
-# and 4 byte aligned for the dex2oat tests.
-ART_TEST_HOST_GTEST_EmptyUncompressedAligned_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))EmptyUncompressedAligned$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-ART_TEST_TARGET_GTEST_EmptyUncompressedAligned_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))EmptyUncompressedAligned$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
-
-# Create rules for MultiDexUncompressedAligned, a copy of MultiDex with the classes.dex uncompressed
-# for the OatFile tests.
-ART_TEST_HOST_GTEST_MultiDexUncompressedAligned_DEX := $(basename $(ART_TEST_HOST_GTEST_MultiDex_DEX))UncompressedAligned$(suffix $(ART_TEST_HOST_GTEST_MultiDex_DEX))
-ART_TEST_TARGET_GTEST_MultiDexUncompressedAligned_DEX := $(basename $(ART_TEST_TARGET_GTEST_MultiDex_DEX))UncompressedAligned$(suffix $(ART_TEST_TARGET_GTEST_MultiDex_DEX))
-
-ifdef ART_TEST_HOST_GTEST_Main_DEX
-$(ART_TEST_HOST_GTEST_MainStripped_DEX): $(ART_TEST_HOST_GTEST_Main_DEX)
-	cp $< $@
-	$(call dexpreopt-remove-classes.dex,$@)
-endif
-
-ifdef ART_TEST_TARGET_GTEST_Main_DEX
-$(ART_TEST_TARGET_GTEST_MainStripped_DEX): $(ART_TEST_TARGET_GTEST_Main_DEX)
-	cp $< $@
-	$(call dexpreopt-remove-classes.dex,$@)
-endif
-
-ifdef ART_TEST_HOST_GTEST_Main_DEX
-$(ART_TEST_HOST_GTEST_MainUncompressedAligned_DEX): $(ART_TEST_HOST_GTEST_Main_DEX) $(ZIPALIGN)
-	cp $< $@
-	$(call uncompress-dexs, $@)
-	$(call align-package, $@)
-endif
-
-ifdef ART_TEST_TARGET_GTEST_Main_DEX
-$(ART_TEST_TARGET_GTEST_MainUncompressedAligned_DEX): $(ART_TEST_TARGET_GTEST_Main_DEX) $(ZIPALIGN)
-	cp $< $@
-	$(call uncompress-dexs, $@)
-	$(call align-package, $@)
-endif
-
-ifdef ART_TEST_HOST_GTEST_Main_DEX
-$(ART_TEST_HOST_GTEST_EmptyUncompressed_DEX):
-	touch $@_classes.dex
-	zip -j -qD -X -0 $@ $@_classes.dex
-	rm $@_classes.dex
-endif
-
-ifdef ART_TEST_TARGET_GTEST_Main_DEX
-$(ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX):
-	touch $@_classes.dex
-	zip -j -qD -X -0 $@ $@_classes.dex
-	rm $@_classes.dex
-endif
-
-ifdef ART_TEST_HOST_GTEST_Main_DEX
-$(ART_TEST_HOST_GTEST_EmptyUncompressedAligned_DEX): $(ZIPALIGN)
-	touch $@_classes.dex
-	zip -j -0 $@_temp.zip $@_classes.dex
-	$(ZIPALIGN) -f 4 $@_temp.zip $@
-	rm $@_classes.dex
-	rm $@_temp.zip
-endif
-
-ifdef ART_TEST_TARGET_GTEST_Main_DEX
-$(ART_TEST_TARGET_GTEST_EmptyUncompressedAligned_DEX): $(ZIPALIGN)
-	touch $@_classes.dex
-	zip -j -0 $@_temp.zip $@_classes.dex
-	$(ZIPALIGN) -f 4 $@_temp.zip $@
-	rm $@_classes.dex
-	rm $@_temp.zip
-endif
-
-ifdef ART_TEST_HOST_GTEST_MultiDex_DEX
-$(ART_TEST_HOST_GTEST_MultiDexUncompressedAligned_DEX): $(ART_TEST_HOST_GTEST_MultiDex_DEX) $(ZIPALIGN)
-	cp $< $@
-	$(call uncompress-dexs, $@)
-	$(call align-package, $@)
-endif
-
-ifdef ART_TEST_TARGET_GTEST_MultiDex_DEX
-$(ART_TEST_TARGET_GTEST_MultiDexUncompressedAligned_DEX): $(ART_TEST_TARGET_GTEST_MultiDex_DEX) $(ZIPALIGN)
-	cp $< $@
-	$(call uncompress-dexs, $@)
-	$(call align-package, $@)
-endif
-
-ART_TEST_GTEST_VerifierDeps_SRC := $(abspath $(wildcard $(LOCAL_PATH)/VerifierDeps/*.smali))
-ART_TEST_GTEST_VerifierDepsMulti_SRC := $(abspath $(wildcard $(LOCAL_PATH)/VerifierDepsMulti/*.smali))
-ART_TEST_HOST_GTEST_VerifierDeps_DEX := $(dir $(ART_TEST_HOST_GTEST_Main_DEX))$(subst Main,VerifierDeps,$(basename $(notdir $(ART_TEST_HOST_GTEST_Main_DEX))))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-ART_TEST_TARGET_GTEST_VerifierDeps_DEX := $(dir $(ART_TEST_TARGET_GTEST_Main_DEX))$(subst Main,VerifierDeps,$(basename $(notdir $(ART_TEST_TARGET_GTEST_Main_DEX))))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
-ART_TEST_HOST_GTEST_VerifierDepsMulti_DEX := $(dir $(ART_TEST_HOST_GTEST_Main_DEX))$(subst Main,VerifierDepsMulti,$(basename $(notdir $(ART_TEST_HOST_GTEST_Main_DEX))))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-ART_TEST_TARGET_GTEST_VerifierDepsMulti_DEX := $(dir $(ART_TEST_TARGET_GTEST_Main_DEX))$(subst Main,VerifierDepsMulti,$(basename $(notdir $(ART_TEST_TARGET_GTEST_Main_DEX))))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
-
-$(ART_TEST_HOST_GTEST_VerifierDeps_DEX): $(ART_TEST_GTEST_VerifierDeps_SRC) $(HOST_OUT_EXECUTABLES)/smali
-	 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
-
-$(ART_TEST_TARGET_GTEST_VerifierDeps_DEX): $(ART_TEST_GTEST_VerifierDeps_SRC) $(HOST_OUT_EXECUTABLES)/smali
-	 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
-
-$(ART_TEST_HOST_GTEST_VerifierDepsMulti_DEX): $(ART_TEST_GTEST_VerifierDepsMulti_SRC) $(HOST_OUT_EXECUTABLES)/smali
-	 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
-
-$(ART_TEST_TARGET_GTEST_VerifierDepsMulti_DEX): $(ART_TEST_GTEST_VerifierDepsMulti_SRC) $(HOST_OUT_EXECUTABLES)/smali
-	 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
-
-ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC := $(abspath $(wildcard $(LOCAL_PATH)/VerifySoftFailDuringClinit/*.smali))
-ART_TEST_HOST_GTEST_VerifySoftFailDuringClinit_DEX := $(dir $(ART_TEST_HOST_GTEST_Main_DEX))$(subst Main,VerifySoftFailDuringClinit,$(basename $(notdir $(ART_TEST_HOST_GTEST_Main_DEX))))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-ART_TEST_TARGET_GTEST_VerifySoftFailDuringClinit_DEX := $(dir $(ART_TEST_TARGET_GTEST_Main_DEX))$(subst Main,VerifySoftFailDuringClinit,$(basename $(notdir $(ART_TEST_TARGET_GTEST_Main_DEX))))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX))
-
-$(ART_TEST_HOST_GTEST_VerifySoftFailDuringClinit_DEX): $(ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC) $(HOST_OUT_EXECUTABLES)/smali
-	 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
-
-$(ART_TEST_TARGET_GTEST_VerifySoftFailDuringClinit_DEX): $(ART_TEST_GTEST_VerifySoftFailDuringClinit_SRC) $(HOST_OUT_EXECUTABLES)/smali
-	 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
-
-# Linkage test artifacts.
-ART_TEST_GTEST_LinkageTest_SRC := $(abspath $(wildcard $(LOCAL_PATH)/LinkageTest/*.smali))
-ART_TEST_HOST_GTEST_LinkageTest_DEX := $(dir $(ART_TEST_HOST_GTEST_Main_DEX))$(subst Main,LinkageTest,$(basename $(notdir $(ART_TEST_HOST_GTEST_Main_DEX))))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX))
-$(ART_TEST_HOST_GTEST_LinkageTest_DEX): $(ART_TEST_GTEST_LinkageTest_SRC) $(HOST_OUT_EXECUTABLES)/smali
-	 $(HOST_OUT_EXECUTABLES)/smali assemble --output $@ $(filter %.smali,$^)
-
-# Dex file dependencies for each gtest.
-ART_GTEST_art_dex_file_loader_test_DEX_DEPS := GetMethodSignature Main Nested MultiDex
-ART_GTEST_dex2oat_environment_tests_DEX_DEPS := Main MainStripped MultiDex MultiDexModifiedSecondary MyClassNatives Nested VerifierDeps VerifierDepsMulti LinkageTest
-
-ART_GTEST_atomic_dex_ref_map_test_DEX_DEPS := Interfaces
-ART_GTEST_class_linker_test_DEX_DEPS := AllFields ErroneousA ErroneousB ErroneousInit ForClassLoaderA ForClassLoaderB ForClassLoaderC ForClassLoaderD Interfaces MethodTypes MultiDex MyClass Nested Statics StaticsFromCode
-ART_GTEST_class_loader_context_test_DEX_DEPS := Main MultiDex MyClass ForClassLoaderA ForClassLoaderB ForClassLoaderC ForClassLoaderD
-ART_GTEST_class_table_test_DEX_DEPS := XandY
-ART_GTEST_compiler_driver_test_DEX_DEPS := AbstractMethod StaticLeafMethods ProfileTestMultiDex
-ART_GTEST_dex_cache_test_DEX_DEPS := Main Packages MethodTypes
-ART_GTEST_dexanalyze_test_DEX_DEPS := MultiDex
-ART_GTEST_dexlayout_test_DEX_DEPS := ManyMethods
-ART_GTEST_dex2oat_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) ManyMethods Statics VerifierDeps MainUncompressedAligned EmptyUncompressed EmptyUncompressedAligned StringLiterals
-ART_GTEST_dex2oat_image_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Statics VerifierDeps
-ART_GTEST_exception_test_DEX_DEPS := ExceptionHandle
-ART_GTEST_hiddenapi_test_DEX_DEPS := HiddenApi HiddenApiStubs
-ART_GTEST_hidden_api_test_DEX_DEPS := HiddenApiSignatures Main MultiDex
-ART_GTEST_image_test_DEX_DEPS := ImageLayoutA ImageLayoutB DefaultMethods VerifySoftFailDuringClinit
-ART_GTEST_imtable_test_DEX_DEPS := IMTA IMTB
-ART_GTEST_instrumentation_test_DEX_DEPS := Instrumentation
-ART_GTEST_jni_compiler_test_DEX_DEPS := MyClassNatives
-ART_GTEST_jni_internal_test_DEX_DEPS := AllFields StaticLeafMethods MyClassNatives
-ART_GTEST_oat_file_assistant_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
-ART_GTEST_dexoptanalyzer_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS)
-ART_GTEST_image_space_test_DEX_DEPS := $(ART_GTEST_dex2oat_environment_tests_DEX_DEPS) Extension1 Extension2
-ART_GTEST_oat_file_test_DEX_DEPS := Main MultiDex MainUncompressedAligned MultiDexUncompressedAligned MainStripped Nested MultiDexModifiedSecondary
-ART_GTEST_oat_test_DEX_DEPS := Main
-ART_GTEST_oat_writer_test_DEX_DEPS := Main
-# two_runtimes_test build off dex2oat_environment_test, which does sanity checks on the following dex files.
-ART_GTEST_two_runtimes_test_DEX_DEPS := Main MainStripped Nested MultiDex MultiDexModifiedSecondary
-ART_GTEST_object_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
-ART_GTEST_proxy_test_DEX_DEPS := Interfaces
-ART_GTEST_reflection_test_DEX_DEPS := Main NonStaticLeafMethods StaticLeafMethods
-ART_GTEST_profile_assistant_test_DEX_DEPS := ProfileTestMultiDex
-ART_GTEST_profile_compilation_info_test_DEX_DEPS := ManyMethods ProfileTestMultiDex
-ART_GTEST_profile_boot_info_test_DEX_DEPS := ManyMethods ProfileTestMultiDex MultiDex
-ART_GTEST_profiling_info_test_DEX_DEPS := ProfileTestMultiDex
-ART_GTEST_runtime_callbacks_test_DEX_DEPS := XandY
-ART_GTEST_stub_test_DEX_DEPS := AllFields
-ART_GTEST_transaction_test_DEX_DEPS := Transaction
-ART_GTEST_type_lookup_table_test_DEX_DEPS := Lookup
-ART_GTEST_unstarted_runtime_test_DEX_DEPS := Nested
-ART_GTEST_heap_verification_test_DEX_DEPS := ProtoCompare ProtoCompare2 StaticsFromCode XandY
-ART_GTEST_verifier_deps_test_DEX_DEPS := VerifierDeps VerifierDepsMulti MultiDex
-ART_GTEST_dex_to_dex_decompiler_test_DEX_DEPS := VerifierDeps DexToDexDecompiler
-ART_GTEST_oatdump_app_test_DEX_DEPS := ProfileTestMultiDex
-ART_GTEST_oatdump_test_DEX_DEPS := ProfileTestMultiDex
-ART_GTEST_reg_type_test_DEX_DEPS := Interfaces
-
 # Deprecated core.art dependencies.
 HOST_CORE_IMAGE_DEFAULT_32 :=
 HOST_CORE_IMAGE_DEFAULT_64 :=
@@ -439,26 +206,8 @@
   gtest_suffix :=
 endef  # define-art-gtest-rule-host
 
-# Global list of all dependencies. All tests depend on all tools.
-# Removal of test_per_src broke the naming convention for dependencies,
-# so the fine-grained dependencies no longer work for now.
-# TODO: Move all dependency tracking to the blueprint file.
-ART_GTEST_ALL_DEX_DEPS := \
-  EmptyUncompressed \
-  EmptyUncompressedAligned \
-  LinkageTest \
-  MainStripped \
-  MainUncompressedAligned \
-  MultiDexUncompressedAligned \
-  VerifierDeps \
-  VerifierDepsMulti  \
-  VerifySoftFailDuringClinit \
-  $(foreach dir,$(GTEST_DEX_DIRECTORIES),$(dir))
-ART_TEST_HOST_GTEST_DEPENDENCIES += \
-  $(foreach file,$(ART_GTEST_ALL_DEX_DEPS),$(ART_TEST_HOST_GTEST_$(file)_DEX))
-ART_TEST_TARGET_GTEST_DEPENDENCIES += \
-  $(TESTING_ART_APEX) \
-  $(foreach file,$(ART_GTEST_ALL_DEX_DEPS),$(ART_TEST_TARGET_GTEST_$(file)_DEX))
+ART_TEST_HOST_GTEST_DEPENDENCIES :=
+ART_TEST_TARGET_GTEST_DEPENDENCIES := $(TESTING_ART_APEX)
 
 # Add the additional dependencies for the specified test
 # $(1): test name