Don't fail if the target module is disabled in dex2oat tool
dependencies.
dexpreopt.RegisterToolDeps runs late after prebuilt dependencies have
been resolved, and there's special code in dex2oatPathFromDep to
resolve the prebuilt from the source module. However, if the source
module is disabled then the dependencies check in validateAndroidModule
will complain, so we need to disable that check in this particular
situation.
Also add a comment to explain why dexpreopt.RegisterToolDeps needs to
run so late.
Test: m nothing
Bug: 145934348
Bug: 172480615
Change-Id: Ibc673303d0336768fa23261a2068e91a08f46a30
diff --git a/java/testing.go b/java/testing.go
index 387d595..51a1c62 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -24,6 +24,7 @@
"android/soong/android"
"android/soong/cc"
"android/soong/dexpreopt"
+
"github.com/google/blueprint"
)
@@ -55,8 +56,9 @@
}.AddToFixture(),
)
-// Test fixture preparer that will define default java modules, e.g. standard prebuilt modules.
-var PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers(
+// Test fixture preparer that will define all default java modules except the
+// fake_tool_binary for dex2oatd.
+var PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd = android.GroupFixturePreparers(
// Make sure that all the module types used in the defaults are registered.
PrepareForTestWithJavaBuildComponents,
// Additional files needed when test disallows non-existent source.
@@ -72,6 +74,11 @@
android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", gatherRequiredDepsForTest()),
// Add dexpreopt compat libs (android.test.base, etc.) and a fake dex2oatd module.
dexpreopt.PrepareForTestWithDexpreoptCompatLibs,
+)
+
+// Test fixture preparer that will define default java modules, e.g. standard prebuilt modules.
+var PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd,
dexpreopt.PrepareForTestWithFakeDex2oatd,
)