mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
meson: add optional Rust bindings build
This commit is contained in:
1 parent
758f280651
commit
487bc2fce2
2 files changed
+43
No files matched your search
+42
@@ -208,6 +208,48 @@ if get_option('c').enabled()
|
||||
endif
|
||||
endif
|
||||
|
||||
rust_option = get_option('rust').require(
|
||||
get_option('c').enabled(),
|
||||
error_message: 'rust requires c',
|
||||
).require(
|
||||
get_option('default_library') != 'static',
|
||||
error_message: 'rust requires shared libraries',
|
||||
)
|
||||
if rust_option.allowed()
|
||||
cargo = find_program('cargo', required: rust_option)
|
||||
if cargo.found()
|
||||
rust_env = environment()
|
||||
rust_env.prepend('LIBRARY_PATH', meson.current_build_dir())
|
||||
rust_env.prepend('LD_LIBRARY_PATH', meson.current_build_dir())
|
||||
rust_env.prepend('DYLD_LIBRARY_PATH', meson.current_build_dir())
|
||||
rust_env.prepend('PATH', meson.current_build_dir())
|
||||
cargo_args = [
|
||||
'--manifest-path', meson.current_source_dir() / 'rust/Cargo.toml',
|
||||
'--target-dir', meson.current_build_dir() / 'rust',
|
||||
]
|
||||
rust_build = custom_target(
|
||||
'rust-bindings',
|
||||
output: 'rust-build.json',
|
||||
command: [cargo, 'build', '--lib', '--examples', '--message-format=json-render-diagnostics'] + cargo_args,
|
||||
env: rust_env,
|
||||
depends: opendht_c,
|
||||
capture: true,
|
||||
build_by_default: true,
|
||||
build_always_stale: true,
|
||||
)
|
||||
if get_option('tests').enabled()
|
||||
test(
|
||||
'Rust',
|
||||
cargo,
|
||||
args: ['test'] + cargo_args,
|
||||
env: rust_env,
|
||||
depends: rust_build,
|
||||
timeout: 120,
|
||||
)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if get_option('python').require(
|
||||
get_option('indexation').enabled(),
|
||||
error_message: 'python requires indexation',
|
||||
|
||||
@@ -4,6 +4,7 @@ option('push_notifications', type : 'feature', value : 'disabled')
|
||||
option('peer_discovery', type : 'feature', value : 'enabled')
|
||||
option('tools', type : 'feature', value : 'enabled')
|
||||
option('c', type : 'feature', value : 'enabled')
|
||||
option('rust', type : 'feature', value : 'disabled')
|
||||
option('indexation', type : 'feature', value : 'enabled')
|
||||
option('python', type : 'feature', value : 'enabled')
|
||||
option('tests', type : 'feature', value : 'enabled')
|
||||
|
||||
Reference in new issue
Block a user