diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/dexpreopt.go | 6 | ||||
| -rw-r--r-- | java/dexpreopt_bootjars.go | 12 | ||||
| -rw-r--r-- | java/dexpreopt_bootjars_test.go | 2 | ||||
| -rw-r--r-- | java/dexpreopt_config.go | 50 | ||||
| -rw-r--r-- | java/java.go | 2 | ||||
| -rw-r--r-- | java/java_test.go | 4 |
6 files changed, 16 insertions, 60 deletions
diff --git a/java/dexpreopt.go b/java/dexpreopt.go index ec0b5c659..428aee2aa 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -59,7 +59,7 @@ type DexpreoptProperties struct { } func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool { - global := dexpreoptGlobalConfig(ctx) + global := dexpreopt.GetGlobalConfig(ctx) if global.DisablePreopt { return true @@ -96,7 +96,7 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool { } func odexOnSystemOther(ctx android.ModuleContext, installPath android.InstallPath) bool { - return dexpreopt.OdexOnSystemOtherByName(ctx.ModuleName(), android.InstallPathToOnDevicePath(ctx, installPath), dexpreoptGlobalConfig(ctx)) + return dexpreopt.OdexOnSystemOtherByName(ctx.ModuleName(), android.InstallPathToOnDevicePath(ctx, installPath), dexpreopt.GetGlobalConfig(ctx)) } func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.ModuleOutPath) android.ModuleOutPath { @@ -105,7 +105,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo } globalSoong := dexpreopt.GetGlobalSoongConfig(ctx) - global := dexpreoptGlobalConfig(ctx) + global := dexpreopt.GetGlobalConfig(ctx) bootImage := defaultBootImageConfig(ctx) dexFiles := bootImage.dexPathsDeps.Paths() dexLocations := bootImage.dexLocationsDeps diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 25da25860..2a2e6dae5 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -165,7 +165,7 @@ func dexpreoptBootJarsFactory() android.Singleton { } func skipDexpreoptBootJars(ctx android.PathContext) bool { - if dexpreoptGlobalConfig(ctx).DisablePreopt { + if dexpreopt.GetGlobalConfig(ctx).DisablePreopt { return true } @@ -209,7 +209,7 @@ func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) { d.dexpreoptConfigForMake = android.PathForOutput(ctx, ctx.Config().DeviceName(), "dexpreopt.config") writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake) - global := dexpreoptGlobalConfig(ctx) + global := dexpreopt.GetGlobalConfig(ctx) // Skip recompiling the boot image for the second sanitization phase. We'll get separate paths // and invalidate first-stage artifacts which are crucial to SANITIZE_LITE builds. @@ -296,7 +296,7 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage, arch android.ArchType, profile android.Path, missingDeps []string) android.WritablePaths { globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx) - global := dexpreoptGlobalConfig(ctx) + global := dexpreopt.GetGlobalConfig(ctx) symbolsDir := image.symbolsDir.Join(ctx, image.installSubdir, arch.String()) symbolsFile := symbolsDir.Join(ctx, image.stem+".oat") @@ -435,7 +435,7 @@ Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath { globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx) - global := dexpreoptGlobalConfig(ctx) + global := dexpreopt.GetGlobalConfig(ctx) if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { return nil @@ -490,7 +490,7 @@ var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule") func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath { globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx) - global := dexpreoptGlobalConfig(ctx) + global := dexpreopt.GetGlobalConfig(ctx) if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { return nil @@ -578,7 +578,7 @@ func dumpOatRules(ctx android.SingletonContext, image *bootImage) { } func writeGlobalConfigForMake(ctx android.SingletonContext, path android.WritablePath) { - data := dexpreoptGlobalConfigRaw(ctx).data + data := dexpreopt.GetGlobalConfigRawData(ctx) ctx.Build(pctx, android.BuildParams{ Rule: android.WriteFile, diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go index 4ce30f678..c3b2133a9 100644 --- a/java/dexpreopt_bootjars_test.go +++ b/java/dexpreopt_bootjars_test.go @@ -49,7 +49,7 @@ func TestDexpreoptBootJars(t *testing.T) { pathCtx := android.PathContextForTesting(config) dexpreoptConfig := dexpreopt.GlobalConfigForTests(pathCtx) dexpreoptConfig.BootJars = []string{"foo", "bar", "baz"} - setDexpreoptTestGlobalConfig(config, dexpreoptConfig) + dexpreopt.SetTestGlobalConfig(config, dexpreoptConfig) ctx := testContext() diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index 0aa9005f6..96f8042a0 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -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.MakeVarsContext) []string { return ctx.Config().OnceStringSlice(systemServerClasspathKey, func() []string { - global := dexpreoptGlobalConfig(ctx) + global := dexpreopt.GetGlobalConfig(ctx) var systemServerClasspathLocations []string for _, m := range *DexpreoptedSystemServerJars(ctx.Config()) { systemServerClasspathLocations = append(systemServerClasspathLocations, @@ -120,7 +76,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()) @@ -226,7 +182,7 @@ func defaultBootImageConfig(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)) diff --git a/java/java.go b/java/java.go index d84d16272..b20f5f244 100644 --- a/java/java.go +++ b/java/java.go @@ -105,7 +105,7 @@ func DexpreoptedSystemServerJars(config android.Config) *[]string { // 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)) + jars := dexpreopt.NonUpdatableSystemServerJars(ctx, dexpreopt.GetGlobalConfig(ctx)) name := ctx.ModuleName() if android.InList(name, jars) { dexpreoptedSystemServerJarsLock.Lock() diff --git a/java/java_test.go b/java/java_test.go index 9c5680b0c..129b17bf7 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -99,7 +99,7 @@ func run(t *testing.T, ctx *android.TestContext, config android.Config) { t.Helper() pathCtx := android.PathContextForTesting(config) - setDexpreoptTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx)) + dexpreopt.SetTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx)) ctx.Register(config) _, errs := ctx.ParseBlueprintsFiles("Android.bp") @@ -118,7 +118,7 @@ func testJavaErrorWithConfig(t *testing.T, pattern string, config android.Config ctx := testContext() pathCtx := android.PathContextForTesting(config) - setDexpreoptTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx)) + dexpreopt.SetTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx)) ctx.Register(config) _, errs := ctx.ParseBlueprintsFiles("Android.bp") |