1
1
use std:: ascii;
2
+ use std:: cell:: OnceCell ;
2
3
use std:: char;
3
4
use std:: env;
4
5
use std:: ffi:: OsString ;
5
6
use std:: fmt;
6
7
use std:: fs;
7
8
use std:: io;
8
- use std:: cell:: OnceCell ;
9
9
use std:: path:: { Path , PathBuf } ;
10
10
use std:: process:: { Output , Stdio } ;
11
11
use std:: str;
@@ -89,13 +89,12 @@ pub fn link_binary(
89
89
90
90
// `output_dir` is not necessarily the parent of `output_file`, such as with
91
91
// `--output-dir _build --output bin/myapp`
92
- let output_file_parent = output_file. parent ( ) . with_context ( || {
93
- format ! (
94
- "{} does not have a parent directory" ,
95
- output_file. as_display( )
96
- )
97
- } ) ?;
98
- fs:: create_dir_all ( output_file_parent) . with_context ( || {
92
+ let output_file_parent = if output_file. is_absolute ( ) {
93
+ output_file. parent ( ) . unwrap ( ) . to_path_buf ( )
94
+ } else {
95
+ output_dir. clone ( )
96
+ } ;
97
+ fs:: create_dir_all ( output_file_parent. as_path ( ) ) . with_context ( || {
99
98
format ! (
100
99
"Could not create parent directories ({}) of file ({})" ,
101
100
output_file_parent. as_display( ) ,
@@ -168,7 +167,7 @@ pub fn link_binary(
168
167
// about all dynamic library dependencies that they're not linked in.
169
168
fn link_staticlib < ' a > (
170
169
options : & ' a Options ,
171
- _diagnostics : & DiagnosticsHandler ,
170
+ diagnostics : & DiagnosticsHandler ,
172
171
project_type : ProjectType ,
173
172
codegen_results : & CodegenResults ,
174
173
output_file : & Path ,
@@ -190,6 +189,11 @@ fn link_staticlib<'a>(
190
189
191
190
ab. build ( ) ;
192
191
192
+ diagnostics. success (
193
+ "Linker" ,
194
+ format ! ( "generated static library to {}" , output_file. display( ) ) ,
195
+ ) ;
196
+
193
197
Ok ( ( ) )
194
198
}
195
199
@@ -239,7 +243,7 @@ fn link_natively(
239
243
}
240
244
241
245
if options. debugging_opts . print_link_args {
242
- println ! ( "{:?}" , & cmd) ;
246
+ diagnostics . notice ( "Linker" , format ! ( "{:?}" , & cmd) ) ;
243
247
}
244
248
245
249
// May have not found libraries in the right formats.
@@ -366,6 +370,11 @@ fn link_natively(
366
370
}
367
371
}
368
372
373
+ diagnostics. success (
374
+ "Linker" ,
375
+ format ! ( "generated executable to {}" , output_file. display( ) ) ,
376
+ ) ;
377
+
369
378
Ok ( ( ) )
370
379
}
371
380
0 commit comments