From 0403fe4cde1c0448c02f965e534018e500d356cc Mon Sep 17 00:00:00 2001 From: MoonlightWave-12 <135532-MoonlightWave-12@users.noreply.gitlab.gnome.org> Date: Sat, 3 Aug 2024 10:34:34 +0200 Subject: [PATCH 1/2] 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: --- Cargo.toml | 8 ++++---- meson.build | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 344d3c4c..cf94f4f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,21 +5,21 @@ edition = "2021" [lib] name = "rs" -path = "@path@/src/lib.rs" +path = "src/lib.rs" crate-type = ["staticlib", "rlib"] # Cargo can't do autodiscovery if Cargo.toml is not in the root. [[bin]] name = "test_layout" -path = "@path@/src/bin/test_layout.rs" +path = "src/bin/test_layout.rs" [[example]] name = "test_layout" -path = "@path@/examples/test_layout.rs" +path = "examples/test_layout.rs" [[example]] name = "find_orphan_layouts" -path = "@path@/examples/find_orphan_layouts.rs" +path = "examples/find_orphan_layouts.rs" [features] zbus_v1_5 = [] diff --git a/meson.build b/meson.build index bb7d8b37..89ded202 100644 --- a/meson.build +++ b/meson.build @@ -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, ) From 271184b9d12041dab300ba1504b5cf1ad56c3467 Mon Sep 17 00:00:00 2001 From: MoonlightWave-12 <135532-MoonlightWave-12@users.noreply.gitlab.gnome.org> Date: Tue, 6 Aug 2024 14:41:19 +0200 Subject: [PATCH 2/2] .gitignore: Ignore more files Part-of: --- .gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 8d4c9330..a135d60d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,20 @@ _build/ +debian/.debhelper/ +debian/cargo/registry/ +debian/cargo/.*cache* +debian/debhelper-build-stamp +debian/files +debian/*.substvars +debian/squeekboard/ +debian/squeekboard-devel/ +debian/tmp/ +meson_Cargo.toml.in po/squeekboard.pot po/*.mo TAGS tags target/ +vendor/ vgdump *.swp *~