@@ -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 ] ,
@@ -1449,6 +1449,8 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1449
1449
}
1450
1450
1451
1451
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".
1452
1454
let mut parts = s. splitn ( 2 , '=' ) ;
1453
1455
let kind = parts. next ( ) . unwrap ( ) ;
1454
1456
let ( name, kind) = match ( parts. next ( ) , kind) {
@@ -1462,7 +1464,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1462
1464
s) ) ;
1463
1465
}
1464
1466
} ;
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)
1466
1471
} ) . collect ( ) ;
1467
1472
1468
1473
let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
@@ -1728,8 +1733,8 @@ mod dep_tracking {
1728
1733
impl_dep_tracking_hash_for_sortable_vec_of ! ( String ) ;
1729
1734
impl_dep_tracking_hash_for_sortable_vec_of ! ( CrateType ) ;
1730
1735
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 ) ) ;
1733
1738
impl DepTrackingHash for SearchPaths {
1734
1739
fn hash ( & self , hasher : & mut DefaultHasher , _: ErrorOutputType ) {
1735
1740
let mut elems: Vec < _ > = self
@@ -1752,6 +1757,21 @@ mod dep_tracking {
1752
1757
}
1753
1758
}
1754
1759
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
+
1755
1775
// This is a stable hash because BTreeMap is a sorted container
1756
1776
pub fn stable_hash ( sub_hashes : BTreeMap < & ' static str , & DepTrackingHash > ,
1757
1777
hasher : & mut DefaultHasher ,
@@ -2155,29 +2175,37 @@ mod tests {
2155
2175
let mut v1 = super :: basic_options ( ) ;
2156
2176
let mut v2 = super :: basic_options ( ) ;
2157
2177
let mut v3 = super :: basic_options ( ) ;
2178
+ let mut v4 = super :: basic_options ( ) ;
2158
2179
2159
2180
// 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 ) ] ;
2163
2184
2164
2185
// 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 ) ] ;
2168
2189
2169
2190
// 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 ) ] ;
2173
2199
2174
2200
assert ! ( v1. dep_tracking_hash( ) != v2. dep_tracking_hash( ) ) ;
2175
2201
assert ! ( v1. dep_tracking_hash( ) != v3. dep_tracking_hash( ) ) ;
2202
+ assert ! ( v1. dep_tracking_hash( ) != v4. dep_tracking_hash( ) ) ;
2176
2203
2177
2204
// Check clone
2178
2205
assert_eq ! ( v1. dep_tracking_hash( ) , v1. clone( ) . dep_tracking_hash( ) ) ;
2179
2206
assert_eq ! ( v2. dep_tracking_hash( ) , v2. clone( ) . dep_tracking_hash( ) ) ;
2180
2207
assert_eq ! ( v3. dep_tracking_hash( ) , v3. clone( ) . dep_tracking_hash( ) ) ;
2208
+ assert_eq ! ( v4. dep_tracking_hash( ) , v4. clone( ) . dep_tracking_hash( ) ) ;
2181
2209
}
2182
2210
2183
2211
#[ test]
@@ -2187,17 +2215,17 @@ mod tests {
2187
2215
let mut v3 = super :: basic_options ( ) ;
2188
2216
2189
2217
// 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 ) ] ;
2193
2221
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 ) ] ;
2197
2225
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 ) ] ;
2201
2229
2202
2230
assert ! ( v1. dep_tracking_hash( ) == v2. dep_tracking_hash( ) ) ;
2203
2231
assert ! ( v1. dep_tracking_hash( ) == v3. dep_tracking_hash( ) ) ;
0 commit comments