Reworks: * Add MESON_SKIP_TEST error for darwin from polyglot test * Remove dependencies from executable Dylan's changes: * Add support for both static and shared testing * Test with pkg-config, cmake, and system * reformat to meson's style Co-authored-by: Dylan Baker <dylan@pnwbakers.com>pull/8404/head
parent
4c1a0c400f
commit
5edbc0acd7
5 changed files with 59 additions and 0 deletions
@ -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); |
||||
} |
@ -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) |
@ -0,0 +1,2 @@ |
||||
option('static', type : 'boolean') |
||||
option('method', type : 'string') |
@ -0,0 +1,9 @@ |
||||
extern "C" { |
||||
fn c_accessing_zlib(); |
||||
} |
||||
|
||||
fn main() { |
||||
unsafe { |
||||
c_accessing_zlib(); |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
{ |
||||
"matrix": { |
||||
"options": { |
||||
"static": [ |
||||
{ "val": true }, |
||||
{ "val": false } |
||||
], |
||||
"method": [ |
||||
{ "val": "pkg-config" }, |
||||
{ "val": "cmake" }, |
||||
{ "val": "system" } |
||||
] |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue