mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Move proc-macro-srv RUSTC_VERSION fetching from include to env var
This commit is contained in:
parent
21a3d01875
commit
23b043a622
2 changed files with 3 additions and 16 deletions
|
@ -4,24 +4,12 @@
|
||||||
use std::{env, fs::File, io::Write, path::PathBuf, process::Command};
|
use std::{env, fs::File, io::Write, path::PathBuf, process::Command};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rustc-check-cfg=cfg(rust_analyzer)");
|
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();
|
|
||||||
|
|
||||||
let rustc = env::var("RUSTC").expect("proc-macro-srv's build script expects RUSTC to be set");
|
let rustc = env::var("RUSTC").expect("proc-macro-srv's build script expects RUSTC to be set");
|
||||||
let output = Command::new(rustc).arg("--version").output().expect("rustc --version must run");
|
let output = Command::new(rustc).arg("--version").output().expect("rustc --version must run");
|
||||||
let version_string = std::str::from_utf8(&output.stdout[..])
|
let version_string = std::str::from_utf8(&output.stdout[..])
|
||||||
.expect("rustc --version output must be UTF-8")
|
.expect("rustc --version output must be UTF-8")
|
||||||
.trim();
|
.trim();
|
||||||
|
println!("cargo::rustc-env=RUSTC_VERSION={}", version_string);
|
||||||
write!(
|
|
||||||
f,
|
|
||||||
"
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub(crate) const RUSTC_VERSION_STRING: &str = {version_string:?};
|
|
||||||
"
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,7 @@ use span::Span;
|
||||||
|
|
||||||
use crate::server::TokenStream;
|
use crate::server::TokenStream;
|
||||||
|
|
||||||
// see `build.rs`
|
pub const RUSTC_VERSION_STRING: &str = env!("RUSTC_VERSION");
|
||||||
include!(concat!(env!("OUT_DIR"), "/rustc_version.rs"));
|
|
||||||
|
|
||||||
trait ProcMacroSrvSpan: Copy {
|
trait ProcMacroSrvSpan: Copy {
|
||||||
type Server: proc_macro::bridge::server::Server<TokenStream = TokenStream<Self>>;
|
type Server: proc_macro::bridge::server::Server<TokenStream = TokenStream<Self>>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue