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

Commit ab99498e authored by David Srbecky's avatar David Srbecky
Browse files

Adjust embedded dex locations in host boot image.

ART tests require that "out/host/linux-x86" is included.

This requires making the dexLocations per-variant specific.

Test: m test-art-host-gtest
Bug: 147817558
Bug: 147819342
Change-Id: I7839ee15cb6dfc62508bdd3fa0f306336af17055
parent 1aacc6c3
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -127,7 +127,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
	global := dexpreopt.GetGlobalConfig(ctx)
	bootImage := defaultBootImageConfig(ctx)
	dexFiles := bootImage.dexPathsDeps.Paths()
	dexLocations := bootImage.dexLocationsDeps
	// The dex locations for all Android variants are identical.
	dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps
	if global.UseArtImage {
		bootImage = artBootImageConfig(ctx)
	}
@@ -155,8 +156,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
		images = append(images, variant.images)
		imagesDeps = append(imagesDeps, variant.imagesDeps)
	}
	// The locations for all Android targets are identical. Pick the first one.
	imageLocations := bootImage.getVariant(targets[0]).imageLocations()
	// The image locations for all Android variants are identical.
	imageLocations := bootImage.getAnyAndroidVariant().imageLocations()

	dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath)

+18 −12
Original line number Diff line number Diff line
@@ -51,10 +51,6 @@ type bootImageConfig struct {
	// The names of jars that constitute this image.
	modules []string

	// The "locations" of jars.
	dexLocations     []string // for this image
	dexLocationsDeps []string // for the dependency images and in this image

	// File paths to jars.
	dexPaths     android.WritablePaths // for this image
	dexPathsDeps android.WritablePaths // for the dependency images and in this image
@@ -76,6 +72,10 @@ type bootImageVariant struct {
	// Target for which the image is generated.
	target android.Target

	// The "locations" of jars.
	dexLocations     []string // for this image
	dexLocationsDeps []string // for the dependency images and in this image

	// Paths to image files.
	images     android.OutputPath  // first image file
	imagesDeps android.OutputPaths // all files
@@ -98,6 +98,16 @@ func (image bootImageConfig) getVariant(target android.Target) *bootImageVariant
	return nil
}

// Return any (the first) variant which is for the device (as opposed to for the host)
func (image bootImageConfig) getAnyAndroidVariant() *bootImageVariant {
	for _, variant := range image.variants {
		if variant.target.Os == android.Android {
			return variant
		}
	}
	return nil
}

func (image bootImageConfig) moduleName(idx int) string {
	// Dexpreopt on the boot class path produces multiple files. The first dex file
	// is converted into 'name'.art (to match the legacy assumption that 'name'.art
@@ -475,7 +485,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig,
			Tool(globalSoong.Profman).
			FlagWithInput("--create-profile-from=", bootImageProfile).
			FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
			FlagForEachArg("--dex-location=", image.dexLocationsDeps).
			FlagForEachArg("--dex-location=", image.getAnyAndroidVariant().dexLocationsDeps).
			FlagWithOutput("--reference-profile-file=", profile)

		rule.Install(profile, "/system/etc/boot-image.prof")
@@ -526,7 +536,7 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
			Flag("--generate-boot-profile").
			FlagWithInput("--create-profile-from=", bootFrameworkProfile).
			FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
			FlagForEachArg("--dex-location=", image.dexLocationsDeps).
			FlagForEachArg("--dex-location=", image.getAnyAndroidVariant().dexLocationsDeps).
			FlagWithOutput("--reference-profile-file=", profile)

		rule.Install(profile, "/system/etc/boot-image.bprof")
@@ -606,12 +616,11 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
	if image != nil {
		ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
		ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPathsDeps.Strings(), " "))
		ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.dexLocationsDeps, " "))
		ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.getAnyAndroidVariant().dexLocationsDeps, " "))

		var imageNames []string
		for _, current := range append(d.otherImages, image) {
			imageNames = append(imageNames, current.name)
			imageLocations := []string{}
			for _, variant := range current.variants {
				suffix := ""
				if variant.target.Os.Class == android.Host {
@@ -623,11 +632,8 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
				ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(variant.imagesDeps.Strings(), " "))
				ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String())
				ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, variant.unstrippedInstalls.String())
				if variant.target.Os == android.Android {
					// The locations for all Android targets are identical. Pick one.
					imageLocations = variant.imageLocations()
				}
			}
			imageLocations := current.getAnyAndroidVariant().imageLocations()
			ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(imageLocations, ":"))
			ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String())
		}
