diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 5b1be22c5..20421defd 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -478,6 +478,10 @@ func (b *BootclasspathFragmentModule) generateBootImageBuildActions(ctx android. // Copy the dex jars of this fragment's content modules to their predefined locations. copyBootJarsToPredefinedLocations(ctx, contents, imageConfig.modules, imageConfig.dexPaths) + + // Build a profile for the image config and then use that to build the boot image. + profile := bootImageProfileRule(ctx, imageConfig) + buildBootImage(ctx, imageConfig, profile) } type bootclasspathFragmentMemberType struct { diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index a639d2808..07715ab87 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -427,19 +427,10 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC return } - // Generate the profile rule from the default boot image. defaultImageConfig := defaultBootImageConfig(ctx) - profile := bootImageProfileRule(ctx, defaultImageConfig) - d.defaultBootImage = defaultImageConfig artBootImageConfig := artBootImageConfig(ctx) d.otherImages = []*bootImageConfig{artBootImageConfig} - - // Create the default boot image (build artifacts are accessed via the global boot image config). - buildBootImage(ctx, defaultImageConfig, profile) - - // Create boot image for the ART apex (build artifacts are accessed via the global boot image config). - buildBootImage(ctx, artBootImageConfig, profile) } // shouldBuildBootImages determines whether boot images should be built. @@ -507,7 +498,7 @@ func copyBootJarsToPredefinedLocations(ctx android.ModuleContext, bootModules [] } // buildBootImage takes a bootImageConfig, creates rules to build it, and returns the image. -func buildBootImage(ctx android.SingletonContext, image *bootImageConfig, profile android.WritablePath) { +func buildBootImage(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath) { var zipFiles android.Paths for _, variant := range image.variants { files := buildBootImageVariant(ctx, variant, profile) @@ -529,7 +520,7 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig, profil } // Generate boot image build rules for a specific target. -func buildBootImageVariant(ctx android.SingletonContext, image *bootImageVariant, profile android.Path) android.WritablePaths { +func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, profile android.Path) android.WritablePaths { globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx) global := dexpreopt.GetGlobalConfig(ctx) @@ -679,7 +670,7 @@ const failureMessage = `ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.` -func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig) android.WritablePath { +func bootImageProfileRule(ctx android.ModuleContext, image *bootImageConfig) android.WritablePath { globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx) global := dexpreopt.GetGlobalConfig(ctx) diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go index 73f21d12e..bc7a55eb9 100644 --- a/java/dexpreopt_bootjars_test.go +++ b/java/dexpreopt_bootjars_test.go @@ -20,7 +20,6 @@ import ( "testing" "android/soong/android" - "android/soong/dexpreopt" ) func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOutputs []string) { @@ -42,17 +41,21 @@ func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOu name: "baz", jars: ["a.jar"], } + + platform_bootclasspath { + name: "platform-bootclasspath", + } ` result := android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("foo"), - dexpreopt.FixtureSetBootJars("platform:foo", "system_ext:bar", "platform:baz"), + FixtureConfigureBootJars("platform:foo", "system_ext:bar", "platform:baz"), ).RunTestWithBp(t, bp) - dexpreoptBootJars := result.SingletonForTests("dex_bootjars") - rule := dexpreoptBootJars.Output(ruleFile) + platformBootclasspath := result.ModuleForTests("platform-bootclasspath", "android_common") + rule := platformBootclasspath.Output(ruleFile) for i := range expectedInputs { expectedInputs[i] = filepath.Join("out/soong/test_device", expectedInputs[i]) diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index eccea6172..1feed3ddd 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -458,5 +458,9 @@ func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android. config := GetUpdatableBootConfig(ctx) copyBootJarsToPredefinedLocations(ctx, updatableModules, config.modules, config.dexPaths) + // Build a profile for the image config and then use that to build the boot image. + profile := bootImageProfileRule(ctx, imageConfig) + buildBootImage(ctx, imageConfig, profile) + dumpOatRules(ctx, imageConfig) }