From b832fbb643447cc641c81d9e0a36195eb0eeb287 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Fri, 15 Sep 2023 17:16:36 +0000 Subject: [PATCH] Unconditionally generate hash-based proguard mapping files Previously, this was restricted to targets that enable R8 full mode, but that was really just a temporary carveout to avoid disrupting other targets. Since then, R8 full mode has been enabled by default for all app targets, and the hash-based mapping mechanism is further integrated into various debugging and retracing pipelines. As of now, there are are only a very small number of targets that have enabled optimization/obfuscation and are still using R8 compat mode, so the build-time impact of this change should be minimal, and there should be no functional runtime side effects. Bug: 297566172 Test: m framework-appsearch + inspect proguard mapping Change-Id: I5dfea60f60dc37b8445c8fddba6a4eab0dc41d96 --- java/dex.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/java/dex.go b/java/dex.go index 5b8cf3dfb..c1d51c7bf 100644 --- a/java/dex.go +++ b/java/dex.go @@ -315,15 +315,14 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl if BoolDefault(opt.Proguard_compatibility, true) { r8Flags = append(r8Flags, "--force-proguard-compatibility") - } else { + } + + if Bool(opt.Optimize) || Bool(opt.Obfuscate) { // TODO(b/213833843): Allow configuration of the prefix via a build variable. var sourceFilePrefix = "go/retraceme " var sourceFileTemplate = "\"" + sourceFilePrefix + "%MAP_ID\"" - // TODO(b/200967150): Also tag the source file in compat builds. - if Bool(opt.Optimize) || Bool(opt.Obfuscate) { - r8Flags = append(r8Flags, "--map-id-template", "%MAP_HASH") - r8Flags = append(r8Flags, "--source-file-template", sourceFileTemplate) - } + r8Flags = append(r8Flags, "--map-id-template", "%MAP_HASH") + r8Flags = append(r8Flags, "--source-file-template", sourceFileTemplate) } // TODO(ccross): Don't shrink app instrumentation tests by default.