Skip to content

Commit

Permalink
Teach cargo about cfg(rust_analyzer)
Browse files Browse the repository at this point in the history
  • Loading branch information
lnicola committed Jan 4, 2024
1 parent a2aab00 commit 007c176
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions 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)");
}
2 changes: 2 additions & 0 deletions crates/proc-macro-srv/build.rs
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion crates/proc-macro-srv/proc-macro-test/build.rs
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions 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)");
}

0 comments on commit 007c176

Please sign in to comment.