Merge "dexpreopt rules for google mainline prebuilts with missing source" into main am: 529da9b897

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3241767

Change-Id: Ic80a3aef33c0b43c1c28e1bc8c8b9501a6bd4799
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-08-28 01:28:20 +00:00
committed by Automerger Merge Worker
2 changed files with 107 additions and 0 deletions

View File

@@ -409,3 +409,106 @@ func TestDexpreoptProfileWithMultiplePrebuiltArtApexes(t *testing.T) {
android.AssertStringListContains(t, tc.desc, inputs, tc.expectedProfile)
}
}
// Check that dexpreopt works with Google mainline prebuilts even in workspaces where source is missing
func TestDexpreoptWithMainlinePrebuiltNoSource(t *testing.T) {
bp := `
// Platform.
platform_bootclasspath {
name: "platform-bootclasspath",
fragments: [
{
apex: "com.android.art",
module: "art-bootclasspath-fragment",
},
],
}
// Source AOSP ART apex
java_library {
name: "core-oj",
srcs: ["core-oj.java"],
installable: true,
apex_available: [
"com.android.art",
],
}
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
contents: ["core-oj"],
apex_available: [
"com.android.art",
],
hidden_api: {
split_packages: ["*"],
},
}
apex_key {
name: "com.android.art.key",
public_key: "com.android.art.avbpubkey",
private_key: "com.android.art.pem",
}
apex {
name: "com.android.art",
key: "com.android.art.key",
bootclasspath_fragments: ["art-bootclasspath-fragment"],
updatable: false,
}
// Prebuilt Google ART APEX.
java_import {
name: "core-oj",
jars: ["core-oj.jar"],
apex_available: [
"com.android.art",
],
}
prebuilt_bootclasspath_fragment {
name: "art-bootclasspath-fragment",
image_name: "art",
contents: ["core-oj"],
hidden_api: {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
metadata: "my-bootclasspath-fragment/metadata.csv",
index: "my-bootclasspath-fragment/index.csv",
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
all_flags: "my-bootclasspath-fragment/all-flags.csv",
},
apex_available: [
"com.android.art",
],
}
prebuilt_apex {
name: "com.google.android.art",
apex_name: "com.android.art",
src: "com.android.art-arm.apex",
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
}
apex_contributions {
name: "art.prebuilt.contributions",
api_domain: "com.android.art",
contents: ["prebuilt_com.google.android.art"],
}
`
res := android.GroupFixturePreparers(
java.PrepareForTestWithDexpreopt,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureConfigureBootJars("com.android.art:core-oj"),
PrepareForTestWithApexBuildComponents,
prepareForTestWithArtApex,
android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "art.prebuilt.contributions"),
).RunTestWithBp(t, bp)
if !java.CheckModuleHasDependency(t, res.TestContext, "dex_bootjars", "android_common", "prebuilt_com.google.android.art") {
t.Errorf("Expected dexpreopt to use prebuilt apex")
}
}

View File

@@ -558,6 +558,10 @@ func addDependenciesOntoSelectedBootImageApexes(ctx android.BottomUpMutatorConte
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))
}
}
}