| 1 |
config_rs = configure_file( |
| 2 |
input: 'config.rs.in', |
| 3 |
output: 'config.rs', |
| 4 |
configuration: config_rs |
| 5 |
) |
| 6 |
run_command( |
| 7 |
'cp', |
| 8 |
meson.project_build_root() / 'src' / 'config.rs', |
| 9 |
meson.project_source_root() / 'src' / 'config.rs', |
| 10 |
check: true |
| 11 |
) |
| 12 |
|
| 13 |
cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] |
| 14 |
cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ] |
| 15 |
|
| 16 |
if profile == 'debug' |
| 17 |
rust_target = 'debug' |
| 18 |
message('Building in debug mode') |
| 19 |
else |
| 20 |
cargo_options += [ '--release' ] |
| 21 |
rust_target = 'release' |
| 22 |
message('Building in release mode') |
| 23 |
endif |
| 24 |
|
| 25 |
robots = custom_target( |
| 26 |
'cargo-build', |
| 27 |
build_by_default: true, |
| 28 |
build_always_stale: true, |
| 29 |
input: [config_rs], |
| 30 |
output: meson.project_name(), |
| 31 |
console: true, |
| 32 |
install: true, |
| 33 |
install_dir: bindir, |
| 34 |
command: [ |
| 35 |
cargo, 'build', cargo_options, |
| 36 |
'&&', |
| 37 |
'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', |
| 38 |
] |
| 39 |
) |
| 40 |
|
| 41 |
test( |
| 42 |
'cargo-test', cargo, |
| 43 |
args: ['test', '--no-fail-fast'] + cargo_options, |
| 44 |
depends: [robots], |
| 45 |
timeout: 180 |
| 46 |
) |