apex: track transitive dependencies of rust jni lib
dependencies of rust library registered as jni_lib are correctly
tracked.
Bug: 220397949
Test: m nothing
Change-Id: I43016a77656d04f59f798b02d541c6a19288ec9c
diff --git a/apex/apex.go b/apex/apex.go
index d12a786..6275c4d 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1745,6 +1745,7 @@
fi := apexFileForRustLibrary(ctx, r)
fi.isJniLib = isJniLib
filesInfo = append(filesInfo, fi)
+ return true // track transitive dependencies
} else {
propertyName := "native_shared_libs"
if isJniLib {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 6d77b06..2ed5a4d 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -971,6 +971,9 @@
rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000").Rule("rustc").Args["linkFlags"]
ensureContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared_current/libfoo.shared_from_rust.so")
ensureNotContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared/libfoo.shared_from_rust.so")
+
+ apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexManifestRule")
+ ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libfoo.shared_from_rust.so")
}
func TestApexCanUsePrivateApis(t *testing.T) {
@@ -6830,7 +6833,7 @@
apex {
name: "myapex",
key: "myapex.key",
- jni_libs: ["mylib"],
+ jni_libs: ["mylib", "libfoo.rust"],
updatable: false,
}
@@ -6856,15 +6859,41 @@
stl: "none",
apex_available: [ "myapex" ],
}
+
+ rust_ffi_shared {
+ name: "libfoo.rust",
+ crate_name: "foo",
+ srcs: ["foo.rs"],
+ shared_libs: ["libfoo.shared_from_rust"],
+ prefer_rlib: true,
+ apex_available: ["myapex"],
+ }
+
+ cc_library_shared {
+ name: "libfoo.shared_from_rust",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ stubs: {
+ versions: ["10", "11", "12"],
+ },
+ }
+
`)
rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexManifestRule")
// Notice mylib2.so (transitive dep) is not added as a jni_lib
- ensureEquals(t, rule.Args["opt"], "-a jniLibs mylib.so")
+ ensureEquals(t, rule.Args["opt"], "-a jniLibs libfoo.rust.so mylib.so")
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
"lib64/mylib.so",
"lib64/mylib2.so",
+ "lib64/libfoo.rust.so",
+ "lib64/libc++.so", // auto-added to libfoo.rust by Soong
+ "lib64/liblog.so", // auto-added to libfoo.rust by Soong
})
+
+ // b/220397949
+ ensureListContains(t, names(rule.Args["requireNativeLibs"]), "libfoo.shared_from_rust.so")
}
func TestApexMutatorsDontRunIfDisabled(t *testing.T) {