Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #16257 - lnicola:rustc-check-cfg, r=Veykril
internal: Teach cargo about `cfg(rust_analyzer)` r? `@Urgau` is this a good idea?, CC `@Veykril`
bors 2024-04-18
parent 08c706f · parent 3a2ae64 · commit af1fd88
-rw-r--r--crates/proc-macro-srv-cli/build.rs5
-rw-r--r--crates/proc-macro-srv/build.rs2
-rw-r--r--crates/proc-macro-srv/proc-macro-test/build.rs2
-rw-r--r--crates/proc-macro-srv/proc-macro-test/imp/build.rs5
4 files changed, 13 insertions, 1 deletions
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 c76c201d69..6a0ae362d8 100644
--- a/crates/proc-macro-srv/proc-macro-test/build.rs
+++ b/crates/proc-macro-srv/proc-macro-test/build.rs
@@ -53,7 +53,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)");
+}