+24 −23
Original line number Diff line number Diff line
@@ -79,6 +79,14 @@ func stemOf(moduleName string) string {
	return moduleName
}

func getDexLocation(ctx android.PathContext, target android.Target, subdir string, name string) string {
	if target.Os.Class == android.Host {
		return filepath.Join("out", "host", ctx.Config().PrebuiltOS(), subdir, name)
	} else {
		return filepath.Join("/", subdir, name)
	}
}

var (
	bootImageConfigKey     = android.NewOnceKey("bootImageConfig")
	artBootImageName       = "art"
@@ -104,14 +112,6 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
		artSubdir := "apex/com.android.art/javalib"
		frameworkSubdir := "system/framework"

		var artLocations, frameworkLocations []string
		for _, m := range artModules {
			artLocations = append(artLocations, filepath.Join("/"+artSubdir, stemOf(m)+".jar"))
		}
		for _, m := range frameworkModules {
			frameworkLocations = append(frameworkLocations, filepath.Join("/"+frameworkSubdir, stemOf(m)+".jar"))
		}

		// ART config for the primary boot image in the ART apex.
		// It includes the Core Libraries.
		artCfg := bootImageConfig{
@@ -119,8 +119,6 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
			stem:          "boot",
			installSubdir: artSubdir,
			modules:       artModules,
			dexLocations:     artLocations,
			dexLocationsDeps: artLocations,
		}

		// Framework config for the boot image extension.
@@ -131,8 +129,6 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
			stem:          "boot",
			installSubdir: frameworkSubdir,
			modules:       frameworkModules,
			dexLocations:     frameworkLocations,
			dexLocationsDeps: append(artLocations, frameworkLocations...),
		}

		configs := map[string]*bootImageConfig{
@@ -168,6 +164,10 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
					images:          imageDir.Join(ctx, imageName),
					imagesDeps:      c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex"),
				}
				for _, m := range c.modules {
					variant.dexLocations = append(variant.dexLocations, getDexLocation(ctx, target, c.installSubdir, stemOf(m)+".jar"))
				}
				variant.dexLocationsDeps = variant.dexLocations
				c.variants = append(c.variants, variant)
			}

@@ -178,6 +178,7 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
		frameworkCfg.dexPathsDeps = append(artCfg.dexPathsDeps, frameworkCfg.dexPathsDeps...)
		for i := range targets {
			frameworkCfg.variants[i].primaryImages = artCfg.variants[i].images
			frameworkCfg.variants[i].dexLocationsDeps = append(artCfg.variants[i].dexLocations, frameworkCfg.variants[i].dexLocationsDeps...)
		}

		return configs
@@ -202,7 +203,7 @@ func defaultBootclasspath(ctx android.PathContext) []string {
			updatableBootclasspath[i] = dexpreopt.GetJarLocationFromApexJarPair(p)
		}

		bootclasspath := append(copyOf(image.dexLocationsDeps), updatableBootclasspath...)
		bootclasspath := append(copyOf(image.getAnyAndroidVariant().dexLocationsDeps), updatableBootclasspath...)
		return bootclasspath
	})
}
@@ -217,7 +218,7 @@ func init() {

func dexpreoptConfigMakevars(ctx android.MakeVarsContext) {
	ctx.Strict("PRODUCT_BOOTCLASSPATH", strings.Join(defaultBootclasspath(ctx), ":"))
	ctx.Strict("PRODUCT_DEX2OAT_BOOTCLASSPATH", strings.Join(defaultBootImageConfig(ctx).dexLocationsDeps, ":"))
	ctx.Strict("PRODUCT_DEX2OAT_BOOTCLASSPATH", strings.Join(defaultBootImageConfig(ctx).getAnyAndroidVariant().dexLocationsDeps, ":"))
	ctx.Strict("PRODUCT_SYSTEM_SERVER_CLASSPATH", strings.Join(systemServerClasspath(ctx), ":"))

	ctx.Strict("DEXPREOPT_BOOT_JARS_MODULES", strings.Join(defaultBootImageConfig(ctx).modules, ":"))