Separate dexpreopt.GlobalSoongConfig to allow independent caching of it. am: be9d0d21d1 am: 852db0c1da am: 8e761f91c8

Change-Id: Ibf451ceb57c5770727ee1674634ef4d37e486213
This commit is contained in:
Automerger Merge Worker
2020-01-25 03:36:58 +00:00
8 changed files with 104 additions and 61 deletions

View File

@@ -104,6 +104,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
return dexJarFile
}
globalSoong := dexpreopt.GetGlobalSoongConfig(ctx)
global := dexpreoptGlobalConfig(ctx)
bootImage := defaultBootImageConfig(ctx)
if global.UseApexImage {
@@ -189,7 +190,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
PresignedPrebuilt: d.isPresignedPrebuilt,
}
dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, global, dexpreoptConfig)
dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, globalSoong, global, dexpreoptConfig)
if err != nil {
ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error())
return dexJarFile

View File

@@ -304,6 +304,7 @@ func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootI
func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
arch android.ArchType, profile android.Path, missingDeps []string) android.WritablePaths {
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreoptGlobalConfig(ctx)
symbolsDir := image.symbolsDir.Join(ctx, image.installSubdir, arch.String())
@@ -339,7 +340,7 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
invocationPath := outputPath.ReplaceExtension(ctx, "invocation")
cmd.Tool(global.SoongConfig.Dex2oat).
cmd.Tool(globalSoong.Dex2oat).
Flag("--avoid-storing-invocation").
FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath).
Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatImageXms).
@@ -442,6 +443,7 @@ It is likely that the boot classpath is inconsistent.
Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.`
func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreoptGlobalConfig(ctx)
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
@@ -473,7 +475,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin
rule.Command().
Text(`ANDROID_LOG_TAGS="*:e"`).
Tool(global.SoongConfig.Profman).
Tool(globalSoong.Profman).
FlagWithInput("--create-profile-from=", bootImageProfile).
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
FlagForEachArg("--dex-location=", image.dexLocationsDeps).
@@ -496,6 +498,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin
var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreoptGlobalConfig(ctx)
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
@@ -522,7 +525,7 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, mi
rule.Command().
Text(`ANDROID_LOG_TAGS="*:e"`).
Tool(global.SoongConfig.Profman).
Tool(globalSoong.Profman).
Flag("--generate-boot-profile").
FlagWithInput("--create-profile-from=", bootFrameworkProfile).
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).

View File

@@ -39,8 +39,7 @@ func dexpreoptGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw {
if data, err := ctx.Config().DexpreoptGlobalConfig(ctx); err != nil {
panic(err)
} else if data != nil {
soongConfig := dexpreopt.CreateGlobalSoongConfig(ctx)
globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, data, soongConfig)
globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, data)
if err != nil {
panic(err)
}

View File

@@ -57,7 +57,13 @@ func TestMain(m *testing.M) {
}
func testConfig(env map[string]string, bp string, fs map[string][]byte) android.Config {
return TestConfig(buildDir, env, bp, fs)
config := TestConfig(buildDir, env, bp, fs)
// Set up the global Once cache used for dexpreopt.GlobalSoongConfig, so that
// it doesn't create a real one, which would fail.
_ = dexpreopt.GlobalSoongConfigForTests(config)
return config
}
func testContext() *android.TestContext {