@@ -130,8 +130,11 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
130
130
let mut child = Command :: new ( "rust-semver-public" ) ;
131
131
child
132
132
. arg ( "--crate-type=lib" )
133
- . args ( & [ "--extern" , & * format ! ( "new={}" , current_rlib. display( ) ) ] )
134
- . args ( & [ format ! ( "-L{}" , current_deps_output. display( ) ) ] ) ;
133
+ . args ( & [ "--extern" , & * format ! ( "new={}" , current_rlib. display( ) ) ] ) ;
134
+
135
+ for link_path in current_deps_output {
136
+ child. args ( & [ format ! ( "-L{}" , link_path. display( ) ) ] ) ;
137
+ }
135
138
136
139
if let Some ( target) = matches. opt_str ( "target" ) {
137
140
child. args ( & [ "--target" , & target] ) ;
@@ -195,13 +198,16 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
195
198
stable. rlib_and_dep_output ( config, & name, false , matches) ?;
196
199
197
200
if matches. opt_present ( "d" ) {
198
- println ! (
199
- "--extern old={} -L{} --extern new={} -L{}" ,
200
- stable_rlib. display( ) ,
201
- stable_deps_output. display( ) ,
202
- current_rlib. display( ) ,
203
- current_deps_output. display( )
204
- ) ;
201
+ print ! ( "--extern old={} " , stable_rlib. display( ) ) ;
202
+ for link_path in stable_deps_output {
203
+ print ! ( "-L {} " , link_path. display( ) ) ;
204
+ }
205
+ print ! ( "--extern new={}" , current_rlib. display( ) ) ;
206
+ for link_path in current_deps_output {
207
+ print ! ( "-L {} " , link_path. display( ) ) ;
208
+ }
209
+ println ! ( ) ;
210
+
205
211
return Ok ( ( ) ) ;
206
212
}
207
213
@@ -210,10 +216,14 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
210
216
let mut child = Command :: new ( "rust-semverver" ) ;
211
217
child
212
218
. arg ( "--crate-type=lib" )
213
- . args ( & [ "--extern" , & * format ! ( "old={}" , stable_rlib. display( ) ) ] )
214
- . args ( & [ format ! ( "-L{}" , stable_deps_output. display( ) ) ] )
215
- . args ( & [ "--extern" , & * format ! ( "new={}" , current_rlib. display( ) ) ] )
216
- . args ( & [ format ! ( "-L{}" , current_deps_output. display( ) ) ] ) ;
219
+ . args ( & [ "--extern" , & * format ! ( "old={}" , stable_rlib. display( ) ) ] ) ;
220
+ for link_path in stable_deps_output {
221
+ child. args ( & [ format ! ( "-L{}" , link_path. display( ) ) ] ) ;
222
+ }
223
+ child. args ( & [ "--extern" , & * format ! ( "new={}" , current_rlib. display( ) ) ] ) ;
224
+ for link_path in current_deps_output {
225
+ child. args ( & [ format ! ( "-L{}" , link_path. display( ) ) ] ) ;
226
+ }
217
227
218
228
if let Some ( target) = matches. opt_str ( "target" ) {
219
229
child. args ( & [ "--target" , & target] ) ;
@@ -235,6 +245,8 @@ fn run(config: &cargo::Config, matches: &getopts::Matches) -> Result<()> {
235
245
} ,
236
246
) ;
237
247
248
+ debug ! ( "rust-semverver invocation: {:?}" , child) ;
249
+
238
250
let mut child = child
239
251
. spawn ( )
240
252
. map_err ( |e| anyhow:: Error :: msg ( format ! ( "could not spawn rustc: {}" , e) ) ) ?;
@@ -474,7 +486,7 @@ impl<'a> WorkInfo<'a> {
474
486
name : & str ,
475
487
current : bool ,
476
488
matches : & getopts:: Matches ,
477
- ) -> Result < ( PathBuf , PathBuf ) > {
489
+ ) -> Result < ( PathBuf , Vec < PathBuf > ) > {
478
490
// We don't need codegen-ready artifacts (which .rlib files are) so
479
491
// settle for .rmeta files, which result from `cargo check` mode
480
492
let mode = cargo:: core:: compiler:: CompileMode :: Check { test : false } ;
@@ -531,18 +543,29 @@ impl<'a> WorkInfo<'a> {
531
543
let build_plan: BuildPlan = serde_json:: from_slice ( & plan_output)
532
544
. map_err ( |_| anyhow:: anyhow!( "Can't read build plan" ) ) ?;
533
545
534
- // TODO: handle multiple outputs gracefully
535
- for i in & build_plan. invocations {
546
+ debug ! ( "{:?}" , & build_plan . invocations ) ;
547
+ let paths = build_plan. invocations . iter ( ) . find_map ( |i| {
536
548
if let Some ( kind) = i. target_kind . get ( 0 ) {
537
549
if kind. contains ( "lib" ) && i. package_name == name {
538
- let deps_output = & compilation. deps_output [ & compile_kind] ;
539
-
540
- return Ok ( ( i. outputs [ 0 ] . clone ( ) , deps_output. clone ( ) ) ) ;
550
+ let rlib_path = i. outputs [ 0 ] . clone ( ) ;
551
+ let mut link_paths = vec ! [
552
+ compilation. deps_output[ & compile_kind] . clone( ) ,
553
+ compilation. deps_output[ & cargo:: core:: compiler:: CompileKind :: Host ] . clone( ) ,
554
+ ] ;
555
+ // if host and `compile_kind` are the same, only return once
556
+ link_paths. dedup ( ) ;
557
+ return Some ( ( rlib_path, link_paths) ) ;
541
558
}
542
559
}
543
- }
544
560
545
- Err ( anyhow:: Error :: msg ( "lost build artifact" . to_owned ( ) ) )
561
+ None
562
+ } ) ;
563
+
564
+ if let Some ( paths) = paths {
565
+ Ok ( paths)
566
+ } else {
567
+ Err ( anyhow:: Error :: msg ( "lost build artifact" . to_owned ( ) ) )
568
+ }
546
569
}
547
570
}
548
571
0 commit comments