|
1 | | -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT |
| 1 | +// Copyright 2012-2014 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 | // |
@@ -641,41 +641,50 @@ impl<'a> Context<'a> { |
641 | 641 | // rlibs/dylibs. |
642 | 642 | let sess = self.sess; |
643 | 643 | let dylibname = self.dylibname(); |
644 | | - let mut locs = locs.iter().map(|l| Path::new(l.as_slice())).filter(|loc| { |
645 | | - if !loc.exists() { |
646 | | - sess.err(format!("extern location does not exist: {}", |
647 | | - loc.display()).as_slice()); |
648 | | - return false; |
649 | | - } |
650 | | - let file = loc.filename_str().unwrap(); |
651 | | - if file.starts_with("lib") && file.ends_with(".rlib") { |
652 | | - return true |
653 | | - } else { |
654 | | - match dylibname { |
655 | | - Some((prefix, suffix)) => { |
656 | | - if file.starts_with(prefix) && file.ends_with(suffix) { |
657 | | - return true |
| 644 | + let mut rlibs = HashSet::new(); |
| 645 | + let mut dylibs = HashSet::new(); |
| 646 | + { |
| 647 | + let mut locs = locs.iter().map(|l| Path::new(l.as_slice())).filter(|loc| { |
| 648 | + if !loc.exists() { |
| 649 | + sess.err(format!("extern location for {} does not exist: {}", |
| 650 | + self.crate_name, loc.display()).as_slice()); |
| 651 | + return false; |
| 652 | + } |
| 653 | + let file = match loc.filename_str() { |
| 654 | + Some(file) => file, |
| 655 | + None => { |
| 656 | + sess.err(format!("extern location for {} is not a file: {}", |
| 657 | + self.crate_name, loc.display()).as_slice()); |
| 658 | + return false; |
| 659 | + } |
| 660 | + }; |
| 661 | + if file.starts_with("lib") && file.ends_with(".rlib") { |
| 662 | + return true |
| 663 | + } else { |
| 664 | + match dylibname { |
| 665 | + Some((prefix, suffix)) => { |
| 666 | + if file.starts_with(prefix) && file.ends_with(suffix) { |
| 667 | + return true |
| 668 | + } |
658 | 669 | } |
| 670 | + None => {} |
659 | 671 | } |
660 | | - None => {} |
661 | 672 | } |
662 | | - } |
663 | | - sess.err(format!("extern location is of an unknown type: {}", |
664 | | - loc.display()).as_slice()); |
665 | | - false |
666 | | - }); |
| 673 | + sess.err(format!("extern location for {} is of an unknown type: {}", |
| 674 | + self.crate_name, loc.display()).as_slice()); |
| 675 | + false |
| 676 | + }); |
667 | 677 |
|
668 | | - // Now that we have an iterator of good candidates, make sure there's at |
669 | | - // most one rlib and at most one dylib. |
670 | | - let mut rlibs = HashSet::new(); |
671 | | - let mut dylibs = HashSet::new(); |
672 | | - for loc in locs { |
673 | | - if loc.filename_str().unwrap().ends_with(".rlib") { |
674 | | - rlibs.insert(fs::realpath(&loc).unwrap()); |
675 | | - } else { |
676 | | - dylibs.insert(fs::realpath(&loc).unwrap()); |
| 678 | + // Now that we have an iterator of good candidates, make sure there's at |
| 679 | + // most one rlib and at most one dylib. |
| 680 | + for loc in locs { |
| 681 | + if loc.filename_str().unwrap().ends_with(".rlib") { |
| 682 | + rlibs.insert(fs::realpath(&loc).unwrap()); |
| 683 | + } else { |
| 684 | + dylibs.insert(fs::realpath(&loc).unwrap()); |
| 685 | + } |
677 | 686 | } |
678 | | - } |
| 687 | + }; |
679 | 688 |
|
680 | 689 | // Extract the rlib/dylib pair. |
681 | 690 | let mut metadata = None; |
|
0 commit comments