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/dexpreopt/config.go b/dexpreopt/config.go
index 7e73bf7..0bcec17 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -372,6 +372,15 @@
func (d dex2oatDependencyTag) ExcludeFromApexContents() {
}
+func (d dex2oatDependencyTag) AllowDisabledModuleDependency(target android.Module) bool {
+ // RegisterToolDeps may run after the prebuilt mutators and hence register a
+ // dependency on the source module even when the prebuilt is to be used.
+ // dex2oatPathFromDep takes that into account when it retrieves the path to
+ // the binary, but we also need to disable the check for dependencies on
+ // disabled modules.
+ return target.IsReplacedByPrebuilt()
+}
+
// Dex2oatDepTag represents the dependency onto the dex2oatd module. It is added to any module that
// needs dexpreopting and so it makes no sense for it to be checked for visibility or included in
// the apex.
@@ -379,6 +388,7 @@
var _ android.ExcludeFromVisibilityEnforcementTag = Dex2oatDepTag
var _ android.ExcludeFromApexContentsTag = Dex2oatDepTag
+var _ android.AllowDisabledModuleDependency = Dex2oatDepTag
// RegisterToolDeps adds the necessary dependencies to binary modules for tools
// that are required later when Get(Cached)GlobalSoongConfig is called. It