Merge "Revert^4 "Package dexpreopt artifacts for libcore jars in the ART apex.""
This commit is contained in:
17
apex/apex.go
17
apex/apex.go
@@ -652,6 +652,7 @@ type apexBundle struct {
|
|||||||
|
|
||||||
testApex bool
|
testApex bool
|
||||||
vndkApex bool
|
vndkApex bool
|
||||||
|
artApex bool
|
||||||
primaryApexType bool
|
primaryApexType bool
|
||||||
|
|
||||||
// intermediate path for apex_manifest.json
|
// intermediate path for apex_manifest.json
|
||||||
@@ -1261,6 +1262,19 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
|
||||||
|
// Build rules are generated by the dexpreopt singleton, and here we access build artifacts
|
||||||
|
// via the global boot image config.
|
||||||
|
if a.artApex {
|
||||||
|
for arch, files := range java.DexpreoptedArtApexJars(ctx) {
|
||||||
|
dirInApex := filepath.Join("javalib", arch.String())
|
||||||
|
for _, f := range files {
|
||||||
|
localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
|
||||||
|
filesInfo = append(filesInfo, apexFile{f, localModule, dirInApex, etc, nil, nil})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if a.private_key_file == nil {
|
if a.private_key_file == nil {
|
||||||
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
|
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
|
||||||
return
|
return
|
||||||
@@ -1875,9 +1889,10 @@ func newApexBundle() *apexBundle {
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
func ApexBundleFactory(testApex bool) android.Module {
|
func ApexBundleFactory(testApex bool, artApex bool) android.Module {
|
||||||
bundle := newApexBundle()
|
bundle := newApexBundle()
|
||||||
bundle.testApex = testApex
|
bundle.testApex = testApex
|
||||||
|
bundle.artApex = artApex
|
||||||
return bundle
|
return bundle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,6 +51,7 @@ func init() {
|
|||||||
|
|
||||||
type bootImageConfig struct {
|
type bootImageConfig struct {
|
||||||
name string
|
name string
|
||||||
|
stem string
|
||||||
modules []string
|
modules []string
|
||||||
dexLocations []string
|
dexLocations []string
|
||||||
dexPaths android.WritablePaths
|
dexPaths android.WritablePaths
|
||||||
@@ -71,7 +72,7 @@ func (image bootImageConfig) moduleFiles(ctx android.PathContext, dir android.Ou
|
|||||||
// In addition, each .art file has an associated .oat and .vdex file, and an
|
// In addition, each .art file has an associated .oat and .vdex file, and an
|
||||||
// unstripped .oat file
|
// unstripped .oat file
|
||||||
for i, m := range image.modules {
|
for i, m := range image.modules {
|
||||||
name := image.name
|
name := image.stem
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
name += "-" + stemOf(m)
|
name += "-" + stemOf(m)
|
||||||
}
|
}
|
||||||
@@ -139,6 +140,12 @@ func skipDexpreoptBootJars(ctx android.PathContext) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func skipDexpreoptArtBootJars(ctx android.BuilderContext) bool {
|
||||||
|
// with EMMA_INSTRUMENT_FRAMEWORK=true ART boot class path libraries have dependencies on framework,
|
||||||
|
// therefore dexpreopt ART libraries cannot be dexpreopted in isolation => no ART boot image
|
||||||
|
return ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK")
|
||||||
|
}
|
||||||
|
|
||||||
type dexpreoptBootJars struct {
|
type dexpreoptBootJars struct {
|
||||||
defaultBootImage *bootImage
|
defaultBootImage *bootImage
|
||||||
otherImages []*bootImage
|
otherImages []*bootImage
|
||||||
@@ -146,6 +153,14 @@ type dexpreoptBootJars struct {
|
|||||||
dexpreoptConfigForMake android.WritablePath
|
dexpreoptConfigForMake android.WritablePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Accessor function for the apex package. Returns nil if dexpreopt is disabled.
|
||||||
|
func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.Paths {
|
||||||
|
if skipDexpreoptBootJars(ctx) || skipDexpreoptArtBootJars(ctx) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return artBootImageConfig(ctx).imagesDeps
|
||||||
|
}
|
||||||
|
|
||||||
// dexpreoptBoot singleton rules
|
// dexpreoptBoot singleton rules
|
||||||
func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
if skipDexpreoptBootJars(ctx) {
|
if skipDexpreoptBootJars(ctx) {
|
||||||
@@ -169,7 +184,12 @@ func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
|
|
||||||
// Always create the default boot image first, to get a unique profile rule for all images.
|
// Always create the default boot image first, to get a unique profile rule for all images.
|
||||||
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
|
d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
|
||||||
|
if !skipDexpreoptArtBootJars(ctx) {
|
||||||
|
// Create boot image for the ART apex (build artifacts are accessed via the global boot image config).
|
||||||
|
buildBootImage(ctx, artBootImageConfig(ctx))
|
||||||
|
}
|
||||||
if global.GenerateApexImage {
|
if global.GenerateApexImage {
|
||||||
|
// Create boot images for the JIT-zygote experiment.
|
||||||
d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
|
d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,8 +198,6 @@ func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
|
|
||||||
// buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage.
|
// buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage.
|
||||||
func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootImage {
|
func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootImage {
|
||||||
global := dexpreoptGlobalConfig(ctx)
|
|
||||||
|
|
||||||
image := newBootImage(ctx, config)
|
image := newBootImage(ctx, config)
|
||||||
|
|
||||||
bootDexJars := make(android.Paths, len(image.modules))
|
bootDexJars := make(android.Paths, len(image.modules))
|
||||||
@@ -223,12 +241,9 @@ func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootI
|
|||||||
bootFrameworkProfileRule(ctx, image, missingDeps)
|
bootFrameworkProfileRule(ctx, image, missingDeps)
|
||||||
|
|
||||||
var allFiles android.Paths
|
var allFiles android.Paths
|
||||||
|
for _, target := range image.targets {
|
||||||
if !global.DisablePreopt {
|
files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
|
||||||
for _, target := range image.targets {
|
allFiles = append(allFiles, files.Paths()...)
|
||||||
files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
|
|
||||||
allFiles = append(allFiles, files.Paths()...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if image.zip != nil {
|
if image.zip != nil {
|
||||||
@@ -251,7 +266,7 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
|
|||||||
global := dexpreoptGlobalConfig(ctx)
|
global := dexpreoptGlobalConfig(ctx)
|
||||||
|
|
||||||
symbolsDir := image.symbolsDir.Join(ctx, "system/framework", arch.String())
|
symbolsDir := image.symbolsDir.Join(ctx, "system/framework", arch.String())
|
||||||
symbolsFile := symbolsDir.Join(ctx, image.name+".oat")
|
symbolsFile := symbolsDir.Join(ctx, image.stem+".oat")
|
||||||
outputDir := image.dir.Join(ctx, "system/framework", arch.String())
|
outputDir := image.dir.Join(ctx, "system/framework", arch.String())
|
||||||
outputPath := image.images[arch]
|
outputPath := image.images[arch]
|
||||||
oatLocation := pathtools.ReplaceExtension(dexpreopt.PathToLocation(outputPath, arch), "oat")
|
oatLocation := pathtools.ReplaceExtension(dexpreopt.PathToLocation(outputPath, arch), "oat")
|
||||||
@@ -381,8 +396,9 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin
|
|||||||
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
|
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
|
||||||
tools := global.Tools
|
tools := global.Tools
|
||||||
|
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
|
||||||
|
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
rule.MissingDeps(missingDeps)
|
rule.MissingDeps(missingDeps)
|
||||||
@@ -394,18 +410,13 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin
|
|||||||
bootImageProfile = combinedBootImageProfile
|
bootImageProfile = combinedBootImageProfile
|
||||||
} else if len(global.BootImageProfiles) == 1 {
|
} else if len(global.BootImageProfiles) == 1 {
|
||||||
bootImageProfile = global.BootImageProfiles[0]
|
bootImageProfile = global.BootImageProfiles[0]
|
||||||
|
} else if path := android.ExistentPathForSource(ctx, defaultProfile); path.Valid() {
|
||||||
|
bootImageProfile = path.Path()
|
||||||
} else {
|
} else {
|
||||||
// If not set, use the default. Some branches like master-art-host don't have frameworks/base, so manually
|
// No profile (not even a default one, which is the case on some branches
|
||||||
// handle the case that the default is missing. Those branches won't attempt to build the profile rule,
|
// like master-art-host that don't have frameworks/base).
|
||||||
// and if they do they'll get a missing deps error.
|
// Return nil and continue without profile.
|
||||||
defaultProfile := "frameworks/base/config/boot-image-profile.txt"
|
return nil
|
||||||
path := android.ExistentPathForSource(ctx, defaultProfile)
|
|
||||||
if path.Valid() {
|
|
||||||
bootImageProfile = path.Path()
|
|
||||||
} else {
|
|
||||||
missingDeps = append(missingDeps, defaultProfile)
|
|
||||||
bootImageProfile = android.PathForOutput(ctx, "missing")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
profile := image.dir.Join(ctx, "boot.prof")
|
profile := image.dir.Join(ctx, "boot.prof")
|
||||||
@@ -425,7 +436,11 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin
|
|||||||
image.profileInstalls = rule.Installs()
|
image.profileInstalls = rule.Installs()
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
}).(android.WritablePath)
|
})
|
||||||
|
if profile == nil {
|
||||||
|
return nil // wrap nil into a typed pointer with value nil
|
||||||
|
}
|
||||||
|
return profile.(android.WritablePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
|
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
|
||||||
|
@@ -62,7 +62,6 @@ func TestDexpreoptBootJars(t *testing.T) {
|
|||||||
bootArt := dexpreoptBootJars.Output("boot.art")
|
bootArt := dexpreoptBootJars.Output("boot.art")
|
||||||
|
|
||||||
expectedInputs := []string{
|
expectedInputs := []string{
|
||||||
"dex_bootjars/boot.prof",
|
|
||||||
"dex_bootjars_input/foo.jar",
|
"dex_bootjars_input/foo.jar",
|
||||||
"dex_bootjars_input/bar.jar",
|
"dex_bootjars_input/bar.jar",
|
||||||
"dex_bootjars_input/baz.jar",
|
"dex_bootjars_input/baz.jar",
|
||||||
|
@@ -106,15 +106,20 @@ func stemOf(moduleName string) string {
|
|||||||
return moduleName
|
return moduleName
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name string,
|
// Construct a variant of the global config for dexpreopted bootclasspath jars. The variants differ
|
||||||
needZip bool) bootImageConfig {
|
// in the list of input jars (libcore, framework, or both), in the naming scheme for the dexpreopt
|
||||||
|
// files (ART recognizes "apex" names as special), and whether to include a zip archive.
|
||||||
|
//
|
||||||
|
// 'name' is a string unique for each profile (used in directory names and ninja rule names)
|
||||||
|
// 'stem' is the basename of the image: the resulting filenames are <stem>[-<jar>].{art,oat,vdex}.
|
||||||
|
func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name string, stem string,
|
||||||
|
needZip bool, artApexJarsOnly bool) bootImageConfig {
|
||||||
|
|
||||||
return ctx.Config().Once(key, func() interface{} {
|
return ctx.Config().Once(key, func() interface{} {
|
||||||
global := dexpreoptGlobalConfig(ctx)
|
global := dexpreoptGlobalConfig(ctx)
|
||||||
|
|
||||||
artModules := global.ArtApexJars
|
artModules := global.ArtApexJars
|
||||||
nonFrameworkModules := concat(artModules, global.ProductUpdatableBootModules)
|
imageModules := artModules
|
||||||
frameworkModules := android.RemoveListFromList(global.BootJars, nonFrameworkModules)
|
|
||||||
imageModules := concat(artModules, frameworkModules)
|
|
||||||
|
|
||||||
var bootLocations []string
|
var bootLocations []string
|
||||||
|
|
||||||
@@ -123,9 +128,15 @@ func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name strin
|
|||||||
filepath.Join("/apex/com.android.art/javalib", stemOf(m)+".jar"))
|
filepath.Join("/apex/com.android.art/javalib", stemOf(m)+".jar"))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, m := range frameworkModules {
|
if !artApexJarsOnly {
|
||||||
bootLocations = append(bootLocations,
|
nonFrameworkModules := concat(artModules, global.ProductUpdatableBootModules)
|
||||||
filepath.Join("/system/framework", stemOf(m)+".jar"))
|
frameworkModules := android.RemoveListFromList(global.BootJars, nonFrameworkModules)
|
||||||
|
imageModules = concat(imageModules, frameworkModules)
|
||||||
|
|
||||||
|
for _, m := range frameworkModules {
|
||||||
|
bootLocations = append(bootLocations,
|
||||||
|
filepath.Join("/system/framework", stemOf(m)+".jar"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The path to bootclasspath dex files needs to be known at module GenerateAndroidBuildAction time, before
|
// The path to bootclasspath dex files needs to be known at module GenerateAndroidBuildAction time, before
|
||||||
@@ -143,13 +154,14 @@ func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name strin
|
|||||||
|
|
||||||
var zip android.WritablePath
|
var zip android.WritablePath
|
||||||
if needZip {
|
if needZip {
|
||||||
zip = dir.Join(ctx, name+".zip")
|
zip = dir.Join(ctx, stem+".zip")
|
||||||
}
|
}
|
||||||
|
|
||||||
targets := dexpreoptTargets(ctx)
|
targets := dexpreoptTargets(ctx)
|
||||||
|
|
||||||
imageConfig := bootImageConfig{
|
imageConfig := bootImageConfig{
|
||||||
name: name,
|
name: name,
|
||||||
|
stem: stem,
|
||||||
modules: imageModules,
|
modules: imageModules,
|
||||||
dexLocations: bootLocations,
|
dexLocations: bootLocations,
|
||||||
dexPaths: bootDexPaths,
|
dexPaths: bootDexPaths,
|
||||||
@@ -163,7 +175,7 @@ func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name strin
|
|||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
imageDir := dir.Join(ctx, "system/framework", target.Arch.ArchType.String())
|
imageDir := dir.Join(ctx, "system/framework", target.Arch.ArchType.String())
|
||||||
imageConfig.images[target.Arch.ArchType] = imageDir.Join(ctx, name+".art")
|
imageConfig.images[target.Arch.ArchType] = imageDir.Join(ctx, stem+".art")
|
||||||
|
|
||||||
imagesDeps := make([]android.Path, 0, len(imageConfig.modules)*3)
|
imagesDeps := make([]android.Path, 0, len(imageConfig.modules)*3)
|
||||||
for _, dep := range imageConfig.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex") {
|
for _, dep := range imageConfig.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex") {
|
||||||
@@ -176,15 +188,25 @@ func getBootImageConfig(ctx android.PathContext, key android.OnceKey, name strin
|
|||||||
}).(bootImageConfig)
|
}).(bootImageConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default config is the one that goes in the system image. It includes both libcore and framework.
|
||||||
var defaultBootImageConfigKey = android.NewOnceKey("defaultBootImageConfig")
|
var defaultBootImageConfigKey = android.NewOnceKey("defaultBootImageConfig")
|
||||||
var apexBootImageConfigKey = android.NewOnceKey("apexBootImageConfig")
|
|
||||||
|
|
||||||
func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||||
return getBootImageConfig(ctx, defaultBootImageConfigKey, "boot", true)
|
return getBootImageConfig(ctx, defaultBootImageConfigKey, "boot", "boot", true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apex config is used for the JIT-zygote experiment. It includes both libcore and framework, but AOT-compiles only libcore.
|
||||||
|
var apexBootImageConfigKey = android.NewOnceKey("apexBootImageConfig")
|
||||||
|
|
||||||
func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
func apexBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||||
return getBootImageConfig(ctx, apexBootImageConfigKey, "apex", false)
|
return getBootImageConfig(ctx, apexBootImageConfigKey, "apex", "apex", false, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ART config is the one used for the ART apex. It includes only libcore.
|
||||||
|
var artBootImageConfigKey = android.NewOnceKey("artBootImageConfig")
|
||||||
|
|
||||||
|
func artBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||||
|
return getBootImageConfig(ctx, artBootImageConfigKey, "art", "boot", false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultBootclasspath(ctx android.PathContext) []string {
|
func defaultBootclasspath(ctx android.PathContext) []string {
|
||||||
|
Reference in New Issue
Block a user