@@ -262,7 +262,7 @@ top_level_options!(
262262 // much sense: The search path can stay the same while the
263263 // things discovered there might have changed on disk.
264264 search_paths: SearchPaths [ TRACKED ] ,
265- libs: Vec <( String , cstore:: NativeLibraryKind ) > [ TRACKED ] ,
265+ libs: Vec <( String , Option < String > , cstore:: NativeLibraryKind ) > [ TRACKED ] ,
266266 maybe_sysroot: Option <PathBuf > [ TRACKED ] ,
267267
268268 target_triple: String [ TRACKED ] ,
@@ -1449,6 +1449,8 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
14491449 }
14501450
14511451 let libs = matches. opt_strs ( "l" ) . into_iter ( ) . map ( |s| {
1452+ // Parse string of the form "[KIND=]lib[:new_name]",
1453+ // where KIND is one of "dylib", "framework", "static".
14521454 let mut parts = s. splitn ( 2 , '=' ) ;
14531455 let kind = parts. next ( ) . unwrap ( ) ;
14541456 let ( name, kind) = match ( parts. next ( ) , kind) {
@@ -1462,7 +1464,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
14621464 s) ) ;
14631465 }
14641466 } ;
1465- ( name. to_string ( ) , kind)
1467+ let mut name_parts = name. splitn ( 2 , ':' ) ;
1468+ let name = name_parts. next ( ) . unwrap ( ) ;
1469+ let new_name = name_parts. next ( ) ;
1470+ ( name. to_string ( ) , new_name. map ( |n| n. to_string ( ) ) , kind)
14661471 } ) . collect ( ) ;
14671472
14681473 let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
@@ -1728,8 +1733,8 @@ mod dep_tracking {
17281733 impl_dep_tracking_hash_for_sortable_vec_of ! ( String ) ;
17291734 impl_dep_tracking_hash_for_sortable_vec_of ! ( CrateType ) ;
17301735 impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , lint:: Level ) ) ;
1731- impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , cstore :: NativeLibraryKind ) ) ;
1732-
1736+ impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , Option < String > ,
1737+ cstore :: NativeLibraryKind ) ) ;
17331738 impl DepTrackingHash for SearchPaths {
17341739 fn hash ( & self , hasher : & mut DefaultHasher , _: ErrorOutputType ) {
17351740 let mut elems: Vec < _ > = self
@@ -1752,6 +1757,21 @@ mod dep_tracking {
17521757 }
17531758 }
17541759
1760+ impl < T1 , T2 , T3 > DepTrackingHash for ( T1 , T2 , T3 )
1761+ where T1 : DepTrackingHash ,
1762+ T2 : DepTrackingHash ,
1763+ T3 : DepTrackingHash
1764+ {
1765+ fn hash ( & self , hasher : & mut DefaultHasher , error_format : ErrorOutputType ) {
1766+ Hash :: hash ( & 0 , hasher) ;
1767+ DepTrackingHash :: hash ( & self . 0 , hasher, error_format) ;
1768+ Hash :: hash ( & 1 , hasher) ;
1769+ DepTrackingHash :: hash ( & self . 1 , hasher, error_format) ;
1770+ Hash :: hash ( & 2 , hasher) ;
1771+ DepTrackingHash :: hash ( & self . 2 , hasher, error_format) ;
1772+ }
1773+ }
1774+
17551775 // This is a stable hash because BTreeMap is a sorted container
17561776 pub fn stable_hash ( sub_hashes : BTreeMap < & ' static str , & DepTrackingHash > ,
17571777 hasher : & mut DefaultHasher ,
@@ -2155,29 +2175,37 @@ mod tests {
21552175 let mut v1 = super :: basic_options ( ) ;
21562176 let mut v2 = super :: basic_options ( ) ;
21572177 let mut v3 = super :: basic_options ( ) ;
2178+ let mut v4 = super :: basic_options ( ) ;
21582179
21592180 // Reference
2160- v1. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2161- ( String :: from( "b" ) , cstore:: NativeFramework ) ,
2162- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2181+ v1. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2182+ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ,
2183+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
21632184
21642185 // Change label
2165- v2. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2166- ( String :: from( "X" ) , cstore:: NativeFramework ) ,
2167- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2186+ v2. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2187+ ( String :: from( "X" ) , None , cstore:: NativeFramework ) ,
2188+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
21682189
21692190 // Change kind
2170- v3. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2171- ( String :: from( "b" ) , cstore:: NativeStatic ) ,
2172- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2191+ v3. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2192+ ( String :: from( "b" ) , None , cstore:: NativeStatic ) ,
2193+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
2194+
2195+ // Change new-name
2196+ v4. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2197+ ( String :: from( "b" ) , Some ( String :: from( "X" ) ) , cstore:: NativeFramework ) ,
2198+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
21732199
21742200 assert ! ( v1. dep_tracking_hash( ) != v2. dep_tracking_hash( ) ) ;
21752201 assert ! ( v1. dep_tracking_hash( ) != v3. dep_tracking_hash( ) ) ;
2202+ assert ! ( v1. dep_tracking_hash( ) != v4. dep_tracking_hash( ) ) ;
21762203
21772204 // Check clone
21782205 assert_eq ! ( v1. dep_tracking_hash( ) , v1. clone( ) . dep_tracking_hash( ) ) ;
21792206 assert_eq ! ( v2. dep_tracking_hash( ) , v2. clone( ) . dep_tracking_hash( ) ) ;
21802207 assert_eq ! ( v3. dep_tracking_hash( ) , v3. clone( ) . dep_tracking_hash( ) ) ;
2208+ assert_eq ! ( v4. dep_tracking_hash( ) , v4. clone( ) . dep_tracking_hash( ) ) ;
21812209 }
21822210
21832211 #[ test]
@@ -2187,17 +2215,17 @@ mod tests {
21872215 let mut v3 = super :: basic_options ( ) ;
21882216
21892217 // Reference
2190- v1. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2191- ( String :: from( "b" ) , cstore:: NativeFramework ) ,
2192- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2218+ v1. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2219+ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ,
2220+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
21932221
2194- v2. libs = vec ! [ ( String :: from( "b" ) , cstore:: NativeFramework ) ,
2195- ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2196- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2222+ v2. libs = vec ! [ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ,
2223+ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2224+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
21972225
2198- v3. libs = vec ! [ ( String :: from( "c" ) , cstore:: NativeUnknown ) ,
2199- ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2200- ( String :: from( "b" ) , cstore:: NativeFramework ) ] ;
2226+ v3. libs = vec ! [ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ,
2227+ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2228+ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ] ;
22012229
22022230 assert ! ( v1. dep_tracking_hash( ) == v2. dep_tracking_hash( ) ) ;
22032231 assert ! ( v1. dep_tracking_hash( ) == v3. dep_tracking_hash( ) ) ;
0 commit comments