Merge "Use precise class loader context for system server jars." am: 394b9b379a am: 1b8156a3cf am: 71010c3e87

Change-Id: I441d52a0d7fcdd0ca90bfe2c71a2f1278d6a030a
This commit is contained in:
Automerger Merge Worker
2020-02-13 18:01:22 +00:00
3 changed files with 122 additions and 19 deletions

View File

@@ -70,12 +70,11 @@ var dexpreoptTestGlobalConfigKey = android.NewOnceKey("TestDexpreoptGlobalConfig
// systemServerClasspath returns the on-device locations of the modules in the system server classpath. It is computed
// once the first time it is called for any ctx.Config(), and returns the same slice for all future calls with the same
// ctx.Config().
func systemServerClasspath(ctx android.PathContext) []string {
func systemServerClasspath(ctx android.MakeVarsContext) []string {
return ctx.Config().OnceStringSlice(systemServerClasspathKey, func() []string {
global := dexpreoptGlobalConfig(ctx)
var systemServerClasspathLocations []string
for _, m := range global.SystemServerJars {
for _, m := range *DexpreoptedSystemServerJars(ctx.Config()) {
systemServerClasspathLocations = append(systemServerClasspathLocations,
filepath.Join("/system/framework", m+".jar"))
}
@@ -112,15 +111,6 @@ func stemOf(moduleName string) string {
return moduleName
}
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 (
bootImageConfigKey = android.NewOnceKey("bootImageConfig")
artBootImageName = "art"
@@ -141,7 +131,7 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
artModules = append(artModules, "jacocoagent")
}
frameworkModules := android.RemoveListFromList(global.BootJars,
concat(artModules, getJarsFromApexJarPairs(global.UpdatableBootJars)))
concat(artModules, dexpreopt.GetJarsFromApexJarPairs(global.UpdatableBootJars)))
artSubdir := "apex/com.android.art/javalib"
frameworkSubdir := "system/framework"

View File

@@ -23,12 +23,14 @@ import (
"path/filepath"
"strconv"
"strings"
"sync"
"github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/dexpreopt"
"android/soong/java/config"
"android/soong/tradefed"
)
@@ -52,6 +54,8 @@ func init() {
PropertyName: "java_tests",
},
})
android.PostDepsMutators(RegisterPostDepsMutators)
}
func RegisterJavaBuildComponents(ctx android.RegistrationContext) {
@@ -76,6 +80,44 @@ func RegisterJavaBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterSingletonType("kythe_java_extract", kytheExtractJavaFactory)
}
func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("ordered_system_server_jars", systemServerJarsDepsMutator)
}
var (
dexpreoptedSystemServerJarsKey = android.NewOnceKey("dexpreoptedSystemServerJars")
dexpreoptedSystemServerJarsLock sync.Mutex
)
func DexpreoptedSystemServerJars(config android.Config) *[]string {
return config.Once(dexpreoptedSystemServerJarsKey, func() interface{} {
return &[]string{}
}).(*[]string)
}
// A PostDepsMutator pass that enforces total order on non-updatable system server jars. A total
// order is neededed because such jars must be dexpreopted together (each jar on the list must have
// all preceding jars in its class loader context). The total order must be compatible with the
// partial order imposed by genuine dependencies between system server jars (which is not always
// respected by the PRODUCT_SYSTEM_SERVER_JARS variable).
//
// An earlier mutator pass creates genuine dependencies, and this pass traverses the jars in that
// order (which is partial and non-deterministic). This pass adds additional dependencies between
// jars, making the order total and deterministic. It also constructs a global ordered list.
func systemServerJarsDepsMutator(ctx android.BottomUpMutatorContext) {
jars := dexpreopt.NonUpdatableSystemServerJars(ctx, dexpreoptGlobalConfig(ctx))
name := ctx.ModuleName()
if android.InList(name, jars) {
dexpreoptedSystemServerJarsLock.Lock()
defer dexpreoptedSystemServerJarsLock.Unlock()
jars := DexpreoptedSystemServerJars(ctx.Config())
for _, dep := range *jars {
ctx.AddDependency(ctx.Module(), dexpreopt.SystemServerDepTag, dep)
}
*jars = append(*jars, name)
}
}
func (j *Module) checkSdkVersion(ctx android.ModuleContext) {
if j.SocSpecific() || j.DeviceSpecific() ||
(j.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
@@ -659,6 +701,11 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} else if j.shouldInstrumentStatic(ctx) {
ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent")
}
// services depend on com.android.location.provider, but dependency in not registered in a Blueprint file
if ctx.ModuleName() == "services" {
ctx.AddDependency(ctx.Module(), dexpreopt.SystemServerForcedDepTag, "com.android.location.provider")
}
}
func hasSrcExt(srcs []string, ext string) bool {