@@ -262,7 +262,7 @@ top_level_options!(
262
262
// much sense: The search path can stay the same while the
263
263
// things discovered there might have changed on disk.
264
264
search_paths: SearchPaths [ TRACKED ] ,
265
- libs: Vec <( String , cstore:: NativeLibraryKind ) > [ TRACKED ] ,
265
+ libs: Vec <( String , Option < String > , cstore:: NativeLibraryKind ) > [ TRACKED ] ,
266
266
maybe_sysroot: Option <PathBuf > [ TRACKED ] ,
267
267
268
268
target_triple: String [ TRACKED ] ,
@@ -1439,6 +1439,8 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1439
1439
}
1440
1440
1441
1441
let libs = matches. opt_strs ( "l" ) . into_iter ( ) . map ( |s| {
1442
+ // Parse string of the form "[KIND=]lib[:new_name]",
1443
+ // where KIND is one of "dylib", "framework", "static".
1442
1444
let mut parts = s. splitn ( 2 , '=' ) ;
1443
1445
let kind = parts. next ( ) . unwrap ( ) ;
1444
1446
let ( name, kind) = match ( parts. next ( ) , kind) {
@@ -1452,7 +1454,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1452
1454
s) ) ;
1453
1455
}
1454
1456
} ;
1455
- ( name. to_string ( ) , kind)
1457
+ let mut name_parts = name. splitn ( 2 , ':' ) ;
1458
+ let name = name_parts. next ( ) . unwrap ( ) ;
1459
+ let new_name = name_parts. next ( ) ;
1460
+ ( name. to_string ( ) , new_name. map ( |n| n. to_string ( ) ) , kind)
1456
1461
} ) . collect ( ) ;
1457
1462
1458
1463
let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
@@ -1716,8 +1721,8 @@ mod dep_tracking {
1716
1721
impl_dep_tracking_hash_for_sortable_vec_of ! ( String ) ;
1717
1722
impl_dep_tracking_hash_for_sortable_vec_of ! ( CrateType ) ;
1718
1723
impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , lint:: Level ) ) ;
1719
- impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , cstore :: NativeLibraryKind ) ) ;
1720
-
1724
+ impl_dep_tracking_hash_for_sortable_vec_of ! ( ( String , Option < String > ,
1725
+ cstore :: NativeLibraryKind ) ) ;
1721
1726
impl DepTrackingHash for SearchPaths {
1722
1727
fn hash ( & self , hasher : & mut DefaultHasher , _: ErrorOutputType ) {
1723
1728
let mut elems: Vec < _ > = self
@@ -1740,6 +1745,21 @@ mod dep_tracking {
1740
1745
}
1741
1746
}
1742
1747
1748
+ impl < T1 , T2 , T3 > DepTrackingHash for ( T1 , T2 , T3 )
1749
+ where T1 : DepTrackingHash ,
1750
+ T2 : DepTrackingHash ,
1751
+ T3 : DepTrackingHash
1752
+ {
1753
+ fn hash ( & self , hasher : & mut DefaultHasher , error_format : ErrorOutputType ) {
1754
+ Hash :: hash ( & 0 , hasher) ;
1755
+ DepTrackingHash :: hash ( & self . 0 , hasher, error_format) ;
1756
+ Hash :: hash ( & 1 , hasher) ;
1757
+ DepTrackingHash :: hash ( & self . 1 , hasher, error_format) ;
1758
+ Hash :: hash ( & 2 , hasher) ;
1759
+ DepTrackingHash :: hash ( & self . 2 , hasher, error_format) ;
1760
+ }
1761
+ }
1762
+
1743
1763
// This is a stable hash because BTreeMap is a sorted container
1744
1764
pub fn stable_hash ( sub_hashes : BTreeMap < & ' static str , & DepTrackingHash > ,
1745
1765
hasher : & mut DefaultHasher ,
@@ -2143,29 +2163,37 @@ mod tests {
2143
2163
let mut v1 = super :: basic_options ( ) ;
2144
2164
let mut v2 = super :: basic_options ( ) ;
2145
2165
let mut v3 = super :: basic_options ( ) ;
2166
+ let mut v4 = super :: basic_options ( ) ;
2146
2167
2147
2168
// Reference
2148
- v1. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2149
- ( String :: from( "b" ) , cstore:: NativeFramework ) ,
2150
- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2169
+ v1. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2170
+ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ,
2171
+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
2151
2172
2152
2173
// Change label
2153
- v2. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2154
- ( String :: from( "X" ) , cstore:: NativeFramework ) ,
2155
- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2174
+ v2. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2175
+ ( String :: from( "X" ) , None , cstore:: NativeFramework ) ,
2176
+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
2156
2177
2157
2178
// Change kind
2158
- v3. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2159
- ( String :: from( "b" ) , cstore:: NativeStatic ) ,
2160
- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2179
+ v3. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2180
+ ( String :: from( "b" ) , None , cstore:: NativeStatic ) ,
2181
+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
2182
+
2183
+ // Change new-name
2184
+ v4. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2185
+ ( String :: from( "b" ) , Some ( String :: from( "X" ) ) , cstore:: NativeFramework ) ,
2186
+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
2161
2187
2162
2188
assert ! ( v1. dep_tracking_hash( ) != v2. dep_tracking_hash( ) ) ;
2163
2189
assert ! ( v1. dep_tracking_hash( ) != v3. dep_tracking_hash( ) ) ;
2190
+ assert ! ( v1. dep_tracking_hash( ) != v4. dep_tracking_hash( ) ) ;
2164
2191
2165
2192
// Check clone
2166
2193
assert_eq ! ( v1. dep_tracking_hash( ) , v1. clone( ) . dep_tracking_hash( ) ) ;
2167
2194
assert_eq ! ( v2. dep_tracking_hash( ) , v2. clone( ) . dep_tracking_hash( ) ) ;
2168
2195
assert_eq ! ( v3. dep_tracking_hash( ) , v3. clone( ) . dep_tracking_hash( ) ) ;
2196
+ assert_eq ! ( v4. dep_tracking_hash( ) , v4. clone( ) . dep_tracking_hash( ) ) ;
2169
2197
}
2170
2198
2171
2199
#[ test]
@@ -2175,17 +2203,17 @@ mod tests {
2175
2203
let mut v3 = super :: basic_options ( ) ;
2176
2204
2177
2205
// Reference
2178
- v1. libs = vec ! [ ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2179
- ( String :: from( "b" ) , cstore:: NativeFramework ) ,
2180
- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2206
+ v1. libs = vec ! [ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2207
+ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ,
2208
+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
2181
2209
2182
- v2. libs = vec ! [ ( String :: from( "b" ) , cstore:: NativeFramework ) ,
2183
- ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2184
- ( String :: from( "c" ) , cstore:: NativeUnknown ) ] ;
2210
+ v2. libs = vec ! [ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ,
2211
+ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2212
+ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ] ;
2185
2213
2186
- v3. libs = vec ! [ ( String :: from( "c" ) , cstore:: NativeUnknown ) ,
2187
- ( String :: from( "a" ) , cstore:: NativeStatic ) ,
2188
- ( String :: from( "b" ) , cstore:: NativeFramework ) ] ;
2214
+ v3. libs = vec ! [ ( String :: from( "c" ) , None , cstore:: NativeUnknown ) ,
2215
+ ( String :: from( "a" ) , None , cstore:: NativeStatic ) ,
2216
+ ( String :: from( "b" ) , None , cstore:: NativeFramework ) ] ;
2189
2217
2190
2218
assert ! ( v1. dep_tracking_hash( ) == v2. dep_tracking_hash( ) ) ;
2191
2219
assert ! ( v1. dep_tracking_hash( ) == v3. dep_tracking_hash( ) ) ;
0 commit comments