From a8008f959551b4b4618504b1f2e270eba33d51a0 Mon Sep 17 00:00:00 2001 From: Mohammad Samiul Islam Date: Tue, 22 Dec 2020 10:47:50 +0000 Subject: [PATCH] Add property to apex soong modules to forcefully compress an APEX This makes creating compressed APEX artifacts for testing simpler. Bug: 172911820 Test: atest apex_compression_platform_tests Change-Id: I77b8bea4662c273420e7b37d5fde181b86c9cb78 --- apex/apex.go | 9 +++++++++ apex/builder.go | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 9e6625471..2d8df1fe1 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -164,6 +164,10 @@ type apexBundleProperties struct { // used in tests. Test_only_unsigned_payload *bool + // Whenever apex should be compressed, regardless of product flag used. Should be only + // used in tests. + Test_only_force_compression *bool + IsCoverageVariant bool `blueprint:"mutated"` // List of sanitizer names that this APEX is enabled for @@ -1235,6 +1239,11 @@ func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool { return proptools.Bool(a.properties.Test_only_unsigned_payload) } +// See the test_only_force_compression property +func (a *apexBundle) testOnlyShouldForceCompression() bool { + return proptools.Bool(a.properties.Test_only_force_compression) +} + // These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its // members) can be sanitized, either forcibly, or by the global configuration. For some of the // sanitizers, extra dependencies can be forcibly added as well. diff --git a/apex/builder.go b/apex/builder.go index 9db8e5929..8d200ff3e 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -763,9 +763,13 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { }) a.outputFile = signedOutputFile - // Process APEX compression if enabled + // Process APEX compression if enabled or forced + if ctx.ModuleDir() != "system/apex/apexd/apexd_testdata" && a.testOnlyShouldForceCompression() { + ctx.PropertyErrorf("test_only_force_compression", "not available") + return + } compressionEnabled := ctx.Config().CompressedApex() && proptools.BoolDefault(a.properties.Compressible, true) - if compressionEnabled && apexType == imageApex { + if apexType == imageApex && (compressionEnabled || a.testOnlyShouldForceCompression()) { a.isCompressed = true unsignedCompressedOutputFile := android.PathForModuleOut(ctx, a.Name()+".capex.unsigned")