Support symbolized odex preopt output

Add support for generating symbolized .odex output alongside existing
stripped .odex output for dexpreopt'ed targets. This creates the
symbolized artifact in the same output intermediate directory as its
stripped counterpart with a `.symbols.odex` suffix.

A follow-up change will collect and archive these symbolized artifacts
alongside other comparable preopted artifacts.

Bug: 342009826
Test: m CredentialManager + inspect intermediate `symbols.odex` output
Change-Id: I1bf25932ee47d6cb10a89132441aaab593de9c1a
This commit is contained in:
Jared Duke
2024-05-22 20:48:45 +00:00
parent 2d5e7579d4
commit 9c17ad6ec3

View File

@@ -244,6 +244,7 @@ func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig
}
odexPath := module.BuildPath.InSameDir(ctx, "oat", arch.String(), pathtools.ReplaceExtension(base, "odex"))
odexSymbolsPath := odexPath.ReplaceExtension(ctx, "symbols.odex")
odexInstallPath := ToOdexPath(module.DexLocation, arch)
if odexOnSystemOther(module, global) {
odexInstallPath = filepath.Join(SystemOtherPartition, odexInstallPath)
@@ -258,7 +259,8 @@ func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig
systemServerClasspathJars := global.AllSystemServerClasspathJars(ctx)
rule.Command().FlagWithArg("mkdir -p ", filepath.Dir(odexPath.String()))
rule.Command().FlagWithOutput("rm -f ", odexPath)
rule.Command().FlagWithOutput("rm -f ", odexPath).
FlagWithArg("rm -f ", odexSymbolsPath.String())
if jarIndex := systemServerJars.IndexOfJar(module.Name); jarIndex >= 0 {
// System server jars should be dexpreopted together: class loader context of each jar
@@ -386,7 +388,9 @@ func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig
FlagWithArg("--instruction-set=", arch.String()).
FlagWithArg("--instruction-set-variant=", global.CpuVariant[arch]).
FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]).
Flag("--no-generate-debug-info").
FlagWithOutput("--oat-symbols=", odexSymbolsPath).
Flag("--generate-debug-info").
Flag("--strip").
Flag("--generate-build-id").
Flag("--abort-on-hard-verifier-error").
Flag("--force-determinism").