@@ -40,12 +40,17 @@ pub fn target() -> String {
40
40
41
41
/// Check if target is windows-like.
42
42
pub fn is_windows ( ) -> bool {
43
- env :: var_os ( "IS_WINDOWS" ) . is_some ( )
43
+ target ( ) . contains ( "windows" )
44
44
}
45
45
46
46
/// Check if target uses msvc.
47
47
pub fn is_msvc ( ) -> bool {
48
- env:: var_os ( "IS_MSVC" ) . is_some ( )
48
+ target ( ) . contains ( "msvc" )
49
+ }
50
+
51
+ /// Check if target uses macOS.
52
+ pub fn is_darwin ( ) -> bool {
53
+ target ( ) . contains ( "darwin" )
49
54
}
50
55
51
56
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
@@ -84,7 +89,7 @@ pub fn static_lib_name(name: &str) -> String {
84
89
// ```
85
90
assert ! ( !name. contains( char :: is_whitespace) , "static library name cannot contain whitespace" ) ;
86
91
87
- if target ( ) . contains ( "msvc" ) { format ! ( "{name}.lib" ) } else { format ! ( "lib{name}.a" ) }
92
+ if is_msvc ( ) { format ! ( "{name}.lib" ) } else { format ! ( "lib{name}.a" ) }
88
93
}
89
94
90
95
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
@@ -110,15 +115,21 @@ pub fn dynamic_lib_name(name: &str) -> String {
110
115
// ```
111
116
assert ! ( !name. contains( char :: is_whitespace) , "dynamic library name cannot contain whitespace" ) ;
112
117
113
- if target ( ) . contains ( "darwin" ) {
118
+ if is_darwin ( ) {
114
119
format ! ( "lib{name}.dylib" )
115
- } else if target ( ) . contains ( "windows" ) {
120
+ } else if is_windows ( ) {
116
121
format ! ( "{name}.dll" )
117
122
} else {
118
123
format ! ( "lib{name}.so" )
119
124
}
120
125
}
121
126
127
+ /// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
128
+ /// path with `$TMPDIR` joined with the library name.
129
+ pub fn rust_lib ( name : & str ) -> PathBuf {
130
+ tmp_dir ( ) . join ( format ! ( "lib{name}.rlib" ) )
131
+ }
132
+
122
133
/// Construct the binary name based on platform.
123
134
pub fn bin_name ( name : & str ) -> String {
124
135
if is_windows ( ) { format ! ( "{name}.exe" ) } else { name. to_string ( ) }
0 commit comments