blob: 8b7e3bab406ff05450013c513d6a1bad8302e79d [file] [log] [blame]
Colin Crossf0056cb2017-12-22 15:56:08 -08001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17import (
Jiyong Park54105c42021-03-31 18:17:53 +090018 "strconv"
Colin Crossf0056cb2017-12-22 15:56:08 -080019 "strings"
20
21 "github.com/google/blueprint"
David Srbeckye033cba2020-05-20 22:20:28 +010022 "github.com/google/blueprint/proptools"
Colin Crossf0056cb2017-12-22 15:56:08 -080023
24 "android/soong/android"
Ramy Medhat1dcc27e2020-04-21 21:36:23 -040025 "android/soong/remoteexec"
Colin Crossf0056cb2017-12-22 15:56:08 -080026)
27
Liz Kammera7a64f32020-07-09 15:16:41 -070028type DexProperties struct {
29 // If set to true, compile dex regardless of installable. Defaults to false.
30 Compile_dex *bool
31
32 // list of module-specific flags that will be used for dex compiles
33 Dxflags []string `android:"arch_variant"`
34
35 Optimize struct {
36 // If false, disable all optimization. Defaults to true for android_app and android_test
37 // modules, false for java_library and java_test modules.
38 Enabled *bool
39 // True if the module containing this has it set by default.
40 EnabledByDefault bool `blueprint:"mutated"`
41
Christoffer Quist Adamsenf2d7b162020-08-24 15:56:16 +020042 // If true, runs R8 in Proguard compatibility mode (default).
43 // Otherwise, runs R8 in full mode.
44 Proguard_compatibility *bool
45
Liz Kammera7a64f32020-07-09 15:16:41 -070046 // If true, optimize for size by removing unused code. Defaults to true for apps,
47 // false for libraries and tests.
48 Shrink *bool
49
50 // If true, optimize bytecode. Defaults to false.
51 Optimize *bool
52
53 // If true, obfuscate bytecode. Defaults to false.
54 Obfuscate *bool
55
56 // If true, do not use the flag files generated by aapt that automatically keep
57 // classes referenced by the app manifest. Defaults to false.
58 No_aapt_flags *bool
59
60 // Flags to pass to proguard.
61 Proguard_flags []string
62
63 // Specifies the locations of files containing proguard flags.
64 Proguard_flags_files []string `android:"path"`
65 }
66
67 // Keep the data uncompressed. We always need uncompressed dex for execution,
68 // so this might actually save space by avoiding storing the same data twice.
69 // This defaults to reasonable value based on module and should not be set.
70 // It exists only to support ART tests.
71 Uncompress_dex *bool
72}
73
74type dexer struct {
75 dexProperties DexProperties
76
77 // list of extra proguard flag files
78 extraProguardFlagFiles android.Paths
79 proguardDictionary android.OptionalPath
Colin Crosscb6143a2020-08-14 17:39:29 -070080 proguardUsageZip android.OptionalPath
Liz Kammera7a64f32020-07-09 15:16:41 -070081}
82
83func (d *dexer) effectiveOptimizeEnabled() bool {
84 return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault)
85}
86
Colin Cross29c294b2021-04-30 14:01:14 -070087func init() {
88 pctx.HostBinToolVariable("runWithTimeoutCmd", "run_with_timeout")
89 pctx.SourcePathVariable("jstackCmd", "${config.JavaToolchain}/jstack")
90}
91
Colin Cross77cdcfd2021-03-12 11:28:25 -080092var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8",
Colin Crossf0056cb2017-12-22 15:56:08 -080093 blueprint.RuleParams{
94 Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
Colin Cross05ca7c82021-08-04 10:52:44 -070095 `${config.Zip2ZipCmd} -i $in -o $outDir/in.jar -x '**/*.dex' &&` +
96 `$d8Template${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $outDir/in.jar && ` +
Kousik Kumar366afc52020-05-20 11:27:16 -070097 `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` +
Colin Cross4c03f682018-07-15 08:16:31 -070098 `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`,
Colin Crossf0056cb2017-12-22 15:56:08 -080099 CommandDeps: []string{
100 "${config.D8Cmd}",
Colin Cross05ca7c82021-08-04 10:52:44 -0700101 "${config.Zip2ZipCmd}",
Colin Crossf0056cb2017-12-22 15:56:08 -0800102 "${config.SoongZipCmd}",
103 "${config.MergeZipsCmd}",
104 },
Kousik Kumar366afc52020-05-20 11:27:16 -0700105 }, map[string]*remoteexec.REParams{
106 "$d8Template": &remoteexec.REParams{
107 Labels: map[string]string{"type": "compile", "compiler": "d8"},
108 Inputs: []string{"${config.D8Jar}"},
109 ExecStrategy: "${config.RED8ExecStrategy}",
110 ToolchainInputs: []string{"${config.JavaCmd}"},
111 Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
112 },
113 "$zipTemplate": &remoteexec.REParams{
114 Labels: map[string]string{"type": "tool", "name": "soong_zip"},
115 Inputs: []string{"${config.SoongZipCmd}", "$outDir"},
116 OutputFiles: []string{"$outDir/classes.dex.jar"},
117 ExecStrategy: "${config.RED8ExecStrategy}",
118 Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
119 },
Ramy Medhat1dcc27e2020-04-21 21:36:23 -0400120 }, []string{"outDir", "d8Flags", "zipFlags"}, nil)
Colin Crossf0056cb2017-12-22 15:56:08 -0800121
Colin Cross77cdcfd2021-03-12 11:28:25 -0800122var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8",
Colin Cross66dbc0b2017-12-28 12:23:20 -0800123 blueprint.RuleParams{
124 Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` +
Colin Crosscb6143a2020-08-14 17:39:29 -0700125 `rm -f "$outDict" && rm -rf "${outUsageDir}" && ` +
126 `mkdir -p $$(dirname ${outUsage}) && ` +
Colin Cross05ca7c82021-08-04 10:52:44 -0700127 `${config.Zip2ZipCmd} -i $in -o $outDir/in.jar -x '**/*.dex' &&` +
Colin Cross29c294b2021-04-30 14:01:14 -0700128 // TODO(b/181095653): remove R8 timeout and go back to config.R8Cmd.
129 `${runWithTimeoutCmd} -timeout 30m -on_timeout '${jstackCmd} $$PID' -- ` +
130 `$r8Template${config.JavaCmd} ${config.DexJavaFlags} -cp ${config.R8Jar} ` +
Colin Cross05ca7c82021-08-04 10:52:44 -0700131 `com.android.tools.r8.compatproguard.CompatProguard -injars $outDir/in.jar --output $outDir ` +
Søren Gjesse24f17022018-09-14 15:20:42 +0200132 `--no-data-resources ` +
Colin Crosscb6143a2020-08-14 17:39:29 -0700133 `-printmapping ${outDict} ` +
134 `-printusage ${outUsage} ` +
Colin Crossffb657e2018-09-21 12:29:22 -0700135 `$r8Flags && ` +
Colin Crosscb6143a2020-08-14 17:39:29 -0700136 `touch "${outDict}" "${outUsage}" && ` +
137 `${config.SoongZipCmd} -o ${outUsageZip} -C ${outUsageDir} -f ${outUsage} && ` +
138 `rm -rf ${outUsageDir} && ` +
Kousik Kumar366afc52020-05-20 11:27:16 -0700139 `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` +
Colin Cross4c03f682018-07-15 08:16:31 -0700140 `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`,
Colin Cross66dbc0b2017-12-28 12:23:20 -0800141 CommandDeps: []string{
Colin Cross29c294b2021-04-30 14:01:14 -0700142 "${config.R8Jar}",
Colin Cross05ca7c82021-08-04 10:52:44 -0700143 "${config.Zip2ZipCmd}",
Colin Cross66dbc0b2017-12-28 12:23:20 -0800144 "${config.SoongZipCmd}",
145 "${config.MergeZipsCmd}",
Colin Cross29c294b2021-04-30 14:01:14 -0700146 "${runWithTimeoutCmd}",
Colin Cross66dbc0b2017-12-28 12:23:20 -0800147 },
Kousik Kumar366afc52020-05-20 11:27:16 -0700148 }, map[string]*remoteexec.REParams{
149 "$r8Template": &remoteexec.REParams{
150 Labels: map[string]string{"type": "compile", "compiler": "r8"},
151 Inputs: []string{"$implicits", "${config.R8Jar}"},
Colin Crosse00c0e72020-09-17 11:54:30 -0700152 OutputFiles: []string{"${outUsage}"},
Kousik Kumar366afc52020-05-20 11:27:16 -0700153 ExecStrategy: "${config.RER8ExecStrategy}",
154 ToolchainInputs: []string{"${config.JavaCmd}"},
155 Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
156 },
157 "$zipTemplate": &remoteexec.REParams{
158 Labels: map[string]string{"type": "tool", "name": "soong_zip"},
159 Inputs: []string{"${config.SoongZipCmd}", "$outDir"},
160 OutputFiles: []string{"$outDir/classes.dex.jar"},
161 ExecStrategy: "${config.RER8ExecStrategy}",
162 Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
163 },
Colin Crosscb6143a2020-08-14 17:39:29 -0700164 "$zipUsageTemplate": &remoteexec.REParams{
165 Labels: map[string]string{"type": "tool", "name": "soong_zip"},
166 Inputs: []string{"${config.SoongZipCmd}", "${outUsage}"},
167 OutputFiles: []string{"${outUsageZip}"},
168 ExecStrategy: "${config.RER8ExecStrategy}",
169 Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"},
170 },
171 }, []string{"outDir", "outDict", "outUsage", "outUsageZip", "outUsageDir",
172 "r8Flags", "zipFlags"}, []string{"implicits"})
Colin Cross66dbc0b2017-12-28 12:23:20 -0800173
Jiyong Parkf1691d22021-03-29 20:11:58 +0900174func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion android.SdkSpec) []string {
Liz Kammera7a64f32020-07-09 15:16:41 -0700175 flags := d.dexProperties.Dxflags
Colin Crossbafb8972018-06-06 21:46:32 +0000176 // Translate all the DX flags to D8 ones until all the build files have been migrated
177 // to D8 flags. See: b/69377755
178 flags = android.RemoveListFromList(flags,
179 []string{"--core-library", "--dex", "--multi-dex"})
Colin Crossf0056cb2017-12-22 15:56:08 -0800180
181 if ctx.Config().Getenv("NO_OPTIMIZE_DX") != "" {
Colin Crossbafb8972018-06-06 21:46:32 +0000182 flags = append(flags, "--debug")
Colin Crossf0056cb2017-12-22 15:56:08 -0800183 }
184
185 if ctx.Config().Getenv("GENERATE_DEX_DEBUG") != "" {
186 flags = append(flags,
187 "--debug",
188 "--verbose")
Colin Crossf0056cb2017-12-22 15:56:08 -0800189 }
190
Jiyong Parkf1691d22021-03-29 20:11:58 +0900191 effectiveVersion, err := minSdkVersion.EffectiveVersion(ctx)
Colin Cross83bb3162018-06-25 15:48:06 -0700192 if err != nil {
193 ctx.PropertyErrorf("min_sdk_version", "%s", err)
194 }
195
Jiyong Park54105c42021-03-31 18:17:53 +0900196 flags = append(flags, "--min-api "+strconv.Itoa(effectiveVersion.FinalOrFutureInt()))
Colin Crossf0056cb2017-12-22 15:56:08 -0800197 return flags
198}
199
Liz Kammera7a64f32020-07-09 15:16:41 -0700200func d8Flags(flags javaBuilderFlags) (d8Flags []string, d8Deps android.Paths) {
Colin Crossc2557d12019-10-31 15:22:57 -0700201 d8Flags = append(d8Flags, flags.bootClasspath.FormRepeatedClassPath("--lib ")...)
202 d8Flags = append(d8Flags, flags.classpath.FormRepeatedClassPath("--lib ")...)
Colin Crossffb657e2018-09-21 12:29:22 -0700203
Colin Cross6dab9bd2018-09-28 08:06:24 -0700204 d8Deps = append(d8Deps, flags.bootClasspath...)
205 d8Deps = append(d8Deps, flags.classpath...)
206
207 return d8Flags, d8Deps
Colin Crossffb657e2018-09-21 12:29:22 -0700208}
209
Liz Kammera7a64f32020-07-09 15:16:41 -0700210func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Flags []string, r8Deps android.Paths) {
211 opt := d.dexProperties.Optimize
Colin Cross66dbc0b2017-12-28 12:23:20 -0800212
213 // When an app contains references to APIs that are not in the SDK specified by
214 // its LOCAL_SDK_VERSION for example added by support library or by runtime
Colin Crossbafb8972018-06-06 21:46:32 +0000215 // classes added by desugaring, we artifically raise the "SDK version" "linked" by
Colin Cross66dbc0b2017-12-28 12:23:20 -0800216 // ProGuard, to
217 // - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version.
218 // - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
219 // See b/20667396
220 var proguardRaiseDeps classpath
Colin Crossdcf71b22021-02-01 13:59:03 -0800221 ctx.VisitDirectDepsWithTag(proguardRaiseTag, func(m android.Module) {
222 dep := ctx.OtherModuleProvider(m, JavaInfoProvider).(JavaInfo)
223 proguardRaiseDeps = append(proguardRaiseDeps, dep.HeaderJars...)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800224 })
225
226 r8Flags = append(r8Flags, proguardRaiseDeps.FormJavaClassPath("-libraryjars"))
227 r8Flags = append(r8Flags, flags.bootClasspath.FormJavaClassPath("-libraryjars"))
228 r8Flags = append(r8Flags, flags.classpath.FormJavaClassPath("-libraryjars"))
Colin Cross66dbc0b2017-12-28 12:23:20 -0800229
Colin Cross6dab9bd2018-09-28 08:06:24 -0700230 r8Deps = append(r8Deps, proguardRaiseDeps...)
231 r8Deps = append(r8Deps, flags.bootClasspath...)
232 r8Deps = append(r8Deps, flags.classpath...)
233
Colin Cross66dbc0b2017-12-28 12:23:20 -0800234 flagFiles := android.Paths{
235 android.PathForSource(ctx, "build/make/core/proguard.flags"),
236 }
237
Liz Kammera7a64f32020-07-09 15:16:41 -0700238 flagFiles = append(flagFiles, d.extraProguardFlagFiles...)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800239 // TODO(ccross): static android library proguard files
240
Liz Kammera7a64f32020-07-09 15:16:41 -0700241 flagFiles = append(flagFiles, android.PathsForModuleSrc(ctx, opt.Proguard_flags_files)...)
Colin Crossbd1cef52018-08-13 10:28:18 -0700242
Colin Cross66dbc0b2017-12-28 12:23:20 -0800243 r8Flags = append(r8Flags, android.JoinWithPrefix(flagFiles.Strings(), "-include "))
244 r8Deps = append(r8Deps, flagFiles...)
245
246 // TODO(b/70942988): This is included from build/make/core/proguard.flags
247 r8Deps = append(r8Deps, android.PathForSource(ctx,
248 "build/make/core/proguard_basic_keeps.flags"))
249
Liz Kammera7a64f32020-07-09 15:16:41 -0700250 r8Flags = append(r8Flags, opt.Proguard_flags...)
Colin Cross66dbc0b2017-12-28 12:23:20 -0800251
Christoffer Quist Adamsenf2d7b162020-08-24 15:56:16 +0200252 if BoolDefault(opt.Proguard_compatibility, true) {
253 r8Flags = append(r8Flags, "--force-proguard-compatibility")
254 }
255
Colin Cross66dbc0b2017-12-28 12:23:20 -0800256 // TODO(ccross): Don't shrink app instrumentation tests by default.
257 if !Bool(opt.Shrink) {
258 r8Flags = append(r8Flags, "-dontshrink")
259 }
260
261 if !Bool(opt.Optimize) {
262 r8Flags = append(r8Flags, "-dontoptimize")
263 }
264
265 // TODO(ccross): error if obufscation + app instrumentation test.
266 if !Bool(opt.Obfuscate) {
267 r8Flags = append(r8Flags, "-dontobfuscate")
268 }
Colin Cross4b964c02018-10-15 16:18:06 -0700269 // TODO(ccross): if this is an instrumentation test of an obfuscated app, use the
270 // dictionary of the app and move the app from libraryjars to injars.
Colin Cross66dbc0b2017-12-28 12:23:20 -0800271
Jaewoong Jung1d6eb682018-11-29 15:08:44 -0800272 // Don't strip out debug information for eng builds.
273 if ctx.Config().Eng() {
274 r8Flags = append(r8Flags, "--debug")
275 }
276
Christoffer Quist Adamsene8507372021-02-22 09:44:09 +0100277 // TODO(b/180878971): missing classes should be added to the relevant builds.
278 r8Flags = append(r8Flags, "-ignorewarnings")
279
Colin Cross66dbc0b2017-12-28 12:23:20 -0800280 return r8Flags, r8Deps
281}
282
Jiyong Parkf1691d22021-03-29 20:11:58 +0900283func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, minSdkVersion android.SdkSpec,
Paul Duffin612e6102021-02-02 13:38:13 +0000284 classesJar android.Path, jarName string) android.OutputPath {
Colin Crossf0056cb2017-12-22 15:56:08 -0800285
Colin Crossf0056cb2017-12-22 15:56:08 -0800286 // Compile classes.jar into classes.dex and then javalib.jar
Paul Duffin612e6102021-02-02 13:38:13 +0000287 javalibJar := android.PathForModuleOut(ctx, "dex", jarName).OutputPath
Colin Crossf0056cb2017-12-22 15:56:08 -0800288 outDir := android.PathForModuleOut(ctx, "dex")
289
Sasha Smundakd3cf4ee2019-02-15 10:14:23 -0800290 zipFlags := "--ignore_missing_files"
Liz Kammera7a64f32020-07-09 15:16:41 -0700291 if proptools.Bool(d.dexProperties.Uncompress_dex) {
Sasha Smundakd3cf4ee2019-02-15 10:14:23 -0800292 zipFlags += " -L 0"
Colin Cross5a0dcd52018-10-05 14:20:06 -0700293 }
294
Liz Kammera7a64f32020-07-09 15:16:41 -0700295 commonFlags := d.dexCommonFlags(ctx, minSdkVersion)
296
297 useR8 := d.effectiveOptimizeEnabled()
Colin Cross66dbc0b2017-12-28 12:23:20 -0800298 if useR8 {
Colin Crossc0c664c2018-05-16 16:47:21 -0700299 proguardDictionary := android.PathForModuleOut(ctx, "proguard_dictionary")
Liz Kammera7a64f32020-07-09 15:16:41 -0700300 d.proguardDictionary = android.OptionalPathForPath(proguardDictionary)
Colin Crosscb6143a2020-08-14 17:39:29 -0700301 proguardUsageDir := android.PathForModuleOut(ctx, "proguard_usage")
302 proguardUsage := proguardUsageDir.Join(ctx, ctx.Namespace().Path,
303 android.ModuleNameWithPossibleOverride(ctx), "unused.txt")
304 proguardUsageZip := android.PathForModuleOut(ctx, "proguard_usage.zip")
305 d.proguardUsageZip = android.OptionalPathForPath(proguardUsageZip)
Liz Kammera7a64f32020-07-09 15:16:41 -0700306 r8Flags, r8Deps := d.r8Flags(ctx, flags)
Ramy Medhat1dcc27e2020-04-21 21:36:23 -0400307 rule := r8
308 args := map[string]string{
Colin Crosscb6143a2020-08-14 17:39:29 -0700309 "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "),
310 "zipFlags": zipFlags,
311 "outDict": proguardDictionary.String(),
312 "outUsageDir": proguardUsageDir.String(),
313 "outUsage": proguardUsage.String(),
314 "outUsageZip": proguardUsageZip.String(),
315 "outDir": outDir.String(),
Ramy Medhat1dcc27e2020-04-21 21:36:23 -0400316 }
Ramy Medhat16f23a42020-09-03 01:29:49 -0400317 if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8") {
Ramy Medhat1dcc27e2020-04-21 21:36:23 -0400318 rule = r8RE
319 args["implicits"] = strings.Join(r8Deps.Strings(), ",")
320 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800321 ctx.Build(pctx, android.BuildParams{
Colin Crosscb6143a2020-08-14 17:39:29 -0700322 Rule: rule,
323 Description: "r8",
324 Output: javalibJar,
325 ImplicitOutputs: android.WritablePaths{proguardDictionary, proguardUsageZip},
326 Input: classesJar,
327 Implicits: r8Deps,
328 Args: args,
Colin Cross66dbc0b2017-12-28 12:23:20 -0800329 })
330 } else {
Liz Kammera7a64f32020-07-09 15:16:41 -0700331 d8Flags, d8Deps := d8Flags(flags)
Ramy Medhat1dcc27e2020-04-21 21:36:23 -0400332 rule := d8
Ramy Medhat16f23a42020-09-03 01:29:49 -0400333 if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_D8") {
Ramy Medhat1dcc27e2020-04-21 21:36:23 -0400334 rule = d8RE
335 }
Colin Cross66dbc0b2017-12-28 12:23:20 -0800336 ctx.Build(pctx, android.BuildParams{
Ramy Medhat1dcc27e2020-04-21 21:36:23 -0400337 Rule: rule,
Colin Crossbafb8972018-06-06 21:46:32 +0000338 Description: "d8",
Colin Cross66dbc0b2017-12-28 12:23:20 -0800339 Output: javalibJar,
340 Input: classesJar,
Colin Cross6dab9bd2018-09-28 08:06:24 -0700341 Implicits: d8Deps,
Colin Cross66dbc0b2017-12-28 12:23:20 -0800342 Args: map[string]string{
Liz Kammera7a64f32020-07-09 15:16:41 -0700343 "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "),
Colin Cross5a0dcd52018-10-05 14:20:06 -0700344 "zipFlags": zipFlags,
345 "outDir": outDir.String(),
Colin Cross66dbc0b2017-12-28 12:23:20 -0800346 },
347 })
Colin Crossf0056cb2017-12-22 15:56:08 -0800348 }
Liz Kammera7a64f32020-07-09 15:16:41 -0700349 if proptools.Bool(d.dexProperties.Uncompress_dex) {
Paul Duffin612e6102021-02-02 13:38:13 +0000350 alignedJavalibJar := android.PathForModuleOut(ctx, "aligned", jarName).OutputPath
Nicolas Geoffray65fd8ba2019-01-21 23:20:23 +0000351 TransformZipAlign(ctx, alignedJavalibJar, javalibJar)
352 javalibJar = alignedJavalibJar
353 }
Colin Crossf0056cb2017-12-22 15:56:08 -0800354
Colin Crossf0056cb2017-12-22 15:56:08 -0800355 return javalibJar
356}