Use rustc --print sysroot, bump to v66
This commit is contained in:
parent
da122a394b
commit
03a309d182
2 changed files with 10 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "clippy"
|
name = "clippy"
|
||||||
version = "0.0.65"
|
version = "0.0.66"
|
||||||
authors = [
|
authors = [
|
||||||
"Manish Goregaokar <manishsmail@gmail.com>",
|
"Manish Goregaokar <manishsmail@gmail.com>",
|
||||||
"Andre Bogus <bogusandre@gmail.com>",
|
"Andre Bogus <bogusandre@gmail.com>",
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -17,6 +17,7 @@ use rustc::session::{config, Session};
|
||||||
use rustc::session::config::{Input, ErrorOutputType};
|
use rustc::session::config::{Input, ErrorOutputType};
|
||||||
use syntax::diagnostics;
|
use syntax::diagnostics;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
struct ClippyCompilerCalls(RustcDefaultCalls);
|
struct ClippyCompilerCalls(RustcDefaultCalls);
|
||||||
|
|
||||||
|
@ -109,9 +110,14 @@ pub fn main() {
|
||||||
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
|
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
|
||||||
let sys_root = match (home, toolchain) {
|
let sys_root = match (home, toolchain) {
|
||||||
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
|
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
|
||||||
_ => option_env!("SYSROOT")
|
_ => option_env!("SYSROOT").map(|s| s.to_owned())
|
||||||
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust")
|
.or(Command::new("rustc").arg("--print")
|
||||||
.to_owned(),
|
.arg("sysroot")
|
||||||
|
.output().ok()
|
||||||
|
.and_then(|out| String::from_utf8(out.stdout).ok())
|
||||||
|
.map(|s| s.trim().to_owned())
|
||||||
|
)
|
||||||
|
.expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
|
if let Some("clippy") = std::env::args().nth(1).as_ref().map(AsRef::as_ref) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue