summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2025-02-21 20:42:48 +0000
committer Ivan Lozano <ivanlozano@google.com> 2025-02-25 14:42:08 +0000
commit422eb2b1847ccf29d90f2af988bd9cfa0561bc9f (patch)
treec53a47f266d718118f168e26ebcf1bc57d237eda /rust
parentdbcf9da57530287ff53aa5707bda1262c4cd2769 (diff)
cc: Add cc_rustlibs_for_make to bundle rust_ffi_static
Adds a new module cc_rustlibs_for_make to whole-link the generated staticlib for a cc_library_static that would otherwise wait for a final link to be generated. This is intended to support bundling rust_ffi_static libraries for use in Make as they're no longer true staticlibs and instead rlibs. Bug: 393511828 Bug: 396666286 Test: m <Make static executable with rust_ffi_static deps> Change-Id: I158ecf9b7493ecb259f3732af0db821a828efd5b
Diffstat (limited to 'rust')
-rw-r--r--rust/library_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/rust/library_test.go b/rust/library_test.go
index 6db95253f..6cc4f2517 100644
--- a/rust/library_test.go
+++ b/rust/library_test.go
@@ -426,6 +426,45 @@ func TestRustFFIExportedIncludes(t *testing.T) {
android.AssertStringDoesContain(t, "cFlags for lib module", libfooStatic.Args["cFlags"], " -Irust_includes ")
}
+// Make sure cc_rustlibs_for_make has the expected behavior, and that
+// cc_library_static does as well.
+// This is here instead of cc/library_test.go because the test needs to
+// define a rust_ffi module which can't be done in soong-cc to avoid the
+// circular dependency.
+func TestCCRustlibsForMake(t *testing.T) {
+ t.Parallel()
+ result := testRust(t, `
+ rust_ffi_static {
+ name: "libbar",
+ srcs: ["foo.rs"],
+ crate_name: "bar",
+ export_include_dirs: ["rust_includes"],
+ host_supported: true,
+ }
+
+ cc_rustlibs_for_make {
+ name: "libmakerustlibs",
+ whole_static_libs: ["libbar"],
+ }
+
+ cc_library_static {
+ name: "libccstatic",
+ whole_static_libs: ["libbar"],
+ }
+ `)
+
+ libmakerustlibs := result.ModuleForTests(t, "libmakerustlibs", "android_arm64_armv8-a_static").MaybeRule("rustc")
+ libccstatic := result.ModuleForTests(t, "libccstatic", "android_arm64_armv8-a_static").MaybeRule("rustc")
+
+ if libmakerustlibs.Output == nil {
+ t.Errorf("cc_rustlibs_for_make is not generating a Rust staticlib when it should")
+ }
+
+ if libccstatic.Output != nil {
+ t.Errorf("cc_library_static is generating a Rust staticlib when it should not")
+ }
+}
+
func TestRustVersionScript(t *testing.T) {
ctx := testRust(t, `
rust_library {