Build boot images in bootclasspath_fragment/platform_bootclasspath
Moves the building of boot images from the dexpreopt_bootjars singleton
to the bootclasspath_fragment and platform_bootclasspath.
The art boot image is generated by the art-bootclasspath-fragment
module and the framework boot image by the platform-bootclasspath
module.
This does temporarly duplicate the generation of an identical boot
profile for each image. As part of the work to modularize the boot
image profile each image will have its own custom default boot profile.
Bug: 177892522
Bug: 186455808
Test: m droid and TreeHugger
Change-Id: I23cf05ec7648749b21c7cf6fcba282b46649a981
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index 5b1be22..20421de 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -478,6 +478,10 @@
// 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 a639d28..07715ab 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -427,19 +427,10 @@
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 @@
}
// 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 @@
}
// 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 @@
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 73f21d1..bc7a55e 100644
--- a/java/dexpreopt_bootjars_test.go
+++ b/java/dexpreopt_bootjars_test.go
@@ -20,7 +20,6 @@
"testing"
"android/soong/android"
- "android/soong/dexpreopt"
)
func testDexpreoptBoot(t *testing.T, ruleFile string, expectedInputs, expectedOutputs []string) {
@@ -42,17 +41,21 @@
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 eccea61..1feed3d 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -458,5 +458,9 @@
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)
}