Add GetEmbeddedPrebuilt and IsModulePrebuilt

Dedups the many repetitions of the code to obtain a *Prebuilt from a
module.

Bug: 177892522
Test: m nothing
Change-Id: I1ededbe9ee79e89ea6dd8882dfee4be0bf0b51b7
This commit is contained in:
Paul Duffin
2021-04-28 10:41:21 +01:00
parent 8d817b70e6
commit f7c99f5983
4 changed files with 44 additions and 28 deletions

View File

@@ -404,14 +404,14 @@ func dex2oatPathFromDep(ctx android.ModuleContext) android.Path {
if parent == ctx.Module() && ctx.OtherModuleDependencyTag(child) == Dex2oatDepTag {
// Found the source module, or prebuilt module that has replaced the source.
dex2oatModule = child
if p, ok := child.(android.PrebuiltInterface); ok && p.Prebuilt() != nil {
if android.IsModulePrebuilt(child) {
return false // If it's the prebuilt we're done.
} else {
return true // Recurse to check if the source has a prebuilt dependency.
}
}
if parent == dex2oatModule && ctx.OtherModuleDependencyTag(child) == android.PrebuiltDepTag {
if p, ok := child.(android.PrebuiltInterface); ok && p.Prebuilt() != nil && p.Prebuilt().UsePrebuilt() {
if p := android.GetEmbeddedPrebuilt(child); p != nil && p.UsePrebuilt() {
dex2oatModule = child // Found a prebuilt that should be used.
}
}