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