@@ -27,6 +27,11 @@ fn host_libs() -> PathBuf {
27
27
}
28
28
}
29
29
30
+ #[ must_use]
31
+ fn target_libs ( ) -> Option < PathBuf > {
32
+ option_env ! ( "TARGET_LIBS" ) . map ( PathBuf :: from)
33
+ }
34
+
30
35
#[ must_use]
31
36
fn rustc_test_suite ( ) -> Option < PathBuf > {
32
37
option_env ! ( "RUSTC_TEST_SUITE" ) . map ( PathBuf :: from)
@@ -57,8 +62,14 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config {
57
62
// See https://github.com/rust-lang/rust-clippy/issues/4015.
58
63
let needs_disambiguation = [ "serde" , "regex" , "clippy_lints" ] ;
59
64
// This assumes that deps are compiled (they are for Cargo integration tests).
60
- let deps = std:: fs:: read_dir ( host_libs ( ) . join ( "deps" ) ) . unwrap ( ) ;
65
+ let deps = fs:: read_dir ( host_libs ( ) . join ( "deps" ) ) . unwrap ( ) ;
66
+ let deps: Vec < _ > = if let Some ( target_libs) = target_libs ( ) {
67
+ deps. chain ( fs:: read_dir ( target_libs. join ( "deps" ) ) . unwrap ( ) ) . collect ( )
68
+ } else {
69
+ deps. collect ( )
70
+ } ;
61
71
let disambiguated = deps
72
+ . into_iter ( )
62
73
. filter_map ( |dep| {
63
74
let path = dep. ok ( ) ?. path ( ) ;
64
75
let name = path. file_name ( ) ?. to_string_lossy ( ) ;
@@ -75,8 +86,9 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config {
75
86
. collect :: < Vec < _ > > ( ) ;
76
87
77
88
config. target_rustcflags = Some ( format ! (
78
- "-L {0} -L {0}/deps -Dwarnings -Zui-testing {1 }" ,
89
+ "-L {0} -L {0}/deps {1} -Dwarnings -Zui-testing {2 }" ,
79
90
host_libs( ) . display( ) ,
91
+ target_libs( ) . map_or_else( String :: new, |path| format!( "-L {0} -L {0}/deps" , path. display( ) ) ) ,
80
92
disambiguated. join( " " )
81
93
) ) ;
82
94
0 commit comments