aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/rust/13 external c dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'meson/test cases/rust/13 external c dependencies')
-rw-r--r--meson/test cases/rust/13 external c dependencies/c_accessing_zlib.c10
-rw-r--r--meson/test cases/rust/13 external c dependencies/meson.build23
-rw-r--r--meson/test cases/rust/13 external c dependencies/meson_options.txt2
-rw-r--r--meson/test cases/rust/13 external c dependencies/prog.rs9
-rw-r--r--meson/test cases/rust/13 external c dependencies/test.json18
5 files changed, 62 insertions, 0 deletions
diff --git a/meson/test cases/rust/13 external c dependencies/c_accessing_zlib.c b/meson/test cases/rust/13 external c dependencies/c_accessing_zlib.c
new file mode 100644
index 000000000..358b98998
--- /dev/null
+++ b/meson/test cases/rust/13 external c dependencies/c_accessing_zlib.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include <string.h>
+#include <zlib.h>
+
+void c_accessing_zlib(void) {
+ struct z_stream_s zstream;
+ printf("Hello from C!\n");
+ memset(&zstream, 0, sizeof(zstream));
+ inflateInit(&zstream);
+}
diff --git a/meson/test cases/rust/13 external c dependencies/meson.build b/meson/test cases/rust/13 external c dependencies/meson.build
new file mode 100644
index 000000000..e5caf70cf
--- /dev/null
+++ b/meson/test cases/rust/13 external c dependencies/meson.build
@@ -0,0 +1,23 @@
+project('rust linking to c using dependency', 'c', 'rust')
+
+if host_machine.system() == 'darwin'
+ error('MESON_SKIP_TEST: doesnt work right on macos, please fix!')
+endif
+
+dep_zlib = dependency('zlib', static : get_option('static'), method : get_option('method'), required : false)
+if not dep_zlib.found()
+ error('MESON_SKIP_TEST: Could not find a @0@ zlib'.format(get_option('static') ? 'static' : 'shared'))
+endif
+
+l = static_library(
+ 'c_accessing_zlib',
+ 'c_accessing_zlib.c',
+ dependencies: [dep_zlib],
+)
+
+e = executable(
+ 'prog', 'prog.rs',
+ link_with : l,
+)
+
+test('cdepstest', e)
diff --git a/meson/test cases/rust/13 external c dependencies/meson_options.txt b/meson/test cases/rust/13 external c dependencies/meson_options.txt
new file mode 100644
index 000000000..f501348b6
--- /dev/null
+++ b/meson/test cases/rust/13 external c dependencies/meson_options.txt
@@ -0,0 +1,2 @@
+option('static', type : 'boolean')
+option('method', type : 'string')
diff --git a/meson/test cases/rust/13 external c dependencies/prog.rs b/meson/test cases/rust/13 external c dependencies/prog.rs
new file mode 100644
index 000000000..b30ec24fb
--- /dev/null
+++ b/meson/test cases/rust/13 external c dependencies/prog.rs
@@ -0,0 +1,9 @@
+extern "C" {
+ fn c_accessing_zlib();
+}
+
+fn main() {
+ unsafe {
+ c_accessing_zlib();
+ }
+}
diff --git a/meson/test cases/rust/13 external c dependencies/test.json b/meson/test cases/rust/13 external c dependencies/test.json
new file mode 100644
index 000000000..423581ff6
--- /dev/null
+++ b/meson/test cases/rust/13 external c dependencies/test.json
@@ -0,0 +1,18 @@
+{
+ "matrix": {
+ "options": {
+ "static": [
+ { "val": true },
+ { "val": false }
+ ],
+ "method": [
+ { "val": "pkg-config" },
+ { "val": "cmake" },
+ { "val": "system" }
+ ]
+ },
+ "exclude": [
+ { "static": true, "method": "pkg-config" }
+ ]
+ }
+}