Merge "Use two-column format for PRODUCT_BOOT_JARS components."
This commit is contained in:
commit
2aa8e0be11
6 changed files with 48 additions and 39 deletions
|
@ -906,13 +906,18 @@ func SplitApexJarPair(apexJarValue string) (string, string) {
|
|||
return apexJarPair[0], apexJarPair[1]
|
||||
}
|
||||
|
||||
func (c *config) BootJars() []string {
|
||||
jars := c.productVariables.BootJars
|
||||
for _, p := range c.productVariables.UpdatableBootJars {
|
||||
func GetJarsFromApexJarPairs(apexJarPairs []string) []string {
|
||||
modules := make([]string, len(apexJarPairs))
|
||||
for i, p := range apexJarPairs {
|
||||
_, jar := SplitApexJarPair(p)
|
||||
jars = append(jars, jar)
|
||||
modules[i] = jar
|
||||
}
|
||||
return jars
|
||||
return modules
|
||||
}
|
||||
|
||||
func (c *config) BootJars() []string {
|
||||
return append(GetJarsFromApexJarPairs(c.productVariables.BootJars),
|
||||
GetJarsFromApexJarPairs(c.productVariables.UpdatableBootJars)...)
|
||||
}
|
||||
|
||||
func (c *config) DexpreoptGlobalConfig(ctx PathContext) ([]byte, error) {
|
||||
|
|
|
@ -4526,68 +4526,68 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) {
|
|||
|
||||
// updatable jar from ART apex in the ART boot image => ok
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-art-lib"}
|
||||
config.ArtApexJars = []string{"com.android.art.something:some-art-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
||||
|
||||
// updatable jar from ART apex in the framework boot image => error
|
||||
error = "module 'some-art-lib' from updatable apex 'com.android.art.something' is not allowed in the framework boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-art-lib"}
|
||||
config.BootJars = []string{"com.android.art.something:some-art-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
|
||||
// updatable jar from some other apex in the ART boot image => error
|
||||
error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-updatable-apex-lib"}
|
||||
config.ArtApexJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
|
||||
// non-updatable jar from some other apex in the ART boot image => error
|
||||
error = "module 'some-non-updatable-apex-lib' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-non-updatable-apex-lib"}
|
||||
config.ArtApexJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
|
||||
// updatable jar from some other apex in the framework boot image => error
|
||||
error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the framework boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-updatable-apex-lib"}
|
||||
config.BootJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
|
||||
// non-updatable jar from some other apex in the framework boot image => ok
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-non-updatable-apex-lib"}
|
||||
config.BootJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
||||
|
||||
// nonexistent jar in the ART boot image => error
|
||||
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"nonexistent"}
|
||||
config.ArtApexJars = []string{"platform:nonexistent"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
|
||||
// nonexistent jar in the framework boot image => error
|
||||
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"nonexistent"}
|
||||
config.BootJars = []string{"platform:nonexistent"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
|
||||
// platform jar in the ART boot image => error
|
||||
error = "module 'some-platform-lib' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-platform-lib"}
|
||||
config.ArtApexJars = []string{"platform:some-platform-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
|
||||
// platform jar in the framework boot image => ok
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-platform-lib"}
|
||||
config.BootJars = []string{"platform:some-platform-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ func GenerateDexpreoptRule(ctx android.PathContext, globalSoong *GlobalSoongConf
|
|||
|
||||
if !dexpreoptDisabled(ctx, global, module) {
|
||||
// Don't preopt individual boot jars, they will be preopted together.
|
||||
if !contains(global.BootJars, module.Name) {
|
||||
if !contains(android.GetJarsFromApexJarPairs(global.BootJars), module.Name) {
|
||||
appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) &&
|
||||
!module.NoCreateAppImage
|
||||
|
||||
|
@ -113,7 +113,7 @@ func dexpreoptDisabled(ctx android.PathContext, global *GlobalConfig, module *Mo
|
|||
// Also preopt system server jars since selinux prevents system server from loading anything from
|
||||
// /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
|
||||
// or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options.
|
||||
if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) &&
|
||||
if global.OnlyPreoptBootImageAndSystemServer && !contains(android.GetJarsFromApexJarPairs(global.BootJars), module.Name) &&
|
||||
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
||||
return true
|
||||
}
|
||||
|
@ -566,15 +566,6 @@ func GetJarLocationFromApexJarPair(apexJarValue string) string {
|
|||
return filepath.Join("/apex", apex, "javalib", jar+".jar")
|
||||
}
|
||||
|
||||
func GetJarsFromApexJarPairs(apexJarPairs []string) []string {
|
||||
modules := make([]string, len(apexJarPairs))
|
||||
for i, p := range apexJarPairs {
|
||||
_, jar := android.SplitApexJarPair(p)
|
||||
modules[i] = jar
|
||||
}
|
||||
return modules
|
||||
}
|
||||
|
||||
var nonUpdatableSystemServerJarsKey = android.NewOnceKey("nonUpdatableSystemServerJars")
|
||||
|
||||
// TODO: eliminate the superficial global config parameter by moving global config definition
|
||||
|
@ -582,7 +573,7 @@ var nonUpdatableSystemServerJarsKey = android.NewOnceKey("nonUpdatableSystemServ
|
|||
func NonUpdatableSystemServerJars(ctx android.PathContext, global *GlobalConfig) []string {
|
||||
return ctx.Config().Once(nonUpdatableSystemServerJarsKey, func() interface{} {
|
||||
return android.RemoveListFromList(global.SystemServerJars,
|
||||
GetJarsFromApexJarPairs(global.UpdatableSystemServerJars))
|
||||
android.GetJarsFromApexJarPairs(global.UpdatableSystemServerJars))
|
||||
}).([]string)
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ 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
|
||||
// exists), and the rest are converted to 'name'-<jar>.art.
|
||||
m := image.modules[idx]
|
||||
_, m := android.SplitApexJarPair(image.modules[idx])
|
||||
name := image.stem
|
||||
if idx != 0 || image.extends != nil {
|
||||
name += "-" + stemOf(m)
|
||||
|
@ -261,7 +261,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
|
|||
}
|
||||
|
||||
name := ctx.ModuleName(module)
|
||||
index := android.IndexList(name, image.modules)
|
||||
index := android.IndexList(name, android.GetJarsFromApexJarPairs(image.modules))
|
||||
if index == -1 {
|
||||
return -1, nil
|
||||
}
|
||||
|
@ -314,13 +314,13 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootI
|
|||
// Ensure all modules were converted to paths
|
||||
for i := range bootDexJars {
|
||||
if bootDexJars[i] == nil {
|
||||
_, m := android.SplitApexJarPair(image.modules[i])
|
||||
if ctx.Config().AllowMissingDependencies() {
|
||||
missingDeps = append(missingDeps, image.modules[i])
|
||||
missingDeps = append(missingDeps, m)
|
||||
bootDexJars[i] = android.PathForOutput(ctx, "missing")
|
||||
} else {
|
||||
ctx.Errorf("failed to find a dex jar path for module '%s'"+
|
||||
", note that some jars may be filtered out by module constraints",
|
||||
image.modules[i])
|
||||
", note that some jars may be filtered out by module constraints", m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConf
|
|||
|
||||
return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
updatableModules := dexpreopt.GetJarsFromApexJarPairs(global.UpdatableBootJars)
|
||||
updatableModules := android.GetJarsFromApexJarPairs(global.UpdatableBootJars)
|
||||
|
||||
// Collect `permitted_packages` for updatable boot jars.
|
||||
var updatablePackages []string
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestDexpreoptBootJars(t *testing.T) {
|
|||
|
||||
pathCtx := android.PathContextForTesting(config)
|
||||
dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx)
|
||||
dexpreoptConfig.BootJars = []string{"foo", "bar", "baz"}
|
||||
dexpreoptConfig.BootJars = []string{"platform:foo", "platform:bar", "platform:baz"}
|
||||
dexpreopt.SetTestGlobalConfig(config, dexpreoptConfig)
|
||||
|
||||
ctx := testContext()
|
||||
|
|
|
@ -79,7 +79,20 @@ func stemOf(moduleName string) string {
|
|||
return moduleName
|
||||
}
|
||||
|
||||
func getDexLocation(ctx android.PathContext, target android.Target, subdir string, name string) string {
|
||||
func getDexLocation(ctx android.PathContext, target android.Target, module string) string {
|
||||
apex, jar := android.SplitApexJarPair(module)
|
||||
|
||||
name := stemOf(jar) + ".jar"
|
||||
|
||||
var subdir string
|
||||
if apex == "platform" {
|
||||
// Special apex name "platform" denotes jars do not come from an apex, but are part
|
||||
// of the platform. Such jars are installed on the /system partition on device.
|
||||
subdir = "system/framework"
|
||||
} else {
|
||||
subdir = filepath.Join("apex", apex, "javalib")
|
||||
}
|
||||
|
||||
if target.Os.Class == android.Host {
|
||||
return filepath.Join(ctx.Config().Getenv("OUT_DIR"), "host", ctx.Config().PrebuiltOS(), subdir, name)
|
||||
} else {
|
||||
|
@ -106,8 +119,7 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
|||
if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
|
||||
artModules = append(artModules, "jacocoagent")
|
||||
}
|
||||
frameworkModules := android.RemoveListFromList(global.BootJars,
|
||||
concat(artModules, dexpreopt.GetJarsFromApexJarPairs(global.UpdatableBootJars)))
|
||||
frameworkModules := android.RemoveListFromList(global.BootJars, artModules)
|
||||
|
||||
artSubdir := "apex/com.android.art/javalib"
|
||||
frameworkSubdir := "system/framework"
|
||||
|
@ -150,7 +162,8 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
|||
// TODO(b/143682396): use module dependencies instead
|
||||
inputDir := deviceDir.Join(ctx, "dex_"+c.name+"jars_input")
|
||||
for _, m := range c.modules {
|
||||
c.dexPaths = append(c.dexPaths, inputDir.Join(ctx, stemOf(m)+".jar"))
|
||||
_, jar := android.SplitApexJarPair(m)
|
||||
c.dexPaths = append(c.dexPaths, inputDir.Join(ctx, stemOf(jar)+".jar"))
|
||||
}
|
||||
c.dexPathsDeps = c.dexPaths
|
||||
|
||||
|
@ -165,7 +178,7 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
|||
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.dexLocations = append(variant.dexLocations, getDexLocation(ctx, target, m))
|
||||
}
|
||||
variant.dexLocationsDeps = variant.dexLocations
|
||||
c.variants = append(c.variants, variant)
|
||||
|
|
Loading…
Reference in a new issue