about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoshua Nelson <jnelson@cloudflare.com>2022-09-14 18:09:33 -0500
committerJoshua Nelson <jnelson@cloudflare.com>2022-09-14 18:27:04 -0500
commitb31628ddacda76253b707e230293f13d95b88369 (patch)
treeb5c1690f0a6011db483289f09d562846d8eece00
parent55c040e52964e4ad81b4b2af3c91068a80b92f11 (diff)
downloadrust-b31628ddacda76253b707e230293f13d95b88369.tar.gz
rust-b31628ddacda76253b707e230293f13d95b88369.zip
Don't hardcode the path to `bootstrap_out`
The `rust-dev` dist component puts binaries in `bootstrap/bin`, but we expected them to be in
`bootstrap/debug` to match cargo's behavior.  Rather than making the dist component inconsistent
with other components, make bootstrap slightly smarter and allow using any path as long as all the
binaries are in the same directory.

As a bonus, this greatly simplifies the logic, and makes it possible for the shell scripts to start
avoiding python.

Co-authored-by: Joshua Nelson <github@jyn.dev>
-rw-r--r--src/bootstrap/lib.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index cc0cf12bd18..2f2b3aed98e 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -456,19 +456,15 @@ impl Build {
             .expect("failed to read src/version");
         let version = version.trim();
 
-        let bootstrap_out = if std::env::var("BOOTSTRAP_PYTHON").is_ok() {
-            out.join("bootstrap").join("debug")
-        } else {
-            let workspace_target_dir = std::env::var("CARGO_TARGET_DIR")
-                .map(PathBuf::from)
-                .unwrap_or_else(|_| src.join("target"));
-            let bootstrap_out = workspace_target_dir.join("debug");
-            if !bootstrap_out.join("rustc").exists() && !cfg!(test) {
-                // this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented
-                panic!("run `cargo build --bins` before `cargo run`")
-            }
-            bootstrap_out
-        };
+        let bootstrap_out = std::env::current_exe()
+            .expect("could not determine path to running process")
+            .parent()
+            .unwrap()
+            .to_path_buf();
+        if !bootstrap_out.join("rustc").exists() && !cfg!(test) {
+            // this restriction can be lifted whenever https://github.com/rust-lang/rfcs/pull/3028 is implemented
+            panic!("run `cargo build --bins` before `cargo run`")
+        }
 
         let mut build = Build {
             initial_rustc: config.initial_rustc.clone(),