1
- // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
@@ -257,6 +257,7 @@ pub struct Context<'a> {
257
257
pub root : & ' a Option < CratePaths > ,
258
258
pub rejected_via_hash : Vec < CrateMismatch > ,
259
259
pub rejected_via_triple : Vec < CrateMismatch > ,
260
+ pub rejected_via_kind : Vec < CrateMismatch > ,
260
261
pub should_match_name : bool ,
261
262
}
262
263
@@ -311,6 +312,8 @@ impl<'a> Context<'a> {
311
312
} else if self . rejected_via_triple . len ( ) > 0 {
312
313
format ! ( "couldn't find crate `{}` with expected target triple {}" ,
313
314
self . ident, self . triple)
315
+ } else if self . rejected_via_kind . len ( ) > 0 {
316
+ format ! ( "found staticlib `{}` instead of rlib or dylib" , self . ident)
314
317
} else {
315
318
format ! ( "can't find crate for `{}`" , self . ident)
316
319
} ;
@@ -335,8 +338,8 @@ impl<'a> Context<'a> {
335
338
let mismatches = self . rejected_via_hash . iter ( ) ;
336
339
for ( i, & CrateMismatch { ref path, .. } ) in mismatches. enumerate ( ) {
337
340
self . sess . fileline_note ( self . span ,
338
- & format ! ( "crate `{}` path {} {}: {}" ,
339
- self . ident, "#" , i+1 , path. display( ) ) [ ] ) ;
341
+ & format ! ( "crate `{}` path # {}: {}" ,
342
+ self . ident, i+1 , path. display( ) ) [ ] ) ;
340
343
}
341
344
match self . root {
342
345
& None => { }
@@ -349,6 +352,16 @@ impl<'a> Context<'a> {
349
352
}
350
353
}
351
354
}
355
+ if self . rejected_via_kind . len ( ) > 0 {
356
+ self . sess . span_help ( self . span , "please recompile this crate using \
357
+ --crate-type lib") ;
358
+ let mismatches = self . rejected_via_kind . iter ( ) ;
359
+ for ( i, & CrateMismatch { ref path, .. } ) in mismatches. enumerate ( ) {
360
+ self . sess . fileline_note ( self . span ,
361
+ & format ! ( "crate `{}` path #{}: {}" ,
362
+ self . ident, i+1 , path. display( ) ) [ ] ) ;
363
+ }
364
+ }
352
365
self . sess . abort_if_errors ( ) ;
353
366
}
354
367
@@ -369,8 +382,10 @@ impl<'a> Context<'a> {
369
382
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
370
383
let dylib_prefix = format ! ( "{}{}" , dypair. 0 , self . crate_name) ;
371
384
let rlib_prefix = format ! ( "lib{}" , self . crate_name) ;
385
+ let staticlib_prefix = format ! ( "lib{}" , self . crate_name) ;
372
386
373
387
let mut candidates = HashMap :: new ( ) ;
388
+ let mut staticlibs = vec ! ( ) ;
374
389
375
390
// First, find all possible candidate rlibs and dylibs purely based on
376
391
// the name of the files themselves. We're trying to match against an
@@ -391,14 +406,21 @@ impl<'a> Context<'a> {
391
406
Some ( file) => file,
392
407
} ;
393
408
let ( hash, rlib) = if file. starts_with ( & rlib_prefix[ ] ) &&
394
- file. ends_with ( ".rlib" ) {
409
+ file. ends_with ( ".rlib" ) {
395
410
( & file[ ( rlib_prefix. len ( ) ) .. ( file. len ( ) - ".rlib" . len ( ) ) ] ,
396
411
true )
397
412
} else if file. starts_with ( & dylib_prefix) &&
398
413
file. ends_with ( & dypair. 1 ) {
399
414
( & file[ ( dylib_prefix. len ( ) ) .. ( file. len ( ) - dypair. 1 . len ( ) ) ] ,
400
415
false )
401
416
} else {
417
+ if file. starts_with ( & staticlib_prefix[ ] ) &&
418
+ file. ends_with ( ".a" ) {
419
+ staticlibs. push ( CrateMismatch {
420
+ path : path. clone ( ) ,
421
+ got : "static" . to_string ( )
422
+ } ) ;
423
+ }
402
424
return FileDoesntMatch
403
425
} ;
404
426
info ! ( "lib candidate: {}" , path. display( ) ) ;
@@ -415,6 +437,7 @@ impl<'a> Context<'a> {
415
437
416
438
FileMatches
417
439
} ) ;
440
+ self . rejected_via_kind . extend ( staticlibs. into_iter ( ) ) ;
418
441
419
442
// We have now collected all known libraries into a set of candidates
420
443
// keyed of the filename hash listed. For each filename, we also have a
0 commit comments