@@ -3,11 +3,14 @@ use std::env::current_dir;
3
3
use std:: ffi:: OsStr ;
4
4
use std:: fs;
5
5
use std:: path:: { Path , PathBuf } ;
6
+ use std:: process:: Command ;
6
7
use walkdir:: WalkDir ;
7
8
9
+ use crate :: utils:: exit_if_err;
10
+
8
11
use super :: verify_inside_clippy_dir;
9
12
10
- pub fn create ( force : bool , release : bool , name : & str ) {
13
+ pub fn create ( standalone : bool , force : bool , release : bool , name : & str ) {
11
14
if !verify_inside_clippy_dir ( ) {
12
15
return ;
13
16
}
@@ -48,14 +51,22 @@ pub fn create(force: bool, release: bool, name: &str) {
48
51
}
49
52
}
50
53
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) ;
53
62
54
63
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
+ }
56
67
}
57
68
58
- fn symlink_bin ( bin : & str , dest : & Path , release : bool ) {
69
+ fn install_bin ( bin : & str , dest : & Path , standalone : bool , release : bool ) {
59
70
#[ cfg( windows) ]
60
71
use std:: os:: windows:: fs:: symlink_file as symlink;
61
72
@@ -71,5 +82,9 @@ fn symlink_bin(bin: &str, dest: &Path, release: bool) {
71
82
let mut dest = dest. to_path_buf ( ) ;
72
83
dest. extend ( [ "bin" , & file_name] ) ;
73
84
74
- symlink ( src, dest) . unwrap ( ) ;
85
+ if standalone {
86
+ fs:: copy ( src, dest) . unwrap ( ) ;
87
+ } else {
88
+ symlink ( src, dest) . unwrap ( ) ;
89
+ }
75
90
}
0 commit comments