diff options
author | Jaewoong Jung <jungjw@google.com> | 2019-05-09 14:36:34 -0700 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-11 19:03:32 +0200 |
commit | 61732d653e590a6159ae8d7650a59c68c3426c28 (patch) | |
tree | 89e334fc4c43c6aa1b17b8e09a530aeb411a7af1 /java/app.go | |
parent | 73e34b4dbd146f344637319e86d0a9bf4bed28c9 (diff) | |
download | android_build_soong-61732d653e590a6159ae8d7650a59c68c3426c28.tar.gz android_build_soong-61732d653e590a6159ae8d7650a59c68c3426c28.tar.bz2 android_build_soong-61732d653e590a6159ae8d7650a59c68c3426c28.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
Diffstat (limited to 'java/app.go')
-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 |