Skip to content

Commit

Permalink
fix(cargo): Take advantge of CARGO_BIN_EXE
Browse files Browse the repository at this point in the history
This was added to cargo in 1.43 and should make our binary lookup more
reliable.  1.43 should be pretty wide spread but if someone hasn't
upgraded, then we'll still fall back to the old logic.

Fixes #101
  • Loading branch information
Ed Page committed May 13, 2021
1 parent 2f67bd1 commit 674ae49
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,8 @@ pub fn cargo_bin<S: AsRef<str>>(name: S) -> path::PathBuf {
}

fn cargo_bin_str(name: &str) -> path::PathBuf {
target_dir().join(format!("{}{}", name, env::consts::EXE_SUFFIX))
let env_var = format!("CARGO_BIN_EXE_{}", name);
std::env::var_os(&env_var)
.map(|p| p.into())
.unwrap_or_else(|| target_dir().join(format!("{}{}", name, env::consts::EXE_SUFFIX)))
}

0 comments on commit 674ae49

Please sign in to comment.