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
This commit is contained in:
parent
1aacc6c3df
commit
ab99498ea1
3 changed files with 46 additions and 38 deletions
|
@ -127,7 +127,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
bootImage := defaultBootImageConfig(ctx)
|
bootImage := defaultBootImageConfig(ctx)
|
||||||
dexFiles := bootImage.dexPathsDeps.Paths()
|
dexFiles := bootImage.dexPathsDeps.Paths()
|
||||||
dexLocations := bootImage.dexLocationsDeps
|
// The dex locations for all Android variants are identical.
|
||||||
|
dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps
|
||||||
if global.UseArtImage {
|
if global.UseArtImage {
|
||||||
bootImage = artBootImageConfig(ctx)
|
bootImage = artBootImageConfig(ctx)
|
||||||
}
|
}
|
||||||
|
@ -155,8 +156,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
|
||||||
images = append(images, variant.images)
|
images = append(images, variant.images)
|
||||||
imagesDeps = append(imagesDeps, variant.imagesDeps)
|
imagesDeps = append(imagesDeps, variant.imagesDeps)
|
||||||
}
|
}
|
||||||
// The locations for all Android targets are identical. Pick the first one.
|
// The image locations for all Android variants are identical.
|
||||||
imageLocations := bootImage.getVariant(targets[0]).imageLocations()
|
imageLocations := bootImage.getAnyAndroidVariant().imageLocations()
|
||||||
|
|
||||||
dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath)
|
dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath)
|
||||||
|
|
||||||
|
|
|
@ -51,10 +51,6 @@ type bootImageConfig struct {
|
||||||
// The names of jars that constitute this image.
|
// The names of jars that constitute this image.
|
||||||
modules []string
|
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.
|
// File paths to jars.
|
||||||
dexPaths android.WritablePaths // for this image
|
dexPaths android.WritablePaths // for this image
|
||||||
dexPathsDeps android.WritablePaths // for the dependency images and in 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 for which the image is generated.
|
||||||
target android.Target
|
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.
|
// Paths to image files.
|
||||||
images android.OutputPath // first image file
|
images android.OutputPath // first image file
|
||||||
imagesDeps android.OutputPaths // all files
|
imagesDeps android.OutputPaths // all files
|
||||||
|
@ -98,6 +98,16 @@ func (image bootImageConfig) getVariant(target android.Target) *bootImageVariant
|
||||||
return nil
|
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 {
|
func (image bootImageConfig) moduleName(idx int) string {
|
||||||
// Dexpreopt on the boot class path produces multiple files. The first dex file
|
// 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
|
// 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).
|
Tool(globalSoong.Profman).
|
||||||
FlagWithInput("--create-profile-from=", bootImageProfile).
|
FlagWithInput("--create-profile-from=", bootImageProfile).
|
||||||
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
|
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
|
||||||
FlagForEachArg("--dex-location=", image.dexLocationsDeps).
|
FlagForEachArg("--dex-location=", image.getAnyAndroidVariant().dexLocationsDeps).
|
||||||
FlagWithOutput("--reference-profile-file=", profile)
|
FlagWithOutput("--reference-profile-file=", profile)
|
||||||
|
|
||||||
rule.Install(profile, "/system/etc/boot-image.prof")
|
rule.Install(profile, "/system/etc/boot-image.prof")
|
||||||
|
@ -526,7 +536,7 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
|
||||||
Flag("--generate-boot-profile").
|
Flag("--generate-boot-profile").
|
||||||
FlagWithInput("--create-profile-from=", bootFrameworkProfile).
|
FlagWithInput("--create-profile-from=", bootFrameworkProfile).
|
||||||
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
|
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
|
||||||
FlagForEachArg("--dex-location=", image.dexLocationsDeps).
|
FlagForEachArg("--dex-location=", image.getAnyAndroidVariant().dexLocationsDeps).
|
||||||
FlagWithOutput("--reference-profile-file=", profile)
|
FlagWithOutput("--reference-profile-file=", profile)
|
||||||
|
|
||||||
rule.Install(profile, "/system/etc/boot-image.bprof")
|
rule.Install(profile, "/system/etc/boot-image.bprof")
|
||||||
|
@ -606,12 +616,11 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
|
||||||
if image != nil {
|
if image != nil {
|
||||||
ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
|
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_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
|
var imageNames []string
|
||||||
for _, current := range append(d.otherImages, image) {
|
for _, current := range append(d.otherImages, image) {
|
||||||
imageNames = append(imageNames, current.name)
|
imageNames = append(imageNames, current.name)
|
||||||
imageLocations := []string{}
|
|
||||||
for _, variant := range current.variants {
|
for _, variant := range current.variants {
|
||||||
suffix := ""
|
suffix := ""
|
||||||
if variant.target.Os.Class == android.Host {
|
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_DEPS_"+sfx, strings.Join(variant.imagesDeps.Strings(), " "))
|
||||||
ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String())
|
ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String())
|
||||||
ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, variant.unstrippedInstalls.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_LOCATIONS_"+current.name, strings.Join(imageLocations, ":"))
|
||||||
ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String())
|
ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String())
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,14 @@ func stemOf(moduleName string) string {
|
||||||
return moduleName
|
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 (
|
var (
|
||||||
bootImageConfigKey = android.NewOnceKey("bootImageConfig")
|
bootImageConfigKey = android.NewOnceKey("bootImageConfig")
|
||||||
artBootImageName = "art"
|
artBootImageName = "art"
|
||||||
|
@ -104,14 +112,6 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
||||||
artSubdir := "apex/com.android.art/javalib"
|
artSubdir := "apex/com.android.art/javalib"
|
||||||
frameworkSubdir := "system/framework"
|
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.
|
// ART config for the primary boot image in the ART apex.
|
||||||
// It includes the Core Libraries.
|
// It includes the Core Libraries.
|
||||||
artCfg := bootImageConfig{
|
artCfg := bootImageConfig{
|
||||||
|
@ -119,8 +119,6 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
||||||
stem: "boot",
|
stem: "boot",
|
||||||
installSubdir: artSubdir,
|
installSubdir: artSubdir,
|
||||||
modules: artModules,
|
modules: artModules,
|
||||||
dexLocations: artLocations,
|
|
||||||
dexLocationsDeps: artLocations,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Framework config for the boot image extension.
|
// Framework config for the boot image extension.
|
||||||
|
@ -131,8 +129,6 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
||||||
stem: "boot",
|
stem: "boot",
|
||||||
installSubdir: frameworkSubdir,
|
installSubdir: frameworkSubdir,
|
||||||
modules: frameworkModules,
|
modules: frameworkModules,
|
||||||
dexLocations: frameworkLocations,
|
|
||||||
dexLocationsDeps: append(artLocations, frameworkLocations...),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configs := map[string]*bootImageConfig{
|
configs := map[string]*bootImageConfig{
|
||||||
|
@ -168,6 +164,10 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
||||||
images: imageDir.Join(ctx, imageName),
|
images: imageDir.Join(ctx, imageName),
|
||||||
imagesDeps: c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex"),
|
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)
|
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...)
|
frameworkCfg.dexPathsDeps = append(artCfg.dexPathsDeps, frameworkCfg.dexPathsDeps...)
|
||||||
for i := range targets {
|
for i := range targets {
|
||||||
frameworkCfg.variants[i].primaryImages = artCfg.variants[i].images
|
frameworkCfg.variants[i].primaryImages = artCfg.variants[i].images
|
||||||
|
frameworkCfg.variants[i].dexLocationsDeps = append(artCfg.variants[i].dexLocations, frameworkCfg.variants[i].dexLocationsDeps...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return configs
|
return configs
|
||||||
|
@ -202,7 +203,7 @@ func defaultBootclasspath(ctx android.PathContext) []string {
|
||||||
updatableBootclasspath[i] = dexpreopt.GetJarLocationFromApexJarPair(p)
|
updatableBootclasspath[i] = dexpreopt.GetJarLocationFromApexJarPair(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
bootclasspath := append(copyOf(image.dexLocationsDeps), updatableBootclasspath...)
|
bootclasspath := append(copyOf(image.getAnyAndroidVariant().dexLocationsDeps), updatableBootclasspath...)
|
||||||
return bootclasspath
|
return bootclasspath
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -217,7 +218,7 @@ func init() {
|
||||||
|
|
||||||
func dexpreoptConfigMakevars(ctx android.MakeVarsContext) {
|
func dexpreoptConfigMakevars(ctx android.MakeVarsContext) {
|
||||||
ctx.Strict("PRODUCT_BOOTCLASSPATH", strings.Join(defaultBootclasspath(ctx), ":"))
|
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("PRODUCT_SYSTEM_SERVER_CLASSPATH", strings.Join(systemServerClasspath(ctx), ":"))
|
||||||
|
|
||||||
ctx.Strict("DEXPREOPT_BOOT_JARS_MODULES", strings.Join(defaultBootImageConfig(ctx).modules, ":"))
|
ctx.Strict("DEXPREOPT_BOOT_JARS_MODULES", strings.Join(defaultBootImageConfig(ctx).modules, ":"))
|
||||||
|
|
Loading…
Reference in a new issue