summaryrefslogtreecommitdiff
path: root/dexpreopt/dexpreopt_tools_zip.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2025-03-04 15:12:14 -0800
committer Cole Faust <colefaust@google.com> 2025-03-04 15:12:14 -0800
commitdd85b0ae69f72b7b751d20e852ad0ff97d735887 (patch)
tree35f1cb27b0f651ac1e0cd317d2819f07ce4eb1d2 /dexpreopt/dexpreopt_tools_zip.go
parentde3a5c4be8aff15998cbf898e06fcc4679fe911f (diff)
Build dexpreopt_tools.zip in soong
For soong-only builds. Bug: 398028319 Test: diff'd zip file before/after, they're the same Change-Id: I6b480f4185546f3b61d81ad80f0fe1db6bafb133
Diffstat (limited to 'dexpreopt/dexpreopt_tools_zip.go')
-rw-r--r--dexpreopt/dexpreopt_tools_zip.go62
1 files changed, 62 insertions, 0 deletions
diff --git a/dexpreopt/dexpreopt_tools_zip.go b/dexpreopt/dexpreopt_tools_zip.go
new file mode 100644
index 000000000..c7cf12830
--- /dev/null
+++ b/dexpreopt/dexpreopt_tools_zip.go
@@ -0,0 +1,62 @@
+package dexpreopt
+
+import "android/soong/android"
+
+func init() {
+ android.InitRegistrationContext.RegisterSingletonType("dexpreopt_tools_zip_singleton", dexpreoptToolsZipSingletonFactory)
+}
+
+func dexpreoptToolsZipSingletonFactory() android.Singleton {
+ return &dexpreoptToolsZipSingleton{}
+}
+
+type dexpreoptToolsZipSingleton struct{}
+
+func (s *dexpreoptToolsZipSingleton) GenerateBuildActions(ctx android.SingletonContext) {
+ // The mac build doesn't build dex2oat, so create the zip file only if the build OS is linux.
+ if !ctx.Config().BuildOS.Linux() {
+ return
+ }
+ global := GetGlobalConfig(ctx)
+ if global.DisablePreopt {
+ return
+ }
+ config := GetCachedGlobalSoongConfig(ctx)
+ if config == nil {
+ return
+ }
+
+ deps := android.Paths{
+ ctx.Config().HostToolPath(ctx, "dexpreopt_gen"),
+ ctx.Config().HostToolPath(ctx, "dexdump"),
+ ctx.Config().HostToolPath(ctx, "oatdump"),
+ config.Profman,
+ config.Dex2oat,
+ config.Aapt,
+ config.SoongZip,
+ config.Zip2zip,
+ config.ManifestCheck,
+ config.ConstructContext,
+ config.UffdGcFlag,
+ }
+
+ out := android.PathForOutput(ctx, "dexpreopt_tools.zip")
+ builder := android.NewRuleBuilder(pctx, ctx)
+
+ cmd := builder.Command().BuiltTool("soong_zip").
+ Flag("-d").
+ FlagWithOutput("-o ", out).
+ Flag("-j")
+
+ for _, dep := range deps {
+ cmd.FlagWithInput("-f ", dep)
+ }
+
+ // This reads through a symlink to include the file it points to. This isn't great for
+ // build reproducibility, will need to be revisited later.
+ cmd.Textf("-f $(realpath %s)", config.Dex2oat)
+
+ builder.Build("dexpreopt_tools_zip", "building dexpreopt_tools.zip")
+
+ ctx.DistForGoal("droidcore", out)
+}