Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2fc82ad0 authored by Paul Duffin's avatar Paul Duffin
Browse files

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
parent 47932935
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 {
+3 −12
Original line number Diff line number Diff line
@@ -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)

+7 −4
Original line number Diff line number Diff line
@@ -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])
+4 −0
Original line number Diff line number Diff line
@@ -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)
}