@@ -3,11 +3,14 @@ use std::env::current_dir;
33use std:: ffi:: OsStr ;
44use std:: fs;
55use std:: path:: { Path , PathBuf } ;
6+ use std:: process:: Command ;
67use walkdir:: WalkDir ;
78
9+ use crate :: utils:: exit_if_err;
10+
811use super :: verify_inside_clippy_dir;
912
10- pub fn create ( force : bool , release : bool , name : & str ) {
13+ pub fn create ( standalone : bool , force : bool , release : bool , name : & str ) {
1114 if !verify_inside_clippy_dir ( ) {
1215 return ;
1316 }
@@ -48,14 +51,22 @@ pub fn create(force: bool, release: bool, name: &str) {
4851 }
4952 }
5053
51- symlink_bin ( "cargo-clippy" , & dest, release) ;
52- symlink_bin ( "clippy-driver" , & dest, release) ;
54+ let status = Command :: new ( "cargo" )
55+ . arg ( "build" )
56+ . args ( release. then_some ( "--release" ) )
57+ . status ( ) ;
58+ exit_if_err ( status) ;
59+
60+ install_bin ( "cargo-clippy" , & dest, standalone, release) ;
61+ install_bin ( "clippy-driver" , & dest, standalone, release) ;
5362
5463 println ! ( "Created toolchain {name}, use it in other projects with e.g. `cargo +{name} clippy`" ) ;
55- println ! ( "Note: This will need to be re-run whenever the Clippy `rust-toolchain` changes" ) ;
64+ if !standalone {
65+ println ! ( "Note: This will need to be re-run whenever the Clippy `rust-toolchain` changes" ) ;
66+ }
5667}
5768
58- fn symlink_bin ( bin : & str , dest : & Path , release : bool ) {
69+ fn install_bin ( bin : & str , dest : & Path , standalone : bool , release : bool ) {
5970 #[ cfg( windows) ]
6071 use std:: os:: windows:: fs:: symlink_file as symlink;
6172
@@ -71,5 +82,9 @@ fn symlink_bin(bin: &str, dest: &Path, release: bool) {
7182 let mut dest = dest. to_path_buf ( ) ;
7283 dest. extend ( [ "bin" , & file_name] ) ;
7384
74- symlink ( src, dest) . unwrap ( ) ;
85+ if standalone {
86+ fs:: copy ( src, dest) . unwrap ( ) ;
87+ } else {
88+ symlink ( src, dest) . unwrap ( ) ;
89+ }
7590}
0 commit comments