@@ -7,6 +7,7 @@ mod command;
7
7
mod macros;
8
8
9
9
pub mod ar;
10
+ pub mod artifact_names;
10
11
pub mod diff;
11
12
pub mod env_checked;
12
13
pub mod external_deps;
@@ -61,6 +62,11 @@ pub use run::{cmd, run, run_fail, run_with_args};
61
62
/// Helpers for checking target information.
62
63
pub use targets:: { is_darwin, is_msvc, is_windows, target, uname} ;
63
64
65
+ /// Helpers for building names of output artifacts that are potentially target-specific.
66
+ pub use artifact_names:: {
67
+ bin_name, dynamic_lib_extension, dynamic_lib_name, rust_lib_name, static_lib_name,
68
+ } ;
69
+
64
70
use command:: { Command , CompletedProcess } ;
65
71
66
72
/// Returns the path for a local test file.
@@ -102,82 +108,6 @@ pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
102
108
) ) ;
103
109
}
104
110
105
- /// Construct the static library name based on the platform.
106
- #[ must_use]
107
- pub fn static_lib_name ( name : & str ) -> String {
108
- // See tools.mk (irrelevant lines omitted):
109
- //
110
- // ```makefile
111
- // ifeq ($(UNAME),Darwin)
112
- // STATICLIB = $(TMPDIR)/lib$(1).a
113
- // else
114
- // ifdef IS_WINDOWS
115
- // ifdef IS_MSVC
116
- // STATICLIB = $(TMPDIR)/$(1).lib
117
- // else
118
- // STATICLIB = $(TMPDIR)/lib$(1).a
119
- // endif
120
- // else
121
- // STATICLIB = $(TMPDIR)/lib$(1).a
122
- // endif
123
- // endif
124
- // ```
125
- assert ! ( !name. contains( char :: is_whitespace) , "static library name cannot contain whitespace" ) ;
126
-
127
- if is_msvc ( ) { format ! ( "{name}.lib" ) } else { format ! ( "lib{name}.a" ) }
128
- }
129
-
130
- /// Construct the dynamic library name based on the platform.
131
- #[ must_use]
132
- pub fn dynamic_lib_name ( name : & str ) -> String {
133
- // See tools.mk (irrelevant lines omitted):
134
- //
135
- // ```makefile
136
- // ifeq ($(UNAME),Darwin)
137
- // DYLIB = $(TMPDIR)/lib$(1).dylib
138
- // else
139
- // ifdef IS_WINDOWS
140
- // DYLIB = $(TMPDIR)/$(1).dll
141
- // else
142
- // DYLIB = $(TMPDIR)/lib$(1).so
143
- // endif
144
- // endif
145
- // ```
146
- assert ! ( !name. contains( char :: is_whitespace) , "dynamic library name cannot contain whitespace" ) ;
147
-
148
- let extension = dynamic_lib_extension ( ) ;
149
- if is_darwin ( ) {
150
- format ! ( "lib{name}.{extension}" )
151
- } else if is_windows ( ) {
152
- format ! ( "{name}.{extension}" )
153
- } else {
154
- format ! ( "lib{name}.{extension}" )
155
- }
156
- }
157
-
158
- #[ must_use]
159
- pub fn dynamic_lib_extension ( ) -> & ' static str {
160
- if is_darwin ( ) {
161
- "dylib"
162
- } else if is_windows ( ) {
163
- "dll"
164
- } else {
165
- "so"
166
- }
167
- }
168
-
169
- /// Generate the name a rust library (rlib) would have.
170
- #[ must_use]
171
- pub fn rust_lib_name ( name : & str ) -> String {
172
- format ! ( "lib{name}.rlib" )
173
- }
174
-
175
- /// Construct the binary name based on platform.
176
- #[ must_use]
177
- pub fn bin_name ( name : & str ) -> String {
178
- if is_windows ( ) { format ! ( "{name}.exe" ) } else { name. to_string ( ) }
179
- }
180
-
181
111
/// Return the current working directory.
182
112
#[ must_use]
183
113
pub fn cwd ( ) -> PathBuf {
0 commit comments