@@ -77,14 +77,18 @@ pub fn source_path() -> PathBuf {
77
77
}
78
78
79
79
/// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
80
+ #[ cfg( target_family = "windows" ) ]
80
81
pub fn create_symlink < P : AsRef < Path > , Q : AsRef < Path > > ( original : P , link : Q ) {
81
- if is_windows ( ) {
82
- use std:: os:: windows:: fs;
83
- fs:: symlink_file ( original, link) . unwrap ( ) ;
84
- } else {
85
- use std:: os:: unix:: fs;
86
- fs:: symlink ( original, link) . unwrap ( ) ;
87
- }
82
+ use std:: os:: windows:: fs;
83
+ fs:: symlink_file ( original, link) . unwrap ( ) ;
84
+ }
85
+
86
+ /// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
87
+ #[ cfg( target_family = "unix" ) ]
88
+ pub fn create_symlink < P : AsRef < Path > , Q : AsRef < Path > > ( original : P , link : Q ) {
89
+ use std:: os:: unix:: fs;
90
+ fs:: symlink ( original, link)
91
+ . expect ( & format ! ( "failed to create symlink {} for {}" , link, original) ) ;
88
92
}
89
93
90
94
/// Construct the static library name based on the platform.
@@ -107,12 +111,7 @@ pub fn static_lib_name(name: &str) -> String {
107
111
// endif
108
112
// ```
109
113
assert ! ( !name. contains( char :: is_whitespace) , "static library name cannot contain whitespace" ) ;
110
-
111
- if is_msvc ( ) {
112
- format ! ( "{name}.lib" )
113
- } else {
114
- format ! ( "lib{name}.a" )
115
- }
114
+ if is_msvc ( ) { format ! ( "{name}.lib" ) } else { format ! ( "lib{name}.a" ) }
116
115
}
117
116
118
117
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
@@ -155,11 +154,7 @@ pub fn rust_lib(name: &str) -> PathBuf {
155
154
156
155
/// Construct the binary name based on platform.
157
156
pub fn bin_name ( name : & str ) -> String {
158
- if is_windows ( ) {
159
- format ! ( "{name}.exe" )
160
- } else {
161
- name. to_string ( )
162
- }
157
+ if is_windows ( ) { format ! ( "{name}.exe" ) } else { name. to_string ( ) }
163
158
}
164
159
165
160
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
0 commit comments