Loading apex/dexpreopt_bootjars_test.go +103 −0 Original line number Diff line number Diff line Loading @@ -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") } } java/dexpreopt_bootjars.go +4 −0 Original line number Diff line number Diff line Loading @@ -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)) } } } Loading Loading
apex/dexpreopt_bootjars_test.go +103 −0 Original line number Diff line number Diff line Loading @@ -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") } }
java/dexpreopt_bootjars.go +4 −0 Original line number Diff line number Diff line Loading @@ -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)) } } } Loading