mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-22 08:19:38 +08:00
Detect rust-analyzer
in build script to enable autocxx
completions
Currently the `autocxx` generated code does not produce any code intelligence because `rust-analyzer` can't find the generated code since it's not in the workspace. Here, we detect `rust-analyzer` by checking for a `RUSTC_WRAPPER` environment variable containing `rust-analyzer` and changing (or avoid changing) the output directory accordingly. Closes #9654.
This commit is contained in:
parent
409bf2995d
commit
06547aef54
@ -48,9 +48,16 @@ fn main() -> miette::Result<()> {
|
|||||||
// Emit autocxx junk.
|
// Emit autocxx junk.
|
||||||
// This allows "C++ to be used from Rust."
|
// This allows "C++ to be used from Rust."
|
||||||
let include_paths = [&fish_src_dir, &fish_build_dir, &cxx_include_dir];
|
let include_paths = [&fish_src_dir, &fish_build_dir, &cxx_include_dir];
|
||||||
let mut b = autocxx_build::Builder::new("src/ffi.rs", include_paths)
|
let mut builder = autocxx_build::Builder::new("src/ffi.rs", include_paths);
|
||||||
.custom_gendir(autocxx_gen_dir.into())
|
// Use autocxx's custom output directory unless we're being called by `rust-analyzer` and co.,
|
||||||
.build()?;
|
// in which case stick to the default target directory so code intelligence continues to work.
|
||||||
|
if std::env::var("RUSTC_WRAPPER").map_or(true, |wrapper| {
|
||||||
|
!(wrapper.contains("rust-analyzer") || wrapper.contains("intellij-rust-native-helper"))
|
||||||
|
}) {
|
||||||
|
// We need this reassignment because of how the builder pattern works
|
||||||
|
builder = builder.custom_gendir(autocxx_gen_dir.into());
|
||||||
|
}
|
||||||
|
let mut b = builder.build()?;
|
||||||
b.flag_if_supported("-std=c++11")
|
b.flag_if_supported("-std=c++11")
|
||||||
.flag("-Wno-comment")
|
.flag("-Wno-comment")
|
||||||
.compile("fish-rust-autocxx");
|
.compile("fish-rust-autocxx");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user