Get the path to cargo from rustbuild
This commit is contained in:
parent
6e016c587f
commit
b9b1c378c5
3 changed files with 10 additions and 7 deletions
|
@ -528,6 +528,7 @@ impl Step for Tidy {
|
|||
println!("tidy check ({})", host);
|
||||
let mut cmd = builder.tool_cmd(Tool::Tidy);
|
||||
cmd.arg(build.src.join("src"));
|
||||
cmd.arg(&build.initial_cargo);
|
||||
if !build.config.vendor {
|
||||
cmd.arg("--no-vendor");
|
||||
}
|
||||
|
|
|
@ -426,9 +426,9 @@ pub fn check(path: &Path, bad: &mut bool) {
|
|||
/// Checks the dependency at the given path. Changes `bad` to `true` if a check failed.
|
||||
///
|
||||
/// Specifically, this checks that the dependencies are on the whitelist.
|
||||
pub fn check_whitelist(path: &Path, bad: &mut bool) {
|
||||
pub fn check_whitelist(path: &Path, cargo: &Path, bad: &mut bool) {
|
||||
// Check dependencies
|
||||
let deps: HashSet<_> = get_deps(&path)
|
||||
let deps: HashSet<_> = get_deps(&path, &cargo)
|
||||
.into_iter()
|
||||
.map(|Package { name, version, .. }| (name, version))
|
||||
.collect();
|
||||
|
@ -492,10 +492,9 @@ fn extract_license(line: &str) -> String {
|
|||
}
|
||||
|
||||
/// Get the dependencies of the crate at the given path using `cargo metadata`.
|
||||
fn get_deps(path: &Path) -> Vec<Package> {
|
||||
fn get_deps(path: &Path, cargo: &Path) -> Vec<Package> {
|
||||
// Run `cargo metadata` to get the set of dependencies
|
||||
println!("Getting metadata from {:?}", path.join("Cargo.toml"));
|
||||
let output = Command::new("cargo")
|
||||
let output = Command::new(cargo)
|
||||
.arg("metadata")
|
||||
.arg("--format-version")
|
||||
.arg("1")
|
||||
|
|
|
@ -24,9 +24,12 @@ use std::path::PathBuf;
|
|||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let path = env::args_os().skip(1).next().expect("need an argument");
|
||||
let path = env::args_os().skip(1).next().expect("need path to src");
|
||||
let path = PathBuf::from(path);
|
||||
|
||||
let cargo = env::args_os().skip(2).next().expect("need path to cargo");
|
||||
let cargo = PathBuf::from(cargo);
|
||||
|
||||
let args: Vec<String> = env::args().skip(1).collect();
|
||||
|
||||
let mut bad = false;
|
||||
|
@ -41,7 +44,7 @@ fn main() {
|
|||
if !args.iter().any(|s| *s == "--no-vendor") {
|
||||
deps::check(&path, &mut bad);
|
||||
}
|
||||
deps::check_whitelist(&path, &mut bad);
|
||||
deps::check_whitelist(&path, &cargo, &mut bad);
|
||||
|
||||
if bad {
|
||||
eprintln!("some tidy checks failed");
|
||||
|
|
Loading…
Reference in a new issue