diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2024-07-23 17:24:16 +0200 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2024-07-24 13:06:28 +0200 |
commit | e7f2fc92c8fd64485d635b1cc7b0c2897d78bc69 (patch) | |
tree | a464901b31e83daafcbfb8049debeab732d4e6d0 /doc/interoperability/rust-from-c/foo | |
parent | d5426a260d88d90c8f275557d8f5ae8e1a55d367 (diff) | |
download | rules-rust-e7f2fc92c8fd64485d635b1cc7b0c2897d78bc69.tar.gz |
rules-rust: add interoperability tutorials
Diffstat (limited to 'doc/interoperability/rust-from-c/foo')
-rw-r--r-- | doc/interoperability/rust-from-c/foo/TARGETS | 9 | ||||
-rw-r--r-- | doc/interoperability/rust-from-c/foo/foo.h | 2 | ||||
-rw-r--r-- | doc/interoperability/rust-from-c/foo/foo.rs | 4 |
3 files changed, 15 insertions, 0 deletions
diff --git a/doc/interoperability/rust-from-c/foo/TARGETS b/doc/interoperability/rust-from-c/foo/TARGETS new file mode 100644 index 0000000..8d19b35 --- /dev/null +++ b/doc/interoperability/rust-from-c/foo/TARGETS @@ -0,0 +1,9 @@ +{ "foo": + { "type": ["@", "rules-rust", "rust", "library"] + , "name": ["foo"] + , "crate_root": ["foo.rs"] + , "native": ["true"] + , "c_hdrs": ["foo.h"] + , "stage": ["foo"] + } +} diff --git a/doc/interoperability/rust-from-c/foo/foo.h b/doc/interoperability/rust-from-c/foo/foo.h new file mode 100644 index 0000000..88deb2e --- /dev/null +++ b/doc/interoperability/rust-from-c/foo/foo.h @@ -0,0 +1,2 @@ +#pragma once +int foo(int); diff --git a/doc/interoperability/rust-from-c/foo/foo.rs b/doc/interoperability/rust-from-c/foo/foo.rs new file mode 100644 index 0000000..65cbffc --- /dev/null +++ b/doc/interoperability/rust-from-c/foo/foo.rs @@ -0,0 +1,4 @@ +#[no_mangle] +pub extern "C" fn foo(x: i32) -> i32 { + return x.abs(); +} |