Merge "Simplify the construction of class loader contexts for system server jars."
This commit is contained in:
@@ -30,9 +30,9 @@ func systemServerClasspath(ctx android.MakeVarsContext) []string {
|
||||
return ctx.Config().OnceStringSlice(systemServerClasspathKey, func() []string {
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
var systemServerClasspathLocations []string
|
||||
var dexpreoptJars = *DexpreoptedSystemServerJars(ctx.Config())
|
||||
// 1) The jars that are dexpreopted.
|
||||
for _, m := range dexpreoptJars {
|
||||
nonUpdatable := dexpreopt.NonUpdatableSystemServerJars(ctx, global)
|
||||
// 1) Non-updatable jars.
|
||||
for _, m := range nonUpdatable {
|
||||
systemServerClasspathLocations = append(systemServerClasspathLocations,
|
||||
filepath.Join("/system/framework", m+".jar"))
|
||||
}
|
||||
@@ -41,13 +41,6 @@ func systemServerClasspath(ctx android.MakeVarsContext) []string {
|
||||
systemServerClasspathLocations = append(systemServerClasspathLocations,
|
||||
dexpreopt.GetJarLocationFromApexJarPair(m))
|
||||
}
|
||||
// 3) The jars from make (which are not updatable, not preopted).
|
||||
for _, m := range dexpreopt.NonUpdatableSystemServerJars(ctx, global) {
|
||||
if !android.InList(m, dexpreoptJars) {
|
||||
systemServerClasspathLocations = append(systemServerClasspathLocations,
|
||||
filepath.Join("/system/framework", m+".jar"))
|
||||
}
|
||||
}
|
||||
if len(systemServerClasspathLocations) != len(global.SystemServerJars)+len(global.UpdatableSystemServerJars) {
|
||||
panic(fmt.Errorf("Wrong number of system server jars, got %d, expected %d",
|
||||
len(systemServerClasspathLocations),
|
||||
|
47
java/java.go
47
java/java.go
@@ -23,14 +23,12 @@ 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"
|
||||
)
|
||||
@@ -60,8 +58,6 @@ func init() {
|
||||
PropertyName: "java_tests",
|
||||
},
|
||||
})
|
||||
|
||||
android.PostDepsMutators(RegisterPostDepsMutators)
|
||||
}
|
||||
|
||||
func RegisterJavaBuildComponents(ctx android.RegistrationContext) {
|
||||
@@ -90,44 +86,6 @@ 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, dexpreopt.GetGlobalConfig(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()) {
|
||||
@@ -711,11 +669,6 @@ 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 {
|
||||
|
Reference in New Issue
Block a user