apex supports ".apex" tag

Tests can embed non-compressed .apex output with the tag.

Bug: 221024307
Test: soong test
Change-Id: Id4a239d1897237105a064cea8c97029f5b996a98
This commit is contained in:
Jooyung Han 2022-02-24 13:58:07 +09:00
parent 315352e71c
commit a6d3667b67
3 changed files with 61 additions and 0 deletions

View file

@ -416,8 +416,12 @@ type apexBundle struct {
mergedNotices android.NoticeOutputs
// The built APEX file. This is the main product.
// Could be .apex or .capex
outputFile android.WritablePath
// The built uncompressed .apex file.
outputApexFile android.WritablePath
// The built APEX file in app bundle format. This file is not directly installed to the
// device. For an APEX, multiple app bundles are created each of which is for a specific ABI
// like arm, arm64, x86, etc. Then they are processed again (outside of the Android build
@ -1284,6 +1288,12 @@ func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
case "", android.DefaultDistTag:
// This is the default dist path.
return android.Paths{a.outputFile}, nil
case imageApexSuffix:
// uncompressed one
if a.outputApexFile != nil {
return android.Paths{a.outputApexFile}, nil
}
fallthrough
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}

View file

@ -8661,6 +8661,54 @@ func TestAndroidMk_RequiredModules(t *testing.T) {
ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherapex")
}
func TestApexOutputFileProducer(t *testing.T) {
for _, tc := range []struct {
name string
ref string
expected_data []string
}{
{
name: "test_using_output",
ref: ":myapex",
expected_data: []string{"out/soong/.intermediates/myapex/android_common_myapex_image/myapex.capex:myapex.capex"},
},
{
name: "test_using_apex",
ref: ":myapex{.apex}",
expected_data: []string{"out/soong/.intermediates/myapex/android_common_myapex_image/myapex.apex:myapex.apex"},
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
compressible: true,
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
java_test {
name: "`+tc.name+`",
srcs: ["a.java"],
data: ["`+tc.ref+`"],
}
`,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.CompressedApex = proptools.BoolPtr(true)
}))
javaTest := ctx.ModuleForTests(tc.name, "android_common").Module().(*java.Test)
data := android.AndroidMkEntriesForTest(t, ctx, javaTest)[0].EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"]
android.AssertStringPathsRelativeToTopEquals(t, "data", ctx.Config(), tc.expected_data, data)
})
}
}
func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
preparer := android.GroupFixturePreparers(
PrepareForTestWithApexBuildComponents,

View file

@ -810,6 +810,9 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
Implicits: implicits,
Args: args,
})
if suffix == imageApexSuffix {
a.outputApexFile = signedOutputFile
}
a.outputFile = signedOutputFile
if ctx.ModuleDir() != "system/apex/apexd/apexd_testdata" && a.testOnlyShouldForceCompression() {