musicus/src/meson.build

57 lines
1.4 KiB
Meson
Raw Normal View History

# Configuration file
2023-06-18 14:02:21 +02:00
conf = configuration_data()
conf.set_quoted('NAME', name)
conf.set_quoted('PKGNAME', meson.project_name())
conf.set_quoted('APP_ID', app_id)
conf.set_quoted('PATH_ID', path_id)
2023-06-18 14:02:21 +02:00
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('PROFILE', profile)
conf.set_quoted('LOCALEDIR', localedir)
conf.set_quoted('DATADIR', datadir)
2023-06-18 14:02:21 +02:00
configure_file(
input: 'config.rs.in',
output: 'config.rs',
configuration: conf,
2023-06-18 14:02:21 +02:00
)
# Copy the config.rs output to the source directory.
run_command(
'cp',
meson.project_build_root() / 'src' / 'config.rs',
meson.project_source_root() / 'src' / 'config.rs',
2023-06-18 14:02:21 +02:00
check: true
)
# Cargo
2023-06-18 14:02:21 +02:00
cargo_bin = find_program('cargo')
cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ]
cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ]
cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ]
if get_option('profile') == 'release'
2023-06-18 14:02:21 +02:00
cargo_options += [ '--release' ]
rust_target = 'release'
message('Building in release mode')
2023-06-18 14:02:21 +02:00
else
rust_target = 'debug'
message('Building in debug mode')
2023-06-18 14:02:21 +02:00
endif
cargo_build = custom_target(
'cargo-build',
build_by_default: true,
build_always_stale: true,
output: meson.project_name(),
console: true,
install: true,
install_dir: bindir,
2023-06-18 14:02:21 +02:00
command: [
'env', cargo_env,
cargo_bin, 'build',
cargo_opt, '&&', 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@',
],
2023-06-18 14:02:21 +02:00
)