14
14
15
15
pub use crate_id:: CrateId ;
16
16
pub use target:: { OutputType , Main , Lib , Test , Bench , Target , Build , Install } ;
17
- pub use version:: { Version , NoVersion , split_version_general, try_parsing_version} ;
17
+ pub use version:: { Version , ExactRevision , NoVersion , split_version, split_version_general,
18
+ try_parsing_version} ;
18
19
pub use rustc:: metadata:: filesearch:: rust_path;
19
20
use rustc:: metadata:: filesearch:: libdir;
20
21
use rustc:: driver:: driver:: host_triple;
@@ -213,8 +214,9 @@ pub fn library_in_workspace(path: &Path, short_name: &str, where: Target,
213
214
}
214
215
215
216
// rustc doesn't use target-specific subdirectories
216
- pub fn system_library ( sysroot : & Path , lib_name : & str ) -> Option < Path > {
217
- library_in ( lib_name, & NoVersion , & sysroot. join ( libdir ( ) ) )
217
+ pub fn system_library ( sysroot : & Path , crate_id : & str ) -> Option < Path > {
218
+ let ( lib_name, version) = split_crate_id ( crate_id) ;
219
+ library_in ( lib_name, & version, & sysroot. join ( libdir ( ) ) )
218
220
}
219
221
220
222
fn library_in ( short_name : & str , version : & Version , dir_to_search : & Path ) -> Option < Path > {
@@ -268,6 +270,7 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
268
270
}
269
271
None => break
270
272
}
273
+
271
274
}
272
275
_ => { f_name = f_name. slice ( 0 , i) ; }
273
276
}
@@ -293,6 +296,22 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
293
296
abs_path
294
297
}
295
298
299
+ fn split_crate_id < ' a > ( crate_id : & ' a str ) -> ( & ' a str , Version ) {
300
+ match split_version ( crate_id) {
301
+ Some ( ( name, vers) ) =>
302
+ match vers {
303
+ ExactRevision ( ref v) => match v. find ( '-' ) {
304
+ Some ( pos) => ( name, ExactRevision ( v. slice ( 0 , pos) . to_owned ( ) ) ) ,
305
+ None => ( name, ExactRevision ( v. to_owned ( ) ) )
306
+ } ,
307
+ _ => ( name, vers)
308
+ } ,
309
+ None => ( crate_id, NoVersion )
310
+ }
311
+ }
312
+
313
+
314
+
296
315
/// Returns the executable that would be installed for <crateid>
297
316
/// in <workspace>
298
317
/// As a side effect, creates the bin-dir if it doesn't exist
0 commit comments