diff options
| author | Jaewoong Jung <jungjw@google.com> | 2019-05-09 14:36:34 -0700 |
|---|---|---|
| committer | Rashed Abdel-Tawab <rashed@linux.com> | 2019-09-27 20:30:59 -0700 |
| commit | 0a7d9b3cfda3747ffb69a305c96d326453019285 (patch) | |
| tree | fcf3dd10eefeeb8428ce2df127a12a3d6df0af30 | |
| parent | bb7143c43df59913ad4b40309d02659dcda3ffe8 (diff) | |
| download | build_soong-0a7d9b3cfda3747ffb69a305c96d326453019285.tar.gz build_soong-0a7d9b3cfda3747ffb69a305c96d326453019285.tar.bz2 build_soong-0a7d9b3cfda3747ffb69a305c96d326453019285.zip | |
Uncompress dex file in imported apk when needed.
This implements the uncompress-dexs macro's behavior in Soong.
Test: Converted TvSampleLeanbackLauncher + zipinfo
Change-Id: I9477aa21429d055f3f36ca90c7fd2c345c999029
| -rw-r--r-- | java/app.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/java/app.go b/java/app.go index bbe034d1..157487fe 100644 --- a/java/app.go +++ b/java/app.go @@ -750,6 +750,19 @@ func (a *AndroidAppImport) shouldUncompressDex(ctx android.ModuleContext) bool { return shouldUncompressDex(ctx, &a.dexpreopter) } +func (a *AndroidAppImport) uncompressDex( + ctx android.ModuleContext, inputPath android.Path, outputPath android.OutputPath) { + rule := android.NewRuleBuilder() + rule.Command(). + Textf(`if (zipinfo %s '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then`, inputPath). + Tool(ctx.Config().HostToolPath(ctx, "zip2zip")). + FlagWithInput("-i ", inputPath). + FlagWithOutput("-o ", outputPath). + FlagWithArg("-0 ", "'classes*.dex'"). + Textf(`; else cp -f %s %s; fi`, inputPath, outputPath) + rule.Build(pctx, ctx, "uncompress-dex", "Uncompress dex files") +} + func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { if String(a.properties.Certificate) == "" && !Bool(a.properties.Presigned) { ctx.PropertyErrorf("certificate", "No certificate specified for prebuilt") @@ -778,6 +791,11 @@ func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext a.dexpreopter.isPresignedPrebuilt = Bool(a.properties.Presigned) a.dexpreopter.uncompressedDex = a.shouldUncompressDex(ctx) dexOutput := a.dexpreopter.dexpreopt(ctx, jnisUncompressed) + if a.dexpreopter.uncompressedDex { + dexUncompressed := android.PathForModuleOut(ctx, "dex-uncompressed", ctx.ModuleName()+".apk") + a.uncompressDex(ctx, dexOutput, dexUncompressed.OutputPath) + dexOutput = dexUncompressed + } // Sign or align the package // TODO: Handle EXTERNAL |
