summaryrefslogtreecommitdiff
path: root/dexpreopt/system_server_zip.go
blob: cef847b7d19ab4475f42743b628865b4058f831e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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)
}