Skip to content

Commit b9b1c37

Browse files
committed
Get the path to cargo from rustbuild
1 parent 6e016c5 commit b9b1c37

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/bootstrap/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ impl Step for Tidy {
528528
println!("tidy check ({})", host);
529529
let mut cmd = builder.tool_cmd(Tool::Tidy);
530530
cmd.arg(build.src.join("src"));
531+
cmd.arg(&build.initial_cargo);
531532
if !build.config.vendor {
532533
cmd.arg("--no-vendor");
533534
}

src/tools/tidy/src/deps.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ pub fn check(path: &Path, bad: &mut bool) {
426426
/// Checks the dependency at the given path. Changes `bad` to `true` if a check failed.
427427
///
428428
/// Specifically, this checks that the dependencies are on the whitelist.
429-
pub fn check_whitelist(path: &Path, bad: &mut bool) {
429+
pub fn check_whitelist(path: &Path, cargo: &Path, bad: &mut bool) {
430430
// Check dependencies
431-
let deps: HashSet<_> = get_deps(&path)
431+
let deps: HashSet<_> = get_deps(&path, &cargo)
432432
.into_iter()
433433
.map(|Package { name, version, .. }| (name, version))
434434
.collect();
@@ -492,10 +492,9 @@ fn extract_license(line: &str) -> String {
492492
}
493493

494494
/// Get the dependencies of the crate at the given path using `cargo metadata`.
495-
fn get_deps(path: &Path) -> Vec<Package> {
495+
fn get_deps(path: &Path, cargo: &Path) -> Vec<Package> {
496496
// Run `cargo metadata` to get the set of dependencies
497-
println!("Getting metadata from {:?}", path.join("Cargo.toml"));
498-
let output = Command::new("cargo")
497+
let output = Command::new(cargo)
499498
.arg("metadata")
500499
.arg("--format-version")
501500
.arg("1")

src/tools/tidy/src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ use std::path::PathBuf;
2424
use std::env;
2525

2626
fn main() {
27-
let path = env::args_os().skip(1).next().expect("need an argument");
27+
let path = env::args_os().skip(1).next().expect("need path to src");
2828
let path = PathBuf::from(path);
2929

30+
let cargo = env::args_os().skip(2).next().expect("need path to cargo");
31+
let cargo = PathBuf::from(cargo);
32+
3033
let args: Vec<String> = env::args().skip(1).collect();
3134

3235
let mut bad = false;
@@ -41,7 +44,7 @@ fn main() {
4144
if !args.iter().any(|s| *s == "--no-vendor") {
4245
deps::check(&path, &mut bad);
4346
}
44-
deps::check_whitelist(&path, &mut bad);
47+
deps::check_whitelist(&path, &cargo, &mut bad);
4548

4649
if bad {
4750
eprintln!("some tidy checks failed");

0 commit comments

Comments
 (0)