diff options
author | 2025-02-24 13:52:04 -0800 | |
---|---|---|
committer | 2025-02-24 14:10:13 -0800 | |
commit | 1d8b521416206db591d38c1d7ebae46c570b35d3 (patch) | |
tree | 9db4df10e37daf488374587484b270b643b54ddc | |
parent | 324d19b8b5a20678586d4e8e4b894a2bba70a2ae (diff) |
Build system_server.zip in soong
For soong-only builds.
The make code was wrapped in 3 conditions: that dexpreopt was enabled,
that we're not only preopting the art boot image, and that
PRODUCT_USES_DEFAULT_ART_CONFIG is true. This code only has the first 2
of those conditions, but that's because if
PRODUCT_USES_DEFAULT_ART_CONFIG is false, dexpreopt is disabled:
https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/dex_preopt_config.mk;l=9;drc=6a8fff595ba4cbb87b7e124fd630f548c5c4e2cb
Fixes: 398036389
Test: Diff'd system_server.zip before/after this change
Change-Id: Ie316c56bf07296372ed89e7ee2f0f38360fe24d7
-rw-r--r-- | dexpreopt/Android.bp | 1 | ||||
-rw-r--r-- | dexpreopt/system_server_zip.go | 49 |
2 files changed, 50 insertions, 0 deletions
diff --git a/dexpreopt/Android.bp b/dexpreopt/Android.bp index 679d06627..ea3f52bd2 100644 --- a/dexpreopt/Android.bp +++ b/dexpreopt/Android.bp @@ -9,6 +9,7 @@ bootstrap_go_package { "class_loader_context.go", "config.go", "dexpreopt.go", + "system_server_zip.go", "testing.go", ], testSrcs: [ diff --git a/dexpreopt/system_server_zip.go b/dexpreopt/system_server_zip.go new file mode 100644 index 000000000..cef847b7d --- /dev/null +++ b/dexpreopt/system_server_zip.go @@ -0,0 +1,49 @@ +package dexpreopt + +import "android/soong/android" + +func init() { + android.InitRegistrationContext.RegisterSingletonType("system_server_zip_singleton", systemServerZipSingletonFactory) +} + +func systemServerZipSingletonFactory() android.Singleton { + return &systemServerZipSingleton{} +} + +type systemServerZipSingleton struct{} + +func (s *systemServerZipSingleton) GenerateBuildActions(ctx android.SingletonContext) { + global := GetGlobalConfig(ctx) + if global.DisablePreopt || global.OnlyPreoptArtBootImage { + return + } + + systemServerDexjarsDir := android.PathForOutput(ctx, SystemServerDexjarsDir) + + out := android.PathForOutput(ctx, "system_server.zip") + builder := android.NewRuleBuilder(pctx, ctx) + cmd := builder.Command().BuiltTool("soong_zip"). + FlagWithOutput("-o ", out). + FlagWithArg("-C ", systemServerDexjarsDir.String()) + + for i := 0; i < global.SystemServerJars.Len(); i++ { + jar := global.SystemServerJars.Jar(i) + ".jar" + cmd.FlagWithInput("-f ", systemServerDexjarsDir.Join(ctx, jar)) + } + for i := 0; i < global.StandaloneSystemServerJars.Len(); i++ { + jar := global.StandaloneSystemServerJars.Jar(i) + ".jar" + cmd.FlagWithInput("-f ", systemServerDexjarsDir.Join(ctx, jar)) + } + for i := 0; i < global.ApexSystemServerJars.Len(); i++ { + jar := global.ApexSystemServerJars.Jar(i) + ".jar" + cmd.FlagWithInput("-f ", systemServerDexjarsDir.Join(ctx, jar)) + } + for i := 0; i < global.ApexStandaloneSystemServerJars.Len(); i++ { + jar := global.ApexStandaloneSystemServerJars.Jar(i) + ".jar" + cmd.FlagWithInput("-f ", systemServerDexjarsDir.Join(ctx, jar)) + } + + builder.Build("system_server_zip", "building system_server.zip") + + ctx.DistForGoal("droidcore", out) +} |