From 3a2ae6410dcca044f8e866c040c0f35592eba538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Thu, 4 Jan 2024 18:10:14 +0200 Subject: [PATCH] Teach cargo about cfg(rust_analyzer) --- crates/proc-macro-srv-cli/build.rs | 5 +++++ crates/proc-macro-srv/build.rs | 2 ++ crates/proc-macro-srv/proc-macro-test/build.rs | 2 +- crates/proc-macro-srv/proc-macro-test/imp/build.rs | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 crates/proc-macro-srv-cli/build.rs create mode 100644 crates/proc-macro-srv/proc-macro-test/imp/build.rs diff --git a/crates/proc-macro-srv-cli/build.rs b/crates/proc-macro-srv-cli/build.rs new file mode 100644 index 0000000000..07f914fece --- /dev/null +++ b/crates/proc-macro-srv-cli/build.rs @@ -0,0 +1,5 @@ +//! This teaches cargo about our cfg(rust_analyzer) + +fn main() { + println!("cargo:rustc-check-cfg=cfg(rust_analyzer)"); +} diff --git a/crates/proc-macro-srv/build.rs b/crates/proc-macro-srv/build.rs index a8c732f315..874d1c6cd3 100644 --- a/crates/proc-macro-srv/build.rs +++ b/crates/proc-macro-srv/build.rs @@ -4,6 +4,8 @@ use std::{env, fs::File, io::Write, path::PathBuf, process::Command}; fn main() { + println!("cargo:rustc-check-cfg=cfg(rust_analyzer)"); + let mut path = PathBuf::from(env::var_os("OUT_DIR").unwrap()); path.push("rustc_version.rs"); let mut f = File::create(&path).unwrap(); diff --git a/crates/proc-macro-srv/proc-macro-test/build.rs b/crates/proc-macro-srv/proc-macro-test/build.rs index 7299147686..17c2595e8a 100644 --- a/crates/proc-macro-srv/proc-macro-test/build.rs +++ b/crates/proc-macro-srv/proc-macro-test/build.rs @@ -40,7 +40,7 @@ fn main() { println!("Creating {}", src_dir.display()); std::fs::create_dir_all(src_dir).unwrap(); - for item_els in [&["Cargo.toml"][..], &["src", "lib.rs"]] { + for item_els in [&["Cargo.toml"][..], &["build.rs"][..], &["src", "lib.rs"]] { let mut src = imp_dir.clone(); let mut dst = staging_dir.clone(); for el in item_els { diff --git a/crates/proc-macro-srv/proc-macro-test/imp/build.rs b/crates/proc-macro-srv/proc-macro-test/imp/build.rs new file mode 100644 index 0000000000..07f914fece --- /dev/null +++ b/crates/proc-macro-srv/proc-macro-test/imp/build.rs @@ -0,0 +1,5 @@ +//! This teaches cargo about our cfg(rust_analyzer) + +fn main() { + println!("cargo:rustc-check-cfg=cfg(rust_analyzer)"); +}