From f87ad41f72ca4465a0c5b4ba9fd36a7b09e4d4f4 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Mon, 24 Jun 2024 15:49:36 +0200 Subject: Initial commit Co-authored-by: Klaus Aehlig --- test/c-from-rust/clib/TARGETS | 19 +++++++++++++++++++ test/c-from-rust/clib/bar.c | 5 +++++ test/c-from-rust/clib/bar.h | 3 +++ test/c-from-rust/clib/foo.c | 5 +++++ test/c-from-rust/clib/foo.h | 3 +++ 5 files changed, 35 insertions(+) create mode 100644 test/c-from-rust/clib/TARGETS create mode 100644 test/c-from-rust/clib/bar.c create mode 100644 test/c-from-rust/clib/bar.h create mode 100644 test/c-from-rust/clib/foo.c create mode 100644 test/c-from-rust/clib/foo.h (limited to 'test/c-from-rust/clib') 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 + +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); + -- cgit v1.2.3