summaryrefslogtreecommitdiff
path: root/test/c-from-rust/rust_interface
diff options
context:
space:
mode:
authorAlberto Sartori <alberto.sartori@huawei.com>2024-07-22 12:20:46 +0200
committerAlberto Sartori <alberto.sartori@huawei.com>2024-07-23 15:41:45 +0200
commited652442176aea086104479bb31aced501df48a2 (patch)
tree582322cce152505eaac16aff5442fcbefbbe3938 /test/c-from-rust/rust_interface
parentcda960a4cd846ca97f90b172014fd02206eb74a0 (diff)
downloadrules-rust-ed652442176aea086104479bb31aced501df48a2.tar.gz
rules-rust: bugfix: correctly propagate link args of C dependencies
Diffstat (limited to 'test/c-from-rust/rust_interface')
-rw-r--r--test/c-from-rust/rust_interface/TARGETS8
-rw-r--r--test/c-from-rust/rust_interface/foo.rs11
2 files changed, 19 insertions, 0 deletions
diff --git a/test/c-from-rust/rust_interface/TARGETS b/test/c-from-rust/rust_interface/TARGETS
new file mode 100644
index 0000000..2404f2b
--- /dev/null
+++ b/test/c-from-rust/rust_interface/TARGETS
@@ -0,0 +1,8 @@
+{ "foo_rust":
+ { "type": ["@", "rules-rust", "rust", "library"]
+ , "name": ["foo_rust"]
+ , "crate_root": ["foo.rs"]
+ , "stage": ["foo_rust"]
+ , "deps": [["./", "../clib", "foo"]]
+ }
+}
diff --git a/test/c-from-rust/rust_interface/foo.rs b/test/c-from-rust/rust_interface/foo.rs
new file mode 100644
index 0000000..acfe2a7
--- /dev/null
+++ b/test/c-from-rust/rust_interface/foo.rs
@@ -0,0 +1,11 @@
+// declaration of the function implemented in the C library
+extern "C" {
+ pub fn c_func(input: i32) -> i32;
+}
+
+// wrapper to call the C function
+pub fn c_call(i:i32) -> i32{
+ unsafe {
+ return c_func(i);
+ }
+}