about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-02-13 10:11:45 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-05-22 17:17:05 +0000
commita2f720d9fe12a0981a14fd16f84cb8b23c284432 (patch)
tree72bf520fddbf2d7a78cf204bab284008afe5e60a /scripts
parent22befab611db45f5448d09db63e67fb72bd9af0c (diff)
downloadrust-a2f720d9fe12a0981a14fd16f84cb8b23c284432.tar.gz
rust-a2f720d9fe12a0981a14fd16f84cb8b23c284432.zip
Allow building and testing without rustup
This can be done by installing the nightly specified in
rust-toolchain.toml and then pointing the CARGO, RUSTC and RUSTDOC env
vars to the right executables.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cargo-clif.rs13
-rw-r--r--scripts/rustc-clif.rs13
-rw-r--r--scripts/rustdoc-clif.rs13
3 files changed, 27 insertions, 12 deletions
diff --git a/scripts/cargo-clif.rs b/scripts/cargo-clif.rs
index e2db7d03a9d..0d5d9f7db01 100644
--- a/scripts/cargo-clif.rs
+++ b/scripts/cargo-clif.rs
@@ -28,8 +28,13 @@ fn main() {
     env::set_var("RUSTFLAGS", env::var("RUSTFLAGS").unwrap_or(String::new()) + &rustflags);
     env::set_var("RUSTDOCFLAGS", env::var("RUSTDOCFLAGS").unwrap_or(String::new()) + &rustflags);
 
-    // Ensure that the right toolchain is used
-    env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
+    let cargo = if let Some(cargo) = option_env!("CARGO") {
+        cargo
+    } else {
+        // Ensure that the right toolchain is used
+        env::set_var("RUSTUP_TOOLCHAIN", option_env!("TOOLCHAIN_NAME").expect("TOOLCHAIN_NAME"));
+        "cargo"
+    };
 
     let args: Vec<_> = match env::args().nth(1).as_deref() {
         Some("jit") => {
@@ -64,10 +69,10 @@ fn main() {
     };
 
     #[cfg(unix)]
-    panic!("Failed to spawn cargo: {}", Command::new("cargo").args(args).exec());
+    panic!("Failed to spawn cargo: {}", Command::new(cargo).args(args).exec());
 
     #[cfg(not(unix))]
     std::process::exit(
-        Command::new("cargo").args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),
+        Command::new(cargo).args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),
     );
 }
diff --git a/scripts/rustc-clif.rs b/scripts/rustc-clif.rs
index 7ef3488672d..df94b80b34f 100644
--- a/scripts/rustc-clif.rs
+++ b/scripts/rustc-clif.rs
@@ -30,14 +30,19 @@ fn main() {
     }
     args.extend(passed_args);
 
-    // Ensure that the right toolchain is used
-    env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
+    let rustc = if let Some(rustc) = option_env!("RUSTC") {
+        rustc
+    } else {
+        // Ensure that the right toolchain is used
+        env::set_var("RUSTUP_TOOLCHAIN", option_env!("TOOLCHAIN_NAME").expect("TOOLCHAIN_NAME"));
+        "rustc"
+    };
 
     #[cfg(unix)]
-    panic!("Failed to spawn rustc: {}", Command::new("rustc").args(args).exec());
+    panic!("Failed to spawn rustc: {}", Command::new(rustc).args(args).exec());
 
     #[cfg(not(unix))]
     std::process::exit(
-        Command::new("rustc").args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),
+        Command::new(rustc).args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),
     );
 }
diff --git a/scripts/rustdoc-clif.rs b/scripts/rustdoc-clif.rs
index 72024e0d494..36a00dc676e 100644
--- a/scripts/rustdoc-clif.rs
+++ b/scripts/rustdoc-clif.rs
@@ -30,14 +30,19 @@ fn main() {
     }
     args.extend(passed_args);
 
-    // Ensure that the right toolchain is used
-    env::set_var("RUSTUP_TOOLCHAIN", env!("TOOLCHAIN_NAME"));
+    let rustdoc = if let Some(rustdoc) = option_env!("RUSTDOC") {
+        rustdoc
+    } else {
+        // Ensure that the right toolchain is used
+        env::set_var("RUSTUP_TOOLCHAIN", option_env!("TOOLCHAIN_NAME").expect("TOOLCHAIN_NAME"));
+        "rustdoc"
+    };
 
     #[cfg(unix)]
-    panic!("Failed to spawn rustdoc: {}", Command::new("rustdoc").args(args).exec());
+    panic!("Failed to spawn rustdoc: {}", Command::new(rustdoc).args(args).exec());
 
     #[cfg(not(unix))]
     std::process::exit(
-        Command::new("rustdoc").args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),
+        Command::new(rustdoc).args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),
     );
 }