diff options
| author | ruki <[email protected]> | 2021-11-11 00:49:33 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-11-11 00:49:33 +0800 |
| commit | 886c51e8ce29b07adb96d4db0f73e38ce9318990 (patch) | |
| tree | e00b49d57f16c6402f0dffc5f0330f188f15b9da | |
| parent | 4d457bd1f9f8e1c899d14e67439d13cf3de2b510 (diff) | |
improve rust tests
| -rw-r--r-- | tests/projects/rust/cxx_call_rust_library/src/bridge.rs | 6 | ||||
| -rw-r--r-- | tests/projects/rust/cxx_call_rust_library/src/foo.rs | 6 | ||||
| -rw-r--r-- | tests/projects/rust/cxx_call_rust_library/src/main.cc | 8 | ||||
| -rw-r--r-- | tests/projects/rust/cxx_call_rust_library/xmake.lua | 13 | ||||
| -rw-r--r-- | tests/projects/rust/rust_call_cxx_library/src/foo.cc (renamed from tests/projects/rust/console_with_cxx_library/src/foo.cc) | 0 | ||||
| -rw-r--r-- | tests/projects/rust/rust_call_cxx_library/src/main.rs (renamed from tests/projects/rust/console_with_cxx_library/src/main.rs) | 0 | ||||
| -rw-r--r-- | tests/projects/rust/rust_call_cxx_library/test.lua (renamed from tests/projects/rust/console_with_cxx_library/test.lua) | 0 | ||||
| -rw-r--r-- | tests/projects/rust/rust_call_cxx_library/xmake.lua (renamed from tests/projects/rust/console_with_cxx_library/xmake.lua) | 0 |
8 files changed, 33 insertions, 0 deletions
diff --git a/tests/projects/rust/cxx_call_rust_library/src/bridge.rs b/tests/projects/rust/cxx_call_rust_library/src/bridge.rs new file mode 100644 index 000000000..3710f4bfd --- /dev/null +++ b/tests/projects/rust/cxx_call_rust_library/src/bridge.rs @@ -0,0 +1,6 @@ +#[cxx::bridge] +mod foo { + extern "Rust" { + fn add(a: i32, b: i32) -> i32; + } +} diff --git a/tests/projects/rust/cxx_call_rust_library/src/foo.rs b/tests/projects/rust/cxx_call_rust_library/src/foo.rs new file mode 100644 index 000000000..38727c484 --- /dev/null +++ b/tests/projects/rust/cxx_call_rust_library/src/foo.rs @@ -0,0 +1,6 @@ +pub fn add(a: i32, b: i32) -> i32 +{ + return a + b; +} + + diff --git a/tests/projects/rust/cxx_call_rust_library/src/main.cc b/tests/projects/rust/cxx_call_rust_library/src/main.cc new file mode 100644 index 000000000..c0d600fd3 --- /dev/null +++ b/tests/projects/rust/cxx_call_rust_library/src/main.cc @@ -0,0 +1,8 @@ +#include <stdio.h> +#include "bridge.rs.h" + +int main(int argc, char** argv) +{ + printf("add(1, 2) == %d\n", add(1, 2)); + return 0; +} diff --git a/tests/projects/rust/cxx_call_rust_library/xmake.lua b/tests/projects/rust/cxx_call_rust_library/xmake.lua new file mode 100644 index 000000000..b8bc7c9a8 --- /dev/null +++ b/tests/projects/rust/cxx_call_rust_library/xmake.lua @@ -0,0 +1,13 @@ +add_rules("mode.debug", "mode.release") + +target("foo") + set_kind("static") + add_files("src/foo.rs") + +target("test") + set_kind("binary") + add_deps("foo") + add_files("src/main.cc") + add_files("src/bridge.rs", {rules = "rust.cxxbridge"}) + + diff --git a/tests/projects/rust/console_with_cxx_library/src/foo.cc b/tests/projects/rust/rust_call_cxx_library/src/foo.cc index 9d989119e..9d989119e 100644 --- a/tests/projects/rust/console_with_cxx_library/src/foo.cc +++ b/tests/projects/rust/rust_call_cxx_library/src/foo.cc diff --git a/tests/projects/rust/console_with_cxx_library/src/main.rs b/tests/projects/rust/rust_call_cxx_library/src/main.rs index 1eac379d2..1eac379d2 100644 --- a/tests/projects/rust/console_with_cxx_library/src/main.rs +++ b/tests/projects/rust/rust_call_cxx_library/src/main.rs diff --git a/tests/projects/rust/console_with_cxx_library/test.lua b/tests/projects/rust/rust_call_cxx_library/test.lua index 92168a8c1..92168a8c1 100644 --- a/tests/projects/rust/console_with_cxx_library/test.lua +++ b/tests/projects/rust/rust_call_cxx_library/test.lua diff --git a/tests/projects/rust/console_with_cxx_library/xmake.lua b/tests/projects/rust/rust_call_cxx_library/xmake.lua index e150aca4a..e150aca4a 100644 --- a/tests/projects/rust/console_with_cxx_library/xmake.lua +++ b/tests/projects/rust/rust_call_cxx_library/xmake.lua |
