From c9a4c36634583490f4849dc1fc186af98ec1cbf9 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 26 Feb 2019 21:13:48 -0800 Subject: [PATCH] Move boot image oatdump phony rules into Soong The boot image oatdump rules depend on the details of dexpreopting the boot image. Instead of exporting all of the necessary values to make, move the rules into Soong instead. Also removes the ART_DUMP_OAT_PATH variable, and moves the output to out/soong/boot.*.oatdump.txt. Test: m dump-oat-boot Change-Id: I055b1c39918ba3425c8393b3e1b5359df055472a --- java/dexpreopt_bootjars.go | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index a35e01142..ca6883263 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -16,6 +16,7 @@ package java import ( "path/filepath" + "sort" "strings" "android/soong/android" @@ -137,6 +138,8 @@ func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) { if global.GenerateApexImage { d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx))) } + + dumpOatRules(ctx, d.defaultBootImage) } // buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage. @@ -389,6 +392,50 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule") +func dumpOatRules(ctx android.SingletonContext, image *bootImage) { + var archs []android.ArchType + for arch := range image.images { + archs = append(archs, arch) + } + sort.Slice(archs, func(i, j int) bool { return archs[i].String() < archs[j].String() }) + + var allPhonies android.Paths + for _, arch := range archs { + // Create a rule to call oatdump. + output := android.PathForOutput(ctx, "boot."+arch.String()+".oatdump.txt") + rule := android.NewRuleBuilder() + rule.Command(). + // TODO: for now, use the debug version for better error reporting + Tool(ctx.Config().HostToolPath(ctx, "oatdumpd")). + FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPaths.Paths(), ":"). + FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocations, ":"). + FlagWithArg("--image=", dexpreopt.PathToLocation(image.images[arch], arch)).Implicit(image.images[arch]). + FlagWithOutput("--output=", output). + FlagWithArg("--instruction-set=", arch.String()) + rule.Build(pctx, ctx, "dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String()) + + // Create a phony rule that depends on the output file and prints the path. + phony := android.PathForPhony(ctx, "dump-oat-boot-"+arch.String()) + rule = android.NewRuleBuilder() + rule.Command(). + Implicit(output). + ImplicitOutput(phony). + Text("echo").FlagWithArg("Output in ", output.String()) + rule.Build(pctx, ctx, "phony-dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String()) + + allPhonies = append(allPhonies, phony) + } + + phony := android.PathForPhony(ctx, "dump-oat-boot") + ctx.Build(pctx, android.BuildParams{ + Rule: android.Phony, + Output: phony, + Inputs: allPhonies, + Description: "dump-oat-boot", + }) + +} + // Export paths for default boot image to Make func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { image := d.defaultBootImage