diff options
Diffstat (limited to 'test cases/rust/14 external libm')
-rw-r--r-- | test cases/rust/14 external libm/meson.build | 24 | ||||
-rw-r--r-- | test cases/rust/14 external libm/meson_options.txt | 2 | ||||
-rw-r--r-- | test cases/rust/14 external libm/prog.rs | 5 | ||||
-rw-r--r-- | test cases/rust/14 external libm/rs_math.rs | 12 | ||||
-rw-r--r-- | test cases/rust/14 external libm/test.json | 10 |
5 files changed, 53 insertions, 0 deletions
diff --git a/test cases/rust/14 external libm/meson.build b/test cases/rust/14 external libm/meson.build new file mode 100644 index 0000000..e42eefe --- /dev/null +++ b/test cases/rust/14 external libm/meson.build @@ -0,0 +1,24 @@ +project('rust linking to libm', 'c', 'rust') + +if host_machine.system() == 'darwin' + error('MESON_SKIP_TEST: does not work right on macos, please fix!') +endif + +cc = meson.get_compiler('c') +dep_m = cc.find_library('m', required : false, static : get_option('static')) +if not dep_m.found() + error('MESON_SKIP_TEST: Could not find a @0@ libm'.format(get_option('static') ? 'static' : 'shared')) +endif + +librs_math = static_library( + 'rs_math', + 'rs_math.rs', + dependencies : [dep_m], +) + +e = executable( + 'prog', 'prog.rs', + link_with : [librs_math], +) + +test('cdepstest', e) diff --git a/test cases/rust/14 external libm/meson_options.txt b/test cases/rust/14 external libm/meson_options.txt new file mode 100644 index 0000000..f501348 --- /dev/null +++ b/test cases/rust/14 external libm/meson_options.txt @@ -0,0 +1,2 @@ +option('static', type : 'boolean') +option('method', type : 'string') diff --git a/test cases/rust/14 external libm/prog.rs b/test cases/rust/14 external libm/prog.rs new file mode 100644 index 0000000..6745977 --- /dev/null +++ b/test cases/rust/14 external libm/prog.rs @@ -0,0 +1,5 @@ +extern crate rs_math; + +fn main() { + assert_eq!(rs_math::rs_log2(8.0), 3.0); +} diff --git a/test cases/rust/14 external libm/rs_math.rs b/test cases/rust/14 external libm/rs_math.rs new file mode 100644 index 0000000..ef53a5c --- /dev/null +++ b/test cases/rust/14 external libm/rs_math.rs @@ -0,0 +1,12 @@ +#![crate_name = "rs_math"] + +use std::os::raw::c_double; + +extern "C" { + fn log2(n: c_double) -> c_double; +} + +#[no_mangle] +pub extern fn rs_log2(n: c_double) -> c_double { + unsafe { log2(n) } +} diff --git a/test cases/rust/14 external libm/test.json b/test cases/rust/14 external libm/test.json new file mode 100644 index 0000000..42d8fe9 --- /dev/null +++ b/test cases/rust/14 external libm/test.json @@ -0,0 +1,10 @@ +{ + "matrix": { + "options": { + "static": [ + { "val": true }, + { "val": false } + ] + } + } +} |