Loading apex/apex_test.go +24 −0 Original line number Diff line number Diff line Loading @@ -8993,6 +8993,30 @@ func TestCompressedApex(t *testing.T) { ensureContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.capex\n") } func TestApexSet_ShouldRespectCompressedApexFlag(t *testing.T) { for _, compressionEnabled := range []bool{true, false} { t.Run(fmt.Sprintf("compressionEnabled=%v", compressionEnabled), func(t *testing.T) { ctx := testApex(t, ` apex_set { name: "com.company.android.myapex", apex_name: "com.android.myapex", set: "company-myapex.apks", } `, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.CompressedApex = proptools.BoolPtr(compressionEnabled) }), ) build := ctx.ModuleForTests("com.company.android.myapex", "android_common_com.android.myapex").Output("com.company.android.myapex.apex") if compressionEnabled { ensureEquals(t, build.Rule.String(), "android/soong/android.Cp") } else { ensureEquals(t, build.Rule.String(), "android/apex.decompressApex") } }) } } func TestPreferredPrebuiltSharedLibDep(t *testing.T) { ctx := testApex(t, ` apex { Loading apex/prebuilt.go +12 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,11 @@ var ( CommandDeps: []string{"${extract_apks}"}, }, "abis", "allow-prereleased", "sdk-version", "skip-sdk-check") decompressApex = pctx.StaticRule("decompressApex", blueprint.RuleParams{ Command: `${deapexer} decompress --copy-if-uncompressed --input ${in} --output ${out}`, CommandDeps: []string{"${deapexer}"}, Description: "decompress", }) ) type prebuilt interface { Loading Loading @@ -1072,8 +1077,14 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) { inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path() a.outputApex = android.PathForModuleOut(ctx, a.installFilename) // Build the output APEX. If compression is not enabled, make sure the output is not compressed even if the input is compressed buildRule := android.Cp if !ctx.Config().ApexCompressionEnabled() { buildRule = decompressApex } ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Rule: buildRule, Input: inputApex, Output: a.outputApex, }) Loading Loading
apex/apex_test.go +24 −0 Original line number Diff line number Diff line Loading @@ -8993,6 +8993,30 @@ func TestCompressedApex(t *testing.T) { ensureContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.capex\n") } func TestApexSet_ShouldRespectCompressedApexFlag(t *testing.T) { for _, compressionEnabled := range []bool{true, false} { t.Run(fmt.Sprintf("compressionEnabled=%v", compressionEnabled), func(t *testing.T) { ctx := testApex(t, ` apex_set { name: "com.company.android.myapex", apex_name: "com.android.myapex", set: "company-myapex.apks", } `, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.CompressedApex = proptools.BoolPtr(compressionEnabled) }), ) build := ctx.ModuleForTests("com.company.android.myapex", "android_common_com.android.myapex").Output("com.company.android.myapex.apex") if compressionEnabled { ensureEquals(t, build.Rule.String(), "android/soong/android.Cp") } else { ensureEquals(t, build.Rule.String(), "android/apex.decompressApex") } }) } } func TestPreferredPrebuiltSharedLibDep(t *testing.T) { ctx := testApex(t, ` apex { Loading
apex/prebuilt.go +12 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,11 @@ var ( CommandDeps: []string{"${extract_apks}"}, }, "abis", "allow-prereleased", "sdk-version", "skip-sdk-check") decompressApex = pctx.StaticRule("decompressApex", blueprint.RuleParams{ Command: `${deapexer} decompress --copy-if-uncompressed --input ${in} --output ${out}`, CommandDeps: []string{"${deapexer}"}, Description: "decompress", }) ) type prebuilt interface { Loading Loading @@ -1072,8 +1077,14 @@ func (a *ApexSet) GenerateAndroidBuildActions(ctx android.ModuleContext) { inputApex := android.OptionalPathForModuleSrc(ctx, a.prebuiltCommonProperties.Selected_apex).Path() a.outputApex = android.PathForModuleOut(ctx, a.installFilename) // Build the output APEX. If compression is not enabled, make sure the output is not compressed even if the input is compressed buildRule := android.Cp if !ctx.Config().ApexCompressionEnabled() { buildRule = decompressApex } ctx.Build(pctx, android.BuildParams{ Rule: android.Cp, Rule: buildRule, Input: inputApex, Output: a.outputApex, }) Loading