Add zip-apex
This adds support for an apex-like file where the payload is a zip
file instead of a FS image. This makes it easier to examine and use
without root. These can also be built for the host.
This can be controlled using the 'type' modifier in the apex build
rule. 'type' may be "image" to build an apex file called {name}.apex
with an FS image payload, "zip" to build an apex with called
{name}.zipapex with a zip-file payload or "both" to build both. By
default we will use "image".
This also adds support for setting apex rules to
"host_supported: true".
Test: cd art/build/apex; mma; examine the com.android.runtime.host.zipapex
artifact.
Test: go test android/soong/apex -v
Bug: 120436895
Change-Id: I534d330672211ac5ccc3bd5a0c89b9fc507bf51e
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 41d8455..d1794ee 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -188,8 +188,56 @@
ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_myapex")
// Ensure that both direct and indirect deps are copied into apex
- ensureContains(t, copyCmds, "image/lib64/mylib.so")
- ensureContains(t, copyCmds, "image/lib64/mylib2.so")
+ ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
+ ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so")
+}
+
+func TestBasicZipApex(t *testing.T) {
+ ctx := testApex(t, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ payload_type: "zip",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ shared_libs: ["mylib2"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "mylib2",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ zipApexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("zipApexRule")
+ copyCmds := zipApexRule.Args["copy_commands"]
+
+ // Ensure that main rule creates an output
+ ensureContains(t, zipApexRule.Output.String(), "myapex.zipapex.unsigned")
+
+ // Ensure that APEX variant is created for the direct dep
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_myapex")
+
+ // Ensure that APEX variant is created for the indirect dep
+ ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_myapex")
+
+ // Ensure that both direct and indirect deps are copied into apex
+ ensureContains(t, copyCmds, "image.zipapex/lib64/mylib.so")
+ ensureContains(t, copyCmds, "image.zipapex/lib64/mylib2.so")
}
func TestApexWithStubs(t *testing.T) {
@@ -239,13 +287,13 @@
copyCmds := apexRule.Args["copy_commands"]
// Ensure that direct non-stubs dep is always included
- ensureContains(t, copyCmds, "image/lib64/mylib.so")
+ ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
// Ensure that indirect stubs dep is not included
- ensureNotContains(t, copyCmds, "image/lib64/mylib2.so")
+ ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
// Ensure that direct stubs dep is included
- ensureContains(t, copyCmds, "image/lib64/mylib3.so")
+ ensureContains(t, copyCmds, "image.apex/lib64/mylib3.so")
mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
@@ -326,12 +374,12 @@
copyCmds := apexRule.Args["copy_commands"]
// Ensure that mylib, libm, libdl are included.
- ensureContains(t, copyCmds, "image/lib64/mylib.so")
- ensureContains(t, copyCmds, "image/lib64/libm.so")
- ensureContains(t, copyCmds, "image/lib64/libdl.so")
+ ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
+ ensureContains(t, copyCmds, "image.apex/lib64/libm.so")
+ ensureContains(t, copyCmds, "image.apex/lib64/libdl.so")
// Ensure that libc is not included (since it has stubs and not listed in native_shared_libs)
- ensureNotContains(t, copyCmds, "image/lib64/libc.so")
+ ensureNotContains(t, copyCmds, "image.apex/lib64/libc.so")
mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_myapex").Rule("ld").Args["libFlags"]
mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"]