Merge "Error on suboptimal system server classpath order, unless explicitly allowed."
This commit is contained in:
commit
eb3f9f1295
|
@ -50,6 +50,8 @@ type GlobalConfig struct {
|
|||
UpdatableSystemServerJars []string // jars within apex that are loaded into system server
|
||||
SpeedApps []string // apps that should be speed optimized
|
||||
|
||||
BrokenSuboptimalOrderOfSystemServerJars bool // if true, sub-optimal order does not cause a build error
|
||||
|
||||
PreoptFlags []string // global dex2oat flags that should be used if no module-specific dex2oat flags are specified
|
||||
|
||||
DefaultCompilerFilter string // default compiler filter to pass to dex2oat, overridden by --compiler-filter= in module-specific dex2oat flags
|
||||
|
|
|
@ -314,6 +314,8 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g
|
|||
dexPathHost := SystemServerDexJarHostPath(ctx, module.Name)
|
||||
rule.Command().Text("mkdir -p").Flag(filepath.Dir(dexPathHost.String()))
|
||||
rule.Command().Text("cp -f").Input(module.DexPath).Output(dexPathHost)
|
||||
|
||||
checkSystemServerOrder(ctx, jarIndex)
|
||||
} else {
|
||||
// Pass special class loader context to skip the classpath and collision check.
|
||||
// This will get removed once LOCAL_USES_LIBRARIES is enforced.
|
||||
|
@ -607,6 +609,29 @@ func SystemServerDexJarHostPath(ctx android.PathContext, jar string) android.Out
|
|||
}
|
||||
}
|
||||
|
||||
// Check the order of jars on the system server classpath and give a warning/error if a jar precedes
|
||||
// one of its dependencies. This is not an error, but a missed optimization, as dexpreopt won't
|
||||
// have the dependency jar in the class loader context, and it won't be able to resolve any
|
||||
// references to its classes and methods.
|
||||
func checkSystemServerOrder(ctx android.PathContext, jarIndex int) {
|
||||
mctx, isModule := ctx.(android.ModuleContext)
|
||||
if isModule {
|
||||
config := GetGlobalConfig(ctx)
|
||||
jars := NonUpdatableSystemServerJars(ctx, config)
|
||||
mctx.WalkDeps(func(dep android.Module, parent android.Module) bool {
|
||||
depIndex := android.IndexList(dep.Name(), jars)
|
||||
if jarIndex < depIndex && !config.BrokenSuboptimalOrderOfSystemServerJars {
|
||||
jar := jars[jarIndex]
|
||||
dep := jars[depIndex]
|
||||
mctx.ModuleErrorf("non-optimal order of jars on the system server classpath:"+
|
||||
" '%s' precedes its dependency '%s', so dexpreopt is unable to resolve any"+
|
||||
" references from '%s' to '%s'.\n", jar, dep, jar, dep)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func contains(l []string, s string) bool {
|
||||
for _, e := range l {
|
||||
if e == s {
|
||||
|
|
Loading…
Reference in New Issue