Build: Use meson_Cargo.toml.in for setting up the build

to make rust-analyzer work correctly.

When the paths in Cargo.toml have '@path@' in them,
rust-analyzer cannot find the correct paths.

Before this change, rust-analyzer was unable to offer information
about code (in files other than main.rs), and instead
showed an error-message:
"1:1 unused: This file is not included anywhere in the module tree,
so rust-analyzer can't offer IDE services.".

Part-of: <https://gitlab.gnome.org/World/Phosh/squeekboard/-/merge_requests/657>
This commit is contained in:
MoonlightWave-12
2024-08-03 10:34:34 +02:00
committed by Marge Bot
parent 0b83eb7d9f
commit 0403fe4cde
2 changed files with 11 additions and 5 deletions

View File

@ -85,10 +85,16 @@ summary = [
]
message('\n'.join(summary))
# 'rust-analyzer' does not work correctly, when the paths in 'Cargo.toml' have '@path@' in them.
cp = find_program('cp')
sed = find_program('sed')
copy_cargo_toml = run_command('cp', 'Cargo.toml', 'meson_Cargo.toml.in')
prepare_cargo_toml = run_command('sed', '-i', 's/path = "/path = "@path@\//', 'meson_Cargo.toml.in')
path_data = configuration_data()
path_data.set('path', meson.source_root())
cargo_toml = configure_file(
input: 'Cargo.toml',
input: 'meson_Cargo.toml.in',
output: 'Cargo.toml',
configuration: path_data,
)