Merge "Raise an error instead of panic in SplitApexJarPairs." am: 7645764e58
Change-Id: I5a65eed47005ea7687b686b1a90abc08360c6bc2
This commit is contained in:
committed by
Automerger Merge Worker
commit
2a6f9587de
@@ -897,27 +897,31 @@ func (c *config) ModulesLoadedByPrivilegedModules() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expected format for apexJarValue = <apex name>:<jar name>
|
// Expected format for apexJarValue = <apex name>:<jar name>
|
||||||
func SplitApexJarPair(apexJarValue string) (string, string) {
|
func SplitApexJarPair(ctx PathContext, str string) (string, string) {
|
||||||
var apexJarPair []string = strings.SplitN(apexJarValue, ":", 2)
|
pair := strings.SplitN(str, ":", 2)
|
||||||
if apexJarPair == nil || len(apexJarPair) != 2 {
|
if len(pair) == 2 {
|
||||||
panic(fmt.Errorf("malformed apexJarValue: %q, expected format: <apex>:<jar>",
|
return pair[0], pair[1]
|
||||||
apexJarValue))
|
} else {
|
||||||
|
reportPathErrorf(ctx, "malformed (apex, jar) pair: '%s', expected format: <apex>:<jar>", str)
|
||||||
|
return "error-apex", "error-jar"
|
||||||
}
|
}
|
||||||
return apexJarPair[0], apexJarPair[1]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetJarsFromApexJarPairs(apexJarPairs []string) []string {
|
func GetJarsFromApexJarPairs(ctx PathContext, apexJarPairs []string) []string {
|
||||||
modules := make([]string, len(apexJarPairs))
|
modules := make([]string, len(apexJarPairs))
|
||||||
for i, p := range apexJarPairs {
|
for i, p := range apexJarPairs {
|
||||||
_, jar := SplitApexJarPair(p)
|
_, jar := SplitApexJarPair(ctx, p)
|
||||||
modules[i] = jar
|
modules[i] = jar
|
||||||
}
|
}
|
||||||
return modules
|
return modules
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) BootJars() []string {
|
func (c *config) BootJars() []string {
|
||||||
return append(GetJarsFromApexJarPairs(c.productVariables.BootJars),
|
ctx := NullPathContext{Config{
|
||||||
GetJarsFromApexJarPairs(c.productVariables.UpdatableBootJars)...)
|
config: c,
|
||||||
|
}}
|
||||||
|
return append(GetJarsFromApexJarPairs(ctx, c.productVariables.BootJars),
|
||||||
|
GetJarsFromApexJarPairs(ctx, c.productVariables.UpdatableBootJars)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) DexpreoptGlobalConfig(ctx PathContext) ([]byte, error) {
|
func (c *config) DexpreoptGlobalConfig(ctx PathContext) ([]byte, error) {
|
||||||
|
@@ -43,6 +43,14 @@ type PathGlobContext interface {
|
|||||||
var _ PathContext = SingletonContext(nil)
|
var _ PathContext = SingletonContext(nil)
|
||||||
var _ PathContext = ModuleContext(nil)
|
var _ PathContext = ModuleContext(nil)
|
||||||
|
|
||||||
|
// "Null" path context is a minimal path context for a given config.
|
||||||
|
type NullPathContext struct {
|
||||||
|
config Config
|
||||||
|
}
|
||||||
|
|
||||||
|
func (NullPathContext) AddNinjaFileDeps(...string) {}
|
||||||
|
func (ctx NullPathContext) Config() Config { return ctx.config }
|
||||||
|
|
||||||
type ModuleInstallPathContext interface {
|
type ModuleInstallPathContext interface {
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
|
|
||||||
|
@@ -82,7 +82,7 @@ func GenerateDexpreoptRule(ctx android.PathContext, globalSoong *GlobalSoongConf
|
|||||||
|
|
||||||
if !dexpreoptDisabled(ctx, global, module) {
|
if !dexpreoptDisabled(ctx, global, module) {
|
||||||
// Don't preopt individual boot jars, they will be preopted together.
|
// Don't preopt individual boot jars, they will be preopted together.
|
||||||
if !contains(android.GetJarsFromApexJarPairs(global.BootJars), module.Name) {
|
if !contains(android.GetJarsFromApexJarPairs(ctx, global.BootJars), module.Name) {
|
||||||
appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) &&
|
appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) &&
|
||||||
!module.NoCreateAppImage
|
!module.NoCreateAppImage
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ func dexpreoptDisabled(ctx android.PathContext, global *GlobalConfig, module *Mo
|
|||||||
|
|
||||||
// Don't preopt system server jars that are updatable.
|
// Don't preopt system server jars that are updatable.
|
||||||
for _, p := range global.UpdatableSystemServerJars {
|
for _, p := range global.UpdatableSystemServerJars {
|
||||||
if _, jar := android.SplitApexJarPair(p); jar == module.Name {
|
if _, jar := android.SplitApexJarPair(ctx, p); jar == module.Name {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
// 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
|
// /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.
|
// or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options.
|
||||||
if global.OnlyPreoptBootImageAndSystemServer && !contains(android.GetJarsFromApexJarPairs(global.BootJars), module.Name) &&
|
if global.OnlyPreoptBootImageAndSystemServer && !contains(android.GetJarsFromApexJarPairs(ctx, global.BootJars), module.Name) &&
|
||||||
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -561,8 +561,8 @@ func makefileMatch(pattern, s string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expected format for apexJarValue = <apex name>:<jar name>
|
// Expected format for apexJarValue = <apex name>:<jar name>
|
||||||
func GetJarLocationFromApexJarPair(apexJarValue string) string {
|
func GetJarLocationFromApexJarPair(ctx android.PathContext, apexJarValue string) string {
|
||||||
apex, jar := android.SplitApexJarPair(apexJarValue)
|
apex, jar := android.SplitApexJarPair(ctx, apexJarValue)
|
||||||
return filepath.Join("/apex", apex, "javalib", jar+".jar")
|
return filepath.Join("/apex", apex, "javalib", jar+".jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,7 +573,7 @@ var nonUpdatableSystemServerJarsKey = android.NewOnceKey("nonUpdatableSystemServ
|
|||||||
func NonUpdatableSystemServerJars(ctx android.PathContext, global *GlobalConfig) []string {
|
func NonUpdatableSystemServerJars(ctx android.PathContext, global *GlobalConfig) []string {
|
||||||
return ctx.Config().Once(nonUpdatableSystemServerJarsKey, func() interface{} {
|
return ctx.Config().Once(nonUpdatableSystemServerJarsKey, func() interface{} {
|
||||||
return android.RemoveListFromList(global.SystemServerJars,
|
return android.RemoveListFromList(global.SystemServerJars,
|
||||||
android.GetJarsFromApexJarPairs(global.UpdatableSystemServerJars))
|
android.GetJarsFromApexJarPairs(ctx, global.UpdatableSystemServerJars))
|
||||||
}).([]string)
|
}).([]string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,11 +109,11 @@ func (image bootImageConfig) getAnyAndroidVariant() *bootImageVariant {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (image bootImageConfig) moduleName(idx int) string {
|
func (image bootImageConfig) moduleName(ctx android.PathContext, 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
|
||||||
// exists), and the rest are converted to 'name'-<jar>.art.
|
// exists), and the rest are converted to 'name'-<jar>.art.
|
||||||
_, m := android.SplitApexJarPair(image.modules[idx])
|
_, m := android.SplitApexJarPair(ctx, image.modules[idx])
|
||||||
name := image.stem
|
name := image.stem
|
||||||
if idx != 0 || image.extends != nil {
|
if idx != 0 || image.extends != nil {
|
||||||
name += "-" + stemOf(m)
|
name += "-" + stemOf(m)
|
||||||
@@ -121,9 +121,9 @@ func (image bootImageConfig) moduleName(idx int) string {
|
|||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (image bootImageConfig) firstModuleNameOrStem() string {
|
func (image bootImageConfig) firstModuleNameOrStem(ctx android.PathContext) string {
|
||||||
if len(image.modules) > 0 {
|
if len(image.modules) > 0 {
|
||||||
return image.moduleName(0)
|
return image.moduleName(ctx, 0)
|
||||||
} else {
|
} else {
|
||||||
return image.stem
|
return image.stem
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ func (image bootImageConfig) firstModuleNameOrStem() string {
|
|||||||
func (image bootImageConfig) moduleFiles(ctx android.PathContext, dir android.OutputPath, exts ...string) android.OutputPaths {
|
func (image bootImageConfig) moduleFiles(ctx android.PathContext, dir android.OutputPath, exts ...string) android.OutputPaths {
|
||||||
ret := make(android.OutputPaths, 0, len(image.modules)*len(exts))
|
ret := make(android.OutputPaths, 0, len(image.modules)*len(exts))
|
||||||
for i := range image.modules {
|
for i := range image.modules {
|
||||||
name := image.moduleName(i)
|
name := image.moduleName(ctx, i)
|
||||||
for _, ext := range exts {
|
for _, ext := range exts {
|
||||||
ret = append(ret, dir.Join(ctx, name+ext))
|
ret = append(ret, dir.Join(ctx, name+ext))
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
|
|||||||
}
|
}
|
||||||
|
|
||||||
name := ctx.ModuleName(module)
|
name := ctx.ModuleName(module)
|
||||||
index := android.IndexList(name, android.GetJarsFromApexJarPairs(image.modules))
|
index := android.IndexList(name, android.GetJarsFromApexJarPairs(ctx, image.modules))
|
||||||
if index == -1 {
|
if index == -1 {
|
||||||
return -1, nil
|
return -1, nil
|
||||||
}
|
}
|
||||||
@@ -314,7 +314,7 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootI
|
|||||||
// Ensure all modules were converted to paths
|
// Ensure all modules were converted to paths
|
||||||
for i := range bootDexJars {
|
for i := range bootDexJars {
|
||||||
if bootDexJars[i] == nil {
|
if bootDexJars[i] == nil {
|
||||||
_, m := android.SplitApexJarPair(image.modules[i])
|
_, m := android.SplitApexJarPair(ctx, image.modules[i])
|
||||||
if ctx.Config().AllowMissingDependencies() {
|
if ctx.Config().AllowMissingDependencies() {
|
||||||
missingDeps = append(missingDeps, m)
|
missingDeps = append(missingDeps, m)
|
||||||
bootDexJars[i] = android.PathForOutput(ctx, "missing")
|
bootDexJars[i] = android.PathForOutput(ctx, "missing")
|
||||||
@@ -614,7 +614,7 @@ func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConf
|
|||||||
|
|
||||||
return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
|
return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
|
||||||
global := dexpreopt.GetGlobalConfig(ctx)
|
global := dexpreopt.GetGlobalConfig(ctx)
|
||||||
updatableModules := android.GetJarsFromApexJarPairs(global.UpdatableBootJars)
|
updatableModules := android.GetJarsFromApexJarPairs(ctx, global.UpdatableBootJars)
|
||||||
|
|
||||||
// Collect `permitted_packages` for updatable boot jars.
|
// Collect `permitted_packages` for updatable boot jars.
|
||||||
var updatablePackages []string
|
var updatablePackages []string
|
||||||
|
@@ -39,7 +39,7 @@ func systemServerClasspath(ctx android.MakeVarsContext) []string {
|
|||||||
// 2) The jars that are from an updatable apex.
|
// 2) The jars that are from an updatable apex.
|
||||||
for _, m := range global.UpdatableSystemServerJars {
|
for _, m := range global.UpdatableSystemServerJars {
|
||||||
systemServerClasspathLocations = append(systemServerClasspathLocations,
|
systemServerClasspathLocations = append(systemServerClasspathLocations,
|
||||||
dexpreopt.GetJarLocationFromApexJarPair(m))
|
dexpreopt.GetJarLocationFromApexJarPair(ctx, m))
|
||||||
}
|
}
|
||||||
if len(systemServerClasspathLocations) != len(global.SystemServerJars)+len(global.UpdatableSystemServerJars) {
|
if len(systemServerClasspathLocations) != len(global.SystemServerJars)+len(global.UpdatableSystemServerJars) {
|
||||||
panic(fmt.Errorf("Wrong number of system server jars, got %d, expected %d",
|
panic(fmt.Errorf("Wrong number of system server jars, got %d, expected %d",
|
||||||
@@ -80,7 +80,7 @@ func stemOf(moduleName string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getDexLocation(ctx android.PathContext, target android.Target, module string) string {
|
func getDexLocation(ctx android.PathContext, target android.Target, module string) string {
|
||||||
apex, jar := android.SplitApexJarPair(module)
|
apex, jar := android.SplitApexJarPair(ctx, module)
|
||||||
|
|
||||||
name := stemOf(jar) + ".jar"
|
name := stemOf(jar) + ".jar"
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
|||||||
c.symbolsDir = deviceDir.Join(ctx, "dex_"+c.name+"jars_unstripped")
|
c.symbolsDir = deviceDir.Join(ctx, "dex_"+c.name+"jars_unstripped")
|
||||||
|
|
||||||
// expands to <stem>.art for primary image and <stem>-<1st module>.art for extension
|
// expands to <stem>.art for primary image and <stem>-<1st module>.art for extension
|
||||||
imageName := c.firstModuleNameOrStem() + ".art"
|
imageName := c.firstModuleNameOrStem(ctx) + ".art"
|
||||||
|
|
||||||
// The path to bootclasspath dex files needs to be known at module
|
// The path to bootclasspath dex files needs to be known at module
|
||||||
// GenerateAndroidBuildAction time, before the bootclasspath modules have been compiled.
|
// GenerateAndroidBuildAction time, before the bootclasspath modules have been compiled.
|
||||||
@@ -164,7 +164,7 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
|||||||
// TODO(b/143682396): use module dependencies instead
|
// TODO(b/143682396): use module dependencies instead
|
||||||
inputDir := deviceDir.Join(ctx, "dex_"+c.name+"jars_input")
|
inputDir := deviceDir.Join(ctx, "dex_"+c.name+"jars_input")
|
||||||
for _, m := range c.modules {
|
for _, m := range c.modules {
|
||||||
_, jar := android.SplitApexJarPair(m)
|
_, jar := android.SplitApexJarPair(ctx, m)
|
||||||
c.dexPaths = append(c.dexPaths, inputDir.Join(ctx, stemOf(jar)+".jar"))
|
c.dexPaths = append(c.dexPaths, inputDir.Join(ctx, stemOf(jar)+".jar"))
|
||||||
}
|
}
|
||||||
c.dexPathsDeps = c.dexPaths
|
c.dexPathsDeps = c.dexPaths
|
||||||
@@ -215,7 +215,7 @@ func defaultBootclasspath(ctx android.PathContext) []string {
|
|||||||
|
|
||||||
updatableBootclasspath := make([]string, len(global.UpdatableBootJars))
|
updatableBootclasspath := make([]string, len(global.UpdatableBootJars))
|
||||||
for i, p := range global.UpdatableBootJars {
|
for i, p := range global.UpdatableBootJars {
|
||||||
updatableBootclasspath[i] = dexpreopt.GetJarLocationFromApexJarPair(p)
|
updatableBootclasspath[i] = dexpreopt.GetJarLocationFromApexJarPair(ctx, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
bootclasspath := append(copyOf(image.getAnyAndroidVariant().dexLocationsDeps), updatableBootclasspath...)
|
bootclasspath := append(copyOf(image.getAnyAndroidVariant().dexLocationsDeps), updatableBootclasspath...)
|
||||||
|
Reference in New Issue
Block a user