Skip to content

Commit

Permalink
Remove xcrun hack
Browse files Browse the repository at this point in the history
rust-lang/rust#36156 was apparently resolved years ago, so the hack is no longer needed
  • Loading branch information
Jake-Shadle committed Feb 9, 2024
1 parent c252d79 commit a18f9cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
6 changes: 1 addition & 5 deletions update/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@
name = "update"
version = "0.1.0"
authors = ["Jake Shadle <[email protected]>"]
edition = "2018"

[[bin]]
name = "xcrun"
path = "src/main.rs"
edition = "2021"
27 changes: 1 addition & 26 deletions update/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,11 @@ use std::{fmt::Write, process::Command};
fn real_main() -> Result<(), String> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_owned());

let mut path = std::env::var("PATH").unwrap_or_else(|_| "".to_owned());

let sep = if cfg!(unix) { ':' } else { ';' };

path.push(sep);
write!(
path,
"{}",
std::env::current_exe().unwrap().parent().unwrap().display()
)
.unwrap();

// Get the rustc version
let output = Command::new(&rustc)
.env("PATH", &path)
.arg("--version")
.output()
.map_err(|e| format!("failed to run rustc --version: {}", e))?;
.map_err(|e| format!("failed to run rustc --version: {e}"))?;

if !output.status.success() {
return Err(format!("rustc --version {}", output.status));
Expand All @@ -32,7 +19,6 @@ fn real_main() -> Result<(), String> {

// Get the list of possible targets
let output = Command::new(&rustc)
.env("PATH", &path)
.args(&["--print", "target-list"])
.output()
.map_err(|e| format!("failed to run rustc --print target-list: {}", e))?;
Expand Down Expand Up @@ -449,17 +435,6 @@ fn write_group_str<'a, T: 'a + GroupElement>(
}

fn main() {
// Workaround for https://github.com/rust-lang/rust/issues/36156
// the ios targets attempt to find an SDK path, and then just hide
// the target altogether if it doesn't exist, but we don't care about
// that, we just want to get the metadata for the target, so we
// cheat and create a script that just echos our current path that
// is enough to satisfy rustc so that it spits out the info we want
if std::env::args().find(|a| a == "--show-sdk-path").is_some() {
println!("{}", std::env::current_dir().unwrap().display());
return;
}

if let Err(ref e) = real_main() {
eprintln!("error: {}", e);
std::process::exit(1);
Expand Down

0 comments on commit a18f9cf

Please sign in to comment.