@@ -26,7 +26,7 @@ mod job_queue;
26
26
mod layout;
27
27
28
28
#[ deriving( PartialEq , Eq ) ]
29
- pub enum Kind { KindForHost , KindTarget }
29
+ pub enum Kind { KindHost , KindTarget }
30
30
31
31
/// Run `rustc` to figure out what its current version string is.
32
32
///
@@ -116,10 +116,10 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
116
116
}
117
117
118
118
let compiled = compiled. contains ( dep. get_package_id ( ) ) ;
119
- try!( compile ( targets. as_slice ( ) , dep, pkg , compiled, & mut cx, & mut queue) ) ;
119
+ try!( compile ( targets. as_slice ( ) , dep, compiled, & mut cx, & mut queue) ) ;
120
120
}
121
121
122
- try!( compile ( targets, pkg, pkg , true , & mut cx, & mut queue) ) ;
122
+ try!( compile ( targets, pkg, true , & mut cx, & mut queue) ) ;
123
123
124
124
// Now that we've figured out everything that we're going to do, do it!
125
125
try!( queue. execute ( cx. config ) ) ;
@@ -128,7 +128,7 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
128
128
}
129
129
130
130
fn compile < ' a , ' b > ( targets : & [ & ' a Target ] , pkg : & ' a Package ,
131
- root_pkg : & ' a Package , compiled : bool ,
131
+ compiled : bool ,
132
132
cx : & mut Context < ' a , ' b > ,
133
133
jobs : & mut JobQueue < ' a , ' b > ) -> CargoResult < ( ) > {
134
134
debug ! ( "compile_pkg; pkg={}; targets={}" , pkg, targets) ;
@@ -149,7 +149,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
149
149
let ( target1, target2) = fingerprint:: prepare_init ( cx, pkg, KindTarget ) ;
150
150
let mut init = vec ! [ ( Job :: new( target1, target2) , Fresh ) ] ;
151
151
if cx. config . target ( ) . is_some ( ) {
152
- let ( plugin1, plugin2) = fingerprint:: prepare_init ( cx, pkg, KindForHost ) ;
152
+ let ( plugin1, plugin2) = fingerprint:: prepare_init ( cx, pkg, KindHost ) ;
153
153
init. push ( ( Job :: new ( plugin1, plugin2) , Fresh ) ) ;
154
154
}
155
155
jobs. enqueue ( pkg, jq:: StageStart , init) ;
@@ -174,14 +174,13 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
174
174
use std:: mem;
175
175
176
176
let ( old_build, script_output) = {
177
- let layout = cx. layout ( pkg, KindForHost ) ;
177
+ let layout = cx. layout ( pkg, KindHost ) ;
178
178
let old_build = layout. proxy ( ) . old_build ( pkg) ;
179
179
let script_output = layout. build ( pkg) ;
180
180
( old_build, script_output)
181
181
} ;
182
182
183
183
let execute_cmd = try!( prepare_execute_custom_build ( pkg,
184
- root_pkg,
185
184
target, cx) ) ;
186
185
187
186
// building a `Work` that creates the directory where the compiled script
@@ -388,7 +387,8 @@ impl CustomBuildCommandOutput {
388
387
} ;
389
388
390
389
if key == "rustc-flags" {
391
- let mut flags_iter = value. split ( |c : char | c == ' ' || c == '\t' ) ;
390
+ // TODO: some arguments (like paths) may contain spaces
391
+ let mut flags_iter = value. words ( ) ;
392
392
loop {
393
393
let flag = match flags_iter. next ( ) {
394
394
Some ( f) => f,
@@ -427,32 +427,22 @@ impl CustomBuildCommandOutput {
427
427
}
428
428
429
429
// Prepares a `Work` that executes the target as a custom build script.
430
- // `pkg` is the package the build script belongs to, and `root_pkg` is the package
431
- // Cargo is being run on.
432
- fn prepare_execute_custom_build ( pkg : & Package , root_pkg : & Package , target : & Target ,
430
+ fn prepare_execute_custom_build ( pkg : & Package , target : & Target ,
433
431
cx : & mut Context )
434
432
-> CargoResult < Work > {
435
- let layout = cx. layout ( pkg, KindForHost ) ;
433
+ let layout = cx. layout ( pkg, KindHost ) ;
436
434
let script_output = layout. build ( pkg) ;
437
435
let build_output = layout. build_out ( pkg) ;
438
436
439
437
// Building the command to execute
440
- let to_exec = try!( cx. target_filenames ( target) ) ;
441
- if to_exec. len ( ) >= 2 {
442
- return Err ( human ( format ! ( "custom build script shouldn't have multiple outputs" ) ) ) ;
443
- }
444
- let to_exec = to_exec. into_iter ( ) . next ( ) ;
445
- let to_exec = match to_exec {
446
- Some ( cmd) => cmd,
447
- None => return Err ( human ( format ! ( "failed to determine output of custom build script" ) ) ) ,
448
- } ;
438
+ let to_exec = try!( cx. target_filenames ( target) ) [ 0 ] . clone ( ) ;
449
439
let to_exec = script_output. join ( to_exec) ;
450
440
451
441
// Filling environment variables
452
442
let profile = target. get_profile ( ) ;
453
443
let mut p = process ( to_exec, pkg, cx)
454
444
. env ( "OUT_DIR" , Some ( & build_output) )
455
- . env ( "CARGO_MANIFEST_DIR" , Some ( root_pkg . get_manifest_path ( )
445
+ . env ( "CARGO_MANIFEST_DIR" , Some ( pkg . get_manifest_path ( )
456
446
. display ( ) . to_string ( ) ) )
457
447
. env ( "NUM_JOBS" , profile. get_codegen_units ( ) . map ( |n| n. to_string ( ) ) )
458
448
. env ( "TARGET" , Some ( cx. target_triple ( ) ) )
@@ -476,7 +466,7 @@ fn prepare_execute_custom_build(pkg: &Package, root_pkg: &Package, target: &Targ
476
466
// building the list of all possible `build/$pkg/output` files
477
467
// whether they exist or not will be checked during the work
478
468
let command_output_files = {
479
- let layout = cx. layout ( pkg, KindForHost ) ;
469
+ let layout = cx. layout ( pkg, KindHost ) ;
480
470
cx. dep_targets ( pkg) . iter ( ) . map ( |& ( pkg, _) | {
481
471
layout. build ( pkg) . join ( "output" )
482
472
} ) . collect :: < Vec < _ > > ( )
@@ -553,7 +543,7 @@ fn rustc(package: &Package, target: &Target,
553
543
let show_warnings = package. get_package_id ( ) == cx. resolve . root ( ) ||
554
544
is_path_source;
555
545
let rustc = if show_warnings { rustc} else { rustc. arg ( "-Awarnings" ) } ;
556
- let build_cmd_layout = cx. layout ( package, KindForHost ) ;
546
+ let build_cmd_layout = cx. layout ( package, KindHost ) ;
557
547
558
548
// building the possible `build/$pkg/output` file for this local package
559
549
let command_output_file = build_cmd_layout. build ( package) . join ( "output" ) ;
@@ -619,19 +609,19 @@ fn prepare_rustc(package: &Package, target: &Target, crate_types: Vec<&str>,
619
609
let base = build_base_args ( cx, base, package, target, crate_types. as_slice ( ) ) ;
620
610
621
611
let target_cmd = build_plugin_args ( base. clone ( ) , cx, package, target, KindTarget ) ;
622
- let plugin_cmd = build_plugin_args ( base, cx, package, target, KindForHost ) ;
612
+ let plugin_cmd = build_plugin_args ( base, cx, package, target, KindHost ) ;
623
613
let target_cmd = try!( build_deps_args ( target_cmd, target, package, cx,
624
614
KindTarget ) ) ;
625
615
let plugin_cmd = try!( build_deps_args ( plugin_cmd, target, package, cx,
626
- KindForHost ) ) ;
616
+ KindHost ) ) ;
627
617
628
618
Ok ( match req {
629
619
PlatformTarget => vec ! [ ( target_cmd, KindTarget ) ] ,
630
- PlatformPlugin => vec ! [ ( plugin_cmd, KindForHost ) ] ,
620
+ PlatformPlugin => vec ! [ ( plugin_cmd, KindHost ) ] ,
631
621
PlatformPluginAndTarget if cx. config . target ( ) . is_none ( ) =>
632
622
vec ! [ ( target_cmd, KindTarget ) ] ,
633
623
PlatformPluginAndTarget => vec ! [ ( target_cmd, KindTarget ) ,
634
- ( plugin_cmd, KindForHost ) ] ,
624
+ ( plugin_cmd, KindHost ) ] ,
635
625
} )
636
626
}
637
627
@@ -840,8 +830,8 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
840
830
// plugin, then we want the plugin directory. Otherwise we want the
841
831
// target directory (hence the || here).
842
832
let layout = cx. layout ( pkg, match kind {
843
- KindForHost => KindForHost ,
844
- KindTarget if target. get_profile ( ) . is_for_host ( ) => KindForHost ,
833
+ KindHost => KindHost ,
834
+ KindTarget if target. get_profile ( ) . is_for_host ( ) => KindHost ,
845
835
KindTarget => KindTarget ,
846
836
} ) ;
847
837
@@ -861,7 +851,7 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
861
851
pub fn process < T : ToCStr > ( cmd : T , pkg : & Package , cx : & Context ) -> ProcessBuilder {
862
852
// When invoking a tool, we need the *host* deps directory in the dynamic
863
853
// library search path for plugins and such which have dynamic dependencies.
864
- let layout = cx. layout ( pkg, KindForHost ) ;
854
+ let layout = cx. layout ( pkg, KindHost ) ;
865
855
let mut search_path = DynamicLibrary :: search_path ( ) ;
866
856
search_path. push ( layout. deps ( ) . clone ( ) ) ;
867
857
0 commit comments