@@ -175,9 +175,10 @@ actual:\n\
175
175
config, props, testfile, make_typecheck_args, option:: some ( src) )
176
176
}
177
177
178
- fn make_typecheck_args ( config : config , _testfile : str ) -> procargs {
178
+ fn make_typecheck_args ( config : config , testfile : str ) -> procargs {
179
179
let prog = config. rustc_path ;
180
- let mut args = [ "-" , "--no-trans" , "--lib" , "-L" , config. build_base ] ;
180
+ let mut args = [ "-" , "--no-trans" , "--lib" , "-L" , config. build_base ,
181
+ "-L" , aux_output_dir_name ( config, testfile) ] ;
181
182
args += split_maybe_args ( config. rustcflags ) ;
182
183
ret { prog : prog, args : args} ;
183
184
}
@@ -290,8 +291,9 @@ type procres = {status: int, stdout: str, stderr: str, cmdline: str};
290
291
291
292
fn compile_test( config: config, props: test_props,
292
293
testfile: str ) -> procres {
294
+ let link_args = [ "-L" , aux_output_dir_name( config, testfile) ] ;
293
295
compose_and_run_compiler( config, props, testfile,
294
- make_compile_args( _, props, [ ] ,
296
+ make_compile_args( _, props, link_args ,
295
297
make_exe_name, _) ,
296
298
none)
297
299
}
@@ -310,11 +312,18 @@ fn compose_and_run_compiler(
310
312
mk_args: fn ( config: config, _testfile: str ) -> procargs,
311
313
input: option < str > ) -> procres {
312
314
315
+ if props. aux_builds. is_not_empty( ) {
316
+ ensure_dir( aux_output_dir_name( config, testfile) ) ;
317
+ }
318
+
319
+ let extra_link_args = [ "-L" , aux_output_dir_name( config, testfile) ] ;
320
+
313
321
vec:: iter( props. aux_builds) { |rel_ab|
314
322
let abs_ab = path:: connect( config. aux_base, rel_ab) ;
315
- let auxres = compose_and_run( config, abs_ab,
316
- make_compile_args( _, props, [ "--lib" ] ,
317
- make_lib_name, _) ,
323
+ let mk_compile_args =
324
+ make_compile_args( _, props, [ "--lib" ] + extra_link_args,
325
+ bind make_lib_name( _, _, testfile) , _) ;
326
+ let auxres = compose_and_run( config, abs_ab, mk_compile_args,
318
327
config. compile_lib_path, option:: none) ;
319
328
if auxres. status != 0 {
320
329
fatal_procres(
@@ -327,6 +336,13 @@ fn compose_and_run_compiler(
327
336
config. compile_lib_path, input)
328
337
}
329
338
339
+ fn ensure_dir( path: path) {
340
+ if os:: path_is_dir( path) { ret; }
341
+ if !os:: make_dir( path, 0x1c0i32 ) {
342
+ fail #fmt( "can't make dir %s" , path) ;
343
+ }
344
+ }
345
+
330
346
fn compose_and_run( config: config, testfile: str ,
331
347
make_args: fn ( config, str) -> procargs, lib_path: str ,
332
348
input: option < str > ) -> procres {
@@ -346,10 +362,11 @@ fn make_compile_args(config: config, props: test_props, extras: [str],
346
362
ret { prog : prog, args : args} ;
347
363
}
348
364
349
- fn make_lib_name( config: config, testfile: str ) -> str {
365
+ fn make_lib_name( config: config, auxfile : str , testfile: str ) -> str {
350
366
// what we return here is not particularly important, as it
351
367
// happens; rustc ignores everything except for the directory.
352
- output_base_name( config, testfile)
368
+ let auxname = output_testname( auxfile) ;
369
+ path:: connect( aux_output_dir_name( config, testfile) , auxname)
353
370
}
354
371
355
372
fn make_exe_name( config: config, testfile: str ) -> str {
@@ -440,12 +457,18 @@ fn make_out_name(config: config, testfile: str, extension: str) -> str {
440
457
output_base_name( config, testfile) + "." + extension
441
458
}
442
459
460
+ fn aux_output_dir_name( config: config, testfile: str ) -> str {
461
+ output_base_name( config, testfile) + ".libaux"
462
+ }
463
+
464
+ fn output_testname( testfile: str ) -> str {
465
+ let parts = str:: split_char( path:: basename( testfile) , '.' ) ;
466
+ str:: connect( vec:: slice( parts, 0 u, vec:: len( parts) - 1 u) , "." )
467
+ }
468
+
443
469
fn output_base_name( config: config, testfile: str ) -> str {
444
470
let base = config. build_base;
445
- let filename = {
446
- let parts = str:: split_char( path:: basename( testfile) , '.' ) ;
447
- str:: connect( vec:: slice( parts, 0 u, vec:: len( parts) - 1 u) , "." )
448
- } ;
471
+ let filename = output_testname( testfile) ;
449
472
#fmt[ "%s%s.%s" , base, filename, config. stage_id]
450
473
}
451
474
0 commit comments