@@ -40,12 +40,17 @@ pub fn target() -> String {
4040
4141/// Check if target is windows-like.
4242pub fn is_windows ( ) -> bool {
43- env :: var_os ( "IS_WINDOWS" ) . is_some ( )
43+ target ( ) . contains ( "windows" )
4444}
4545
4646/// Check if target uses msvc.
4747pub 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" )
4954}
5055
5156/// 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 {
8489 // ```
8590 assert ! ( !name. contains( char :: is_whitespace) , "static library name cannot contain whitespace" ) ;
8691
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" ) }
8893}
8994
9095/// 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 {
110115 // ```
111116 assert ! ( !name. contains( char :: is_whitespace) , "dynamic library name cannot contain whitespace" ) ;
112117
113- if target ( ) . contains ( "darwin" ) {
118+ if is_darwin ( ) {
114119 format ! ( "lib{name}.dylib" )
115- } else if target ( ) . contains ( "windows" ) {
120+ } else if is_windows ( ) {
116121 format ! ( "{name}.dll" )
117122 } else {
118123 format ! ( "lib{name}.so" )
119124 }
120125}
121126
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+
122133/// Construct the binary name based on platform.
123134pub fn bin_name ( name : & str ) -> String {
124135 if is_windows ( ) { format ! ( "{name}.exe" ) } else { name. to_string ( ) }
0 commit comments