File tree 2 files changed +62
-1
lines changed 2 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -193,8 +193,8 @@ impl<'cfg> Compilation<'cfg> {
193
193
} else {
194
194
let mut search_path =
195
195
super :: filter_dynamic_search_path ( self . native_dirs . iter ( ) , & self . root_output ) ;
196
- search_path. push ( self . root_output . clone ( ) ) ;
197
196
search_path. push ( self . deps_output . clone ( ) ) ;
197
+ search_path. push ( self . root_output . clone ( ) ) ;
198
198
search_path. extend ( self . target_dylib_path . clone ( ) ) ;
199
199
search_path
200
200
} ;
Original file line number Diff line number Diff line change @@ -1669,3 +1669,64 @@ fn all_features_all_crates() {
1669
1669
1670
1670
p. cargo ( "build --all-features --all" ) . run ( ) ;
1671
1671
}
1672
+
1673
+ #[ test]
1674
+ fn feature_off_dylib ( ) {
1675
+ let p = project ( )
1676
+ . file (
1677
+ "Cargo.toml" ,
1678
+ r#"
1679
+ [workspace]
1680
+ members = ["bar"]
1681
+
1682
+ [package]
1683
+ name = "foo"
1684
+ version = "0.0.1"
1685
+
1686
+ [lib]
1687
+ crate-type = ["dylib"]
1688
+
1689
+ [features]
1690
+ f1 = []
1691
+ "# ,
1692
+ )
1693
+ . file (
1694
+ "src/lib.rs" ,
1695
+ r#"
1696
+ pub fn hello() -> &'static str {
1697
+ if cfg!(feature = "f1") {
1698
+ "f1"
1699
+ } else {
1700
+ "no f1"
1701
+ }
1702
+ }
1703
+ "# ,
1704
+ )
1705
+ . file (
1706
+ "bar/Cargo.toml" ,
1707
+ r#"
1708
+ [package]
1709
+ name = "bar"
1710
+ version = "0.0.1"
1711
+
1712
+ [dependencies]
1713
+ foo = { path = ".." }
1714
+ "# ,
1715
+ )
1716
+ . file (
1717
+ "bar/src/main.rs" ,
1718
+ r#"
1719
+ extern crate foo;
1720
+
1721
+ fn main() {
1722
+ assert_eq!(foo::hello(), "no f1");
1723
+ }
1724
+ "# ,
1725
+ )
1726
+ . build ( ) ;
1727
+
1728
+ // Build the dylib with `f1` feature.
1729
+ p. cargo ( "build --features f1" ) . run ( ) ;
1730
+ // Check that building without `f1` uses a dylib without `f1`.
1731
+ p. cargo ( "run -p bar" ) . run ( ) ;
1732
+ }
You can’t perform that action at this time.
0 commit comments