1
1
//! A collection of helpers to construct artifact names, such as names of dynamic or static
2
2
//! librarys which are target-dependent.
3
3
4
- use crate :: targets:: { is_darwin, is_msvc, is_windows} ;
4
+ // FIXME(jieyouxu): convert these to return `PathBuf`s instead of strings!
5
+
6
+ use crate :: targets:: is_msvc;
5
7
6
8
/// Construct the static library name based on the target.
7
9
#[ must_use]
@@ -31,41 +33,15 @@ pub fn static_lib_name(name: &str) -> String {
31
33
/// Construct the dynamic library name based on the target.
32
34
#[ must_use]
33
35
pub fn dynamic_lib_name ( name : & str ) -> String {
34
- // See tools.mk (irrelevant lines omitted):
35
- //
36
- // ```makefile
37
- // ifeq ($(UNAME),Darwin)
38
- // DYLIB = $(TMPDIR)/lib$(1).dylib
39
- // else
40
- // ifdef IS_WINDOWS
41
- // DYLIB = $(TMPDIR)/$(1).dll
42
- // else
43
- // DYLIB = $(TMPDIR)/lib$(1).so
44
- // endif
45
- // endif
46
- // ```
47
36
assert ! ( !name. contains( char :: is_whitespace) , "dynamic library name cannot contain whitespace" ) ;
48
37
49
- let extension = dynamic_lib_extension ( ) ;
50
- if is_darwin ( ) {
51
- format ! ( "lib{name}.{extension}" )
52
- } else if is_windows ( ) {
53
- format ! ( "{name}.{extension}" )
54
- } else {
55
- format ! ( "lib{name}.{extension}" )
56
- }
38
+ format ! ( "{}{name}.{}" , std:: env:: consts:: DLL_PREFIX , std:: env:: consts:: DLL_EXTENSION )
57
39
}
58
40
59
41
/// Construct the dynamic library extension based on the target.
60
42
#[ must_use]
61
43
pub fn dynamic_lib_extension ( ) -> & ' static str {
62
- if is_darwin ( ) {
63
- "dylib"
64
- } else if is_windows ( ) {
65
- "dll"
66
- } else {
67
- "so"
68
- }
44
+ std:: env:: consts:: DLL_EXTENSION
69
45
}
70
46
71
47
/// Construct the name of a rust library (rlib).
@@ -77,5 +53,5 @@ pub fn rust_lib_name(name: &str) -> String {
77
53
/// Construct the binary (executable) name based on the target.
78
54
#[ must_use]
79
55
pub fn bin_name ( name : & str ) -> String {
80
- if is_windows ( ) { format ! ( "{name}.exe" ) } else { name . to_string ( ) }
56
+ format ! ( "{name}{}" , std :: env :: consts :: EXE_SUFFIX )
81
57
}
0 commit comments