Handle `test_per_src` modules as indirect dependencies in APEXes.
In `apex.apexBundle.GenerateAndroidBuildActions`, we used to pass the
"all tests" ("") module as `module` for all `apexFile` objects created
from a test module using `test_per_src: true`. An immediate issue of
this situation was that the "" module is hidden from Make, which made
all the generated `apexFile` objects hidden from Make too. This would
break the construction of flattened APEXes, as they rely on Make logic
to install their files.
Instead of collecting `test_per_src` test variations' output files in
`cc.Module.GenerateAndroidBuildActions` and using them in
`apex.apexBundle.GenerateAndroidBuildActions` as part of handling the
"" variation as a direct dependency of an `apexBundle`, process them
as indirect dependencies (and do nothing for the "" variation direct
dependency).
Adjust the indirect dependency logic in
`apex.apexBundle.GenerateAndroidBuildActions` to allow not only
shared/runtime native libraries as indirect dependencies of an
`apexBundle`, but also `test_per_src` tests.
Test: m (`apex/apex_test.go` amended)
Bug: 129534335
Change-Id: I845e0f0dd3a98d61d0b7118c5eaf61f3e5335724
diff --git a/apex/apex_test.go b/apex/apex_test.go
index e44163e..cecdaaf 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -1393,7 +1393,7 @@
}
func TestApexWithTests(t *testing.T) {
- ctx, _ := testApex(t, `
+ ctx, config := testApex(t, `
apex_test {
name: "myapex",
key: "myapex.key",
@@ -1445,6 +1445,22 @@
ensureContains(t, copyCmds, "image.apex/bin/test/mytest1")
ensureContains(t, copyCmds, "image.apex/bin/test/mytest2")
ensureContains(t, copyCmds, "image.apex/bin/test/mytest3")
+
+ // Ensure the module is correctly translated.
+ apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle)
+ data := android.AndroidMkDataForTest(t, config, "", apexBundle)
+ name := apexBundle.BaseModuleName()
+ prefix := "TARGET_"
+ var builder strings.Builder
+ data.Custom(&builder, name, prefix, "", data)
+ androidMk := builder.String()
+ ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest1\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest2\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest3\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := myapex.apex_manifest.json\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := myapex.apex_pubkey\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
}
func TestApexUsesOtherApex(t *testing.T) {