dexpreopt rules for google mainline prebuilts with missing source
AddFarVariationDependencies runs into issues in partner workspaces which
do not contain the sources of google mainline prebuilts, since the
prebuilt would be renamed in a prior prebuilt_rename mutator. To account
for this rename, add `prebuilt_` prefix in
`addDependenciesOntoSelectedBootImageApexes` to ensure that the prebuilt
apex does not get elided
Test: m nothing --no-skip-soong-tests
Test: in v-aml-prebuilt dev,
aninja -t query out/soong/dexpreopt_arm64/dex_bootjars_input/okhttp.jar | head -n3
out/soong/dexpreopt_arm64/dex_bootjars_input/okhttp.jar:
input: g.android.Cp
out/soong/.intermediates/vendor/partner_modules/ArtPrebuilt/prebuilt_com.google.android.art_compressed.deapexer/android_common/deapexer/javalib/okhttp.jar
(uses the prebuilt deapexed boot jar, and no the source apex boot jar)
Bug: 362163831
Change-Id: Ie94a36911ab40ac09a470efe505fd00ef3a5bf9c
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index a81ab83..a2e4734 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -558,6 +558,10 @@
apexVariationOfSelected := append(ctx.Target().Variations(), blueprint.Variation{Mutator: "apex", Variation: apex})
if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, selected) {
ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, selected)
+ } else if ctx.OtherModuleDependencyVariantExists(apexVariationOfSelected, android.RemoveOptionalPrebuiltPrefix(selected)) {
+ // The prebuilt might have been renamed by prebuilt_rename mutator if the source module does not exist.
+ // Remove the prebuilt_ prefix.
+ ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, android.RemoveOptionalPrebuiltPrefix(selected))
}
}
}