mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 03:32:39 +00:00
Remove find_host_deps and use Compilation field.
This patch removes the addition of the find_host_deps() function by adding a host_deps_output field to the Compilation struct instead. The test case is altered to not use an external crate from crates.io but instead use the Package.publish(..) method.
This commit is contained in:
parent
2b7f37b5a2
commit
3b5ec888ff
|
@ -28,9 +28,13 @@ pub struct Compilation<'cfg> {
|
|||
/// Root output directory (for the local package's artifacts)
|
||||
pub root_output: PathBuf,
|
||||
|
||||
/// Output directory for rust dependencies
|
||||
/// Output directory for rust dependencies.
|
||||
/// May be for the host or for a specific target.
|
||||
pub deps_output: PathBuf,
|
||||
|
||||
/// Output directory for the rust host dependencies.
|
||||
pub host_deps_output: PathBuf,
|
||||
|
||||
/// Library search path for compiler plugins and build scripts
|
||||
/// which have dynamic dependencies.
|
||||
pub plugins_dylib_path: PathBuf,
|
||||
|
@ -64,6 +68,7 @@ impl<'cfg> Compilation<'cfg> {
|
|||
native_dirs: HashSet::new(), // TODO: deprecated, remove
|
||||
root_output: PathBuf::from("/"),
|
||||
deps_output: PathBuf::from("/"),
|
||||
host_deps_output: PathBuf::from("/"),
|
||||
plugins_dylib_path: PathBuf::from("/"),
|
||||
host_dylib_path: None,
|
||||
target_dylib_path: None,
|
||||
|
|
|
@ -176,6 +176,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
|||
}
|
||||
|
||||
self.compilation.plugins_dylib_path = self.host.deps().to_path_buf();
|
||||
self.compilation.host_deps_output = self.host.deps().to_path_buf();
|
||||
|
||||
let layout = self.target.as_ref().unwrap_or(&self.host);
|
||||
self.compilation.root_output = layout.dest().to_path_buf();
|
||||
|
|
|
@ -126,7 +126,6 @@ fn run_doc_tests(options: &TestOptions,
|
|||
-> CargoResult<(Test, Vec<ProcessError>)> {
|
||||
let mut errors = Vec::new();
|
||||
let config = options.compile_opts.config;
|
||||
let host_deps = find_host_deps(options, compilation);
|
||||
|
||||
// We don't build/rust doctests if target != host
|
||||
if config.rustc()?.host != compilation.target {
|
||||
|
@ -145,17 +144,22 @@ fn run_doc_tests(options: &TestOptions,
|
|||
p.arg("--test").arg(lib)
|
||||
.arg("--crate-name").arg(&crate_name);
|
||||
|
||||
p.arg("-L").arg(&host_deps);
|
||||
|
||||
for &rust_dep in &[&compilation.deps_output] {
|
||||
let mut arg = OsString::from("dependency=");
|
||||
arg.push(rust_dep);
|
||||
p.arg("-L").arg(arg);
|
||||
}
|
||||
|
||||
for native_dep in compilation.native_dirs.iter() {
|
||||
p.arg("-L").arg(native_dep);
|
||||
}
|
||||
|
||||
for &host_rust_dep in &[&compilation.host_deps_output] {
|
||||
let mut arg = OsString::from("dependency=");
|
||||
arg.push(host_rust_dep);
|
||||
p.arg("-L").arg(arg);
|
||||
}
|
||||
|
||||
for arg in test_args {
|
||||
p.arg("--test-args").arg(arg);
|
||||
}
|
||||
|
@ -201,24 +205,3 @@ fn run_doc_tests(options: &TestOptions,
|
|||
}
|
||||
Ok((Test::Doc, errors))
|
||||
}
|
||||
|
||||
fn find_host_deps(options: &TestOptions, compilation: &Compilation) -> OsString {
|
||||
let build_type = if options.compile_opts.release { "release" } else { "debug" };
|
||||
let mut dir = compilation.root_output.clone();
|
||||
|
||||
// first pop off the build_type
|
||||
dir.pop();
|
||||
// if we see the target next, pop it off
|
||||
let target: &OsStr = compilation.target.as_ref();
|
||||
if dir.file_name().unwrap() == target {
|
||||
dir.pop();
|
||||
}
|
||||
// push the build_type back on
|
||||
dir.push(build_type);
|
||||
// and we are looking for the deps directory
|
||||
dir.push("deps");
|
||||
|
||||
let mut host_deps = OsString::from("dependency=");
|
||||
host_deps.push(dir);
|
||||
host_deps
|
||||
}
|
||||
|
|
|
@ -2816,10 +2816,10 @@ fn find_dependency_of_proc_macro_dependency_with_target() {
|
|||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
base64 = "^0.6"
|
||||
dep_of_proc_macro_dep = "^0.1"
|
||||
"#)
|
||||
.file("proc_macro_dep/src/lib.rs", r#"
|
||||
extern crate base64;
|
||||
extern crate dep_of_proc_macro_dep;
|
||||
extern crate proc_macro;
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
|
@ -2828,6 +2828,7 @@ fn find_dependency_of_proc_macro_dependency_with_target() {
|
|||
"".parse().unwrap()
|
||||
}
|
||||
"#);
|
||||
Package::new("dep_of_proc_macro_dep", "0.1.0").publish();
|
||||
workspace.build();
|
||||
assert_that(workspace.cargo("test").arg("--all").arg("--target").arg(rustc_host()),
|
||||
execs().with_status(0));
|
||||
|
|
Loading…
Reference in a new issue