@@ -135,10 +135,10 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
135
135
let ( mut libs, mut bins) = ( Vec :: new ( ) , Vec :: new ( ) ) ;
136
136
for & target in targets. iter ( ) {
137
137
let work = if target. get_profile ( ) . is_doc ( ) {
138
- vec ! [ ( rustdoc( pkg, target, cx) , KindTarget ) ]
138
+ vec ! [ ( try! ( rustdoc( pkg, target, cx) ) , KindTarget ) ]
139
139
} else {
140
140
let req = cx. get_requirement ( pkg, target) ;
141
- rustc ( pkg, target, cx, req)
141
+ try! ( rustc ( pkg, target, cx, req) )
142
142
} ;
143
143
144
144
let dst = if target. is_lib ( ) { & mut libs} else { & mut bins} ;
@@ -188,15 +188,16 @@ fn compile_custom(pkg: &Package, cmd: &str,
188
188
}
189
189
190
190
fn rustc ( package : & Package , target : & Target ,
191
- cx : & mut Context , req : PlatformRequirement ) -> Vec < ( Work , Kind ) > {
191
+ cx : & mut Context , req : PlatformRequirement )
192
+ -> CargoResult < Vec < ( Work , Kind ) > > {
192
193
let crate_types = target. rustc_crate_types ( ) ;
193
194
let root = package. get_root ( ) ;
194
195
195
196
log ! ( 5 , "root={}; target={}; crate_types={}; verbose={}; req={}" ,
196
197
root. display( ) , target, crate_types, cx. primary, req) ;
197
198
198
199
let primary = cx. primary ;
199
- let rustcs = prepare_rustc ( package, target, crate_types, cx, req) ;
200
+ let rustcs = try! ( prepare_rustc ( package, target, crate_types, cx, req) ) ;
200
201
201
202
let _ = cx. config . shell ( ) . verbose ( |shell| {
202
203
for & ( ref rustc, _) in rustcs. iter ( ) {
@@ -205,7 +206,7 @@ fn rustc(package: &Package, target: &Target,
205
206
Ok ( ( ) )
206
207
} ) ;
207
208
208
- rustcs. move_iter ( ) . map ( |( rustc, kind) | {
209
+ Ok ( rustcs. move_iter ( ) . map ( |( rustc, kind) | {
209
210
let name = package. get_name ( ) . to_string ( ) ;
210
211
211
212
( proc ( ) {
@@ -223,40 +224,43 @@ fn rustc(package: &Package, target: &Target,
223
224
}
224
225
Ok ( ( ) )
225
226
} , kind)
226
- } ) . collect ( )
227
+ } ) . collect ( ) )
227
228
}
228
229
229
230
fn prepare_rustc ( package : & Package , target : & Target , crate_types : Vec < & str > ,
230
231
cx : & Context , req : PlatformRequirement )
231
- -> Vec < ( ProcessBuilder , Kind ) > {
232
+ -> CargoResult < Vec < ( ProcessBuilder , Kind ) > > {
232
233
let base = process ( "rustc" , package, cx) ;
233
234
let base = build_base_args ( base, target, crate_types. as_slice ( ) ) ;
234
235
235
236
let target_cmd = build_plugin_args ( base. clone ( ) , cx, package, target, KindTarget ) ;
236
237
let plugin_cmd = build_plugin_args ( base, cx, package, target, KindPlugin ) ;
237
- let target_cmd = build_deps_args ( target_cmd, target, package, cx, KindTarget ) ;
238
- let plugin_cmd = build_deps_args ( plugin_cmd, target, package, cx, KindPlugin ) ;
238
+ let target_cmd = try!( build_deps_args ( target_cmd, target, package, cx,
239
+ KindTarget ) ) ;
240
+ let plugin_cmd = try!( build_deps_args ( plugin_cmd, target, package, cx,
241
+ KindPlugin ) ) ;
239
242
240
- match req {
243
+ Ok ( match req {
241
244
Target => vec ! [ ( target_cmd, KindTarget ) ] ,
242
245
Plugin => vec ! [ ( plugin_cmd, KindPlugin ) ] ,
243
246
PluginAndTarget if cx. config . target ( ) . is_none ( ) =>
244
247
vec ! [ ( target_cmd, KindTarget ) ] ,
245
248
PluginAndTarget => vec ! [ ( target_cmd, KindTarget ) ,
246
249
( plugin_cmd, KindPlugin ) ] ,
247
- }
250
+ } )
248
251
}
249
252
250
253
251
- fn rustdoc ( package : & Package , target : & Target , cx : & mut Context ) -> Work {
254
+ fn rustdoc ( package : & Package , target : & Target ,
255
+ cx : & mut Context ) -> CargoResult < Work > {
252
256
let kind = KindTarget ;
253
257
let pkg_root = package. get_root ( ) ;
254
258
let cx_root = cx. layout ( kind) . proxy ( ) . dest ( ) . join ( "doc" ) ;
255
259
let rustdoc = process ( "rustdoc" , package, cx) . cwd ( pkg_root. clone ( ) ) ;
256
260
let rustdoc = rustdoc. arg ( target. get_src_path ( ) )
257
261
. arg ( "-o" ) . arg ( cx_root)
258
262
. arg ( "--crate-name" ) . arg ( target. get_name ( ) ) ;
259
- let rustdoc = build_deps_args ( rustdoc, target, package, cx, kind) ;
263
+ let rustdoc = try! ( build_deps_args ( rustdoc, target, package, cx, kind) ) ;
260
264
261
265
log ! ( 5 , "commands={}" , rustdoc) ;
262
266
@@ -266,7 +270,7 @@ fn rustdoc(package: &Package, target: &Target, cx: &mut Context) -> Work {
266
270
267
271
let primary = cx. primary ;
268
272
let name = package. get_name ( ) . to_string ( ) ;
269
- proc ( ) {
273
+ Ok ( proc ( ) {
270
274
if primary {
271
275
try!( rustdoc. exec ( ) . chain_error ( || {
272
276
human ( format ! ( "Could not document `{}`." , name) )
@@ -278,7 +282,7 @@ fn rustdoc(package: &Package, target: &Target, cx: &mut Context) -> Work {
278
282
} ) )
279
283
}
280
284
Ok ( ( ) )
281
- }
285
+ } )
282
286
}
283
287
284
288
fn build_base_args ( mut cmd : ProcessBuilder ,
@@ -355,7 +359,8 @@ fn build_plugin_args(mut cmd: ProcessBuilder, cx: &Context, pkg: &Package,
355
359
}
356
360
357
361
fn build_deps_args ( mut cmd : ProcessBuilder , target : & Target , package : & Package ,
358
- cx : & Context , kind : Kind ) -> ProcessBuilder {
362
+ cx : & Context ,
363
+ kind : Kind ) -> CargoResult < ProcessBuilder > {
359
364
enum LinkReason { Dependency , LocalLib }
360
365
361
366
let layout = cx. layout ( kind) ;
@@ -367,7 +372,7 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
367
372
cmd = push_native_dirs ( cmd, & layout, package, cx, & mut HashSet :: new ( ) ) ;
368
373
369
374
for & ( _, target) in cx. dep_targets ( package) . iter ( ) {
370
- cmd = link_to ( cmd, target, cx, kind, Dependency ) ;
375
+ cmd = try! ( link_to ( cmd, target, cx, kind, Dependency ) ) ;
371
376
}
372
377
373
378
let mut targets = package. get_targets ( ) . iter ( ) . filter ( |target| {
@@ -376,14 +381,15 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
376
381
377
382
if target. is_bin ( ) {
378
383
for target in targets {
379
- cmd = link_to ( cmd, target, cx, kind, LocalLib ) ;
384
+ cmd = try! ( link_to ( cmd, target, cx, kind, LocalLib ) ) ;
380
385
}
381
386
}
382
387
383
- return cmd;
388
+ return Ok ( cmd) ;
384
389
385
390
fn link_to ( mut cmd : ProcessBuilder , target : & Target ,
386
- cx : & Context , kind : Kind , reason : LinkReason ) -> ProcessBuilder {
391
+ cx : & Context , kind : Kind ,
392
+ reason : LinkReason ) -> CargoResult < ProcessBuilder > {
387
393
// If this target is itself a plugin *or* if it's being linked to a
388
394
// plugin, then we want the plugin directory. Otherwise we want the
389
395
// target directory (hence the || here).
@@ -393,7 +399,7 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
393
399
KindTarget => KindTarget ,
394
400
} ) ;
395
401
396
- for filename in cx. target_filenames ( target) . iter ( ) {
402
+ for filename in try! ( cx. target_filenames ( target) ) . iter ( ) {
397
403
let mut v = Vec :: new ( ) ;
398
404
v. push_all ( target. get_name ( ) . as_bytes ( ) ) ;
399
405
v. push ( b'=' ) ;
@@ -405,7 +411,7 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
405
411
v. push_all ( filename. as_bytes ( ) ) ;
406
412
cmd = cmd. arg ( "--extern" ) . arg ( v. as_slice ( ) ) ;
407
413
}
408
- return cmd;
414
+ return Ok ( cmd) ;
409
415
}
410
416
411
417
fn push_native_dirs ( mut cmd : ProcessBuilder , layout : & layout:: LayoutProxy ,
0 commit comments