Skip to content

Commit 908f2d1

Browse files
eternalNighteli-schwartz
authored andcommitted
backend/ninja: Generate sysroot in rust-project.json
Rust-analyzer relies on sysroot to discover its proc-macro server [1] which is typically installed at <sysroot>/libexec/rust-analyzer-proc-macro-srv. When used with rust-project.json, rust-analyzer expects the json file to specify sysroot and fails to launch the proc-macro server otherwise. So add sysroot to the meson-generated rust-project.json and point it to the sysroot of the detected rustc compiler. [1] https://github.com/rust-lang/rust-analyzer/blob/2024-09-16/crates/project-model/src/sysroot.rs#L175 Signed-off-by: Junjie Mao <[email protected]> (cherry picked from commit e5d03f5)
1 parent 72af62b commit 908f2d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mesonbuild/backend/ninjabackend.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,11 @@ def generate_rust_project_json(self) -> None:
700700
return
701701
with open(os.path.join(self.environment.get_build_dir(), 'rust-project.json'),
702702
'w', encoding='utf-8') as f:
703+
sysroot = self.environment.coredata.compilers.host['rust'].get_sysroot()
703704
json.dump(
704705
{
705-
"sysroot_src": os.path.join(self.environment.coredata.compilers.host['rust'].get_sysroot(),
706-
'lib/rustlib/src/rust/library/'),
706+
"sysroot": sysroot,
707+
"sysroot_src": os.path.join(sysroot, 'lib/rustlib/src/rust/library/'),
707708
"crates": [c.to_json() for c in self.rust_crates.values()],
708709
},
709710
f, indent=4)

0 commit comments

Comments
 (0)