about summary refs log tree commit diff
path: root/clippy_dev/src/setup/toolchain.rs
diff options
context:
space:
mode:
Diffstat (limited to 'clippy_dev/src/setup/toolchain.rs')
-rw-r--r--clippy_dev/src/setup/toolchain.rs27
1 files changed, 21 insertions, 6 deletions
diff --git a/clippy_dev/src/setup/toolchain.rs b/clippy_dev/src/setup/toolchain.rs
index 8d98c6c92d9..2966629cf70 100644
--- a/clippy_dev/src/setup/toolchain.rs
+++ b/clippy_dev/src/setup/toolchain.rs
@@ -3,11 +3,14 @@ use std::env::current_dir;
 use std::ffi::OsStr;
 use std::fs;
 use std::path::{Path, PathBuf};
+use std::process::Command;
 use walkdir::WalkDir;
 
+use crate::utils::exit_if_err;
+
 use super::verify_inside_clippy_dir;
 
-pub fn create(force: bool, release: bool, name: &str) {
+pub fn create(standalone: bool, force: bool, release: bool, name: &str) {
     if !verify_inside_clippy_dir() {
         return;
     }
@@ -48,14 +51,22 @@ pub fn create(force: bool, release: bool, name: &str) {
         }
     }
 
-    symlink_bin("cargo-clippy", &dest, release);
-    symlink_bin("clippy-driver", &dest, release);
+    let status = Command::new("cargo")
+        .arg("build")
+        .args(release.then_some("--release"))
+        .status();
+    exit_if_err(status);
+
+    install_bin("cargo-clippy", &dest, standalone, release);
+    install_bin("clippy-driver", &dest, standalone, release);
 
     println!("Created toolchain {name}, use it in other projects with e.g. `cargo +{name} clippy`");
-    println!("Note: This will need to be re-run whenever the Clippy `rust-toolchain` changes");
+    if !standalone {
+        println!("Note: This will need to be re-run whenever the Clippy `rust-toolchain` changes");
+    }
 }
 
-fn symlink_bin(bin: &str, dest: &Path, release: bool) {
+fn install_bin(bin: &str, dest: &Path, standalone: bool, release: bool) {
     #[cfg(windows)]
     use std::os::windows::fs::symlink_file as symlink;
 
@@ -71,5 +82,9 @@ fn symlink_bin(bin: &str, dest: &Path, release: bool) {
     let mut dest = dest.to_path_buf();
     dest.extend(["bin", &file_name]);
 
-    symlink(src, dest).unwrap();
+    if standalone {
+        fs::copy(src, dest).unwrap();
+    } else {
+        symlink(src, dest).unwrap();
+    }
 }