Move the Once cache for dexpreopt.GlobalConfig into the dexpreopt
package. Preparation for a future CL that will need to get the make-written GlobalConfig from within dexpreopt. Also rename the Load*Config functions to Parse*Config, since they don't actually load the config files anymore. Bug: 145934348 Test: m Change-Id: I71df11c1e042ca8135d273a7263e9539ea3cd68f
This commit is contained in:
@@ -22,56 +22,12 @@ import (
|
||||
"android/soong/dexpreopt"
|
||||
)
|
||||
|
||||
// dexpreoptGlobalConfig returns the global dexpreopt.config. It is loaded once the first time it is called for any
|
||||
// ctx.Config(), and returns the same data for all future calls with the same ctx.Config(). A value can be inserted
|
||||
// for tests using setDexpreoptTestGlobalConfig.
|
||||
func dexpreoptGlobalConfig(ctx android.PathContext) dexpreopt.GlobalConfig {
|
||||
return dexpreoptGlobalConfigRaw(ctx).global
|
||||
}
|
||||
|
||||
type globalConfigAndRaw struct {
|
||||
global dexpreopt.GlobalConfig
|
||||
data []byte
|
||||
}
|
||||
|
||||
func dexpreoptGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw {
|
||||
return ctx.Config().Once(dexpreoptGlobalConfigKey, func() interface{} {
|
||||
if data, err := ctx.Config().DexpreoptGlobalConfig(ctx); err != nil {
|
||||
panic(err)
|
||||
} else if data != nil {
|
||||
globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return globalConfigAndRaw{globalConfig, data}
|
||||
}
|
||||
|
||||
// No global config filename set, see if there is a test config set
|
||||
return ctx.Config().Once(dexpreoptTestGlobalConfigKey, func() interface{} {
|
||||
// Nope, return a config with preopting disabled
|
||||
return globalConfigAndRaw{dexpreopt.GlobalConfig{
|
||||
DisablePreopt: true,
|
||||
DisableGenerateProfile: true,
|
||||
}, nil}
|
||||
})
|
||||
}).(globalConfigAndRaw)
|
||||
}
|
||||
|
||||
// setDexpreoptTestGlobalConfig sets a GlobalConfig that future calls to dexpreoptGlobalConfig will return. It must
|
||||
// be called before the first call to dexpreoptGlobalConfig for the config.
|
||||
func setDexpreoptTestGlobalConfig(config android.Config, globalConfig dexpreopt.GlobalConfig) {
|
||||
config.Once(dexpreoptTestGlobalConfigKey, func() interface{} { return globalConfigAndRaw{globalConfig, nil} })
|
||||
}
|
||||
|
||||
var dexpreoptGlobalConfigKey = android.NewOnceKey("DexpreoptGlobalConfig")
|
||||
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 {
|
||||
return ctx.Config().OnceStringSlice(systemServerClasspathKey, func() []string {
|
||||
global := dexpreoptGlobalConfig(ctx)
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
|
||||
var systemServerClasspathLocations []string
|
||||
for _, m := range global.SystemServerJars {
|
||||
@@ -132,7 +88,7 @@ var (
|
||||
func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
||||
return ctx.Config().Once(bootImageConfigKey, func() interface{} {
|
||||
|
||||
global := dexpreoptGlobalConfig(ctx)
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
targets := dexpreoptTargets(ctx)
|
||||
deviceDir := android.PathForOutput(ctx, ctx.Config().DeviceName())
|
||||
|
||||
@@ -273,7 +229,7 @@ func frameworkJZBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||
|
||||
func defaultBootclasspath(ctx android.PathContext) []string {
|
||||
return ctx.Config().OnceStringSlice(defaultBootclasspathKey, func() []string {
|
||||
global := dexpreoptGlobalConfig(ctx)
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
image := defaultBootImageConfig(ctx)
|
||||
|
||||
updatableBootclasspath := make([]string, len(global.UpdatableBootJars))
|
||||
|
Reference in New Issue
Block a user