diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2024-06-24 15:49:36 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-06-24 15:49:36 +0200 |
commit | f87ad41f72ca4465a0c5b4ba9fd36a7b09e4d4f4 (patch) | |
tree | 24d4a3a5975df2046714c6bc114d5d050bdc61fc /test/c-from-rust/clib | |
download | rules-rust-f87ad41f72ca4465a0c5b4ba9fd36a7b09e4d4f4.tar.gz |
Initial commit
Co-authored-by: Klaus Aehlig <klaus.aehlig@huawei.com>
Diffstat (limited to 'test/c-from-rust/clib')
-rw-r--r-- | test/c-from-rust/clib/TARGETS | 19 | ||||
-rw-r--r-- | test/c-from-rust/clib/bar.c | 5 | ||||
-rw-r--r-- | test/c-from-rust/clib/bar.h | 3 | ||||
-rw-r--r-- | test/c-from-rust/clib/foo.c | 5 | ||||
-rw-r--r-- | test/c-from-rust/clib/foo.h | 3 |
5 files changed, 35 insertions, 0 deletions
diff --git a/test/c-from-rust/clib/TARGETS b/test/c-from-rust/clib/TARGETS new file mode 100644 index 0000000..c72e90b --- /dev/null +++ b/test/c-from-rust/clib/TARGETS @@ -0,0 +1,19 @@ +{ "foo": + { "type": ["@", "rules-cc", "CC", "library"] + , "pure C": ["true"] + , "name": ["foo"] + , "srcs": ["foo.c"] + , "hdrs": ["foo.h"] + , "stage": ["foo"] + , "deps": ["bar"] + } +, "bar": + { "type": ["@", "rules-cc", "CC", "library"] + , "pure C": ["true"] + , "name": ["bar"] + , "srcs": ["bar.c"] + , "hdrs": ["bar.h"] + , "ldflags": ["-lm"] + , "stage": ["bar"] + } +} diff --git a/test/c-from-rust/clib/bar.c b/test/c-from-rust/clib/bar.c new file mode 100644 index 0000000..5ad792c --- /dev/null +++ b/test/c-from-rust/clib/bar.c @@ -0,0 +1,5 @@ +#include <math.h> + +int bar(int x){ + return sqrt(x); +} diff --git a/test/c-from-rust/clib/bar.h b/test/c-from-rust/clib/bar.h new file mode 100644 index 0000000..1c88e77 --- /dev/null +++ b/test/c-from-rust/clib/bar.h @@ -0,0 +1,3 @@ +#pragma once + +int bar(int); diff --git a/test/c-from-rust/clib/foo.c b/test/c-from-rust/clib/foo.c new file mode 100644 index 0000000..5306a9c --- /dev/null +++ b/test/c-from-rust/clib/foo.c @@ -0,0 +1,5 @@ +#include "bar/bar.h" + +int c_func(int x){ + return bar(x*x); +} diff --git a/test/c-from-rust/clib/foo.h b/test/c-from-rust/clib/foo.h new file mode 100644 index 0000000..6ce2745 --- /dev/null +++ b/test/c-from-rust/clib/foo.h @@ -0,0 +1,3 @@ +#pragma once +int c_func(int); + |