2020-12-26 02:05:34 -08:00
|
|
|
configure_file(
|
|
|
|
|
input: 'config.rs.in',
|
|
|
|
|
output: 'config.rs',
|
|
|
|
|
configuration: conf
|
|
|
|
|
)
|
|
|
|
|
|
2022-08-05 00:30:15 -04:00
|
|
|
build_root = meson.project_build_root()
|
|
|
|
|
source_root = meson.project_source_root()
|
|
|
|
|
|
2020-12-26 02:05:34 -08:00
|
|
|
# Copy the config.rs output to the source directory.
|
|
|
|
|
run_command(
|
|
|
|
|
'cp',
|
2022-08-05 00:30:15 -04:00
|
|
|
build_root / 'src' / 'config.rs',
|
|
|
|
|
source_root / 'src' / 'config.rs',
|
2020-12-26 02:05:34 -08:00
|
|
|
check: true
|
|
|
|
|
)
|
|
|
|
|
|
2022-08-05 00:30:15 -04:00
|
|
|
cargo_options = [ '--manifest-path', source_root / 'Cargo.toml' ]
|
|
|
|
|
cargo_options += [ '--target-dir', build_root / 'src' ]
|
2022-08-05 00:13:59 -04:00
|
|
|
|
|
|
|
|
if get_option('profile') == 'default'
|
|
|
|
|
cargo_options += [ '--release' ]
|
|
|
|
|
rust_target = 'release'
|
|
|
|
|
message('Building in release mode')
|
|
|
|
|
else
|
|
|
|
|
rust_target = 'debug'
|
|
|
|
|
message('Building in debug mode')
|
|
|
|
|
endif
|
2020-12-26 02:05:34 -08:00
|
|
|
|
2022-11-07 16:19:27 +01:00
|
|
|
cargo_env = { 'CARGO_HOME': build_root / 'cargo-home' }
|
2020-12-26 02:05:34 -08:00
|
|
|
|
2022-11-07 16:19:27 +01:00
|
|
|
cargo_build = custom_target(
|
2020-12-26 02:05:34 -08:00
|
|
|
'cargo-build',
|
|
|
|
|
build_by_default: true,
|
2022-08-05 00:13:59 -04:00
|
|
|
build_always_stale: true,
|
2022-11-07 16:19:27 +01:00
|
|
|
output: 'src',
|
2020-12-26 02:05:34 -08:00
|
|
|
console: true,
|
2022-11-07 16:19:27 +01:00
|
|
|
env: cargo_env,
|
2020-12-26 02:05:34 -08:00
|
|
|
command: [
|
2022-08-05 00:13:59 -04:00
|
|
|
cargo, 'build',
|
|
|
|
|
cargo_options,
|
2020-12-26 02:05:34 -08:00
|
|
|
]
|
|
|
|
|
)
|
2022-11-07 16:19:27 +01:00
|
|
|
|
|
|
|
|
copy_binary = custom_target(
|
|
|
|
|
'cp-binary',
|
|
|
|
|
depends: cargo_build,
|
|
|
|
|
build_by_default: true,
|
|
|
|
|
build_always_stale: true,
|
|
|
|
|
install: true,
|
|
|
|
|
install_dir: get_option('bindir'),
|
|
|
|
|
output: meson.project_name(),
|
|
|
|
|
command: [
|
|
|
|
|
'cp',
|
|
|
|
|
'src' / rust_target / meson.project_name(),
|
|
|
|
|
'@OUTPUT@',
|
|
|
|
|
],
|
|
|
|
|
)
|