use env vars for cargo flags

this is more scuffed but means devenv gets a full env, so one can run all custom
stuff in the `meson devenv -C build` shell which is nicer because you can pass
flags to what you run (e.g. cargo doc --open) instead of needing fixed targets
This commit is contained in:
psykose 2024-11-04 23:18:03 +01:00
parent 0e50cf9f39
commit f15019f49d

View file

@ -52,6 +52,8 @@ endif
cargo = find_program('cargo')
cargo_env = environment()
cargo_env.set('MESON_BUILD_ROOT', meson.project_build_root())
cargo_env.set('CARGO_MANIFEST_DIR', meson.project_source_root())
cargo_env.set('CARGO_TARGET_DIR', meson.project_build_root() / 'target')
meson.add_devenv(cargo_env)
custom_target(
@ -67,13 +69,6 @@ custom_target(
cargo,
'build',
rust_args,
'--manifest-path',
meson.project_source_root() / 'Cargo.toml',
'--target-dir',
meson.project_build_root() / 'cargo-target',
],
env: cargo_env,
)
run_target('clippy', command: [cargo, 'clippy'], env: cargo_env)
run_target('cargo-doc', command: [cargo, 'doc'], env: cargo_env)