|
| 1 | +// git clone https://github.com/rust-lang/rust/blob/0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95/src/tools/x/src/main.rs |
| 2 | +// patched to stop doing python probing, stop the probe, please dont, i have a python |
| 3 | +//! Run bootstrap from any subdirectory of a rust compiler checkout. |
| 4 | +//! |
| 5 | +//! We prefer `exec`, to avoid adding an extra process in the process tree. |
| 6 | +//! However, since `exec` isn't available on Windows, we indirect through |
| 7 | +//! `exec_or_status`, which will call `exec` on unix and `status` on Windows. |
| 8 | +//! |
| 9 | +//! We use `powershell.exe x.ps1` on Windows, and `sh -c x` on Unix, those are |
| 10 | +//! the ones that call `x.py`. We use `sh -c` on Unix, because it is a standard. |
| 11 | +//! We also don't use `pwsh` on Windows, because it is not installed by default; |
| 12 | +
|
| 13 | +use std::env; |
| 14 | +use std::os::unix::process::CommandExt; |
| 15 | +use std::process::{self, Command}; |
| 16 | + |
| 17 | +fn main() { |
| 18 | + match env::args().skip(1).next().as_deref() { |
| 19 | + Some("--wrapper-version") => { |
| 20 | + println!("0.1.0"); |
| 21 | + return; |
| 22 | + } |
| 23 | + _ => {} |
| 24 | + } |
| 25 | + let current = match env::current_dir() { |
| 26 | + Ok(dir) => dir, |
| 27 | + Err(err) => { |
| 28 | + eprintln!("Failed to get current directory: {err}"); |
| 29 | + process::exit(1); |
| 30 | + } |
| 31 | + }; |
| 32 | + |
| 33 | + for dir in current.ancestors() { |
| 34 | + let candidate = dir.join("x.py"); |
| 35 | + if candidate.exists() { |
| 36 | + let mut cmd = Command::new(env!("PYTHON")); |
| 37 | + cmd.arg(dir.join("x.py")); |
| 38 | + cmd.args(env::args().skip(1)).current_dir(dir); |
| 39 | + |
| 40 | + let error = cmd.exec(); |
| 41 | + eprintln!("Failed to invoke `{:?}`: {}", cmd, error); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + eprintln!( |
| 46 | + "x.py not found. Please run inside of a checkout of `https://github.com/rust-lang/rust`." |
| 47 | + ); |
| 48 | + |
| 49 | + process::exit(1); |
| 50 | +} |
0 commit comments