Debian Codegraph @

test cases/rust/38 probes/meson.build

raw
1 project('rust compiles', 'rust')
2
3 rustc = meson.get_compiler('rust')
4
5 # Test that compiles() works without and with a main function
6 assert(rustc.compiles('pub fn foo() {}'), 'compiles() without main should work')
7 assert(rustc.compiles('pub fn main() {}'), 'compiles() with main should work')
8
9 # Test with a simple expression
10 assert(rustc.compiles('pub fn bar() { let _x: i32 = 1; }'), 'compiles() with simple code should work')
11
12 # Test that invalid code fails
13 assert(not rustc.compiles('pub fn baz() { invalid_syntax }'), 'compiles() should fail on invalid code')
14
15
16 rustmod = import('rust')
17
18 cargo_target = rustmod.compiler_target()
19 message('Host Rust target triple: ' + cargo_target)
20 assert(cargo_target != '', 'compiler_target() should return a non-empty string')
21 assert(cargo_target == rustmod.compiler_target(native: false), 'compiler_target(native: false) should match the default')
22 assert(cargo_target.contains('-'), 'compiler_target() should return a triple containing dashes')
23
24 cargo_host = rustmod.compiler_target(native: true)
25 message('Build Rust target triple: ' + cargo_host)
26 assert(cargo_host != '', 'compiler_target(native: true) should return a non-empty string')
27 assert(cargo_host.contains('-'), 'compiler_target(native: true) should return a triple containing dashes')