mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
fix: doctest searches native libs in build script outputs
HACK: `rustdoc --test` not only compiles but executes doctests. Ideally only execution phase should have search paths appended, so the executions can find native libs just like other tests. However, there is no way to separate these two phase, so this hack is added for both phases.
This commit is contained in:
parent
0e8a67fde3
commit
34215b1b4a
@ -293,6 +293,18 @@ impl<'gctx> Compilation<'gctx> {
|
||||
) -> CargoResult<ProcessBuilder> {
|
||||
let mut search_path = Vec::new();
|
||||
if tool_kind.is_rustc_tool() {
|
||||
if matches!(tool_kind, ToolKind::Rustdoc) {
|
||||
// HACK: `rustdoc --test` not only compiles but executes doctests.
|
||||
// Ideally only execution phase should have search paths appended,
|
||||
// so the executions can find native libs just like other tests.
|
||||
// However, there is no way to separate these two phase, so this
|
||||
// hack is added for both phases.
|
||||
// TODO: handle doctest-xcompile
|
||||
search_path.extend(super::filter_dynamic_search_path(
|
||||
self.native_dirs.iter(),
|
||||
&self.root_output[&CompileKind::Host],
|
||||
));
|
||||
}
|
||||
search_path.push(self.deps_output[&CompileKind::Host].clone());
|
||||
} else {
|
||||
search_path.extend(super::filter_dynamic_search_path(
|
||||
|
@ -2801,8 +2801,8 @@ fn doctest_with_library_paths() {
|
||||
pub fn assert_search_path() {{
|
||||
let search_path = std::env::var_os("{}").unwrap();
|
||||
let paths = std::env::split_paths(&search_path).collect::<Vec<_>>();
|
||||
assert!(!paths.contains(&r#"{}"#.into()));
|
||||
assert!(!paths.contains(&r#"{}"#.into()));
|
||||
assert!(paths.contains(&r#"{}"#.into()));
|
||||
assert!(paths.contains(&r#"{}"#.into()));
|
||||
}}
|
||||
"##,
|
||||
dylib_path_envvar(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user