-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkgx --ensure make, uses the system make if poss
- Loading branch information
Showing
7 changed files
with
115 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#[cfg(target_os = "macos")] | ||
use std::fs; | ||
|
||
#[cfg(target_os = "macos")] | ||
pub fn good_on_macos(cmd: &str) -> bool { | ||
//TODO there’s a lot more in there | ||
//NOTE tricky to know how to keep this updated or varied by CLT version etc. | ||
//THO probs the tools we care about don’t vary or change | ||
match cmd { | ||
"/usr/bin/cc" => has_xcode_clt(), | ||
"/usr/bin/c++" => has_xcode_clt(), | ||
"/usr/bin/make" => has_xcode_clt(), | ||
"/usr/bin/python3" => has_xcode_clt(), | ||
"/usr/bin/pip3" => has_xcode_clt(), | ||
"/usr/bin/strip" => has_xcode_clt(), | ||
"/usr/bin/git" => has_xcode_clt(), | ||
_ => true, | ||
} | ||
} | ||
|
||
#[cfg(target_os = "macos")] | ||
fn has_xcode_clt() -> bool { | ||
fs::metadata("/Library/Developer/CommandLineTools/usr/bin") | ||
.map(|m| m.is_dir()) | ||
.unwrap_or(false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
#[cfg(not(windows))] | ||
use std::os::unix::fs::PermissionsExt; | ||
use std::{error::Error, path::Path}; | ||
use std::path::Path; | ||
|
||
pub async fn find_program(arg: &str, paths: &Vec<String>) -> Result<String, Box<dyn Error>> { | ||
pub async fn find_program(arg: &str, paths: &Vec<String>) -> Option<String> { | ||
if arg.starts_with("/") { | ||
return Ok(arg.to_string()); | ||
return Some(arg.to_string()); | ||
} else if arg.contains("/") { | ||
return Ok(std::env::current_dir() | ||
.unwrap() | ||
.join(arg) | ||
.to_str() | ||
.unwrap() | ||
.to_string()); | ||
return Some( | ||
std::env::current_dir() | ||
.unwrap() | ||
.join(arg) | ||
.to_str() | ||
.unwrap() | ||
.to_string(), | ||
); | ||
} | ||
for path in paths { | ||
let full_path = Path::new(&path).join(arg); | ||
if full_path.is_file() { | ||
#[cfg(unix)] | ||
if let Ok(metadata) = full_path.metadata() { | ||
if metadata.permissions().mode() & 0o111 != 0 { | ||
return Ok(full_path.to_str().unwrap().to_string()); | ||
return Some(full_path.to_str().unwrap().to_string()); | ||
} | ||
} | ||
#[cfg(windows)] | ||
if let Some(ext) = full_path.extension() { | ||
match ext.to_str() { | ||
Some("exe") | Some("bat") | Some("cmd") => { | ||
return Ok(full_path.to_str().unwrap().to_string()) | ||
return Some(full_path.to_str().unwrap().to_string()) | ||
} | ||
_ => {} | ||
} | ||
} | ||
} | ||
} | ||
Err(format!("cmd not found: {}", arg).into()) | ||
None | ||
} |