From 606a7cb745b0b61285015a66f8b581c5b6cc270f Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Sat, 29 Aug 2015 11:20:13 +0200 Subject: [PATCH 0001/3888] path: do not recurse into hidden/dot directories Cargo recursively looks for TOML manifest into child directories, sometimes getting into unrelated files when exploring hidden directories (eg. quilt .pc). This commit lets cargo skip dot directories, to partially avoid the issues described in #1423. Signed-off-by: Luca Bruno --- src/cargo/ops/cargo_read_manifest.rs | 5 +++-- src/cargo/sources/path.rs | 15 ++++++++++----- tests/test_cargo_compile.rs | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 123a92039c1..741445510b9 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -43,8 +43,9 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config) try!(walk(path, &mut |dir| { trace!("looking for child package: {}", dir.display()); - // Don't recurse into git databases - if dir.file_name().and_then(|s| s.to_str()) == Some(".git") { + // Don't recurse into hidden/dot directories + let name = dir.file_name().and_then(|s| s.to_str()); + if name.map(|s| s.starts_with(".")) == Some(true) { return Ok(false) } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 0e3668b42b4..0bca3de26f5 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -255,11 +255,16 @@ impl<'cfg> PathSource<'cfg> { } for dir in try!(fs::read_dir(path)) { let dir = try!(dir).path(); - match (is_root, dir.file_name().and_then(|s| s.to_str())) { - (_, Some(".git")) | - (true, Some("target")) | - (true, Some("Cargo.lock")) => continue, - _ => {} + let name = dir.file_name().and_then(|s| s.to_str()); + // Skip dotfile directories + if name.map(|s| s.starts_with(".")) == Some(true) { + continue + } else if is_root { + // Skip cargo artifacts + match name { + Some("target") | Some("Cargo.lock") => continue, + _ => {} + } } try!(PathSource::walk(&dir, ret, false, filter)); } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index ca147db349b..62dfd76f2c2 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1828,6 +1828,24 @@ test!(ignore_dotfile { execs().with_status(0)); }); +test!(ignore_dotdirs { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/bin/a.rs", "fn main() {}") + .file(".git/Cargo.toml", "") + .file(".pc/dummy-fix.patch/Cargo.toml", ""); + p.build(); + + assert_that(p.cargo("build"), + execs().with_status(0)); +}); + + test!(custom_target_dir { let p = project("foo") .file("Cargo.toml", r#" From d86e7bd0c555d8c48d19f5a965f74c6630ecde29 Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Thu, 3 Sep 2015 04:59:13 +0800 Subject: [PATCH 0002/3888] avoid warning when cargo not found --- src/etc/cargo.bashcomp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh index 2d8a421a6cf..14540ca14b4 100644 --- a/src/etc/cargo.bashcomp.sh +++ b/src/etc/cargo.bashcomp.sh @@ -81,7 +81,7 @@ _cargo() } && complete -F _cargo cargo -__cargo_commands=$(cargo --list | tail -n +2) +__cargo_commands=$(cargo --list 2>/dev/null | tail -n +2) _locate_manifest(){ local manifest=`cargo locate-project 2>/dev/null` From ace10f8c509b2808ec83797950df84ddf9e84270 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 3 Sep 2015 12:28:30 -0400 Subject: [PATCH 0003/3888] Fix syntax in build-script This has changed, apparently. --- src/doc/build-script.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/build-script.md b/src/doc/build-script.md index c4b7ec87592..8e28e26004f 100644 --- a/src/doc/build-script.md +++ b/src/doc/build-script.md @@ -329,7 +329,7 @@ portable, and standardized. For example, the build script could be written as: extern crate gcc; fn main() { - gcc::compile_library("libhello.a", &["src/hello.c"]).unwrap(); + gcc::compile_library("libhello.a", &["src/hello.c"]); } ``` From 3355a354f797255f45312bcd59240b0913128d5f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 4 Sep 2015 10:33:11 -0700 Subject: [PATCH 0004/3888] Fix documenting target-specific dependencies for real It's possible to have multiple dependencies of the same name for a project if a dependency shows up multiple times as a target-specific dependency. This means that we can't just find the first one with the relevant name and assume it's the right one, we instead need to check all of them. --- src/cargo/ops/cargo_rustc/context.rs | 7 +++--- tests/test_cargo_doc.rs | 34 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 44839f7c9bd..5cfe983593d 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -417,10 +417,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let deps = deps.flat_map(|a| a).map(|id| { self.get_package(id) }).filter(|dep| { - let dep = pkg.dependencies().iter().find(|d| { + pkg.dependencies().iter().filter(|d| { d.name() == dep.name() - }).unwrap(); - dep.is_transitive() && self.dep_platform_activated(dep, kind) + }).any(|dep| { + dep.is_transitive() && self.dep_platform_activated(dep, kind) + }) }).filter_map(|dep| { dep.targets().iter().find(|t| t.is_lib()).map(|t| (dep, t)) }); diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 5d6d8a90e1f..87dd0ed2541 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -313,3 +313,37 @@ test!(target_specific_not_documented { assert_that(p.cargo_process("doc"), execs().with_status(0)); }); + +test!(target_specific_documented { + let p = project("foo") + .file("Cargo.toml", &format!(r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [target.foo.dependencies] + a = {{ path = "a" }} + [target.{}.dependencies] + a = {{ path = "a" }} + "#, ::rustc_host())) + .file("src/lib.rs", " + extern crate a; + + /// test + pub fn foo() {} + ") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", " + /// test + pub fn foo() {} + "); + + assert_that(p.cargo_process("doc"), + execs().with_status(0)); +}); From 610641a28cbcf824f3025926b59b5cd4e490a0f6 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sun, 6 Sep 2015 15:52:13 -0400 Subject: [PATCH 0005/3888] If --vcs flag specified, use vcs even if under an existing repo Fixes #1210. If either `--vcs git` or `--vcs hg` is specified, assume that means the user really wants the new project to use that VCS, even if the project's location would be beneath an existing repository. --- src/cargo/ops/cargo_new.rs | 2 +- tests/test_cargo_new.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index c8b2fdca6d4..5b36097b394 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -118,7 +118,7 @@ fn mk(config: &Config, path: &Path, name: &str, let vcs = match (opts.version_control, cfg.version_control, in_existing_vcs_repo) { (None, None, false) => VersionControl::Git, (None, Some(option), false) => option, - (Some(option), _, false) => option, + (Some(option), _, _) => option, (_, _, true) => VersionControl::NoVcs, }; diff --git a/tests/test_cargo_new.rs b/tests/test_cargo_new.rs index 981b75a3218..398e07bec3f 100644 --- a/tests/test_cargo_new.rs +++ b/tests/test_cargo_new.rs @@ -257,6 +257,23 @@ test!(subpackage_no_git { is_not(existing_file())); }); +test!(subpackage_git_with_vcs_arg { + assert_that(cargo_process("new").arg("foo").env("USER", "foo"), + execs().with_status(0)); + + let subpackage = paths::root().join("foo").join("components"); + fs::create_dir(&subpackage).unwrap(); + assert_that(cargo_process("new").arg("foo/components/subcomponent") + .arg("--vcs").arg("git") + .env("USER", "foo"), + execs().with_status(0)); + + assert_that(&paths::root().join("foo/components/subcomponent/.git"), + existing_dir()); + assert_that(&paths::root().join("foo/components/subcomponent/.gitignore"), + existing_file()); +}); + test!(unknown_flags { assert_that(cargo_process("new").arg("foo").arg("--flag"), execs().with_status(1) From 53fd71c1cca66e29de780e7b02dbdb21669491b0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 8 Sep 2015 10:39:40 -0700 Subject: [PATCH 0006/3888] Update curl bindings Includes a fix for #1937 to not panic on downloading crates on newer OSX versions. Closes #1937 --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8ec3f854a6..f835ae19ad0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "crates-io 0.1.0", - "curl 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.70 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -71,13 +71,13 @@ dependencies = [ name = "crates-io" version = "0.1.0" dependencies = [ - "curl 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -162,7 +162,7 @@ name = "git2-curl" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", From a61a2a42f98af3ffedd446eea0b32c864e3406e8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 4 Sep 2015 17:09:24 -0700 Subject: [PATCH 0007/3888] Add --release flag to `cargo doc` While this may not necessarily make sense all the time, this enables Cargo to not rebuild anything if a `cargo build --release` was previously executed. --- src/bin/doc.rs | 4 +++- tests/test_cargo_doc.rs | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/bin/doc.rs b/src/bin/doc.rs index 6bc43a86b04..8fa2bae7cc0 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -12,6 +12,7 @@ struct Options { flag_no_deps: bool, flag_open: bool, flag_verbose: bool, + flag_release: bool, flag_quiet: bool, flag_color: Option, flag_package: Option, @@ -29,6 +30,7 @@ Options: -p SPEC, --package SPEC Package to document --no-deps Don't build documentation for dependencies -j N, --jobs N The number of jobs to run in parallel + --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple @@ -63,7 +65,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { spec: options.flag_package.as_ref().map(|s| &s[..]), exec_engine: None, filter: ops::CompileFilter::Everything, - release: false, + release: options.flag_release, mode: ops::CompileMode::Doc { deps: !options.flag_no_deps, }, diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 87dd0ed2541..42c7a950641 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -1,5 +1,5 @@ use support::{project, execs, path2url}; -use support::COMPILING; +use support::{COMPILING, RUNNING}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; fn setup() { @@ -347,3 +347,23 @@ test!(target_specific_documented { assert_that(p.cargo_process("doc"), execs().with_status(0)); }); + +test!(doc_release { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/lib.rs", ""); + + assert_that(p.cargo_process("build").arg("--release"), + execs().with_status(0)); + assert_that(p.cargo("doc").arg("--release").arg("-v"), + execs().with_status(0) + .with_stdout(&format!("\ +{compiling} foo v0.0.1 ([..]) +{running} `rustdoc src[..]lib.rs [..]` +", compiling = COMPILING, running = RUNNING))); +}); From 3141e59d410d73c6ac059f3fd7ba81770d04838a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 4 Sep 2015 17:30:59 -0700 Subject: [PATCH 0008/3888] Don't document build dependencies They're not actually relevant to the documentation, so omit them. --- src/cargo/ops/cargo_rustc/context.rs | 6 +++++- tests/test_cargo_doc.rs | 31 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 5cfe983593d..93ef0357cd3 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -8,6 +8,7 @@ use regex::Regex; use core::{SourceMap, Package, PackageId, PackageSet, Resolve, Target, Profile}; use core::{TargetKind, LibKind, Profiles, Metadata, Dependency}; +use core::dependency::Kind as DepKind; use util::{self, CargoResult, ChainError, internal, Config, profile}; use util::human; @@ -420,7 +421,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> { pkg.dependencies().iter().filter(|d| { d.name() == dep.name() }).any(|dep| { - dep.is_transitive() && self.dep_platform_activated(dep, kind) + match dep.kind() { + DepKind::Normal => self.dep_platform_activated(dep, kind), + _ => false, + } }) }).filter_map(|dep| { dep.targets().iter().find(|t| t.is_lib()).map(|t| (dep, t)) diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 42c7a950641..6def20ba21d 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -348,6 +348,37 @@ test!(target_specific_documented { execs().with_status(0)); }); +test!(no_document_build_deps { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [build-dependencies] + a = { path = "a" } + "#) + .file("src/lib.rs", " + pub fn foo() {} + ") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", " + /// ``` + /// ☃ + /// ``` + pub fn foo() {} + "); + + assert_that(p.cargo_process("doc"), + execs().with_status(0)); +}); + test!(doc_release { let p = project("foo") .file("Cargo.toml", r#" From 61e7fdeda6984a69929f292a7b8f4f4b8bf23271 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 8 Sep 2015 10:39:15 -0700 Subject: [PATCH 0009/3888] Don't capture rustdoc output for transitive deps We already started doing this for the compiler awhile back, so this just brings rustdoc up to the same parity --- src/cargo/ops/cargo_rustc/mod.rs | 24 ++++------------------ tests/test_cargo_doc.rs | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index ab0887864c9..a13a74dc00f 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve}; use core::{Profile, Profiles}; -use util::{self, CargoResult, human, caused_human}; +use util::{self, CargoResult, human}; use util::{Config, internal, ChainError, Fresh, profile, join_paths}; use self::job::{Job, Work}; @@ -533,31 +533,15 @@ fn rustdoc(package: &Package, target: &Target, profile: &Profile, trace!("commands={}", rustdoc); - let primary = package.package_id() == cx.resolve.root(); let name = package.name().to_string(); let desc = rustdoc.to_string(); let exec_engine = cx.exec_engine.clone(); Ok(Work::new(move |desc_tx| { desc_tx.send(desc).unwrap(); - if primary { - try!(exec_engine.exec(rustdoc).chain_error(|| { - human(format!("Could not document `{}`.", name)) - })) - } else { - try!(exec_engine.exec_with_output(rustdoc).and(Ok(())).map_err(|err| { - match err.exit { - Some(..) => { - caused_human(format!("Could not document `{}`.", - name), err) - } - None => { - caused_human("Failed to run rustdoc", err) - } - } - })) - } - Ok(()) + exec_engine.exec(rustdoc).chain_error(|| { + human(format!("Could not document `{}`.", name)) + }) })) } diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 6def20ba21d..57d37129d6c 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -1,3 +1,5 @@ +use std::str; + use support::{project, execs, path2url}; use support::{COMPILING, RUNNING}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; @@ -314,6 +316,38 @@ test!(target_specific_not_documented { execs().with_status(0)); }); +test!(output_not_captured { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a" } + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", " + /// ``` + /// ☃ + /// ``` + pub fn foo() {} + "); + + let output = p.cargo_process("doc").exec_with_output().err().unwrap() + .output.unwrap(); + let stderr = str::from_utf8(&output.stderr).unwrap(); + assert!(stderr.contains("☃"), "no snowman\n{}", stderr); + assert!(stderr.contains("unknown start of token"), "no message\n{}", stderr); +}); + test!(target_specific_documented { let p = project("foo") .file("Cargo.toml", &format!(r#" From 0cc9ac3784532d63b8db13821c8b7bacee7af89b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Sep 2015 15:44:43 -0700 Subject: [PATCH 0010/3888] Use a stamp file to protect against corrupt checkouts We already take this strategy for extracting tarballs from crates.io for example, so this just applies the same strategy to checkouts of git repos. Closes #1979 --- src/cargo/sources/git/utils.rs | 18 ++++++++++++++++-- tests/test_cargo_compile.rs | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 51f69a6d27e..f51b9dc97b9 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -1,6 +1,6 @@ use std::fmt; use std::path::{Path, PathBuf}; -use std::fs; +use std::fs::{self, File}; use rustc_serialize::{Encodable, Encoder}; use url::Url; @@ -267,7 +267,10 @@ impl<'a> GitCheckout<'a> { fn is_fresh(&self) -> bool { match self.repo.revparse_single("HEAD") { - Ok(head) => head.id().to_string() == self.revision.to_string(), + Ok(ref head) if head.id() == self.revision.0 => { + // See comments in reset() for why we check this + fs::metadata(self.location.join(".cargo-ok")).is_ok() + } _ => false, } } @@ -282,9 +285,20 @@ impl<'a> GitCheckout<'a> { } fn reset(&self) -> CargoResult<()> { + // If we're interrupted while performing this reset (e.g. we die because + // of a signal) Cargo needs to be sure to try to check out this repo + // again on the next go-round. + // + // To enable this we have a dummy file in our checkout, .cargo-ok, which + // if present means that the repo has been successfully reset and is + // ready to go. Hence if we start to do a reset, we make sure this file + // *doesn't* exist, and then once we're done we create the file. + let ok_file = self.location.join(".cargo-ok"); + let _ = fs::remove_file(&ok_file); info!("reset {} to {}", self.repo.path().display(), self.revision); let object = try!(self.repo.find_object(self.revision.0, None)); try!(self.repo.reset(&object, git2::ResetType::Hard, None)); + try!(File::create(ok_file)); Ok(()) } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 62dfd76f2c2..482a6dee442 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1508,7 +1508,7 @@ test!(cargo_platform_specific_dependency { execs().with_status(0)); assert_that(&p.bin("foo"), existing_file()); - assert_that(p.cargo_process("test"), + assert_that(p.cargo("test"), execs().with_status(0)); }); From 440616f7559d341cee60f39c8f0dc575a23c8fcc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Sep 2015 09:35:43 -0700 Subject: [PATCH 0011/3888] Bump to 0.6.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- Makefile.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f835ae19ad0..3d78596b9e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "cargo" -version = "0.5.0" +version = "0.6.0" dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 5c360c81df9..13f389c15c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [project] name = "cargo" -version = "0.5.0" +version = "0.6.0" authors = ["Yehuda Katz ", "Carl Lerche ", "Alex Crichton "] diff --git a/Makefile.in b/Makefile.in index 0dd5c2c88a1..9cc1993f23b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -CFG_RELEASE_NUM=0.5.0 +CFG_RELEASE_NUM=0.6.0 CFG_RELEASE_LABEL= include config.mk From 10bdc20f43f96871ef9f1633cef299c9b64e7b77 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 13:06:23 -0400 Subject: [PATCH 0012/3888] Update source when getting its root_package This way, callers who want source.root_package() don't have to remember to call source.update() before that. Since source.update() is a noop if the source has already been updated, there's not a reason I could see to raise an error instead of just calling it. The one remaining place that calls source.root_package() that is still calling source.update() immediately before is in bin/read_manifest, where the errors from update() are mapped to CliErrors. --- src/cargo/ops/cargo_clean.rs | 1 - src/cargo/ops/cargo_compile.rs | 2 -- src/cargo/ops/cargo_doc.rs | 2 -- src/cargo/ops/cargo_fetch.rs | 1 - src/cargo/ops/cargo_generate_lockfile.rs | 4 +--- src/cargo/ops/cargo_package.rs | 3 +-- src/cargo/ops/cargo_pkgid.rs | 3 +-- src/cargo/ops/cargo_run.rs | 2 -- src/cargo/ops/registry.rs | 3 --- src/cargo/sources/path.rs | 6 ++---- 10 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 03b0575556d..caae5e4f9c7 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -19,7 +19,6 @@ pub struct CleanOptions<'a> { pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), opts.config)); - try!(src.update()); let root = try!(src.root_package()); let target_dir = opts.config.target_dir(&root); diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 74d0b09423e..f177e5e7e4e 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -89,8 +89,6 @@ pub fn compile<'a>(manifest_path: &Path, let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), options.config)); - try!(source.update()); - // TODO: Move this into PathSource let package = try!(source.root_package()); debug!("loaded package; package={}", package); diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 8090a35fe18..763512caffc 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -4,7 +4,6 @@ use std::path::Path; use std::process::Command; use core::PackageIdSpec; -use core::source::Source; use ops; use sources::PathSource; use util::{CargoResult, human}; @@ -18,7 +17,6 @@ pub fn doc(manifest_path: &Path, options: &DocOptions) -> CargoResult<()> { let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), options.compile_opts.config)); - try!(source.update()); let package = try!(source.root_package()); let mut lib_names = HashSet::new(); diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index cbd3382f90d..34e6bb27d74 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -10,7 +10,6 @@ use util::{CargoResult, Config, human, ChainError}; pub fn fetch(manifest_path: &Path, config: &Config) -> CargoResult<()> { let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), config)); - try!(source.update()); let package = try!(source.root_package()); let mut registry = PackageRegistry::new(config); diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index f561664b876..c3de1dc435b 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -3,7 +3,7 @@ use std::path::Path; use core::PackageId; use core::registry::PackageRegistry; -use core::{Source, Resolve, SourceId}; +use core::{Resolve, SourceId}; use core::resolver::Method; use ops; use sources::{PathSource}; @@ -21,7 +21,6 @@ pub fn generate_lockfile(manifest_path: &Path, config: &Config) -> CargoResult<()> { let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), config)); - try!(source.update()); let package = try!(source.root_package()); let mut registry = PackageRegistry::new(config); registry.preload(package.package_id().source_id(), Box::new(source)); @@ -36,7 +35,6 @@ pub fn update_lockfile(manifest_path: &Path, opts: &UpdateOptions) -> CargoResult<()> { let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), opts.config)); - try!(source.update()); let package = try!(source.root_package()); let previous_resolve = match try!(ops::load_pkg_lockfile(&package)) { diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index bcd74f460a7..684c539fe04 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -6,7 +6,7 @@ use tar::Archive; use flate2::{GzBuilder, Compression}; use flate2::read::GzDecoder; -use core::{Source, SourceId, Package, PackageId}; +use core::{SourceId, Package, PackageId}; use sources::PathSource; use util::{self, CargoResult, human, internal, ChainError, Config}; use ops; @@ -29,7 +29,6 @@ pub fn package(manifest_path: &Path, metadata: bool) -> CargoResult> { let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), config)); - try!(src.update()); let pkg = try!(src.root_package()); if metadata { diff --git a/src/cargo/ops/cargo_pkgid.rs b/src/cargo/ops/cargo_pkgid.rs index d900510b380..9e982aa37cf 100644 --- a/src/cargo/ops/cargo_pkgid.rs +++ b/src/cargo/ops/cargo_pkgid.rs @@ -1,7 +1,7 @@ use std::path::Path; use ops; -use core::{Source, PackageIdSpec}; +use core::{PackageIdSpec}; use sources::{PathSource}; use util::{CargoResult, human, Config}; @@ -10,7 +10,6 @@ pub fn pkgid(manifest_path: &Path, config: &Config) -> CargoResult { let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(), config)); - try!(source.update()); let package = try!(source.root_package()); let lockfile = package.root().join("Cargo.lock"); diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 419a7ab155a..5db34762376 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -2,7 +2,6 @@ use std::path::Path; use ops::{self, ExecEngine, CompileFilter}; use util::{self, CargoResult, human, process, ProcessError}; -use core::source::Source; use sources::PathSource; pub fn run(manifest_path: &Path, @@ -11,7 +10,6 @@ pub fn run(manifest_path: &Path, let config = options.config; let mut src = try!(PathSource::for_path(&manifest_path.parent().unwrap(), config)); - try!(src.update()); let root = try!(src.root_package()); let mut bins = root.manifest().targets().iter().filter(|a| { diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 9f9b035f804..a81dda28ce3 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -33,7 +33,6 @@ pub fn publish(manifest_path: &Path, verify: bool) -> CargoResult<()> { let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), config)); - try!(src.update()); let pkg = try!(src.root_package()); let (mut registry, reg_id) = try!(registry(config, token, index)); @@ -266,7 +265,6 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> { let manifest_path = try!(find_root_manifest_for_cwd(None)); let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), config)); - try!(src.update()); let pkg = try!(src.root_package()); pkg.name().to_string() } @@ -329,7 +327,6 @@ pub fn yank(config: &Config, let manifest_path = try!(find_root_manifest_for_cwd(None)); let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), config)); - try!(src.update()); let pkg = try!(src.root_package()); pkg.name().to_string() } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 0bca3de26f5..8589836d288 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -46,12 +46,10 @@ impl<'cfg> PathSource<'cfg> { } } - pub fn root_package(&self) -> CargoResult { + pub fn root_package(&mut self) -> CargoResult { trace!("root_package; source={:?}", self); - if !self.updated { - return Err(internal("source has not been updated")) - } + try!(self.update()); match self.packages.iter().find(|p| p.root() == &*self.path) { Some(pkg) => Ok(pkg.clone()), From 2380e0d17664c862b59bc5db830395b5d2478a03 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 13:50:14 -0400 Subject: [PATCH 0013/3888] Extract contructor for Package where only root_package is needed There are many places where both source and its root_package() are used, but in these places, the only reason the source is created is to get to the root_package. This just extracts the source creation into a Package constructor for now, but I think this can be made to not use source at all. --- src/cargo/core/package.rs | 9 ++++++++- src/cargo/ops/cargo_clean.rs | 7 ++----- src/cargo/ops/cargo_doc.rs | 7 ++----- src/cargo/ops/cargo_pkgid.rs | 7 ++----- src/cargo/ops/cargo_run.rs | 6 ++---- src/cargo/ops/registry.rs | 14 ++++---------- 6 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index f71f5025e5d..1860257eaf8 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -6,9 +6,10 @@ use semver::Version; use core::{Dependency, Manifest, PackageId, Registry, Target, Summary, Metadata}; use core::dependency::SerializedDependency; -use util::{CargoResult, graph}; +use util::{CargoResult, graph, Config}; use rustc_serialize::{Encoder,Encodable}; use core::source::Source; +use sources::PathSource; /// Informations about a package that is available somewhere in the file system. /// @@ -58,6 +59,12 @@ impl Package { } } + pub fn for_path(manifest_path: &Path, config: &Config) -> CargoResult { + let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), + config)); + source.root_package() + } + pub fn dependencies(&self) -> &[Dependency] { self.manifest.dependencies() } pub fn manifest(&self) -> &Manifest { &self.manifest } pub fn manifest_path(&self) -> &Path { &self.manifest_path } diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index caae5e4f9c7..8a28168c9b6 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -3,9 +3,8 @@ use std::fs; use std::io::prelude::*; use std::path::Path; -use core::{PackageSet, Profiles, Profile}; +use core::{Package, PackageSet, Profiles, Profile}; use core::source::{Source, SourceMap}; -use sources::PathSource; use util::{CargoResult, human, ChainError, Config}; use ops::{self, Layout, Context, BuildConfig, Kind}; @@ -17,9 +16,7 @@ pub struct CleanOptions<'a> { /// Cleans the project from build artifacts. pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { - let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), - opts.config)); - let root = try!(src.root_package()); + let root = try!(Package::for_path(manifest_path, opts.config)); let target_dir = opts.config.target_dir(&root); // If we have a spec, then we need to delete some package,s otherwise, just diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 763512caffc..11e5d5bf736 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -3,9 +3,8 @@ use std::fs; use std::path::Path; use std::process::Command; -use core::PackageIdSpec; +use core::{Package, PackageIdSpec}; use ops; -use sources::PathSource; use util::{CargoResult, human}; pub struct DocOptions<'a> { @@ -15,9 +14,7 @@ pub struct DocOptions<'a> { pub fn doc(manifest_path: &Path, options: &DocOptions) -> CargoResult<()> { - let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), - options.compile_opts.config)); - let package = try!(source.root_package()); + let package = try!(Package::for_path(manifest_path, options.compile_opts.config)); let mut lib_names = HashSet::new(); let mut bin_names = HashSet::new(); diff --git a/src/cargo/ops/cargo_pkgid.rs b/src/cargo/ops/cargo_pkgid.rs index 9e982aa37cf..ab5cfe6911d 100644 --- a/src/cargo/ops/cargo_pkgid.rs +++ b/src/cargo/ops/cargo_pkgid.rs @@ -1,16 +1,13 @@ use std::path::Path; use ops; -use core::{PackageIdSpec}; -use sources::{PathSource}; +use core::{PackageIdSpec, Package}; use util::{CargoResult, human, Config}; pub fn pkgid(manifest_path: &Path, spec: Option<&str>, config: &Config) -> CargoResult { - let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(), - config)); - let package = try!(source.root_package()); + let package = try!(Package::for_path(manifest_path, config)); let lockfile = package.root().join("Cargo.lock"); let source_id = package.package_id().source_id(); diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 5db34762376..da576189a89 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -2,15 +2,13 @@ use std::path::Path; use ops::{self, ExecEngine, CompileFilter}; use util::{self, CargoResult, human, process, ProcessError}; -use sources::PathSource; +use core::Package; pub fn run(manifest_path: &Path, options: &ops::CompileOptions, args: &[String]) -> CargoResult> { let config = options.config; - let mut src = try!(PathSource::for_path(&manifest_path.parent().unwrap(), - config)); - let root = try!(src.root_package()); + let root = try!(Package::for_path(manifest_path, config)); let mut bins = root.manifest().targets().iter().filter(|a| { !a.is_lib() && !a.is_custom_build() && match options.filter { diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index a81dda28ce3..d526dc7fc36 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -15,7 +15,7 @@ use core::{Package, SourceId}; use core::dependency::Kind; use core::manifest::ManifestMetadata; use ops; -use sources::{PathSource, RegistrySource}; +use sources::{RegistrySource}; use util::config; use util::{CargoResult, human, ChainError, ToUrl}; use util::config::{Config, ConfigValue, Location}; @@ -31,9 +31,7 @@ pub fn publish(manifest_path: &Path, token: Option, index: Option, verify: bool) -> CargoResult<()> { - let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), - config)); - let pkg = try!(src.root_package()); + let pkg = try!(Package::for_path(&manifest_path, config)); let (mut registry, reg_id) = try!(registry(config, token, index)); try!(verify_dependencies(&pkg, ®_id)); @@ -263,9 +261,7 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> { Some(ref name) => name.clone(), None => { let manifest_path = try!(find_root_manifest_for_cwd(None)); - let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), - config)); - let pkg = try!(src.root_package()); + let pkg = try!(Package::for_path(&manifest_path, config)); pkg.name().to_string() } }; @@ -325,9 +321,7 @@ pub fn yank(config: &Config, Some(name) => name, None => { let manifest_path = try!(find_root_manifest_for_cwd(None)); - let mut src = try!(PathSource::for_path(manifest_path.parent().unwrap(), - config)); - let pkg = try!(src.root_package()); + let pkg = try!(Package::for_path(&manifest_path, config)); pkg.name().to_string() } }; From f8a0d1f3855780a70af7f8ee0b0f04cd274d3f1c Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 14:07:04 -0400 Subject: [PATCH 0014/3888] Remove dependency on Source if we only want a Package As alluded to in the previous commit, we don't actually need a Source at all in order to be able to get a Package given a manifest and a config. --- src/cargo/core/package.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 1860257eaf8..90c605512c9 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -4,12 +4,12 @@ use std::slice; use std::path::{Path, PathBuf}; use semver::Version; -use core::{Dependency, Manifest, PackageId, Registry, Target, Summary, Metadata}; +use core::{Dependency, Manifest, PackageId, SourceId, Registry, Target, Summary, Metadata}; +use ops; use core::dependency::SerializedDependency; use util::{CargoResult, graph, Config}; use rustc_serialize::{Encoder,Encodable}; use core::source::Source; -use sources::PathSource; /// Informations about a package that is available somewhere in the file system. /// @@ -60,9 +60,11 @@ impl Package { } pub fn for_path(manifest_path: &Path, config: &Config) -> CargoResult { - let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), - config)); - source.root_package() + let path = manifest_path.parent().unwrap(); + let source_id = try!(SourceId::for_path(path)); + let (pkg, _) = try!(ops::read_package(&manifest_path, &source_id, + config)); + Ok(pkg) } pub fn dependencies(&self) -> &[Dependency] { self.manifest.dependencies() } From cdff85f8d69ea948290b9d9825c9c53f2c4873d0 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 16:13:55 -0400 Subject: [PATCH 0015/3888] Remove registry preload and avoid updating sources prematurely instead So registry preloading was added[1] to avoid updating the root path multiple times unnecessarily, since that's an expensive operation. But with Package::from_path, we can get the root package just from a manifest and a config without having to update the whole path source. So now we don't have to remember to preload the registry if we've already updated a source and want to use the registry later. Instead, we just avoid loading the source initially and let the registry do it when it needs to -- which is now in resolve_with_previous. This does cause one tested error message to happen slightly later than it used to, but it still happens. [1] - ef8c651af --- src/cargo/core/registry.rs | 5 ----- src/cargo/ops/cargo_compile.rs | 15 ++------------- src/cargo/ops/cargo_fetch.rs | 9 ++------- src/cargo/ops/cargo_generate_lockfile.rs | 13 +++---------- src/cargo/ops/cargo_package.rs | 2 +- src/cargo/ops/resolve.rs | 3 +++ tests/test_cargo_compile_path_deps.rs | 8 ++++++-- 7 files changed, 17 insertions(+), 38 deletions(-) diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 273bb5ed56b..de00c40b5a6 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -147,11 +147,6 @@ impl<'cfg> PackageRegistry<'cfg> { Ok(()) } - pub fn preload(&mut self, id: &SourceId, source: Box) { - self.sources.insert(id, source); - self.source_ids.insert(id.clone(), (id.clone(), Kind::Locked)); - } - pub fn add_sources(&mut self, ids: &[SourceId]) -> CargoResult<()> { for id in ids.iter() { try!(self.load(id, Kind::Locked)); diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index f177e5e7e4e..e9191304417 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -32,7 +32,6 @@ use core::{Source, SourceId, PackageSet, Package, Target, PackageId}; use core::{Profile, TargetKind}; use core::resolver::Method; use ops::{self, BuildOutput, ExecEngine}; -use sources::{PathSource}; use util::config::{ConfigValue, Config}; use util::{CargoResult, internal, human, ChainError, profile}; @@ -87,20 +86,16 @@ pub fn compile<'a>(manifest_path: &Path, -> CargoResult> { debug!("compile; manifest-path={}", manifest_path.display()); - let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), - options.config)); - // TODO: Move this into PathSource - let package = try!(source.root_package()); + let package = try!(Package::for_path(manifest_path, options.config)); debug!("loaded package; package={}", package); for key in package.manifest().warnings().iter() { try!(options.config.shell().warn(key)) } - compile_pkg(&package, Some(Box::new(source)), options) + compile_pkg(&package, options) } pub fn compile_pkg<'a>(package: &Package, - source: Option>, options: &CompileOptions<'a>) -> CargoResult> { let CompileOptions { config, jobs, target, spec, features, @@ -125,12 +120,6 @@ pub fn compile_pkg<'a>(package: &Package, let (packages, resolve_with_overrides, sources) = { let mut registry = PackageRegistry::new(config); - if let Some(source) = source { - registry.preload(package.package_id().source_id(), source); - } else { - try!(registry.add_sources(&[package.package_id().source_id() - .clone()])); - } // First, resolve the package's *listed* dependencies, as well as // downloading and updating all remotes and such. diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index 34e6bb27d74..612d88c05ad 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -1,19 +1,14 @@ use std::path::Path; use core::registry::PackageRegistry; -use core::{Source, PackageId}; +use core::{Package, PackageId}; use ops; -use sources::PathSource; use util::{CargoResult, Config, human, ChainError}; /// Executes `cargo fetch`. pub fn fetch(manifest_path: &Path, config: &Config) -> CargoResult<()> { - let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), - config)); - let package = try!(source.root_package()); - + let package = try!(Package::for_path(manifest_path, config)); let mut registry = PackageRegistry::new(config); - registry.preload(package.package_id().source_id(), Box::new(source)); let resolve = try!(ops::resolve_pkg(&mut registry, &package)); let ids: Vec = resolve.iter().cloned().collect(); diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index c3de1dc435b..5edca1acef7 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -3,10 +3,9 @@ use std::path::Path; use core::PackageId; use core::registry::PackageRegistry; -use core::{Resolve, SourceId}; +use core::{Resolve, SourceId, Package}; use core::resolver::Method; use ops; -use sources::{PathSource}; use util::config::{Config}; use util::{CargoResult, human}; @@ -19,11 +18,8 @@ pub struct UpdateOptions<'a> { pub fn generate_lockfile(manifest_path: &Path, config: &Config) -> CargoResult<()> { - let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), - config)); - let package = try!(source.root_package()); + let package = try!(Package::for_path(manifest_path, config)); let mut registry = PackageRegistry::new(config); - registry.preload(package.package_id().source_id(), Box::new(source)); let resolve = try!(ops::resolve_with_previous(&mut registry, &package, Method::Everything, None, None)); @@ -33,9 +29,7 @@ pub fn generate_lockfile(manifest_path: &Path, config: &Config) pub fn update_lockfile(manifest_path: &Path, opts: &UpdateOptions) -> CargoResult<()> { - let mut source = try!(PathSource::for_path(manifest_path.parent().unwrap(), - opts.config)); - let package = try!(source.root_package()); + let package = try!(Package::for_path(manifest_path, opts.config)); let previous_resolve = match try!(ops::load_pkg_lockfile(&package)) { Some(resolve) => resolve, @@ -83,7 +77,6 @@ pub fn update_lockfile(manifest_path: &Path, None => to_avoid.extend(previous_resolve.iter()), } - registry.preload(package.package_id().source_id(), Box::new(source)); let resolve = try!(ops::resolve_with_previous(&mut registry, &package, Method::Everything, diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 684c539fe04..0988f00df52 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -178,7 +178,7 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path) let new_pkg = Package::new(new_manifest, &manifest_path); // Now that we've rewritten all our path dependencies, compile it! - try!(ops::compile_pkg(&new_pkg, None, &ops::CompileOptions { + try!(ops::compile_pkg(&new_pkg, &ops::CompileOptions { config: config, jobs: None, target: None, diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 7f17321bd7d..4657181bb38 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -37,6 +37,9 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, to_avoid: Option<&HashSet<&'a PackageId>>) -> CargoResult { + try!(registry.add_sources(&[package.package_id().source_id() + .clone()])); + // Here we place an artificial limitation that all non-registry sources // cannot be locked at more than one revision. This means that if a git // repository provides more than one package, they must all be updated in diff --git a/tests/test_cargo_compile_path_deps.rs b/tests/test_cargo_compile_path_deps.rs index 87174cc4220..b8b89fe6515 100644 --- a/tests/test_cargo_compile_path_deps.rs +++ b/tests/test_cargo_compile_path_deps.rs @@ -513,8 +513,12 @@ test!(error_message_for_missing_manifest { assert_that(p.cargo_process("build"), execs() .with_status(101) - .with_stderr(&format!("Could not find `Cargo.toml` in `{}`\n", - p.root().join("src").join("bar").display()))); + .with_stderr(&format!("\ +Unable to update file://[..] + +Caused by: + Could not find `Cargo.toml` in `{}` +", p.root().join("src").join("bar").display()))); }); From 70976106f25ed05be34ebcb2734340536271fc0a Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 20:41:40 -0400 Subject: [PATCH 0016/3888] Extract a function for getting resolved packages from a registry This code was happening in both cargo fetch and cargo compile and had a slightly different error message in each ;) --- src/cargo/ops/cargo_compile.rs | 9 ++------- src/cargo/ops/cargo_fetch.rs | 14 +++++++++----- src/cargo/ops/mod.rs | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index e9191304417..80e380fb2d5 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -28,7 +28,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use core::registry::PackageRegistry; -use core::{Source, SourceId, PackageSet, Package, Target, PackageId}; +use core::{Source, SourceId, PackageSet, Package, Target}; use core::{Profile, TargetKind}; use core::resolver::Method; use ops::{self, BuildOutput, ExecEngine}; @@ -142,12 +142,7 @@ pub fn compile_pkg<'a>(package: &Package, try!(ops::resolve_with_previous(&mut registry, package, method, Some(&resolve), None)); - let req: Vec = resolved_with_overrides.iter().map(|r| { - r.clone() - }).collect(); - let packages = try!(registry.get(&req).chain_error(|| { - human("Unable to get packages from source") - })); + let packages = try!(ops::get_resolved_packages(&resolved_with_overrides, &mut registry)); (packages, resolved_with_overrides, registry.move_sources()) }; diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index 612d88c05ad..b1e5c213f56 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -1,7 +1,7 @@ use std::path::Path; use core::registry::PackageRegistry; -use core::{Package, PackageId}; +use core::{Package, PackageId, Resolve}; use ops; use util::{CargoResult, Config, human, ChainError}; @@ -10,10 +10,14 @@ pub fn fetch(manifest_path: &Path, config: &Config) -> CargoResult<()> { let package = try!(Package::for_path(manifest_path, config)); let mut registry = PackageRegistry::new(config); let resolve = try!(ops::resolve_pkg(&mut registry, &package)); + let _ = get_resolved_packages(&resolve, &mut registry); + Ok(()) +} +pub fn get_resolved_packages(resolve: &Resolve, registry: &mut PackageRegistry) + -> CargoResult> { let ids: Vec = resolve.iter().cloned().collect(); - try!(registry.get(&ids).chain_error(|| { - human("unable to get packages from source") - })); - Ok(()) + registry.get(&ids).chain_error(|| { + human("Unable to get packages from source") + }) } diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 545187a98df..e5736071eb7 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -20,7 +20,7 @@ pub use self::cargo_package::package; pub use self::registry::{publish, registry_configuration, RegistryConfig}; pub use self::registry::{registry_login, search, http_proxy_exists, http_handle}; pub use self::registry::{modify_owners, yank, OwnersOptions}; -pub use self::cargo_fetch::{fetch}; +pub use self::cargo_fetch::{fetch, get_resolved_packages}; pub use self::cargo_pkgid::pkgid; pub use self::resolve::{resolve_pkg, resolve_with_previous}; From e1f315f1430220e753ab583e164f5567f968e957 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 10:36:07 -0400 Subject: [PATCH 0017/3888] Remove unneeded commented-out code --- tests/test_cargo_compile.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 482a6dee442..6b54f05c909 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -650,8 +650,6 @@ consider running `cargo update` to update a path dependency's locked version ")); }); -// test!(compiling_project_with_invalid_manifest) - test!(crate_version_env_vars { let p = project("foo") .file("Cargo.toml", r#" From f7e5b54a8b8ce4c0601da6341655ccd839ee2d43 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 10:41:06 -0400 Subject: [PATCH 0018/3888] Move test to a more appropriate location This test isn't testing generate-lockfile at all-- it's generating a lockfile with `\r\n` in it in the test itself and then testing that building will succeed even if there are `\r\n`s in the lockfile. Given that generate-lockfile could change and have no effect on this test, I think this fits in better with the other `cargo build` tests. --- tests/test_cargo_compile.rs | 25 +++++++++++++++++++++++++ tests/test_cargo_generate_lockfile.rs | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 6b54f05c909..e16456977f9 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -650,6 +650,31 @@ consider running `cargo update` to update a path dependency's locked version ")); }); +test!(ignores_carriage_return_in_lockfile { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + authors = [] + version = "0.0.1" + "#) + .file("src/main.rs", r#" + mod a; fn main() {} + "#) + .file("src/a.rs", ""); + + assert_that(p.cargo_process("build"), + execs().with_status(0)); + + let lockfile = p.root().join("Cargo.lock"); + let mut lock = String::new(); + File::open(&lockfile).unwrap().read_to_string(&mut lock).unwrap(); + let lock = lock.replace("\n", "\r\n"); + File::create(&lockfile).unwrap().write_all(lock.as_bytes()).unwrap(); + assert_that(p.cargo("build"), + execs().with_status(0)); +}); + test!(crate_version_env_vars { let p = project("foo") .file("Cargo.toml", r#" diff --git a/tests/test_cargo_generate_lockfile.rs b/tests/test_cargo_generate_lockfile.rs index ddfa48ea73f..276791aa033 100644 --- a/tests/test_cargo_generate_lockfile.rs +++ b/tests/test_cargo_generate_lockfile.rs @@ -6,31 +6,6 @@ use hamcrest::assert_that; fn setup() {} -test!(ignores_carriage_return { - let p = project("foo") - .file("Cargo.toml", r#" - [package] - name = "foo" - authors = [] - version = "0.0.1" - "#) - .file("src/main.rs", r#" - mod a; fn main() {} - "#) - .file("src/a.rs", ""); - - assert_that(p.cargo_process("build"), - execs().with_status(0)); - - let lockfile = p.root().join("Cargo.lock"); - let mut lock = String::new(); - File::open(&lockfile).unwrap().read_to_string(&mut lock).unwrap(); - let lock = lock.replace("\n", "\r\n"); - File::create(&lockfile).unwrap().write_all(lock.as_bytes()).unwrap(); - assert_that(p.cargo("build"), - execs().with_status(0)); -}); - test!(adding_and_removing_packages { let p = project("foo") .file("Cargo.toml", r#" From 2815fb23d01f5fd1e5ee88fcbb86a7d183af3b8b Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 14:39:34 -0400 Subject: [PATCH 0019/3888] Remove unnecessary PathSource update in cargo test I don't think updating the source here is hurting anything, per se, it's just unnecessary since ops::compile makes a PathSource and then calls root_package, which will call update if it needs to. --- src/cargo/ops/cargo_test.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 8b5ca97a5e8..555b239c0a2 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -1,8 +1,6 @@ use std::ffi::{OsString, OsStr}; use std::path::Path; -use core::Source; -use sources::PathSource; use ops::{self, ExecEngine, ProcessEngine, Compilation}; use util::{self, CargoResult, CargoTestError, ProcessError}; @@ -63,11 +61,6 @@ pub fn run_benches(manifest_path: &Path, fn compile_tests<'a>(manifest_path: &Path, options: &TestOptions<'a>) -> CargoResult> { - let config = options.compile_opts.config; - let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(), - config)); - try!(source.update()); - let mut compilation = try!(ops::compile(manifest_path, &options.compile_opts)); compilation.tests.sort(); Ok(compilation) From d631212fe2ddda89ce10f9afe86b26e2f338cf03 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sat, 19 Sep 2015 23:47:53 -0400 Subject: [PATCH 0020/3888] Fixing typos and grammar in comments --- src/cargo/core/package.rs | 4 ++-- src/cargo/core/registry.rs | 10 +++++----- src/cargo/ops/cargo_clean.rs | 2 +- src/cargo/ops/cargo_compile.rs | 2 +- src/cargo/ops/cargo_package.rs | 6 +++--- src/cargo/ops/resolve.rs | 4 ++-- src/cargo/sources/path.rs | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index f71f5025e5d..317c5cf352e 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -10,9 +10,9 @@ use util::{CargoResult, graph}; use rustc_serialize::{Encoder,Encodable}; use core::source::Source; -/// Informations about a package that is available somewhere in the file system. +/// Information about a package that is available somewhere in the file system. /// -/// A package is a `Cargo.toml` file, plus all the files that are part of it. +/// A package is a `Cargo.toml` file plus all the files that are part of it. // TODO: Is manifest_path a relic? #[derive(Clone, Debug)] pub struct Package { diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 273bb5ed56b..94a484c63de 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -4,7 +4,7 @@ use std::collections::hash_map::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use util::{CargoResult, ChainError, Config, human, profile}; -/// Source of informations about a group of packages. +/// Source of information about a group of packages. /// /// See also `core::Source`. pub trait Registry { @@ -32,11 +32,11 @@ impl Registry for Vec { /// /// The resolution phase of Cargo uses this to drive knowledge about new /// packages as well as querying for lists of new packages. It is here that -/// sources are updated and (e.g. network operations) as well as overrides are +/// sources are updated (e.g. network operations) and overrides are /// handled. /// /// The general idea behind this registry is that it is centered around the -/// `SourceMap` structure contained within which is a mapping of a `SourceId` to +/// `SourceMap` structure, contained within which is a mapping of a `SourceId` to /// a `Source`. Each `Source` in the map has been updated (using network /// operations if necessary) and is ready to be queried for packages. pub struct PackageRegistry<'cfg> { @@ -213,7 +213,7 @@ impl<'cfg> PackageRegistry<'cfg> { // possible. This is where the concept of a lockfile comes into play. // // If a summary points at a package id which was previously locked, then we - // override the summary's id itself as well as all dependencies to be + // override the summary's id itself, as well as all dependencies, to be // rewritten to the locked versions. This will transform the summary's // source to a precise source (listed in the locked version) as well as // transforming all of the dependencies from range requirements on imprecise @@ -242,7 +242,7 @@ impl<'cfg> PackageRegistry<'cfg> { // one of a few cases can arise: // // 1. We have a lock entry for this dependency from the same - // source as its listed as coming from. In this case we make + // source as it's listed as coming from. In this case we make // sure to lock to precisely the given package id. // // 2. We have a lock entry for this dependency, but it's from a diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 03b0575556d..2c1818667fc 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -23,7 +23,7 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { let root = try!(src.root_package()); let target_dir = opts.config.target_dir(&root); - // If we have a spec, then we need to delete some package,s otherwise, just + // If we have a spec, then we need to delete some packages, otherwise, just // remove the whole target directory and be done with it! let spec = match opts.spec { Some(spec) => spec, diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 74d0b09423e..bcab998418a 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -36,7 +36,7 @@ use sources::{PathSource}; use util::config::{ConfigValue, Config}; use util::{CargoResult, internal, human, ChainError, profile}; -/// Contains informations about how a package should be compiled. +/// Contains information about how a package should be compiled. pub struct CompileOptions<'a> { pub config: &'a Config, /// Number of concurrent jobs to use. diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index bcd74f460a7..b198c155526 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -162,10 +162,10 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path) // implicitly converted to registry-based dependencies, so we rewrite those // dependencies here. // - // We also be sure to point all paths at `dst` instead of the previous - // location that the package was original read from. In locking the + // We also make sure to point all paths at `dst` instead of the previous + // location that the package was originally read from. In locking the // `SourceId` we're telling it that the corresponding `PathSource` will be - // considered updated and won't actually read any packages. + // considered updated and we won't actually read any packages. let registry = try!(SourceId::for_central(config)); let precise = Some("locked".to_string()); let new_src = try!(SourceId::for_path(&dst)).with_precise(precise); diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 7f17321bd7d..9b23fed342d 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -9,7 +9,7 @@ use util::CargoResult; /// Resolve all dependencies for the specified `package` using the previous /// lockfile as a guide if present. /// -/// This function will also generate a write the result of resolution as a new +/// This function will also write the result of resolution as a new /// lockfile. pub fn resolve_pkg(registry: &mut PackageRegistry, package: &Package) -> CargoResult { @@ -73,7 +73,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, // 2. The specified package's summary will have its dependencies // modified to their precise variants. This will instruct the // first step of the resolution process to not query for ranges - // but rather precise dependency versions. + // but rather for precise dependency versions. // // This process must handle altered dependencies, however, as // it's possible for a manifest to change over time to have diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 0bca3de26f5..d84aed39596 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -79,7 +79,7 @@ impl<'cfg> PathSource<'cfg> { /// List all files relevant to building this package inside this source. /// - /// This function will use the appropriate methods to determine what is the + /// This function will use the appropriate methods to determine the /// set of files underneath this source's directory which are relevant for /// building `pkg`. /// @@ -115,7 +115,7 @@ impl<'cfg> PathSource<'cfg> { // We check all packages in this source that are ancestors of the // specified package (including the same package) to see if they're at // the root of the git repository. This isn't always true, but it'll get - // us there most of the time!. + // us there most of the time! let repo = self.packages.iter() .map(|pkg| pkg.root()) .filter(|path| root.starts_with(path)) @@ -139,11 +139,11 @@ impl<'cfg> PathSource<'cfg> { let mut ret = Vec::new(); - // We use information from the git repository to guide use in traversing + // We use information from the git repository to guide us in traversing // its tree. The primary purpose of this is to take advantage of the // .gitignore and auto-ignore files that don't matter. // - // Here we're also careful to look at both tracked an untracked files as + // Here we're also careful to look at both tracked and untracked files as // the untracked files are often part of a build and may become relevant // as part of a future commit. let index_files = index.iter().map(|entry| { From f59ce1d2309e2641407d81d4ace6e0345d6e469f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Sep 2015 12:02:46 -0700 Subject: [PATCH 0021/3888] Don't use an 8MB stack any more Now that the resolver isn't recursive this shouldn't be necessary --- src/bin/cargo.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 3442357209f..bfa763852e0 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -11,7 +11,6 @@ use std::fs; use std::io; use std::path::{PathBuf, Path}; use std::process::Command; -use std::thread::Builder; use cargo::{execute_main_without_stdin, handle_error, shell}; use cargo::core::MultiShell; @@ -58,18 +57,7 @@ See 'cargo help ' for more information on a specific command. fn main() { env_logger::init().unwrap(); - - // Right now the algorithm in cargo::core::resolve is pretty recursive and - // runs the risk of blowing the stack. Platforms tend to have different - // stack limits by default (I just witnessed 512K on OSX and 2MB on Linux) - // so to get a consistent experience just spawn ourselves with a large stack - // size. - let stack_size = env::var("CARGO_STACK_SIZE").ok() - .and_then(|s| s.parse().ok()) - .unwrap_or(8 * 1024 * 1024); // 8MB - Builder::new().stack_size(stack_size).spawn(|| { - execute_main_without_stdin(execute, true, USAGE) - }).unwrap().join().unwrap(); + execute_main_without_stdin(execute, true, USAGE) } macro_rules! each_subcommand{ ($mac:ident) => ({ From 4ce01c9bbfb39c53f7266df8da12d63fb3048431 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Sep 2015 12:03:05 -0700 Subject: [PATCH 0022/3888] Avoid a to_vec in the resolver --- src/cargo/core/resolver/mod.rs | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 1ac67168d5d..cece19c73a0 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -317,24 +317,27 @@ fn activate_deps_loop(mut cx: Context, uses_default_features: dep.uses_default_features(), }; - let prev_active = cx.prev_active(&dep).to_vec(); - trace!("{}[{}]>{} {} candidates", parent.name(), cur, dep.name(), - candidates.len()); - trace!("{}[{}]>{} {} prev activations", parent.name(), cur, - dep.name(), prev_active.len()); - - // Filter the set of candidates based on the previously activated - // versions for this dependency. We can actually use a version if it - // precisely matches an activated version or if it is otherwise - // incompatible with all other activated versions. Note that we define - // "compatible" here in terms of the semver sense where if the left-most - // nonzero digit is the same they're considered compatible. - let my_candidates = candidates.iter().filter(|&b| { - prev_active.iter().any(|a| a == b) || - prev_active.iter().all(|a| { - !compatible(a.version(), b.version()) - }) - }).cloned().collect(); + let my_candidates = { + let prev_active = cx.prev_active(&dep); + trace!("{}[{}]>{} {} candidates", parent.name(), cur, dep.name(), + candidates.len()); + trace!("{}[{}]>{} {} prev activations", parent.name(), cur, + dep.name(), prev_active.len()); + + // Filter the set of candidates based on the previously activated + // versions for this dependency. We can actually use a version if it + // precisely matches an activated version or if it is otherwise + // incompatible with all other activated versions. Note that we + // define "compatible" here in terms of the semver sense where if + // the left-most nonzero digit is the same they're considered + // compatible. + candidates.iter().filter(|&b| { + prev_active.iter().any(|a| a == b) || + prev_active.iter().all(|a| { + !compatible(a.version(), b.version()) + }) + }).cloned().collect() + }; // Alright, for each candidate that's gotten this far, it meets the // following requirements: @@ -372,7 +375,8 @@ fn activate_deps_loop(mut cx: Context, &mut remaining_deps, &mut parent, &mut cur, &mut dep) { None => return Err(activation_error(&cx, registry, &parent, - &dep, &prev_active, + &dep, + &cx.prev_active(&dep), &candidates)), Some(candidate) => candidate, } From c99b854afa643dc3aee21485082d280910e06e02 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Sep 2015 12:57:13 -0700 Subject: [PATCH 0023/3888] Touch up some style and comments in resolution --- src/cargo/core/resolver/mod.rs | 49 ++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index cece19c73a0..bd9ba548ac9 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -290,25 +290,33 @@ fn activate_deps_loop(mut cx: Context, let mut backtrack_stack = Vec::new(); let mut remaining_deps = Vec::new(); remaining_deps.extend(try!(activate(&mut cx, registry, top, &top_method))); - loop { - // Retrieves the next dependency to try, from `remaining_deps`. - let frame = match remaining_deps.pop() { - None => break, - Some(mut deps_frame) => { - match deps_frame.remaining_siblings.next() { - None => { - cx.visited.remove(&deps_frame.id); - continue - } - Some((cur, (dep, candidates, features))) => { - let parent = deps_frame.parent.clone(); - remaining_deps.push(deps_frame); - (parent, cur, dep, candidates, features) - } - } + + // Main resolution loop, this is the workhorse of the resolution algorithm. + // + // You'll note that a few stacks are maintained on the side, which might + // seem odd when this algorithm looks like it could be implemented + // recursively. While correct, this is implemented iteratively to avoid + // blowing the stack (the recusion depth is proportional to the size of the + // input). + // + // The general sketch of this loop is to run until there are no dependencies + // left to activate, and for each dependency to attempt to activate all of + // its own dependencies in turn. The `backtrack_stack` is a side table of + // backtracking states where if we hit an error we can return to in order to + // attempt to continue resolving. + while let Some(mut deps_frame) = remaining_deps.pop() { + let frame = match deps_frame.remaining_siblings.next() { + Some(sibling) => { + let parent = deps_frame.parent.clone(); + remaining_deps.push(deps_frame); + (parent, sibling) + } + None => { + cx.visited.remove(&deps_frame.id); + continue } }; - let (mut parent, mut cur, mut dep, candidates, features) = frame; + let (mut parent, (mut cur, (mut dep, candidates, features))) = frame; assert!(!remaining_deps.is_empty()); let method = Method::Required { @@ -370,7 +378,8 @@ fn activate_deps_loop(mut cx: Context, // find a dependency that does have a candidate to try, and try // to activate that one. This resets the `remaining_deps` to // their state at the found level of the `backtrack_stack`. - trace!("{}[{}]>{} -- no candidates", parent.name(), cur, dep.name()); + trace!("{}[{}]>{} -- no candidates", parent.name(), cur, + dep.name()); match find_candidate(&mut backtrack_stack, &mut cx, &mut remaining_deps, &mut parent, &mut cur, &mut dep) { @@ -415,10 +424,10 @@ fn find_candidate(backtrack_stack: &mut Vec, *cur = remaining_deps.last().unwrap().remaining_siblings.cur_index(); *dep = frame.dep.clone(); backtrack_stack.push(frame); - return Some(candidate); + return Some(candidate) } } - return None; + return None } #[allow(deprecated)] // connect => join in 1.3 From f585c79bea595dbb35b50714da1118b2a13de293 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sun, 20 Sep 2015 14:25:53 -0400 Subject: [PATCH 0024/3888] Update tests to be tolerant of new error code [E0463] Added in https://github.com/rust-lang/rust/commit/7358a5e8ea7c2ab0aaa76b503ef68161e44681a0 --- tests/test_cargo_compile.rs | 2 +- tests/test_cargo_compile_custom_build.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index e16456977f9..b8930f2b872 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1686,7 +1686,7 @@ test!(transitive_dependencies_not_available { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(101) .with_stderr("\ -[..] can't find crate for `bbbbb` +[..] can't find crate for `bbbbb`[..] [..] extern crate bbbbb; [..] [..] error: aborting due to previous error diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index f172e34be49..cb352e16b88 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -699,7 +699,7 @@ test!(build_deps_not_for_normal { assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target), execs().with_status(101) .with_stderr("\ -[..]lib.rs[..] error: can't find crate for `aaaaa` +[..]lib.rs[..] error: can't find crate for `aaaaa`[..] [..]lib.rs[..] extern crate aaaaa; [..] ^~~~~~~~~~~~~~~~~~~ error: aborting due to previous error From 47200b91b9bc7dac0638dcc70eff4712335b3e8e Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 21 Sep 2015 20:55:50 -0400 Subject: [PATCH 0025/3888] Test on Travis with Rust 1.1.0 and 1.2.0 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 318daa59b44..e743edaff59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: rust rust: + - 1.1.0 + - 1.2.0 - stable - beta - nightly From 996a58fe9dbc78d3e4cefe69b49278bb3ccb087a Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 21 Sep 2015 21:00:23 -0400 Subject: [PATCH 0026/3888] Keep the error message that starts with a lowercase letter --- src/cargo/ops/cargo_fetch.rs | 2 +- tests/test_cargo_registry.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index b1e5c213f56..dff47938a6b 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -18,6 +18,6 @@ pub fn get_resolved_packages(resolve: &Resolve, registry: &mut PackageRegistry) -> CargoResult> { let ids: Vec = resolve.iter().cloned().collect(); registry.get(&ids).chain_error(|| { - human("Unable to get packages from source") + human("unable to get packages from source") }) } diff --git a/tests/test_cargo_registry.rs b/tests/test_cargo_registry.rs index fef4fa5008a..632511c6830 100644 --- a/tests/test_cargo_registry.rs +++ b/tests/test_cargo_registry.rs @@ -161,7 +161,7 @@ test!(bad_cksum { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(101).with_stderr("\ -Unable to get packages from source +unable to get packages from source Caused by: Failed to download package `bad-cksum v0.0.1 (registry file://[..])` from [..] From f5f44a8dd8d71a863476b57beed7f45bcf91ff09 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 21 Sep 2015 21:06:30 -0400 Subject: [PATCH 0027/3888] Add a try! that I forgot If at first you don't succeed to call try!, try try! again ;) --- src/cargo/ops/cargo_fetch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index dff47938a6b..23267578fa7 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -10,7 +10,7 @@ pub fn fetch(manifest_path: &Path, config: &Config) -> CargoResult<()> { let package = try!(Package::for_path(manifest_path, config)); let mut registry = PackageRegistry::new(config); let resolve = try!(ops::resolve_pkg(&mut registry, &package)); - let _ = get_resolved_packages(&resolve, &mut registry); + let _ = try!(get_resolved_packages(&resolve, &mut registry)); Ok(()) } From 0eb1082da2480938d499286937522e0f46bc4078 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Tue, 22 Sep 2015 13:17:07 -0700 Subject: [PATCH 0028/3888] Document use of features for `cfg` more prominently --- src/doc/manifest.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/doc/manifest.md b/src/doc/manifest.md index 8b5d02e46b6..c79913587b8 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -258,7 +258,8 @@ codegen-units = 1 Cargo supports **features** to allow expression of: -* Optional dependencies, which enhance a package, but are not required +* Conditional compilation options (usable through `cfg` attributes); +* Optional dependencies, which enhance a package, but are not required; * Clusters of optional dependencies, such as "postgres", that would include the `postgres` package, the `postgres-macros` package, and possibly other packages (such as development-time mocking libraries, debugging tools, etc.) @@ -277,6 +278,10 @@ name = "awesome" # feature listed in this manifest. default = ["jquery", "uglifier", "session"] +# A feature with no dependencies is used mainly for conditional +# compilation, like `#[cfg(feature = "go-faster")]`. +go-faster = [] + # The "secure-password" feature depends on the bcrypt package. # This aliasing will allow people to talk about the feature in # a higher-level way and allow this package to add more From 18ba074251b0fd1b5b60bd45e752fe0a057794f4 Mon Sep 17 00:00:00 2001 From: Cesar Eduardo Barros Date: Sat, 26 Sep 2015 11:54:16 -0300 Subject: [PATCH 0029/3888] Regenerate Makefile if Makefile.in or configure change Based on rust's mk/reconfig.mk Fixes #587 and #1993 --- Makefile.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile.in b/Makefile.in index 9cc1993f23b..6d0d0625fe9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -113,6 +113,10 @@ no-exes: # === Misc +Makefile config.mk: config.stamp +config.stamp: $(CFG_SRC_DIR)configure $(CFG_SRC_DIR)Makefile.in + $(CFG_SRC_DIR)configure $(CFG_CONFIGURE_ARGS) + clean-all: clean clean: rm -rf $(TARGET_ROOT) From a0ec59edb474bf4621094c30d80776f1ead1bda2 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 27 Sep 2015 16:52:01 -0700 Subject: [PATCH 0030/3888] Add a warning when packaging crates with wildcard dependencies --- src/cargo/ops/cargo_package.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index cf0bd9d831b..64fc7e2ea57 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -2,11 +2,13 @@ use std::io::prelude::*; use std::fs::{self, File}; use std::path::{self, Path, PathBuf}; +use semver::VersionReq; use tar::Archive; use flate2::{GzBuilder, Compression}; use flate2::read::GzDecoder; use core::{SourceId, Package, PackageId}; +use core::dependency::Kind; use sources::PathSource; use util::{self, CargoResult, human, internal, ChainError, Config}; use ops; @@ -35,6 +37,8 @@ pub fn package(manifest_path: &Path, try!(check_metadata(&pkg, config)); } + try!(check_dependencies(&pkg, config)); + if list { let root = pkg.root(); let mut list: Vec<_> = try!(src.list_files(&pkg)).iter().map(|file| { @@ -102,6 +106,32 @@ fn check_metadata(pkg: &Package, config: &Config) -> CargoResult<()> { Ok(()) } +// Warn about wildcard deps which will soon be prohibited on crates.io +#[allow(deprecated)] // connect => join in 1.3 +fn check_dependencies(pkg: &Package, config: &Config) -> CargoResult<()> { + let wildcard = VersionReq::parse("*").unwrap(); + + let mut wildcard_deps = vec![]; + for dep in pkg.dependencies() { + if dep.kind() != Kind::Development && dep.version_req() == &wildcard { + wildcard_deps.push(dep.name()); + } + } + + if !wildcard_deps.is_empty() { + let deps = wildcard_deps.connect(", "); + try!(config.shell().warn( + "warning: some dependencies have wildcard (\"*\") version constraints. \ + On December 11th, 2015, crates.io will begin rejecting packages with \ + wildcard dependency constraints. See \ + http://doc.crates.io/crates-io.html#using-crates.io-based-crates \ + for information on version constraints.")); + try!(config.shell().warn( + &format!("dependencies for these crates have wildcard constraints: {}", deps))); + } + Ok(()) +} + fn tar(pkg: &Package, src: &PathSource, config: &Config, dst: &Path) -> CargoResult<()> { From afb979d28cfd57961508b78938aa273aa068e4e5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 28 Sep 2015 13:52:34 -0700 Subject: [PATCH 0031/3888] Don't fail if dylib outputs aren't supported Currently it's not possible to inform Cargo about target-specific crate types, so generating a hard error whenever a dylib is seen for a target that can't produce dylibs is a little heavy. This commit disables management of the output dylib (which won't actually exists) and relies on the compiler to print a warning in the case of a dylib output on a non-dylib target. --- src/cargo/ops/cargo_rustc/context.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 93ef0357cd3..1ba89283575 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -324,8 +324,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> { for lib in libs.iter() { match *lib { LibKind::Dylib => { - let (prefix, suffix) = try!(self.dylib(kind)); - ret.push(format!("{}{}{}", prefix, stem, suffix)); + if let Ok((prefix, suffix)) = self.dylib(kind) { + ret.push(format!("{}{}{}", prefix, stem, suffix)); + } } LibKind::Lib | LibKind::Rlib => ret.push(format!("lib{}.rlib", stem)), From f5429d9fb63c3b739a6a178747c11d6183853f33 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 28 Sep 2015 22:30:40 -0700 Subject: [PATCH 0032/3888] Add a test for wildcard constraint warnings --- tests/test_cargo_package.rs | 58 ++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/tests/test_cargo_package.rs b/tests/test_cargo_package.rs index 5ca6b1cf632..6e59a364773 100644 --- a/tests/test_cargo_package.rs +++ b/tests/test_cargo_package.rs @@ -9,7 +9,8 @@ use git2; use tar::Archive; use support::{project, execs, cargo_dir, paths, git, path2url}; -use support::{PACKAGING, VERIFYING, COMPILING, ARCHIVING}; +use support::{PACKAGING, VERIFYING, COMPILING, ARCHIVING, UPDATING, DOWNLOADING}; +use support::registry as r; use hamcrest::{assert_that, existing_file}; fn setup() { @@ -141,6 +142,61 @@ http://doc.crates.io/manifest.html#package-metadata for more info.")); dir = p.url()))); }); +test!(wildcard_deps { + r::init(); + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + license = "MIT" + description = "foo" + repository = "bar" + + [dependencies] + bar = "*" + + [build-dependencies] + baz = "*" + + [dev-dependencies] + buz = "*" + "#) + .file("src/main.rs", "fn main() {}"); + + r::mock_pkg("baz", "0.0.1", &[]); + r::mock_pkg("bar", "0.0.1", &[("baz", "0.0.1", "normal")]); + r::mock_pkg("buz", "0.0.1", &[("bar", "0.0.1", "normal")]); + + assert_that(p.cargo_process("package"), + execs().with_status(0).with_stdout(&format!("\ +{packaging} foo v0.0.1 ({dir}) +{verifying} foo v0.0.1 ({dir}) +{updating} registry `{reg}` +{downloading} [..] v0.0.1 (registry file://[..]) +{downloading} [..] v0.0.1 (registry file://[..]) +{downloading} [..] v0.0.1 (registry file://[..]) +{compiling} baz v0.0.1 (registry file://[..]) +{compiling} bar v0.0.1 (registry file://[..]) +{compiling} foo v0.0.1 ({dir}[..]) +", + packaging = PACKAGING, + verifying = VERIFYING, + updating = UPDATING, + downloading = DOWNLOADING, + compiling = COMPILING, + dir = p.url(), + reg = r::registry())) + .with_stderr("\ +warning: some dependencies have wildcard (\"*\") version constraints. On December 11th, 2015, \ +crates.io will begin rejecting packages with wildcard dependency constraints. See \ +http://doc.crates.io/crates-io.html#using-crates.io-based-crates for information on version \ +constraints. +dependencies for these crates have wildcard constraints: bar, baz")); +}); + test!(package_verbose { let root = paths::root().join("all"); let p = git::repo(&root) From 4aa149099d5b87517548f675190a091c4619cc13 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 27 Sep 2015 16:52:01 -0700 Subject: [PATCH 0033/3888] Add a warning when packaging crates with wildcard dependencies --- src/cargo/ops/cargo_package.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index cf0bd9d831b..64fc7e2ea57 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -2,11 +2,13 @@ use std::io::prelude::*; use std::fs::{self, File}; use std::path::{self, Path, PathBuf}; +use semver::VersionReq; use tar::Archive; use flate2::{GzBuilder, Compression}; use flate2::read::GzDecoder; use core::{SourceId, Package, PackageId}; +use core::dependency::Kind; use sources::PathSource; use util::{self, CargoResult, human, internal, ChainError, Config}; use ops; @@ -35,6 +37,8 @@ pub fn package(manifest_path: &Path, try!(check_metadata(&pkg, config)); } + try!(check_dependencies(&pkg, config)); + if list { let root = pkg.root(); let mut list: Vec<_> = try!(src.list_files(&pkg)).iter().map(|file| { @@ -102,6 +106,32 @@ fn check_metadata(pkg: &Package, config: &Config) -> CargoResult<()> { Ok(()) } +// Warn about wildcard deps which will soon be prohibited on crates.io +#[allow(deprecated)] // connect => join in 1.3 +fn check_dependencies(pkg: &Package, config: &Config) -> CargoResult<()> { + let wildcard = VersionReq::parse("*").unwrap(); + + let mut wildcard_deps = vec![]; + for dep in pkg.dependencies() { + if dep.kind() != Kind::Development && dep.version_req() == &wildcard { + wildcard_deps.push(dep.name()); + } + } + + if !wildcard_deps.is_empty() { + let deps = wildcard_deps.connect(", "); + try!(config.shell().warn( + "warning: some dependencies have wildcard (\"*\") version constraints. \ + On December 11th, 2015, crates.io will begin rejecting packages with \ + wildcard dependency constraints. See \ + http://doc.crates.io/crates-io.html#using-crates.io-based-crates \ + for information on version constraints.")); + try!(config.shell().warn( + &format!("dependencies for these crates have wildcard constraints: {}", deps))); + } + Ok(()) +} + fn tar(pkg: &Package, src: &PathSource, config: &Config, dst: &Path) -> CargoResult<()> { From b40b3fbbdaf87c13e25f19c08a1d0e350fc73209 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 28 Sep 2015 22:30:40 -0700 Subject: [PATCH 0034/3888] Add a test for wildcard constraint warnings --- tests/test_cargo_package.rs | 58 ++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/tests/test_cargo_package.rs b/tests/test_cargo_package.rs index 5ca6b1cf632..6e59a364773 100644 --- a/tests/test_cargo_package.rs +++ b/tests/test_cargo_package.rs @@ -9,7 +9,8 @@ use git2; use tar::Archive; use support::{project, execs, cargo_dir, paths, git, path2url}; -use support::{PACKAGING, VERIFYING, COMPILING, ARCHIVING}; +use support::{PACKAGING, VERIFYING, COMPILING, ARCHIVING, UPDATING, DOWNLOADING}; +use support::registry as r; use hamcrest::{assert_that, existing_file}; fn setup() { @@ -141,6 +142,61 @@ http://doc.crates.io/manifest.html#package-metadata for more info.")); dir = p.url()))); }); +test!(wildcard_deps { + r::init(); + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + license = "MIT" + description = "foo" + repository = "bar" + + [dependencies] + bar = "*" + + [build-dependencies] + baz = "*" + + [dev-dependencies] + buz = "*" + "#) + .file("src/main.rs", "fn main() {}"); + + r::mock_pkg("baz", "0.0.1", &[]); + r::mock_pkg("bar", "0.0.1", &[("baz", "0.0.1", "normal")]); + r::mock_pkg("buz", "0.0.1", &[("bar", "0.0.1", "normal")]); + + assert_that(p.cargo_process("package"), + execs().with_status(0).with_stdout(&format!("\ +{packaging} foo v0.0.1 ({dir}) +{verifying} foo v0.0.1 ({dir}) +{updating} registry `{reg}` +{downloading} [..] v0.0.1 (registry file://[..]) +{downloading} [..] v0.0.1 (registry file://[..]) +{downloading} [..] v0.0.1 (registry file://[..]) +{compiling} baz v0.0.1 (registry file://[..]) +{compiling} bar v0.0.1 (registry file://[..]) +{compiling} foo v0.0.1 ({dir}[..]) +", + packaging = PACKAGING, + verifying = VERIFYING, + updating = UPDATING, + downloading = DOWNLOADING, + compiling = COMPILING, + dir = p.url(), + reg = r::registry())) + .with_stderr("\ +warning: some dependencies have wildcard (\"*\") version constraints. On December 11th, 2015, \ +crates.io will begin rejecting packages with wildcard dependency constraints. See \ +http://doc.crates.io/crates-io.html#using-crates.io-based-crates for information on version \ +constraints. +dependencies for these crates have wildcard constraints: bar, baz")); +}); + test!(package_verbose { let root = paths::root().join("all"); let p = git::repo(&root) From 91be7c687e0e230dd4b439e28a0faf9374287021 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 16 Jul 2015 22:35:40 +0200 Subject: [PATCH 0035/3888] Add support for multiple -p options to `cargo {bench, build, doc}` --- src/bin/bench.rs | 6 +- src/bin/build.rs | 6 +- src/bin/doc.rs | 6 +- src/bin/run.rs | 2 +- src/bin/rustc.rs | 6 +- src/bin/test.rs | 6 +- src/cargo/ops/cargo_clean.rs | 2 +- src/cargo/ops/cargo_compile.rs | 121 +++++++++++++------- src/cargo/ops/cargo_doc.rs | 18 +-- src/cargo/ops/cargo_package.rs | 2 +- src/cargo/ops/cargo_rustc/compilation.rs | 9 +- src/cargo/ops/cargo_rustc/context.rs | 3 +- src/cargo/ops/cargo_rustc/mod.rs | 140 ++++++++++++----------- src/cargo/ops/cargo_test.rs | 41 +++++++ tests/test_cargo_compile.rs | 58 ++++++++++ tests/test_cargo_doc.rs | 45 ++++++++ tests/test_cargo_test.rs | 60 ++++++++++ 17 files changed, 393 insertions(+), 138 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 655fbff60e5..47150dfab89 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -5,7 +5,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { flag_no_run: bool, - flag_package: Option, + flag_package: Vec, flag_jobs: Option, flag_features: Vec, flag_no_default_features: bool, @@ -26,7 +26,7 @@ pub const USAGE: &'static str = " Execute all benchmarks of a local package Usage: - cargo bench [options] [--] [...] + cargo bench [options] [-p SPEC --package SPEC]... [--] [...] Options: -h, --help Print this message @@ -75,7 +75,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: options.flag_target.as_ref().map(|s| &s[..]), features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| &s[..]), + spec: &options.flag_package, exec_engine: None, release: true, mode: ops::CompileMode::Bench, diff --git a/src/bin/build.rs b/src/bin/build.rs index 984a0e752a3..6140ca961be 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -7,7 +7,7 @@ use cargo::util::{CliResult, CliError, Config}; #[derive(RustcDecodable)] struct Options { - flag_package: Option, + flag_package: Vec, flag_jobs: Option, flag_features: Vec, flag_no_default_features: bool, @@ -28,7 +28,7 @@ pub const USAGE: &'static str = " Compile a local package and all of its dependencies Usage: - cargo build [options] + cargo build [options] [-p SPEC --package SPEC]... Options: -h, --help Print this message @@ -72,7 +72,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| &s[..]), + spec: &options.flag_package, exec_engine: None, mode: ops::CompileMode::Build, release: options.flag_release, diff --git a/src/bin/doc.rs b/src/bin/doc.rs index 8fa2bae7cc0..8bc6289b5df 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -15,14 +15,14 @@ struct Options { flag_release: bool, flag_quiet: bool, flag_color: Option, - flag_package: Option, + flag_package: Vec, } pub const USAGE: &'static str = " Build a package's documentation Usage: - cargo doc [options] + cargo doc [options] [-p SPEC --package SPEC]... Options: -h, --help Print this message @@ -62,7 +62,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| &s[..]), + spec: &options.flag_package, exec_engine: None, filter: ops::CompileFilter::Everything, release: options.flag_release, diff --git a/src/bin/run.rs b/src/bin/run.rs index c1c04295886..2483dcc8dfc 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -68,7 +68,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: None, + spec: &[], exec_engine: None, release: options.flag_release, mode: ops::CompileMode::Build, diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 8a589091aae..4b7121f43e5 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -8,7 +8,7 @@ use cargo::util::{CliResult, CliError, Config}; #[derive(RustcDecodable)] struct Options { arg_opts: Option>, - flag_package: Option, + flag_package: Vec, flag_jobs: Option, flag_features: Vec, flag_no_default_features: bool, @@ -29,7 +29,7 @@ pub const USAGE: &'static str = " Compile a package and all of its dependencies Usage: - cargo rustc [options] [--] [...] + cargo rustc [options] [-p SPEC --package SPEC]... [--] [...] Options: -h, --help Print this message @@ -75,7 +75,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| &s[..]), + spec: &options.flag_package, exec_engine: None, mode: ops::CompileMode::Build, release: options.flag_release, diff --git a/src/bin/test.rs b/src/bin/test.rs index ade46016528..9b89fb91211 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -10,7 +10,7 @@ struct Options { flag_manifest_path: Option, flag_no_default_features: bool, flag_no_run: bool, - flag_package: Option, + flag_package: Vec, flag_target: Option, flag_lib: bool, flag_bin: Vec, @@ -28,7 +28,7 @@ pub const USAGE: &'static str = " Execute all unit and integration tests of a local package Usage: - cargo test [options] [--] [...] + cargo test [options] [-p SPEC --package SPEC]... [--] [...] Options: -h, --help Print this message @@ -81,7 +81,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: options.flag_target.as_ref().map(|s| &s[..]), features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: options.flag_package.as_ref().map(|s| &s[..]), + spec: &options.flag_package, exec_engine: None, release: options.flag_release, mode: ops::CompileMode::Test, diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index c3303423e8b..c3bc268278b 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -49,7 +49,7 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { let profiles = Profiles::default(); let cx = try!(Context::new(&resolve, &srcs, &pkgs, opts.config, Layout::at(target_dir), - None, &pkg, BuildConfig::default(), + None, BuildConfig::default(), &profiles)); // And finally, clean everything out! diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 74c073f269f..41d0add87ae 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -28,7 +28,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use core::registry::PackageRegistry; -use core::{Source, SourceId, PackageSet, Package, Target}; +use core::{Source, SourceId, PackageSet, Package, Target, PackageId}; use core::{Profile, TargetKind}; use core::resolver::Method; use ops::{self, BuildOutput, ExecEngine}; @@ -47,7 +47,7 @@ pub struct CompileOptions<'a> { /// Flag if the default feature should be built for the root package pub no_default_features: bool, /// Root package to build (if None it's the current one) - pub spec: Option<&'a str>, + pub spec: &'a [String], /// Filter to apply to the root package to select which targets will be /// built. pub filter: CompileFilter<'a>, @@ -95,10 +95,10 @@ pub fn compile<'a>(manifest_path: &Path, compile_pkg(&package, options) } -pub fn compile_pkg<'a>(package: &Package, +pub fn compile_pkg<'a>(root_package: &Package, options: &CompileOptions<'a>) -> CargoResult> { - let CompileOptions { config, jobs, target, spec, features, + let CompileOptions { config, jobs, target, ref spec, features, no_default_features, release, mode, ref filter, ref exec_engine, ref target_rustc_args } = *options; @@ -108,7 +108,7 @@ pub fn compile_pkg<'a>(package: &Package, s.split(' ') }).map(|s| s.to_string()).collect::>(); - if spec.is_some() && (no_default_features || features.len() > 0) { + if spec.len() > 0 && (no_default_features || features.len() > 0) { return Err(human("features cannot be modified when the main package \ is not being built")) } @@ -116,14 +116,20 @@ pub fn compile_pkg<'a>(package: &Package, return Err(human("jobs must be at least 1")) } - let override_ids = try!(source_ids_from_config(config, package.root())); - let (packages, resolve_with_overrides, sources) = { - let mut registry = PackageRegistry::new(config); + let override_ids = + try!(source_ids_from_config(options.config, root_package.root())); + let mut registry = PackageRegistry::new(options.config); + if let Some(source) = source { + registry.preload(root_package.package_id().source_id(), source); + } else { + try!(registry.add_sources(&[root_package.package_id().source_id() + .clone()])); + } - // First, resolve the package's *listed* dependencies, as well as + // First, resolve the root_package's *listed* dependencies, as well as // downloading and updating all remotes and such. - let resolve = try!(ops::resolve_pkg(&mut registry, package)); + let resolve = try!(ops::resolve_pkg(&mut registry, root_package)); // Second, resolve with precisely what we're doing. Filter out // transitive dependencies if necessary, specify features, handle @@ -132,48 +138,82 @@ pub fn compile_pkg<'a>(package: &Package, try!(registry.add_overrides(override_ids)); - let method = Method::Required { + let method = Method::Required{ dev_deps: true, // TODO: remove this option? features: &features, - uses_default_features: !no_default_features, + uses_default_features: !options.no_default_features, }; let resolved_with_overrides = - try!(ops::resolve_with_previous(&mut registry, package, method, + try!(ops::resolve_with_previous(&mut registry, root_package, method, Some(&resolve), None)); - let packages = try!(ops::get_resolved_packages(&resolved_with_overrides, &mut registry)); + let req: Vec = resolved_with_overrides.iter().map(|r| { + r.clone() + }).collect(); + let packages = try!(registry.get(&req).chain_error(|| { + human("Unable to get packages from source") + })); (packages, resolved_with_overrides, registry.move_sources()) }; - let pkgid = match spec { - Some(spec) => try!(resolve_with_overrides.query(spec)), - None => package.package_id(), + let mut invalid_spec = vec![]; + let pkgids = if spec.len() > 0 { + spec.iter().filter_map(|p| { + match resolve_with_overrides.query(&p) { + Ok(p) => Some(p), + Err(..) => { invalid_spec.push(p.to_string()); None } + } + }).collect::>() + } else { + vec![root_package.package_id()] }; - let to_build = packages.iter().find(|p| p.package_id() == pkgid).unwrap(); - let targets = try!(generate_targets(to_build, mode, filter, release)); - - let target_with_args = match *target_rustc_args { - Some(args) if targets.len() == 1 => { - let (target, profile) = targets[0]; - let mut profile = profile.clone(); - profile.rustc_args = Some(args.to_vec()); - Some((target, profile)) - } - Some(_) => { - return Err(human("extra arguments to `rustc` can only be passed to \ - one target, consider filtering\nthe package by \ - passing e.g. `--lib` or `--bin NAME` to specify \ - a single target")) + + /* + if spec.len() > 0 && invalid_spec.len() > 0 { + return Err(human(format!("could not find package matching spec `{}`", + invalid_spec.join(", ")))); + } */ + + let to_builds = packages.iter().filter(|p| + pkgids.iter().find(|&op| *op == p.package_id()).is_some() + ).collect::>(); + + let mut twas = &mut vec![]; + let mut package_targets = vec![]; + + for &to_build in to_builds.iter() { + let targets = try!(generate_targets(to_build, mode, filter, release)); + + match *target_rustc_args { + Some(args) if targets.len() == 1 => { + let (target, profile) = targets[0]; + let mut profile = profile.clone(); + profile.rustc_args = Some(args.to_vec()); + twas.push((target, profile)); + } + Some(_) => { + return Err(human("extra arguments to `rustc` can only be \ + passed to one target, consider \ + filtering\nthe package by passing e.g. \ + `--lib` or `--bin NAME` to specify \ + a single target")) + } + None => package_targets.push((to_build, targets)), + }; + + } + + for targets in twas { + let (target, ref profile) = *targets; + for &to_build in to_builds.iter() { + package_targets.push((to_build, vec![(target, profile)])); } - None => None, - }; + } - let targets = target_with_args.as_ref().map(|&(t, ref p)| vec![(t, p)]) - .unwrap_or(targets); - let ret = { + let mut ret = { let _p = profile::start("compiling"); let mut build_config = try!(scrape_build_config(config, jobs, target)); build_config.exec_engine = exec_engine.clone(); @@ -182,15 +222,18 @@ pub fn compile_pkg<'a>(package: &Package, build_config.doc_all = deps; } - try!(ops::compile_targets(&targets, to_build, + try!(ops::compile_targets(&package_targets, &PackageSet::new(&packages), &resolve_with_overrides, &sources, config, build_config, - to_build.manifest().profiles())) + root_package.manifest().profiles(), + )) }; + ret.to_doc_test = to_builds.iter().map(|&p| p.clone()).collect(); + return Ok(ret); } diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 11e5d5bf736..ca95b82a92d 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -18,7 +18,7 @@ pub fn doc(manifest_path: &Path, let mut lib_names = HashSet::new(); let mut bin_names = HashSet::new(); - if options.compile_opts.spec.is_none() { + if options.compile_opts.spec.len() == 0 { for target in package.targets().iter().filter(|t| t.documented()) { if target.is_lib() { assert!(lib_names.insert(target.crate_name())); @@ -39,13 +39,15 @@ pub fn doc(manifest_path: &Path, try!(ops::compile(manifest_path, &options.compile_opts)); if options.open_result { - let name = match options.compile_opts.spec { - Some(spec) => try!(PackageIdSpec::parse(spec)).name().replace("-", "_").to_string(), - None => { - match lib_names.iter().chain(bin_names.iter()).nth(0) { - Some(s) => s.to_string(), - None => return Ok(()) - } + let name = if options.compile_opts.spec.len() > 0{ + // TODO + try!(PackageIdSpec::parse(options.compile_opts.spec.first() + .unwrap())).name().replace("-", "_") + .to_string() + } else { + match lib_names.iter().chain(bin_names.iter()).nth(0) { + Some(s) => s.to_string(), + None => return Ok(()) } }; diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 64fc7e2ea57..a1b3cd5afd5 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -214,7 +214,7 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path) target: None, features: &[], no_default_features: false, - spec: None, + spec: &[], filter: ops::CompileFilter::Everything, exec_engine: None, release: false, diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index bd6be3c4c84..2404c1ede96 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -17,7 +17,7 @@ pub struct Compilation<'cfg> { pub libraries: HashMap>, /// An array of all tests created during this compilation. - pub tests: Vec<(String, PathBuf)>, + pub tests: Vec<(Package, Vec<(String, PathBuf)>)>, /// An array of all binaries created. pub binaries: Vec, @@ -39,8 +39,7 @@ pub struct Compilation<'cfg> { /// be passed to future invocations of programs. pub extra_env: HashMap, - /// Top-level package that was compiled - pub package: Package, + pub to_doc_test: Vec, /// Features enabled during this compilation. pub features: HashSet, @@ -49,7 +48,7 @@ pub struct Compilation<'cfg> { } impl<'cfg> Compilation<'cfg> { - pub fn new(pkg: &Package, config: &'cfg Config) -> Compilation<'cfg> { + pub fn new(config: &'cfg Config) -> Compilation<'cfg> { Compilation { libraries: HashMap::new(), native_dirs: HashMap::new(), // TODO: deprecated, remove @@ -58,7 +57,7 @@ impl<'cfg> Compilation<'cfg> { tests: Vec::new(), binaries: Vec::new(), extra_env: HashMap::new(), - package: pkg.clone(), + to_doc_test: Vec::new(), features: HashSet::new(), config: config, } diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 1ba89283575..13699781345 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -59,7 +59,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { config: &'cfg Config, host: Layout, target_layout: Option, - root_pkg: &Package, build_config: BuildConfig, profiles: &'a Profiles) -> CargoResult> { let target = build_config.requested_target.clone(); @@ -90,7 +89,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { host_dylib: host_dylib, host_exe: host_exe, requirements: HashMap::new(), - compilation: Compilation::new(root_pkg, config), + compilation: Compilation::new(config), build_state: Arc::new(BuildState::new(&build_config, deps)), build_config: build_config, exec_engine: engine, diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index a13a74dc00f..1c2ad0705aa 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -54,8 +54,9 @@ pub struct TargetConfig { // Returns a mapping of the root package plus its immediate dependencies to // where the compiled libraries are all located. -pub fn compile_targets<'a, 'cfg: 'a>(targets: &[(&'a Target, &'a Profile)], - pkg: &'a Package, +pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, + Vec<(&Target, + &'a Profile)>)], deps: &'a PackageSet, resolve: &'a Resolve, sources: &'a SourceMap<'cfg>, @@ -63,89 +64,97 @@ pub fn compile_targets<'a, 'cfg: 'a>(targets: &[(&'a Target, &'a Profile)], build_config: BuildConfig, profiles: &'a Profiles) -> CargoResult> { - if targets.is_empty() { - return Ok(Compilation::new(pkg, config)) - } - debug!("compile_targets: {}", pkg); + debug!("compile_targets: {}", pkg_targets.iter().map(|&(ref p, _)| p.name()) + .collect::>().join(", ")); try!(links::validate(deps)); let dest = if build_config.release {"release"} else {"debug"}; - let root = if resolve.root() == pkg.package_id() { - pkg - } else { - deps.iter().find(|p| p.package_id() == resolve.root()).unwrap() - }; + let root = deps.iter().find(|p| p.package_id() == resolve.root()).unwrap(); let host_layout = Layout::new(config, root, None, &dest); let target_layout = build_config.requested_target.as_ref().map(|target| { layout::Layout::new(config, root, Some(&target), &dest) }); let mut cx = try!(Context::new(resolve, sources, deps, config, - host_layout, target_layout, pkg, + host_layout, target_layout, build_config, profiles)); let mut queue = JobQueue::new(cx.resolve, deps, cx.jobs()); - // Prep the context's build requirements and see the job graph for all - // packages initially. { let _p = profile::start("preparing build directories"); - try!(cx.prepare(pkg, targets)); - prepare_init(&mut cx, pkg, &mut queue, &mut HashSet::new()); - custom_build::build_map(&mut cx, pkg, targets); + // Prep the context's build requirements and see the job graph for all + // packages initially. + for &(pkg, ref targets) in pkg_targets { + try!(cx.prepare(pkg, targets)); + prepare_init(&mut cx, pkg, &mut queue, &mut HashSet::new()); + custom_build::build_map(&mut cx, pkg, targets); + } } - // Build up a list of pending jobs, each of which represent compiling a - // particular package. No actual work is executed as part of this, that's - // all done next as part of the `execute` function which will run - // everything in order with proper parallelism. - try!(compile(targets, pkg, &mut cx, &mut queue)); + for &(pkg, ref targets) in pkg_targets { + // Build up a list of pending jobs, each of which represent + // compiling a particular package. No actual work is executed as + // part of this, that's all done next as part of the `execute` + // function which will run everything in order with proper + // parallelism. + try!(compile(targets, pkg, &mut cx, &mut queue)); + } // Now that we've figured out everything that we're going to do, do it! try!(queue.execute(cx.config)); - let out_dir = cx.layout(pkg, Kind::Target).build_out(pkg) - .display().to_string(); - cx.compilation.extra_env.insert("OUT_DIR".to_string(), out_dir); + for &(pkg, ref targets) in pkg_targets.iter() { + let out_dir = cx.layout(pkg, Kind::Target).build_out(pkg) + .display().to_string(); + cx.compilation.extra_env.insert("OUT_DIR".to_string(), out_dir); + + let mut tests = vec![]; + + for &(target, profile) in targets { + let kind = Kind::from(target); + for filename in try!(cx.target_filenames(pkg, target, profile, + kind)).iter() { + let dst = cx.out_dir(pkg, kind, target).join(filename); + if profile.test { + tests.push((target.name().to_string(), dst)); + } else if target.is_bin() || target.is_example() { + cx.compilation.binaries.push(dst); + } else if target.is_lib() { + let pkgid = pkg.package_id().clone(); + cx.compilation.libraries.entry(pkgid).or_insert(Vec::new()) + .push((target.clone(), dst)); + } + if !target.is_lib() { continue } - for &(target, profile) in targets { - let kind = Kind::from(target); - for filename in try!(cx.target_filenames(pkg, target, profile, - kind)).iter() { - let dst = cx.out_dir(pkg, kind, target).join(filename); - if profile.test { - cx.compilation.tests.push((target.name().to_string(), dst)); - } else if target.is_bin() || target.is_example() { - cx.compilation.binaries.push(dst); - } else if target.is_lib() { - let pkgid = pkg.package_id().clone(); - cx.compilation.libraries.entry(pkgid).or_insert(Vec::new()) - .push((target.clone(), dst)); - } - if !target.is_lib() { continue } + // Include immediate lib deps as well + for dep in &cx.dep_targets(pkg, target, kind, profile) { + let (pkg, target, profile) = *dep; + let pkgid = pkg.package_id(); + if !target.is_lib() { continue } + if profile.doc { continue } + if cx.compilation.libraries.contains_key(&pkgid) { + continue + } - // Include immediate lib deps as well - for dep in cx.dep_targets(pkg, target, kind, profile) { - let (pkg, target, profile) = dep; - let pkgid = pkg.package_id(); - if !target.is_lib() { continue } - if profile.doc { continue } - if cx.compilation.libraries.contains_key(&pkgid) { continue } - - let kind = kind.for_target(target); - let v = try!(cx.target_filenames(pkg, target, profile, kind)); - let v = v.into_iter().map(|f| { - (target.clone(), cx.out_dir(pkg, kind, target).join(f)) - }).collect::>(); - cx.compilation.libraries.insert(pkgid.clone(), v); + let kind = kind.for_target(target); + let v = + try!(cx.target_filenames(pkg, target, profile, kind)); + let v = v.into_iter().map(|f| { + (target.clone(), cx.out_dir(pkg, kind, target).join(f)) + }).collect::>(); + cx.compilation.libraries.insert(pkgid.clone(), v); + } } } - } - if let Some(feats) = cx.resolve.features(pkg.package_id()) { - cx.compilation.features.extend(feats.iter().cloned()); + cx.compilation.tests.push((pkg.clone(), tests)); + + if let Some(feats) = cx.resolve.features(pkg.package_id()) { + cx.compilation.features.extend(feats.iter().cloned()); + } } for (&(ref pkg, _), output) in cx.build_state.outputs.lock().unwrap().iter() { @@ -199,18 +208,17 @@ fn compile<'a, 'cfg>(targets: &[(&'a Target, &'a Profile)], }); // Figure out what stage this work will go into - let dst = match (target.is_lib(), + let stage = match (target.is_lib(), profile.test, target.is_custom_build()) { - (_, _, true) => jobs.queue(pkg, Stage::BuildCustomBuild), - (true, true, _) => jobs.queue(pkg, Stage::LibraryTests), - (false, true, _) => jobs.queue(pkg, Stage::BinaryTests), - (true, false, _) => jobs.queue(pkg, Stage::Libraries), - (false, false, _) if !target.is_bin() => { - jobs.queue(pkg, Stage::BinaryTests) - } - (false, false, _) => jobs.queue(pkg, Stage::Binaries), + (_, _, true) => Stage::BuildCustomBuild, + (true, true, _) => Stage::LibraryTests, + (false, true, _) => Stage::BinaryTests, + (true, false, _) => Stage::Libraries, + (false, false, _) if !target.is_bin() => Stage::BinaryTests, + (false, false, _) => Stage::Binaries, }; + let dst = jobs.queue(pkg, stage); dst.push((Job::new(dirty, fresh), freshness)); } diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 555b239c0a2..51357eca1f1 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -169,3 +169,44 @@ fn run_doc_tests(options: &TestOptions, } Ok(errors) } + +fn build_and_run<'a>(manifest_path: &Path, + options: &TestOptions<'a>, + test_args: &[String]) + -> CargoResult, ProcessError>> { + let config = options.compile_opts.config; + let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(), + config)); + try!(source.update()); + + let mut compile = try!(ops::compile(manifest_path, &options.compile_opts)); + if options.no_run { return Ok(Ok(compile)) } + compile.tests.iter_mut() + .map(|&mut (_, ref mut tests)| + tests.sort_by(|&(ref n1, _), &(ref n2, _)| n1.cmp(n2))) + .collect::>(); + + let cwd = config.cwd(); + for &(ref pkg, ref tests) in &compile.tests { + for &(_, ref exe) in tests { + let to_display = match util::without_prefix(exe, &cwd) { + Some(path) => path, + None => &**exe, + }; + let mut cmd = try!(compile.target_process(exe, pkg)); + cmd.args(test_args); + try!(config.shell().concise(|shell| { + shell.status("Running", to_display.display().to_string()) + })); + try!(config.shell().verbose(|shell| { + shell.status("Running", cmd.to_string()) + })); + match ExecEngine::exec(&mut ProcessEngine, cmd) { + Ok(()) => {} + Err(e) => return Ok(Err(e)) + } + } + } + + Ok(Ok(compile)) +} diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index b8930f2b872..87e47c2d446 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1925,3 +1925,61 @@ test!(rustc_no_trans { assert_that(p.cargo("rustc").arg("-v").arg("--").arg("-Zno-trans"), execs().with_status(0)); }); + +test!(build_multiple_packages { + + + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.d1] + path = "d1" + [dependencies.d2] + path = "d2" + + [[bin]] + name = "foo" + "#) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .file("d1/Cargo.toml", r#" + [package] + name = "d1" + version = "0.0.1" + authors = [] + + [[bin]] + name = "d1" + "#) + .file("d1/src/lib.rs", "") + .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }") + .file("d2/Cargo.toml", r#" + [package] + name = "d2" + version = "0.0.1" + authors = [] + + [[bin]] + name = "d2" + doctest = false + "#) + .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }"); + p.build(); + + assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("d2").arg("-p").arg("foo"), execs()); + + assert_that(&p.bin("foo"), existing_file()); + assert_that(process(&p.bin("foo")).unwrap(), + execs().with_stdout("i am foo\n")); + + assert_that(&p.build_dir().join("debug").join("deps").join("d1"), existing_file()); + assert_that(process(&p.build_dir().join("debug").join("deps").join("d1")).unwrap(), + execs().with_stdout("d1")); + + assert_that(&p.build_dir().join("debug").join("deps").join("d2"), existing_file()); + assert_that(process(&p.build_dir().join("debug").join("deps").join("d2")).unwrap(), + execs().with_stdout("d2")); +}); diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 57d37129d6c..93517837978 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -432,3 +432,48 @@ test!(doc_release { {running} `rustdoc src[..]lib.rs [..]` ", compiling = COMPILING, running = RUNNING))); }); + +test!(doc_multiple_deps { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "bar" + + [dependencies.baz] + path = "baz" + "#) + .file("src/lib.rs", r#" + extern crate bar; + pub fn foo() {} + "#) + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + "#) + .file("bar/src/lib.rs", r#" + pub fn bar() {} + "#) + .file("baz/Cargo.toml", r#" + [package] + name = "baz" + version = "0.0.1" + authors = [] + "#) + .file("baz/src/lib.rs", r#" + pub fn baz() {} + "#); + + assert_that(p.cargo_process("doc").arg("-p").arg("bar").arg("-p").arg("baz"), + execs().with_status(0)); + + assert_that(&p.root().join("target/doc"), existing_dir()); + assert_that(&p.root().join("target/doc/bar/index.html"), existing_file()); + assert_that(&p.root().join("target/doc/baz/index.html"), existing_file()); +}); diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index ab29bcc47e5..32787d998a7 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -1935,3 +1935,63 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured ", compiling = COMPILING, running = RUNNING, doctest = DOCTEST))) }); + +test!(test_multiple_packages { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.d1] + path = "d1" + [dependencies.d2] + path = "d2" + + [lib] + name = "foo" + doctest = false + "#) + .file("src/lib.rs", "") + .file("d1/Cargo.toml", r#" + [package] + name = "d1" + version = "0.0.1" + authors = [] + + [lib] + name = "d1" + doctest = false + "#) + .file("d1/src/lib.rs", "") + .file("d2/Cargo.toml", r#" + [package] + name = "d2" + version = "0.0.1" + authors = [] + + [lib] + name = "d2" + doctest = false + "#) + .file("d2/src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("test").arg("-p").arg("d1").arg("-p").arg("d2"), + execs().with_status(0) + .with_stdout_contains(&format!("\ +{running} target[..]debug[..]d1-[..] + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured +", running = RUNNING)) + .with_stdout_contains(&format!("\ +{running} target[..]debug[..]d2-[..] + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured +", running = RUNNING))); +}); From 092107d2163ce1a81b95d523288bd4fa16c6bbe6 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 12 Sep 2015 23:32:35 +0200 Subject: [PATCH 0036/3888] Use docopt's new syntax for repeatable options --- src/bin/bench.rs | 34 +++++------ src/bin/build.rs | 34 +++++------ src/bin/doc.rs | 28 ++++----- src/bin/rustc.rs | 34 +++++------ src/bin/test.rs | 38 ++++++------ src/cargo/ops/cargo_rustc/mod.rs | 3 +- src/cargo/ops/cargo_test.rs | 99 +++++++++++--------------------- tests/support/mod.rs | 47 ++++++++++++++- tests/test_cargo_bench.rs | 85 +++++++++++++++++++++++++++ tests/test_cargo_compile.rs | 6 +- tests/test_cargo_rustc.rs | 69 +++++++++++++++++++++- 11 files changed, 321 insertions(+), 156 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 47150dfab89..7e658997d28 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -26,25 +26,25 @@ pub const USAGE: &'static str = " Execute all benchmarks of a local package Usage: - cargo bench [options] [-p SPEC --package SPEC]... [--] [...] + cargo bench [options] [--] [...] Options: - -h, --help Print this message - --lib Benchmark only this package's library - --bin NAME Benchmark only the specified binary - --example NAME Benchmark only the specified example - --test NAME Benchmark only the specified test target - --bench NAME Benchmark only the specified bench target - --no-run Compile, but don't run benchmarks - -p SPEC, --package SPEC Package to run benchmarks for - -j N, --jobs N The number of jobs to run in parallel - --features FEATURES Space-separated list of features to also build - --no-default-features Do not build the `default` feature - --target TRIPLE Build for the target triple - --manifest-path PATH Path to the manifest to build benchmarks for - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never + -h, --help Print this message + --lib Benchmark only this package's library + --bin NAME Benchmark only the specified binary + --example NAME Benchmark only the specified example + --test NAME Benchmark only the specified test target + --bench NAME Benchmark only the specified bench target + --no-run Compile, but don't run benchmarks + -p SPEC, --package SPEC ... Package to run benchmarks for + -j N, --jobs N The number of jobs to run in parallel + --features FEATURES Space-separated list of features to also build + --no-default-features Do not build the `default` feature + --target TRIPLE Build for the target triple + --manifest-path PATH Path to the manifest to build benchmarks for + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never All of the trailing arguments are passed to the benchmark binaries generated for filtering benchmarks and generally providing options configuring how they diff --git a/src/bin/build.rs b/src/bin/build.rs index 6140ca961be..27bcf57b122 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -28,25 +28,25 @@ pub const USAGE: &'static str = " Compile a local package and all of its dependencies Usage: - cargo build [options] [-p SPEC --package SPEC]... + cargo build [options] Options: - -h, --help Print this message - -p SPEC, --package SPEC Package to build - -j N, --jobs N The number of jobs to run in parallel - --lib Build only this package's library - --bin NAME Build only the specified binary - --example NAME Build only the specified example - --test NAME Build only the specified test target - --bench NAME Build only the specified benchmark target - --release Build artifacts in release mode, with optimizations - --features FEATURES Space-separated list of features to also build - --no-default-features Do not build the `default` feature - --target TRIPLE Build for the target triple - --manifest-path PATH Path to the manifest to compile - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never + -h, --help Print this message + -p SPEC, --package SPEC ... Package to build + -j N, --jobs N The number of jobs to run in parallel + --lib Build only this package's library + --bin NAME Build only the specified binary + --example NAME Build only the specified example + --test NAME Build only the specified test target + --bench NAME Build only the specified benchmark target + --release Build artifacts in release mode, with optimizations + --features FEATURES Space-separated list of features to also build + --no-default-features Do not build the `default` feature + --target TRIPLE Build for the target triple + --manifest-path PATH Path to the manifest to compile + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never If the --package argument is given, then SPEC is a package id specification which indicates which package should be built. If it is not given, then the diff --git a/src/bin/doc.rs b/src/bin/doc.rs index 8bc6289b5df..16fd12430ec 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -22,22 +22,22 @@ pub const USAGE: &'static str = " Build a package's documentation Usage: - cargo doc [options] [-p SPEC --package SPEC]... + cargo doc [options] Options: - -h, --help Print this message - --open Opens the docs in a browser after the operation - -p SPEC, --package SPEC Package to document - --no-deps Don't build documentation for dependencies - -j N, --jobs N The number of jobs to run in parallel - --release Build artifacts in release mode, with optimizations - --features FEATURES Space-separated list of features to also build - --no-default-features Do not build the `default` feature - --target TRIPLE Build for the target triple - --manifest-path PATH Path to the manifest to document - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never + -h, --help Print this message + --open Opens the docs in a browser after the operation + -p SPEC, --package SPEC ... Package to document + --no-deps Don't build documentation for dependencies + -j N, --jobs N The number of jobs to run in parallel + --release Build artifacts in release mode, with optimizations + --features FEATURES Space-separated list of features to also build + --no-default-features Do not build the `default` feature + --target TRIPLE Build for the target triple + --manifest-path PATH Path to the manifest to document + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never By default the documentation for the local package and all dependencies is built. The output is all placed in `target/doc` in rustdoc's usual format. diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 4b7121f43e5..f1fb15a479e 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -29,25 +29,25 @@ pub const USAGE: &'static str = " Compile a package and all of its dependencies Usage: - cargo rustc [options] [-p SPEC --package SPEC]... [--] [...] + cargo rustc [options] [--] [...] Options: - -h, --help Print this message - -p SPEC, --package SPEC The profile to compile for - -j N, --jobs N The number of jobs to run in parallel - --lib Build only this package's library - --bin NAME Build only the specified binary - --example NAME Build only the specified example - --test NAME Build only the specified test target - --bench NAME Build only the specified benchmark target - --release Build artifacts in release mode, with optimizations - --features FEATURES Features to compile for the package - --no-default-features Do not compile default features for the package - --target TRIPLE Target triple which compiles will be for - --manifest-path PATH Path to the manifest to fetch dependencies for - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never + -h, --help Print this message + -p SPEC, --package SPEC ... The profile to compile for + -j N, --jobs N The number of jobs to run in parallel + --lib Build only this package's library + --bin NAME Build only the specified binary + --example NAME Build only the specified example + --test NAME Build only the specified test target + --bench NAME Build only the specified benchmark target + --release Build artifacts in release mode, with optimizations + --features FEATURES Features to compile for the package + --no-default-features Do not compile default features for the package + --target TRIPLE Target triple which compiles will be for + --manifest-path PATH Path to the manifest to fetch dependencies for + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never The specified target for the current package (or package specified by SPEC if provided) will be compiled along with all of its dependencies. The specified diff --git a/src/bin/test.rs b/src/bin/test.rs index 9b89fb91211..09981e0bed8 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -28,27 +28,27 @@ pub const USAGE: &'static str = " Execute all unit and integration tests of a local package Usage: - cargo test [options] [-p SPEC --package SPEC]... [--] [...] + cargo test [options] [--] [...] Options: - -h, --help Print this message - --lib Test only this package's library - --bin NAME Test only the specified binary - --example NAME Test only the specified example - --test NAME Test only the specified integration test target - --bench NAME Test only the specified benchmark target - --no-run Compile, but don't run tests - -p SPEC, --package SPEC Package to run tests for - -j N, --jobs N The number of jobs to run in parallel - --release Build artifacts in release mode, with optimizations - --features FEATURES Space-separated list of features to also build - --no-default-features Do not build the `default` feature - --target TRIPLE Build for the target triple - --manifest-path PATH Path to the manifest to build tests for - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never - --no-fail-fast Run all tests regardless of failure + -h, --help Print this message + --lib Test only this package's library + --bin NAME Test only the specified binary + --example NAME Test only the specified example + --test NAME Test only the specified integration test target + --bench NAME Test only the specified benchmark target + --no-run Compile, but don't run tests + -p SPEC, --package SPEC ... Package to run tests for + -j N, --jobs N The number of jobs to run in parallel + --release Build artifacts in release mode, with optimizations + --features FEATURES Space-separated list of features to also build + --no-default-features Do not build the `default` feature + --target TRIPLE Build for the target triple + --manifest-path PATH Path to the manifest to build tests for + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never + --no-fail-fast Run all tests regardless of failure All of the trailing arguments are passed to the test binaries generated for filtering tests and generally providing options configuring how they run. For diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 1c2ad0705aa..53167b0d4b7 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -54,6 +54,7 @@ pub struct TargetConfig { // Returns a mapping of the root package plus its immediate dependencies to // where the compiled libraries are all located. +#[allow(deprecated)] // connect => join in 1.3 pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, Vec<(&Target, &'a Profile)>)], @@ -66,7 +67,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, -> CargoResult> { debug!("compile_targets: {}", pkg_targets.iter().map(|&(ref p, _)| p.name()) - .collect::>().join(", ")); + .collect::>().connect(", ")); try!(links::validate(deps)); diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 51357eca1f1..d1b985fa5c2 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -62,7 +62,10 @@ fn compile_tests<'a>(manifest_path: &Path, options: &TestOptions<'a>) -> CargoResult> { let mut compilation = try!(ops::compile(manifest_path, &options.compile_opts)); - compilation.tests.sort(); + compilation.tests.iter_mut() + .map(|&mut (_, ref mut tests)| + tests.sort_by(|&(ref n1, _), &(ref n2, _)| n1.cmp(n2))) + .collect::>(); Ok(compilation) } @@ -76,24 +79,26 @@ fn run_unit_tests(options: &TestOptions, let mut errors = Vec::new(); - for &(_, ref exe) in &compilation.tests { - let to_display = match util::without_prefix(exe, &cwd) { - Some(path) => path, - None => &**exe, - }; - let mut cmd = try!(compilation.target_process(exe, &compilation.package)); - cmd.args(test_args); - try!(config.shell().concise(|shell| { - shell.status("Running", to_display.display().to_string()) - })); - try!(config.shell().verbose(|shell| { - shell.status("Running", cmd.to_string()) - })); + for &(ref pkg, ref tests) in &compilation.tests { + for &(_, ref exe) in tests { + let to_display = match util::without_prefix(exe, &cwd) { + Some(path) => path, + None => &**exe, + }; + let mut cmd = try!(compilation.target_process(exe, pkg)); + cmd.args(test_args); + try!(config.shell().concise(|shell| { + shell.status("Running", to_display.display().to_string()) + })); + try!(config.shell().verbose(|shell| { + shell.status("Running", cmd.to_string()) + })); - if let Err(e) = ExecEngine::exec(&mut ProcessEngine, cmd) { - errors.push(e); - if !options.no_fail_fast { - break + if let Err(e) = ExecEngine::exec(&mut ProcessEngine, cmd) { + errors.push(e); + if !options.no_fail_fast { + break + } } } } @@ -107,15 +112,20 @@ fn run_doc_tests(options: &TestOptions, -> CargoResult> { let mut errors = Vec::new(); let config = options.compile_opts.config; - let libs = compilation.package.targets().iter() - .filter(|t| t.doctested()) - .map(|t| (t.src_path(), t.name(), t.crate_name())); - for (lib, name, crate_name) in libs { + + let mut libs = vec![]; + for package in compilation.to_doc_test.iter() { + libs.extend(package.targets().iter() + .filter(|t| t.doctested()) + .map(|t| (package, t.src_path(), t.name(), t.crate_name()))); + } + + for (package, lib, name, crate_name) in libs { try!(config.shell().status("Doc-tests", name)); - let mut p = try!(compilation.rustdoc_process(&compilation.package)); + let mut p = try!(compilation.rustdoc_process(package)); p.arg("--test").arg(lib) .arg("--crate-name").arg(&crate_name) - .cwd(compilation.package.root()); + .cwd(package.root()); for &rust_dep in &[&compilation.deps_output, &compilation.root_output] { let mut arg = OsString::from("dependency="); @@ -169,44 +179,3 @@ fn run_doc_tests(options: &TestOptions, } Ok(errors) } - -fn build_and_run<'a>(manifest_path: &Path, - options: &TestOptions<'a>, - test_args: &[String]) - -> CargoResult, ProcessError>> { - let config = options.compile_opts.config; - let mut source = try!(PathSource::for_path(&manifest_path.parent().unwrap(), - config)); - try!(source.update()); - - let mut compile = try!(ops::compile(manifest_path, &options.compile_opts)); - if options.no_run { return Ok(Ok(compile)) } - compile.tests.iter_mut() - .map(|&mut (_, ref mut tests)| - tests.sort_by(|&(ref n1, _), &(ref n2, _)| n1.cmp(n2))) - .collect::>(); - - let cwd = config.cwd(); - for &(ref pkg, ref tests) in &compile.tests { - for &(_, ref exe) in tests { - let to_display = match util::without_prefix(exe, &cwd) { - Some(path) => path, - None => &**exe, - }; - let mut cmd = try!(compile.target_process(exe, pkg)); - cmd.args(test_args); - try!(config.shell().concise(|shell| { - shell.status("Running", to_display.display().to_string()) - })); - try!(config.shell().verbose(|shell| { - shell.status("Running", cmd.to_string()) - })); - match ExecEngine::exec(&mut ProcessEngine, cmd) { - Ok(()) => {} - Err(e) => return Ok(Err(e)) - } - } - } - - Ok(Ok(compile)) -} diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 0f7602e99da..4411dd62582 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -269,7 +269,8 @@ pub struct Execs { expect_stdout: Option, expect_stdin: Option, expect_stderr: Option, - expect_exit_code: Option + expect_exit_code: Option, + expect_stdout_contains: Vec } impl Execs { @@ -289,6 +290,11 @@ impl Execs { self } + pub fn with_stdout_contains(mut self, expected: S) -> Execs { + self.expect_stdout_contains.push(expected.to_string()); + self + } + fn match_output(&self, actual: &Output) -> ham::MatchResult { self.match_status(actual) .and(self.match_stdout(actual)) @@ -312,6 +318,8 @@ impl Execs { fn match_stdout(&self, actual: &Output) -> ham::MatchResult { self.match_std(self.expect_stdout.as_ref(), &actual.stdout, "stdout", &actual.stderr) + .and(self.match_contains(self.expect_stdout_contains.as_ref(), + &actual.stdout, "stdout")) } fn match_stderr(&self, actual: &Output) -> ham::MatchResult { @@ -319,6 +327,40 @@ impl Execs { "stderr", &actual.stdout) } + #[allow(deprecated)] // connect => join in 1.3 + fn match_contains(&self, expect: &[String], actual: &[u8], + description: &str) -> ham::MatchResult { + for s in expect { + let a: Vec<&str> = match str::from_utf8(actual) { + Err(..) => return Err(format!("{} was not utf8 encoded", + description)), + Ok(actual) => actual.lines().collect(), + }; + let e: Vec<&str> = s.lines().collect(); + + let first = e.first().unwrap(); + let mut ai = a.iter(); + match ai.position(|s| lines_match(first, s)) { + Some(_) => { + let match_count = ai.zip(e.iter().skip(1)) + .take_while(|&(a, e)| lines_match(a, e)).count(); + if match_count != (e.len() - 1) { + return ham::expect(false, + format!("expected: {}\n\ + actual: {}", + e.connect("\n"), + a.iter().take(e.len()).map(|&s| s) + .collect::>().connect("\n"))); + } + }, + None => { + return ham::expect(false, format!("no match")); + } + }; + } + ham::expect(true, format!("OK")) + } + #[allow(deprecated)] // connect => join in 1.3 fn match_std(&self, expected: Option<&String>, actual: &[u8], description: &str, extra: &[u8]) -> ham::MatchResult { @@ -446,7 +488,8 @@ pub fn execs() -> Execs { expect_stdout: None, expect_stderr: None, expect_stdin: None, - expect_exit_code: None + expect_exit_code: None, + expect_stdout_contains: vec![] } } diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index 5e3b21cad53..1439172586d 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -922,3 +922,88 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured ", compiling = COMPILING, running = RUNNING))); }); + +test!(test_bench_multiple_packages { + if !::is_nightly() { return } + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + authors = [] + version = "0.1.0" + + [dependencies.bar] + path = "../bar" + + [dependencies.baz] + path = "../baz" + "#) + .file("src/lib.rs", ""); + + let bar = project("bar") + .file("Cargo.toml", r#" + [project] + name = "bar" + authors = [] + version = "0.1.0" + + [[bench]] + name = "bbar" + test = true + "#) + .file("src/lib.rs", "") + .file("benches/bbar.rs", r#" + #![feature(test)] + extern crate test; + + use test::Bencher; + + #[bench] + fn bench_bar(_b: &mut Bencher) {} + "#); + bar.build(); + + let baz = project("baz") + .file("Cargo.toml", r#" + [project] + name = "baz" + authors = [] + version = "0.1.0" + + [[bench]] + name = "bbaz" + test = true + "#) + .file("src/lib.rs", "") + .file("benches/bbaz.rs", r#" + #![feature(test)] + extern crate test; + + use test::Bencher; + + #[bench] + fn bench_baz(_b: &mut Bencher) {} + "#); + baz.build(); + + + assert_that(p.cargo_process("bench").arg("-p").arg("bar").arg("-p").arg("baz"), + execs().with_status(0) + .with_stdout_contains(&format!("\ +{running} target[..]release[..]bbaz-[..] + +running 1 test +test bench_baz ... bench: 0 ns/iter (+/- 0) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured +", running = RUNNING)) + .with_stdout_contains(&format!("\ +{running} target[..]release[..]bbar-[..] + +running 1 test +test bench_bar ... bench: 0 ns/iter (+/- 0) + +test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured +", running = RUNNING))); +}); diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 87e47c2d446..c67e50bb0ad 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1927,8 +1927,6 @@ test!(rustc_no_trans { }); test!(build_multiple_packages { - - let p = project("foo") .file("Cargo.toml", r#" [package] @@ -1969,7 +1967,9 @@ test!(build_multiple_packages { .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }"); p.build(); - assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("d2").arg("-p").arg("foo"), execs()); + assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("d2") + .arg("-p").arg("foo"), + execs()); assert_that(&p.bin("foo"), existing_file()); assert_that(process(&p.bin("foo")).unwrap(), diff --git a/tests/test_cargo_rustc.rs b/tests/test_cargo_rustc.rs index 8000517932c..18a09fae133 100644 --- a/tests/test_cargo_rustc.rs +++ b/tests/test_cargo_rustc.rs @@ -1,7 +1,9 @@ use std::path::MAIN_SEPARATOR as SEP; use support::{execs, project}; use support::{COMPILING, RUNNING}; -use hamcrest::{assert_that}; +use hamcrest::{assert_that, existing_file}; +use cargo::util::process; + fn setup() { } @@ -296,3 +298,68 @@ test!(build_only_bar_dependency { compiling = COMPILING, running = RUNNING, url = foo.url()))); }); + +test!(build_multiple_dependencies { + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + + [dependencies.baz] + path = "../baz" + "#) + .file("src/main.rs", r#" + fn main() {} + "#); + foo.build(); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", r#" + fn main() { + if cfg!(flag = "1") { println!("Yeah from bar!"); } + } + "#); + + bar.build(); + let baz = project("baz") + .file("Cargo.toml", r#" + [package] + name = "baz" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", r#" + fn main() { + if cfg!(flag = "1") { println!("Yeah from baz!"); } + } + "#); + baz.build(); + + assert_that(foo.cargo_process("rustc").arg("-v").arg("-p").arg("bar") + .arg("-p").arg("baz").arg("--").arg("--cfg").arg("flag=\"1\""), + execs() + .with_status(0)); + + let bar_bin = &foo.build_dir().join("debug").join("deps").join("bar"); + assert_that(bar_bin, existing_file()); + + assert_that( + process(bar_bin).unwrap(), + execs().with_stdout("Yeah from bar!\n")); + + let baz_bin = &foo.build_dir().join("debug").join("deps").join("baz"); + assert_that(bar_bin, existing_file()); + assert_that( + process(baz_bin).unwrap(), + execs().with_stdout("Yeah from baz!\n")); +}); From 6bc57bbf219cf40a0cce23b1355e8901000d0794 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Wed, 16 Sep 2015 00:29:38 +0200 Subject: [PATCH 0037/3888] Add support for multiple -p options to `cargo clean` --- src/bin/clean.rs | 18 +++++------ src/cargo/ops/cargo_clean.rs | 55 +++++++++++++++++---------------- tests/test_cargo_clean.rs | 59 +++++++++++++++++++++++++++++++++++- 3 files changed, 96 insertions(+), 36 deletions(-) diff --git a/src/bin/clean.rs b/src/bin/clean.rs index 18c6111e56e..8aea04d35a7 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -6,7 +6,7 @@ use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] struct Options { - flag_package: Option, + flag_package: Vec, flag_target: Option, flag_manifest_path: Option, flag_verbose: bool, @@ -21,13 +21,13 @@ Usage: cargo clean [options] Options: - -h, --help Print this message - -p SPEC, --package SPEC Package to clean artifacts for - --manifest-path PATH Path to the manifest to the package to clean - --target TRIPLE Target triple to clean output for (default all) - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never + -h, --help Print this message + -p SPEC, --package SPEC ... Package to clean artifacts for + --manifest-path PATH Path to the manifest to the package to clean + --target TRIPLE Target triple to clean output for (default all) + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never If the --package argument is given, then SPEC is a package id specification which indicates which package's artifacts should be cleaned out. If it is not @@ -43,7 +43,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); let opts = ops::CleanOptions { config: config, - spec: options.flag_package.as_ref().map(|s| &s[..]), + spec: &options.flag_package, target: options.flag_target.as_ref().map(|s| &s[..]), }; ops::clean(&root, &opts).map(|_| None).map_err(|err| { diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index c3bc268278b..06542b364c2 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -9,7 +9,7 @@ use util::{CargoResult, human, ChainError, Config}; use ops::{self, Layout, Context, BuildConfig, Kind}; pub struct CleanOptions<'a> { - pub spec: Option<&'a str>, + pub spec: &'a [String], pub target: Option<&'a str>, pub config: &'a Config, } @@ -21,28 +21,19 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { // If we have a spec, then we need to delete some packages, otherwise, just // remove the whole target directory and be done with it! - let spec = match opts.spec { - Some(spec) => spec, - None => return rm_rf(&target_dir), - }; + if opts.spec.len() == 0 { + return rm_rf(&target_dir); + } - // Load the lockfile (if one's available), and resolve spec to a pkgid + // Load the lockfile (if one's available) let lockfile = root.root().join("Cargo.lock"); let source_id = root.package_id().source_id(); let resolve = match try!(ops::load_lockfile(&lockfile, source_id)) { Some(resolve) => resolve, None => return Err(human("A Cargo.lock must exist before cleaning")) }; - let pkgid = try!(resolve.query(spec)); - - // Translate the PackageId to a Package - let pkg = { - let mut source = pkgid.source_id().load(opts.config); - try!(source.update()); - (try!(source.get(&[pkgid.clone()]))).into_iter().next().unwrap() - }; - // Create a compilation context to have access to information like target + // Create a compilation context to have access to information like target // filenames and such let srcs = SourceMap::new(); let pkgs = PackageSet::new(&[]); @@ -52,17 +43,29 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { None, BuildConfig::default(), &profiles)); - // And finally, clean everything out! - for target in pkg.targets().iter() { - // TODO: `cargo clean --release` - let layout = Layout::new(opts.config, &root, opts.target, "debug"); - try!(rm_rf(&layout.fingerprint(&pkg))); - let profiles = [Profile::default_dev(), Profile::default_test()]; - for profile in profiles.iter() { - for filename in try!(cx.target_filenames(&pkg, target, profile, - Kind::Target)).iter() { - try!(rm_rf(&layout.dest().join(&filename))); - try!(rm_rf(&layout.deps().join(&filename))); + // resolve package specs and remove the corresponding packages + for spec in opts.spec { + let pkgid = try!(resolve.query(spec)); + + // Translate the PackageId to a Package + let pkg = { + let mut source = pkgid.source_id().load(opts.config); + try!(source.update()); + (try!(source.get(&[pkgid.clone()]))).into_iter().next().unwrap() + }; + + // And finally, clean everything out! + for target in pkg.targets().iter() { + // TODO: `cargo clean --release` + let layout = Layout::new(opts.config, &root, opts.target, "debug"); + try!(rm_rf(&layout.fingerprint(&pkg))); + let profiles = [Profile::default_dev(), Profile::default_test()]; + for profile in profiles.iter() { + for filename in try!(cx.target_filenames(&pkg, target, profile, + Kind::Target)).iter() { + try!(rm_rf(&layout.dest().join(&filename))); + try!(rm_rf(&layout.deps().join(&filename))); + } } } } diff --git a/tests/test_cargo_clean.rs b/tests/test_cargo_clean.rs index 9ccd8f7314f..4b2828a6e81 100644 --- a/tests/test_cargo_clean.rs +++ b/tests/test_cargo_clean.rs @@ -1,5 +1,5 @@ use support::{project, execs, main_file, basic_bin_manifest}; -use hamcrest::{assert_that, existing_dir, is_not}; +use hamcrest::{assert_that, existing_dir, existing_file, is_not}; fn setup() { } @@ -30,3 +30,60 @@ test!(different_dir { execs().with_status(0).with_stdout("")); assert_that(&p.build_dir(), is_not(existing_dir())); }); + +test!(clean_multiple_packages { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.d1] + path = "d1" + [dependencies.d2] + path = "d2" + + [[bin]] + name = "foo" + "#) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .file("d1/Cargo.toml", r#" + [package] + name = "d1" + version = "0.0.1" + authors = [] + + [[bin]] + name = "d1" + "#) + .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }") + .file("d2/Cargo.toml", r#" + [package] + name = "d2" + version = "0.0.1" + authors = [] + + [[bin]] + name = "d2" + "#) + .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }"); + p.build(); + + assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("d2") + .arg("-p").arg("foo"), + execs().with_status(0)); + + assert_that(&p.bin("foo"), existing_file()); + assert_that(&p.build_dir().join("debug").join("deps").join("d1"), existing_file()); + assert_that(&p.build_dir().join("debug").join("deps").join("d2"), existing_file()); + + assert_that(p.cargo("clean").arg("-p").arg("d1").arg("-p").arg("d2") + .cwd(&p.root().join("src")), + execs().with_status(0).with_stdout("")); + assert_that(&p.bin("foo"), existing_file()); + assert_that(&p.build_dir().join("debug").join("deps").join("d1"), + is_not(existing_file())); + assert_that(&p.build_dir().join("debug").join("deps").join("d2"), + is_not(existing_file())); +}); From dcc372bb5e9c004f50180ac6cf320e02ad9fced3 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Wed, 16 Sep 2015 01:02:37 +0200 Subject: [PATCH 0038/3888] Add support for multiple -p options to `cargo update` closes #1528 --- src/bin/rustc.rs | 36 +++---- src/bin/update.rs | 22 ++-- src/cargo/core/registry.rs | 8 +- src/cargo/ops/cargo_clean.rs | 2 +- src/cargo/ops/cargo_compile.rs | 89 ++++++++-------- src/cargo/ops/cargo_doc.rs | 11 +- src/cargo/ops/cargo_generate_lockfile.rs | 23 ++--- src/cargo/ops/cargo_rustc/context.rs | 22 ++-- src/cargo/ops/cargo_rustc/custom_build.rs | 14 +-- src/cargo/ops/cargo_rustc/mod.rs | 48 ++++----- src/cargo/ops/cargo_test.rs | 118 +++++++++++----------- tests/test_cargo_compile.rs | 38 +++++++ tests/test_cargo_registry.rs | 60 +++++++++++ tests/test_cargo_rustc.rs | 30 ++---- 14 files changed, 301 insertions(+), 220 deletions(-) diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index f1fb15a479e..54c0dd36bcf 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -8,7 +8,7 @@ use cargo::util::{CliResult, CliError, Config}; #[derive(RustcDecodable)] struct Options { arg_opts: Option>, - flag_package: Vec, + flag_package: Option, flag_jobs: Option, flag_features: Vec, flag_no_default_features: bool, @@ -32,22 +32,22 @@ Usage: cargo rustc [options] [--] [...] Options: - -h, --help Print this message - -p SPEC, --package SPEC ... The profile to compile for - -j N, --jobs N The number of jobs to run in parallel - --lib Build only this package's library - --bin NAME Build only the specified binary - --example NAME Build only the specified example - --test NAME Build only the specified test target - --bench NAME Build only the specified benchmark target - --release Build artifacts in release mode, with optimizations - --features FEATURES Features to compile for the package - --no-default-features Do not compile default features for the package - --target TRIPLE Target triple which compiles will be for - --manifest-path PATH Path to the manifest to fetch dependencies for - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never + -h, --help Print this message + -p SPEC, --package SPEC The profile to compile for + -j N, --jobs N The number of jobs to run in parallel + --lib Build only this package's library + --bin NAME Build only the specified binary + --example NAME Build only the specified example + --test NAME Build only the specified test target + --bench NAME Build only the specified benchmark target + --release Build artifacts in release mode, with optimizations + --features FEATURES Features to compile for the package + --no-default-features Do not compile default features for the package + --target TRIPLE Target triple which compiles will be for + --manifest-path PATH Path to the manifest to fetch dependencies for + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never The specified target for the current package (or package specified by SPEC if provided) will be compiled along with all of its dependencies. The specified @@ -75,7 +75,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: &options.flag_package, + spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]), exec_engine: None, mode: ops::CompileMode::Build, release: options.flag_release, diff --git a/src/bin/update.rs b/src/bin/update.rs index cd4cd1173aa..75cac7a70ef 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -6,7 +6,7 @@ use cargo::util::important_paths::find_root_manifest_for_cwd; #[derive(RustcDecodable)] struct Options { - flag_package: Option, + flag_package: Vec, flag_aggressive: bool, flag_precise: Option, flag_manifest_path: Option, @@ -22,14 +22,14 @@ Usage: cargo update [options] Options: - -h, --help Print this message - -p SPEC, --package SPEC Package to update - --aggressive Force updating all dependencies of as well - --precise PRECISE Update a single dependency to exactly PRECISE - --manifest-path PATH Path to the manifest to compile - -v, --verbose Use verbose output - -q, --quiet No output printed to stdout - --color WHEN Coloring: auto, always, never + -h, --help Print this message + -p SPEC, --package SPEC ... Package to update + --aggressive Force updating all dependencies of as well + --precise PRECISE Update a single dependency to exactly PRECISE + --manifest-path PATH Path to the manifest to compile + -v, --verbose Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never This command requires that a `Cargo.lock` already exists as generated by `cargo build` or related commands. @@ -58,12 +58,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path)); - let spec = options.flag_package.as_ref(); - let update_opts = ops::UpdateOptions { aggressive: options.flag_aggressive, precise: options.flag_precise.as_ref().map(|s| &s[..]), - to_update: spec.map(|s| &s[..]), + to_update: &options.flag_package, config: config, }; diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index a5880b0af12..1c21e0d9607 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -111,7 +111,7 @@ impl<'cfg> PackageRegistry<'cfg> { self.sources } - fn ensure_loaded(&mut self, namespace: &SourceId) -> CargoResult<()> { + fn ensure_loaded(&mut self, namespace: &SourceId, kind: Kind) -> CargoResult<()> { match self.source_ids.get(namespace) { // We've previously loaded this source, and we've already locked it, // so we're not allowed to change it even if `namespace` has a @@ -143,13 +143,13 @@ impl<'cfg> PackageRegistry<'cfg> { } } - try!(self.load(namespace, Kind::Normal)); + try!(self.load(namespace, kind)); Ok(()) } pub fn add_sources(&mut self, ids: &[SourceId]) -> CargoResult<()> { for id in ids.iter() { - try!(self.load(id, Kind::Locked)); + try!(self.ensure_loaded(id, Kind::Locked)); } Ok(()) } @@ -288,7 +288,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> { let ret = if overrides.len() == 0 { // Ensure the requested source_id is loaded - try!(self.ensure_loaded(dep.source_id())); + try!(self.ensure_loaded(dep.source_id(), Kind::Normal)); let mut ret = Vec::new(); for (id, src) in self.sources.sources_mut() { if id == dep.source_id() { diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 06542b364c2..f9e4107e9f5 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -33,7 +33,7 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { None => return Err(human("A Cargo.lock must exist before cleaning")) }; - // Create a compilation context to have access to information like target + // Create a compilation context to have access to information like target // filenames and such let srcs = SourceMap::new(); let pkgs = PackageSet::new(&[]); diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 41d0add87ae..b52cae00213 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -28,7 +28,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use core::registry::PackageRegistry; -use core::{Source, SourceId, PackageSet, Package, Target, PackageId}; +use core::{Source, SourceId, PackageSet, Package, Target}; use core::{Profile, TargetKind}; use core::resolver::Method; use ops::{self, BuildOutput, ExecEngine}; @@ -95,10 +95,11 @@ pub fn compile<'a>(manifest_path: &Path, compile_pkg(&package, options) } +#[allow(deprecated)] // connect => join in 1.3 pub fn compile_pkg<'a>(root_package: &Package, options: &CompileOptions<'a>) -> CargoResult> { - let CompileOptions { config, jobs, target, ref spec, features, + let CompileOptions { config, jobs, target, spec, features, no_default_features, release, mode, ref filter, ref exec_engine, ref target_rustc_args } = *options; @@ -116,16 +117,10 @@ pub fn compile_pkg<'a>(root_package: &Package, return Err(human("jobs must be at least 1")) } + let override_ids = try!(source_ids_from_config(options.config, root_package.root())); + let (packages, resolve_with_overrides, sources) = { - let override_ids = - try!(source_ids_from_config(options.config, root_package.root())); let mut registry = PackageRegistry::new(options.config); - if let Some(source) = source { - registry.preload(root_package.package_id().source_id(), source); - } else { - try!(registry.add_sources(&[root_package.package_id().source_id() - .clone()])); - } // First, resolve the root_package's *listed* dependencies, as well as // downloading and updating all remotes and such. @@ -141,19 +136,14 @@ pub fn compile_pkg<'a>(root_package: &Package, let method = Method::Required{ dev_deps: true, // TODO: remove this option? features: &features, - uses_default_features: !options.no_default_features, + uses_default_features: !no_default_features, }; let resolved_with_overrides = try!(ops::resolve_with_previous(&mut registry, root_package, method, Some(&resolve), None)); - let req: Vec = resolved_with_overrides.iter().map(|r| { - r.clone() - }).collect(); - let packages = try!(registry.get(&req).chain_error(|| { - human("Unable to get packages from source") - })); + let packages = try!(ops::get_resolved_packages(&resolved_with_overrides, &mut registry)); (packages, resolved_with_overrides, registry.move_sources()) }; @@ -170,49 +160,52 @@ pub fn compile_pkg<'a>(root_package: &Package, vec![root_package.package_id()] }; - /* if spec.len() > 0 && invalid_spec.len() > 0 { return Err(human(format!("could not find package matching spec `{}`", - invalid_spec.join(", ")))); - } */ - - let to_builds = packages.iter().filter(|p| - pkgids.iter().find(|&op| *op == p.package_id()).is_some() - ).collect::>(); - - let mut twas = &mut vec![]; - let mut package_targets = vec![]; + invalid_spec.connect(", ")))); + } - for &to_build in to_builds.iter() { - let targets = try!(generate_targets(to_build, mode, filter, release)); + let to_builds = packages.iter().filter(|p| pkgids.contains(&p.package_id())) + .collect::>(); + + let mut general_targets = Vec::new(); + let mut package_targets = Vec::new(); + + match *target_rustc_args { + Some(args) => { + if to_builds.len() == 1 { + let targets = try!(generate_targets(to_builds[0], mode, filter, release)); + if targets.len() == 1 { + let (target, profile) = targets[0]; + let mut profile = profile.clone(); + profile.rustc_args = Some(args.to_vec()); + general_targets.push((target, profile)); + } else { + return Err(human("extra arguments to `rustc` can only be \ + passed to one target, consider \ + filtering\nthe package by passing e.g. \ + `--lib` or `--bin NAME` to specify \ + a single target")) - match *target_rustc_args { - Some(args) if targets.len() == 1 => { - let (target, profile) = targets[0]; - let mut profile = profile.clone(); - profile.rustc_args = Some(args.to_vec()); - twas.push((target, profile)); + } + } else { + panic!("`rustc` should not accept multiple `-p` flags") } - Some(_) => { - return Err(human("extra arguments to `rustc` can only be \ - passed to one target, consider \ - filtering\nthe package by passing e.g. \ - `--lib` or `--bin NAME` to specify \ - a single target")) + } + None => { + for &to_build in to_builds.iter() { + let targets = try!(generate_targets(to_build, mode, filter, release)); + package_targets.push((to_build, targets)); } - None => package_targets.push((to_build, targets)), - }; - - } + } + }; - for targets in twas { - let (target, ref profile) = *targets; + for &(target, ref profile) in &general_targets { for &to_build in to_builds.iter() { package_targets.push((to_build, vec![(target, profile)])); } } - let mut ret = { let _p = profile::start("compiling"); let mut build_config = try!(scrape_build_config(config, jobs, target)); diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index ca95b82a92d..296b792c061 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -39,11 +39,12 @@ pub fn doc(manifest_path: &Path, try!(ops::compile(manifest_path, &options.compile_opts)); if options.open_result { - let name = if options.compile_opts.spec.len() > 0{ - // TODO - try!(PackageIdSpec::parse(options.compile_opts.spec.first() - .unwrap())).name().replace("-", "_") - .to_string() + let name = if options.compile_opts.spec.len() > 1 { + return Err(human("Passing multiple packages and `open` is not \ + supported")) + } else if options.compile_opts.spec.len() == 1 { + try!(PackageIdSpec::parse(&options.compile_opts.spec[0])) + .name().replace("-", "_").to_string() } else { match lib_names.iter().chain(bin_names.iter()).nth(0) { Some(s) => s.to_string(), diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 5edca1acef7..ac5578e0c9e 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -11,7 +11,7 @@ use util::{CargoResult, human}; pub struct UpdateOptions<'a> { pub config: &'a Config, - pub to_update: Option<&'a str>, + pub to_update: &'a [String], pub precise: Option<&'a str>, pub aggressive: bool, } @@ -44,15 +44,18 @@ pub fn update_lockfile(manifest_path: &Path, let mut registry = PackageRegistry::new(opts.config); let mut to_avoid = HashSet::new(); - match opts.to_update { - Some(name) => { + if opts.to_update.len() == 0 { + to_avoid.extend(previous_resolve.iter()); + } else { + let mut sources = Vec::new(); + for name in opts.to_update { let dep = try!(previous_resolve.query(name)); if opts.aggressive { fill_with_deps(&previous_resolve, dep, &mut to_avoid, &mut HashSet::new()); } else { to_avoid.insert(dep); - match opts.precise { + sources.push(match opts.precise { Some(precise) => { // TODO: see comment in `resolve.rs` as well, but this // seems like a pretty hokey reason to single out @@ -62,19 +65,15 @@ pub fn update_lockfile(manifest_path: &Path, } else { precise.to_string() }; - let precise = dep.source_id().clone() - .with_precise(Some(precise)); - try!(registry.add_sources(&[precise])); + dep.source_id().clone().with_precise(Some(precise)) } None => { - let imprecise = dep.source_id().clone() - .with_precise(None); - try!(registry.add_sources(&[imprecise])); + dep.source_id().clone().with_precise(None) } - } + }); } } - None => to_avoid.extend(previous_resolve.iter()), + try!(registry.add_sources(&sources)); } let resolve = try!(ops::resolve_with_previous(&mut registry, diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 13699781345..15c5d3dc22e 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -18,6 +18,7 @@ use super::fingerprint::Fingerprint; use super::layout::{Layout, LayoutProxy}; use super::{Kind, Compilation, BuildConfig}; use super::{ProcessEngine, ExecEngine}; +use super::PackagesToBuild; #[derive(Debug, Clone, Copy)] pub enum Platform { @@ -142,36 +143,35 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Prepare this context, ensuring that all filesystem directories are in /// place. - pub fn prepare(&mut self, pkg: &'a Package, - targets: &[(&'a Target, &'a Profile)]) - -> CargoResult<()> { + pub fn prepare(&mut self, root: &Package, + pkgs: &'a PackagesToBuild<'a>) -> CargoResult<()> { let _p = profile::start("preparing layout"); try!(self.host.prepare().chain_error(|| { - internal(format!("couldn't prepare build directories for `{}`", - pkg.name())) + internal(format!("couldn't prepare build directories")) })); match self.target { Some(ref mut target) => { try!(target.prepare().chain_error(|| { - internal(format!("couldn't prepare build directories \ - for `{}`", pkg.name())) + internal(format!("couldn't prepare build directories")) })); } None => {} } - for &(target, profile) in targets { - self.build_requirements(pkg, target, profile, Kind::from(target)); + for &(pkg, ref targets) in pkgs { + for &(target, profile) in targets { + self.build_requirements(pkg, target, profile, Kind::from(target)); + } } let jobs = self.jobs(); self.compilation.extra_env.insert("NUM_JOBS".to_string(), jobs.to_string()); self.compilation.root_output = - self.layout(pkg, Kind::Target).proxy().dest().to_path_buf(); + self.layout(root, Kind::Target).proxy().dest().to_path_buf(); self.compilation.deps_output = - self.layout(pkg, Kind::Target).proxy().deps().to_path_buf(); + self.layout(root, Kind::Target).proxy().deps().to_path_buf(); return Ok(()); } diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index a12f27bfd6f..c84bfeaf10b 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -8,11 +8,12 @@ use std::sync::Mutex; use core::{Package, Target, PackageId, PackageSet, Profile}; use util::{CargoResult, human, Human}; use util::{internal, ChainError, profile}; +use util::Freshness; use super::job::Work; use super::{fingerprint, process, Kind, Context, Platform}; use super::CommandType; -use util::Freshness; +use super::PackagesToBuild; /// Contains the parsed output of a custom build script. #[derive(Clone, Debug)] @@ -350,12 +351,13 @@ impl BuildOutput { /// The given set of targets to this function is the initial set of /// targets/profiles which are being built. pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, - pkg: &'b Package, - targets: &[(&'b Target, &'b Profile)]) { + pkgs: &'b PackagesToBuild<'b>) { let mut ret = HashMap::new(); - for &(target, profile) in targets { - build(&mut ret, Kind::Target, pkg, target, profile, cx); - build(&mut ret, Kind::Host, pkg, target, profile, cx); + for &(pkg, ref targets) in pkgs { + for &(target, profile) in targets { + build(&mut ret, Kind::Target, pkg, target, profile, cx); + build(&mut ret, Kind::Host, pkg, target, profile, cx); + } } // Make the output a little more deterministic by sorting all dependencies diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 53167b0d4b7..55ef3dcc0cf 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -52,12 +52,11 @@ pub struct TargetConfig { pub overrides: HashMap, } +pub type PackagesToBuild<'a> = [(&'a Package,Vec<(&'a Target,&'a Profile)>)]; + // Returns a mapping of the root package plus its immediate dependencies to // where the compiled libraries are all located. -#[allow(deprecated)] // connect => join in 1.3 -pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, - Vec<(&Target, - &'a Profile)>)], +pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a PackagesToBuild<'a>, deps: &'a PackageSet, resolve: &'a Resolve, sources: &'a SourceMap<'cfg>, @@ -66,9 +65,6 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, profiles: &'a Profiles) -> CargoResult> { - debug!("compile_targets: {}", pkg_targets.iter().map(|&(ref p, _)| p.name()) - .collect::>().connect(", ")); - try!(links::validate(deps)); let dest = if build_config.release {"release"} else {"debug"}; @@ -88,11 +84,14 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, let _p = profile::start("preparing build directories"); // Prep the context's build requirements and see the job graph for all // packages initially. - for &(pkg, ref targets) in pkg_targets { - try!(cx.prepare(pkg, targets)); - prepare_init(&mut cx, pkg, &mut queue, &mut HashSet::new()); - custom_build::build_map(&mut cx, pkg, targets); + + + try!(cx.prepare(root, pkg_targets)); + let mut visited = HashSet::new(); + for &(pkg, _) in pkg_targets { + prepare_init(&mut cx, pkg, &mut queue, &mut visited); } + custom_build::build_map(&mut cx, pkg_targets); } for &(pkg, ref targets) in pkg_targets { @@ -141,8 +140,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, } let kind = kind.for_target(target); - let v = - try!(cx.target_filenames(pkg, target, profile, kind)); + let v = try!(cx.target_filenames(pkg, target, profile, kind)); let v = v.into_iter().map(|f| { (target.clone(), cx.out_dir(pkg, kind, target).join(f)) }).collect::>(); @@ -153,9 +151,10 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a [(&Package, cx.compilation.tests.push((pkg.clone(), tests)); - if let Some(feats) = cx.resolve.features(pkg.package_id()) { - cx.compilation.features.extend(feats.iter().cloned()); - } + } + + if let Some(feats) = cx.resolve.features(root.package_id()) { + cx.compilation.features.extend(feats.iter().cloned()); } for (&(ref pkg, _), output) in cx.build_state.outputs.lock().unwrap().iter() { @@ -209,17 +208,18 @@ fn compile<'a, 'cfg>(targets: &[(&'a Target, &'a Profile)], }); // Figure out what stage this work will go into - let stage = match (target.is_lib(), + let dst = match (target.is_lib(), profile.test, target.is_custom_build()) { - (_, _, true) => Stage::BuildCustomBuild, - (true, true, _) => Stage::LibraryTests, - (false, true, _) => Stage::BinaryTests, - (true, false, _) => Stage::Libraries, - (false, false, _) if !target.is_bin() => Stage::BinaryTests, - (false, false, _) => Stage::Binaries, + (_, _, true) => jobs.queue(pkg, Stage::BuildCustomBuild), + (true, true, _) => jobs.queue(pkg, Stage::LibraryTests), + (false, true, _) => jobs.queue(pkg, Stage::BinaryTests), + (true, false, _) => jobs.queue(pkg, Stage::Libraries), + (false, false, _) if !target.is_bin() => { + jobs.queue(pkg, Stage::BinaryTests) + } + (false, false, _) => jobs.queue(pkg, Stage::Binaries), }; - let dst = jobs.queue(pkg, stage); dst.push((Job::new(dirty, fresh), freshness)); } diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index d1b985fa5c2..a34556dd890 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -62,10 +62,10 @@ fn compile_tests<'a>(manifest_path: &Path, options: &TestOptions<'a>) -> CargoResult> { let mut compilation = try!(ops::compile(manifest_path, &options.compile_opts)); - compilation.tests.iter_mut() - .map(|&mut (_, ref mut tests)| - tests.sort_by(|&(ref n1, _), &(ref n2, _)| n1.cmp(n2))) - .collect::>(); + for tests in compilation.tests.iter_mut() { + tests.1.sort(); + } + Ok(compilation) } @@ -113,67 +113,67 @@ fn run_doc_tests(options: &TestOptions, let mut errors = Vec::new(); let config = options.compile_opts.config; - let mut libs = vec![]; - for package in compilation.to_doc_test.iter() { - libs.extend(package.targets().iter() - .filter(|t| t.doctested()) - .map(|t| (package, t.src_path(), t.name(), t.crate_name()))); - } - - for (package, lib, name, crate_name) in libs { - try!(config.shell().status("Doc-tests", name)); - let mut p = try!(compilation.rustdoc_process(package)); - p.arg("--test").arg(lib) - .arg("--crate-name").arg(&crate_name) - .cwd(package.root()); - - for &rust_dep in &[&compilation.deps_output, &compilation.root_output] { - let mut arg = OsString::from("dependency="); - arg.push(rust_dep); - p.arg("-L").arg(arg); - } - for native_dep in compilation.native_dirs.values() { - p.arg("-L").arg(native_dep); - } + let libs = compilation.to_doc_test.iter().map(|package| { + (package, package.targets().iter().filter(|t| t.doctested()) + .map(|t| (t.src_path(), t.name(), t.crate_name()))) + }); + + for (package, tests) in libs { + for (lib, name, crate_name) in tests { + try!(config.shell().status("Doc-tests", name)); + let mut p = try!(compilation.rustdoc_process(package)); + p.arg("--test").arg(lib) + .arg("--crate-name").arg(&crate_name) + .cwd(package.root()); + + for &rust_dep in &[&compilation.deps_output, &compilation.root_output] { + let mut arg = OsString::from("dependency="); + arg.push(rust_dep); + p.arg("-L").arg(arg); + } + for native_dep in compilation.native_dirs.values() { + p.arg("-L").arg(native_dep); + } - if test_args.len() > 0 { - p.arg("--test-args").arg(&test_args.connect(" ")); - } + if test_args.len() > 0 { + p.arg("--test-args").arg(&test_args.connect(" ")); + } - for feat in compilation.features.iter() { - p.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); - } + for feat in compilation.features.iter() { + p.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); + } - for (_, libs) in compilation.libraries.iter() { - for &(ref target, ref lib) in libs.iter() { - // Note that we can *only* doctest rlib outputs here. A - // staticlib output cannot be linked by the compiler (it just - // doesn't do that). A dylib output, however, can be linked by - // the compiler, but will always fail. Currently all dylibs are - // built as "static dylibs" where the standard library is - // statically linked into the dylib. The doc tests fail, - // however, for now as they try to link the standard library - // dynamically as well, causing problems. As a result we only - // pass `--extern` for rlib deps and skip out on all other - // artifacts. - if lib.extension() != Some(OsStr::new("rlib")) && - !target.for_host() { - continue + for (_, libs) in compilation.libraries.iter() { + for &(ref target, ref lib) in libs.iter() { + // Note that we can *only* doctest rlib outputs here. A + // staticlib output cannot be linked by the compiler (it just + // doesn't do that). A dylib output, however, can be linked by + // the compiler, but will always fail. Currently all dylibs are + // built as "static dylibs" where the standard library is + // statically linked into the dylib. The doc tests fail, + // however, for now as they try to link the standard library + // dynamically as well, causing problems. As a result we only + // pass `--extern` for rlib deps and skip out on all other + // artifacts. + if lib.extension() != Some(OsStr::new("rlib")) && + !target.for_host() { + continue + } + let mut arg = OsString::from(target.crate_name()); + arg.push("="); + arg.push(lib); + p.arg("--extern").arg(&arg); } - let mut arg = OsString::from(target.crate_name()); - arg.push("="); - arg.push(lib); - p.arg("--extern").arg(&arg); } - } - try!(config.shell().verbose(|shell| { - shell.status("Running", p.to_string()) - })); - if let Err(e) = ExecEngine::exec(&mut ProcessEngine, p) { - errors.push(e); - if !options.no_fail_fast { - break + try!(config.shell().verbose(|shell| { + shell.status("Running", p.to_string()) + })); + if let Err(e) = ExecEngine::exec(&mut ProcessEngine, p) { + errors.push(e); + if !options.no_fail_fast { + return Ok(errors); + } } } } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index c67e50bb0ad..affa96bc9ab 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1983,3 +1983,41 @@ test!(build_multiple_packages { assert_that(process(&p.build_dir().join("debug").join("deps").join("d2")).unwrap(), execs().with_stdout("d2")); }); + +test!(invalid_spec { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.d1] + path = "d1" + + [[bin]] + name = "foo" + "#) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + .file("d1/Cargo.toml", r#" + [package] + name = "d1" + version = "0.0.1" + authors = [] + + [[bin]] + name = "d1" + "#) + .file("d1/src/lib.rs", "") + .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }"); + p.build(); + + assert_that(p.cargo_process("build").arg("-p").arg("notAValidDep"), + execs().with_status(101).with_stderr( + "could not find package matching spec `notAValidDep`".to_string())); + + assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("notAValidDep"), + execs().with_status(101).with_stderr( + "could not find package matching spec `notAValidDep`".to_string())); + +}); diff --git a/tests/test_cargo_registry.rs b/tests/test_cargo_registry.rs index 632511c6830..8209b5bb293 100644 --- a/tests/test_cargo_registry.rs +++ b/tests/test_cargo_registry.rs @@ -829,3 +829,63 @@ test!(update_backtracking_ok { {updating} registry `[..]` ", updating = UPDATING))); }); + +test!(update_multiple_packages { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.5.0" + authors = [] + + [dependencies] + a = "*" + b = "*" + c = "*" + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + r::mock_pkg("a", "0.1.0", &[]); + r::mock_pkg("b", "0.1.0", &[]); + r::mock_pkg("c", "0.1.0", &[]); + + assert_that(p.cargo("fetch"), + execs().with_status(0)); + + r::mock_pkg("a", "0.1.1", &[]); + r::mock_pkg("b", "0.1.1", &[]); + r::mock_pkg("c", "0.1.1", &[]); + + assert_that(p.cargo("update").arg("-pa").arg("-pb"), + execs().with_status(0) + .with_stdout(format!("\ +{updating} registry `[..]` +{updating} a v0.1.0 (registry [..]) -> v0.1.1 +{updating} b v0.1.0 (registry [..]) -> v0.1.1 +", updating = UPDATING))); + + assert_that(p.cargo("update").arg("-pb").arg("-pc"), + execs().with_status(0) + .with_stdout(format!("\ +{updating} registry `[..]` +{updating} c v0.1.0 (registry [..]) -> v0.1.1 +", updating = UPDATING))); + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stdout_contains(format!("\ +{downloading} a v0.1.1 (registry file://[..])", downloading = DOWNLOADING)) + .with_stdout_contains(format!("\ +{downloading} b v0.1.1 (registry file://[..])", downloading = DOWNLOADING)) + .with_stdout_contains(format!("\ +{downloading} c v0.1.1 (registry file://[..])", downloading = DOWNLOADING)) + .with_stdout_contains(format!("\ +{compiling} a v0.1.1 (registry [..])", compiling = COMPILING)) + .with_stdout_contains(format!("\ +{compiling} b v0.1.1 (registry [..])", compiling = COMPILING)) + .with_stdout_contains(format!("\ +{compiling} c v0.1.1 (registry [..])", compiling = COMPILING)) + .with_stdout_contains(format!("\ +{compiling} foo v0.5.0 ([..])", compiling = COMPILING))); +}); diff --git a/tests/test_cargo_rustc.rs b/tests/test_cargo_rustc.rs index 18a09fae133..559a5f722cc 100644 --- a/tests/test_cargo_rustc.rs +++ b/tests/test_cargo_rustc.rs @@ -1,8 +1,7 @@ use std::path::MAIN_SEPARATOR as SEP; use support::{execs, project}; use support::{COMPILING, RUNNING}; -use hamcrest::{assert_that, existing_file}; -use cargo::util::process; +use hamcrest::{assert_that}; fn setup() { @@ -299,7 +298,7 @@ test!(build_only_bar_dependency { url = foo.url()))); }); -test!(build_multiple_dependencies { +test!(fail_with_multiple_packages { let foo = project("foo") .file("Cargo.toml", r#" [package] @@ -317,6 +316,7 @@ test!(build_multiple_dependencies { fn main() {} "#); foo.build(); + let bar = project("bar") .file("Cargo.toml", r#" [package] @@ -329,8 +329,8 @@ test!(build_multiple_dependencies { if cfg!(flag = "1") { println!("Yeah from bar!"); } } "#); - bar.build(); + let baz = project("baz") .file("Cargo.toml", r#" [package] @@ -345,21 +345,11 @@ test!(build_multiple_dependencies { "#); baz.build(); - assert_that(foo.cargo_process("rustc").arg("-v").arg("-p").arg("bar") - .arg("-p").arg("baz").arg("--").arg("--cfg").arg("flag=\"1\""), - execs() - .with_status(0)); - - let bar_bin = &foo.build_dir().join("debug").join("deps").join("bar"); - assert_that(bar_bin, existing_file()); - - assert_that( - process(bar_bin).unwrap(), - execs().with_stdout("Yeah from bar!\n")); + assert_that(foo.cargo("rustc").arg("-v").arg("-p").arg("bar") + .arg("-p").arg("baz"), + execs().with_status(1).with_stderr("\ +Invalid arguments. - let baz_bin = &foo.build_dir().join("debug").join("deps").join("baz"); - assert_that(bar_bin, existing_file()); - assert_that( - process(baz_bin).unwrap(), - execs().with_stdout("Yeah from baz!\n")); +Usage: + cargo rustc [options] [--] [...]".to_string())); }); From 5c90be30f053292dd0c16aaeb0a10c90707d9004 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 24 Sep 2015 23:47:50 +0200 Subject: [PATCH 0039/3888] Use std::env::EXE_SUFFIX in new tests --- tests/test_cargo_clean.rs | 18 ++++++++++++------ tests/test_cargo_compile.rs | 14 +++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/tests/test_cargo_clean.rs b/tests/test_cargo_clean.rs index 4b2828a6e81..ff3313d9979 100644 --- a/tests/test_cargo_clean.rs +++ b/tests/test_cargo_clean.rs @@ -1,3 +1,5 @@ +use std::env; + use support::{project, execs, main_file, basic_bin_manifest}; use hamcrest::{assert_that, existing_dir, existing_file, is_not}; @@ -74,16 +76,20 @@ test!(clean_multiple_packages { .arg("-p").arg("foo"), execs().with_status(0)); + let d1_path = &p.build_dir().join("debug").join("deps") + .join(format!("d1{}", env::consts::EXE_SUFFIX)); + let d2_path = &p.build_dir().join("debug").join("deps") + .join(format!("d2{}", env::consts::EXE_SUFFIX)); + + assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.build_dir().join("debug").join("deps").join("d1"), existing_file()); - assert_that(&p.build_dir().join("debug").join("deps").join("d2"), existing_file()); + assert_that(d1_path, existing_file()); + assert_that(d2_path, existing_file()); assert_that(p.cargo("clean").arg("-p").arg("d1").arg("-p").arg("d2") .cwd(&p.root().join("src")), execs().with_status(0).with_stdout("")); assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.build_dir().join("debug").join("deps").join("d1"), - is_not(existing_file())); - assert_that(&p.build_dir().join("debug").join("deps").join("d2"), - is_not(existing_file())); + assert_that(d1_path, is_not(existing_file())); + assert_that(d2_path, is_not(existing_file())); }); diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index affa96bc9ab..cd1714c1876 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -1975,12 +1975,16 @@ test!(build_multiple_packages { assert_that(process(&p.bin("foo")).unwrap(), execs().with_stdout("i am foo\n")); - assert_that(&p.build_dir().join("debug").join("deps").join("d1"), existing_file()); - assert_that(process(&p.build_dir().join("debug").join("deps").join("d1")).unwrap(), - execs().with_stdout("d1")); + let d1_path = &p.build_dir().join("debug").join("deps") + .join(format!("d1{}", env::consts::EXE_SUFFIX)); + let d2_path = &p.build_dir().join("debug").join("deps") + .join(format!("d2{}", env::consts::EXE_SUFFIX)); - assert_that(&p.build_dir().join("debug").join("deps").join("d2"), existing_file()); - assert_that(process(&p.build_dir().join("debug").join("deps").join("d2")).unwrap(), + assert_that(d1_path, existing_file()); + assert_that(process(d1_path).unwrap(), execs().with_stdout("d1")); + + assert_that(d2_path, existing_file()); + assert_that(process(d2_path).unwrap(), execs().with_stdout("d2")); }); From 5962003c6b73c4bcc0c6d37e07b29b61a699ef13 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 30 Sep 2015 17:58:08 -0700 Subject: [PATCH 0040/3888] Fix tests on nightly Some output of failing tests have been tweaked, so update the associated tests. --- tests/support/mod.rs | 151 ++++++++++++++++++--------------------- tests/test_cargo_test.rs | 30 ++++---- 2 files changed, 82 insertions(+), 99 deletions(-) diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 4411dd62582..55589f35054 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -8,6 +8,7 @@ use std::os; use std::path::{Path, PathBuf}; use std::process::Output; use std::str; +use std::usize; use url::Url; use hamcrest as ham; @@ -137,6 +138,7 @@ impl ProjectBuilder { p.cwd(&self.root()) .env("HOME", &paths::home()) .env_remove("CARGO_HOME") // make sure we don't pick up an outer one + .env_remove("CARGO_TARGET_DIR") // we assume 'target' .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows return p; } @@ -316,99 +318,86 @@ impl Execs { } fn match_stdout(&self, actual: &Output) -> ham::MatchResult { - self.match_std(self.expect_stdout.as_ref(), &actual.stdout, - "stdout", &actual.stderr) - .and(self.match_contains(self.expect_stdout_contains.as_ref(), - &actual.stdout, "stdout")) + try!(self.match_std(self.expect_stdout.as_ref(), &actual.stdout, + "stdout", &actual.stderr, false)); + for expect in self.expect_stdout_contains.iter() { + try!(self.match_std(Some(expect), &actual.stdout, "stdout", + &actual.stderr, true)); + } + Ok(()) } fn match_stderr(&self, actual: &Output) -> ham::MatchResult { self.match_std(self.expect_stderr.as_ref(), &actual.stderr, - "stderr", &actual.stdout) + "stderr", &actual.stdout, false) } #[allow(deprecated)] // connect => join in 1.3 - fn match_contains(&self, expect: &[String], actual: &[u8], - description: &str) -> ham::MatchResult { - for s in expect { - let a: Vec<&str> = match str::from_utf8(actual) { - Err(..) => return Err(format!("{} was not utf8 encoded", - description)), - Ok(actual) => actual.lines().collect(), - }; - let e: Vec<&str> = s.lines().collect(); - - let first = e.first().unwrap(); - let mut ai = a.iter(); - match ai.position(|s| lines_match(first, s)) { - Some(_) => { - let match_count = ai.zip(e.iter().skip(1)) - .take_while(|&(a, e)| lines_match(a, e)).count(); - if match_count != (e.len() - 1) { - return ham::expect(false, - format!("expected: {}\n\ - actual: {}", - e.connect("\n"), - a.iter().take(e.len()).map(|&s| s) - .collect::>().connect("\n"))); - } - }, - None => { - return ham::expect(false, format!("no match")); + fn match_std(&self, expected: Option<&String>, actual: &[u8], + description: &str, extra: &[u8], + partial: bool) -> ham::MatchResult { + let out = match expected { + Some(out) => out, + None => return ham::success(), + }; + let actual = match str::from_utf8(actual) { + Err(..) => return Err(format!("{} was not utf8 encoded", + description)), + Ok(actual) => actual, + }; + // Let's not deal with \r\n vs \n on windows... + let actual = actual.replace("\r", ""); + let actual = actual.replace("\t", ""); + + let mut a = actual.lines(); + let e = out.lines(); + + let diffs = if partial { + let mut min = self.diff_lines(a.clone(), e.clone(), partial); + while let Some(..) = a.next() { + let a = self.diff_lines(a.clone(), e.clone(), partial); + if a.len() < min.len() { + min = a; } - }; - } - ham::expect(true, format!("OK")) + } + min + } else { + self.diff_lines(a, e, partial) + }; + ham::expect(diffs.len() == 0, + format!("differences:\n\ + {}\n\n\ + other output:\n\ + `{}`", diffs.connect("\n"), + String::from_utf8_lossy(extra))) + } - #[allow(deprecated)] // connect => join in 1.3 - fn match_std(&self, expected: Option<&String>, actual: &[u8], - description: &str, extra: &[u8]) -> ham::MatchResult { - match expected.map(|s| &s[..]) { - None => ham::success(), - Some(out) => { - let actual = match str::from_utf8(actual) { - Err(..) => return Err(format!("{} was not utf8 encoded", - description)), - Ok(actual) => actual, - }; - // Let's not deal with \r\n vs \n on windows... - let actual = actual.replace("\r", ""); - let actual = actual.replace("\t", ""); - - let a = actual.lines(); - let e = out.lines(); - - let diffs = zip_all(a, e).enumerate(); - let diffs = diffs.filter_map(|(i, (a,e))| { - match (a, e) { - (Some(a), Some(e)) => { - if lines_match(&e, &a) { - None - } else { - Some(format!("{:3} - |{}|\n + |{}|\n", i, e, a)) - } - }, - (Some(a), None) => { - Some(format!("{:3} -\n + |{}|\n", i, a)) - }, - (None, Some(e)) => { - Some(format!("{:3} - |{}|\n +\n", i, e)) - }, - (None, None) => panic!("Cannot get here") + fn diff_lines<'a>(&self, actual: str::Lines<'a>, expected: str::Lines<'a>, + partial: bool) -> Vec { + let actual = actual.take(if partial { + expected.clone().count() + } else { + usize::MAX + }); + zip_all(actual, expected).enumerate().filter_map(|(i, (a,e))| { + match (a, e) { + (Some(a), Some(e)) => { + if lines_match(&e, &a) { + None + } else { + Some(format!("{:3} - |{}|\n + |{}|\n", i, e, a)) } - }); - - let diffs = diffs.collect::>().connect("\n"); - - ham::expect(diffs.len() == 0, - format!("differences:\n\ - {}\n\n\ - other output:\n\ - `{}`", diffs, - String::from_utf8_lossy(extra))) + }, + (Some(a), None) => { + Some(format!("{:3} -\n + |{}|\n", i, a)) + }, + (None, Some(e)) => { + Some(format!("{:3} - |{}|\n +\n", i, e)) + }, + (None, None) => panic!("Cannot get here") } - } + }).collect() } } diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 32787d998a7..587aa448d5b 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -189,9 +189,9 @@ test!(cargo_test_failing_test { execs().with_stdout("hello\n")); assert_that(p.cargo("test"), - execs().with_stdout(format!("\ -{} foo v0.5.0 ({}) -{} target[..]foo-[..] + execs().with_stdout_contains(format!("\ +{compiling} foo v0.5.0 ({url}) +{running} target[..]foo-[..] running 1 test test test_hello ... FAILED @@ -202,17 +202,14 @@ failures: thread 'test_hello' panicked at 'assertion failed: \ `(left == right)` (left: \ `\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:12 - - - +", compiling = COMPILING, url = p.url(), running = RUNNING)) + .with_stdout_contains("\ failures: test_hello test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured - -", - COMPILING, p.url(), RUNNING)) - .with_status(101)); +") + .with_status(101)); }); test!(test_with_lib_dep { @@ -1902,7 +1899,8 @@ test!(no_fail_fast { } "#); assert_that(p.cargo_process("test").arg("--no-fail-fast"), - execs().with_status(101).with_stdout(format!("\ + execs().with_status(101) + .with_stdout_contains(format!("\ {compiling} foo v0.0.1 ([..]) {running} target[..]foo[..] @@ -1911,12 +1909,8 @@ running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured {running} target[..]test_add_one[..] - -running 2 tests -[..]\n[..]\n[..]\n[..]\n[..]\n[..]\n[..]\n[..]\n[..]\n[..] -failures: - fail_add_one_test - +", compiling = COMPILING, running = RUNNING)) + .with_stdout_contains(format!("\ test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured {running} target[..]test_sub_one[..] @@ -1933,7 +1927,7 @@ test sub_one_0 ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured -", compiling = COMPILING, running = RUNNING, doctest = DOCTEST))) +", running = RUNNING, doctest = DOCTEST))) }); test!(test_multiple_packages { From 98ebac06d1565d6579af97c20151560f8648a56a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Oct 2015 10:26:33 -0700 Subject: [PATCH 0041/3888] Touch up docs and use inline table syntax This performs a pass over the docs, touching up sections in a few places and also moving everything to using inline table syntax by default (the favorted way to add a dependency) --- src/doc/build-script.md | 12 +++---- src/doc/guide.md | 17 +++++----- src/doc/manifest.md | 71 +++++++++++++++-------------------------- 3 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/doc/build-script.md b/src/doc/build-script.md index 8e28e26004f..7d98d2f90be 100644 --- a/src/doc/build-script.md +++ b/src/doc/build-script.md @@ -80,8 +80,8 @@ Dependencies are declared through the `build-dependencies` section of the manifest. ```toml -[build-dependencies.foo] -git = "https://github.com/your-packages/foo" +[build-dependencies] +foo = { git = "https://github.com/your-packages/foo" } ``` The build script **does not** have access to the dependencies listed in the @@ -424,11 +424,11 @@ authors = ["..."] links = "git2" build = "build.rs" -[dependencies.libssh2-sys] -git = "https://github.com/alexcrichton/ssh2-rs" +[dependencies] +libssh2-sys = { git = "https://github.com/alexcrichton/ssh2-rs" } -[target.x86_64-unknown-linux-gnu.dependencies.openssl-sys] -git = "https://github.com/alexcrichton/openssl-sys" +[target.x86_64-unknown-linux-gnu.dependencies] +openssl-sys = { git = "https://github.com/alexcrichton/openssl-sys" } # ... ``` diff --git a/src/doc/guide.md b/src/doc/guide.md index e714ac9b78e..aed81ae955d 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -233,8 +233,8 @@ name = "hello_world" version = "0.1.0" authors = ["Your Name "] -[dependencies.color] -git = "https://github.com/bjz/color-rs.git" +[dependencies] +color = { git = "https://github.com/bjz/color-rs.git" } ``` This project has a single dependency, on the `color` library. We've stated in @@ -251,9 +251,8 @@ builds. This would be bad, because we want reproducible builds. We could fix this problem by putting a `rev` line in our `Cargo.toml`: ```toml -[dependencies.color] -git = "https://github.com/bjz/color-rs.git" -rev = "bf739419e2d31050615c1ba1a395b474269a4" +[dependencies] +color = { git = "https://github.com/bjz/color-rs.git", rev = "bf739419" } ``` Now, our builds will be the same. But, there's a big drawback: now we have to @@ -270,8 +269,8 @@ name = "hello_world" version = "0.1.0" authors = ["Your Name "] -[dependencies.color] -git = "https://github.com/bjz/color-rs.git" +[dependencies] +color = { git = "https://github.com/bjz/color-rs.git" } ``` Cargo will take the latest commit, and write that information out into our @@ -435,8 +434,8 @@ This will create a new folder `hello_utils` inside of which a `Cargo.toml` and up `hello_world/Cargo.toml` and add these lines: ```toml -[dependencies.hello_utils] -path = "hello_utils" +[dependencies] +hello_utils = { path = "hello_utils" } ``` This tells Cargo that we depend on a crate called `hello_utils` which is found diff --git a/src/doc/manifest.md b/src/doc/manifest.md index c79913587b8..c8ee1e8ad9d 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -116,52 +116,42 @@ search ranking of a crate. It is highly discouraged to omit everything in a published crate. -# The `[dependencies.*]` Sections +# The `[dependencies]` Section -You list dependencies using `[dependencies.]`. For example, if you -wanted to depend on both `hammer` and `color`: +You list dependencies using keys inside of the `[dependencies]` section. For +example, if you wanted to depend on `hammer`, `color`, and `geometry`: ```toml [package] # ... -[dependencies.hammer] -version = "0.5.0" # optional -git = "https://github.com/wycats/hammer.rs" - -[dependencies.color] -git = "https://github.com/bjz/color-rs" - -[dependencies.geometry] -path = "crates/geometry" -``` - -You may prefer to use TOML's inline table syntax: - -```toml [dependencies] hammer = { version = "0.5.0", git = "https://github.com/wycats/hammer.rs" } color = { git = "https://github.com/bjz/color-rs" } geometry = { path = "crates/geometry" } ``` -You can specify the source of a dependency in one of two ways at the moment: +You can specify the source of a dependency in a few ways: -* `git = ""`: A git repository with a `Cargo.toml` in its root. The - `rev`, `tag`, and `branch` options are also recognized to use something other - than the `master` branch. +* `git = ""`: A git repository with a `Cargo.toml` inside it (not + necessarily at the root). The `rev`, `tag`, and `branch` options are also + recognized to use something other than the `master` branch. * `path = ""`: A path relative to the current `Cargo.toml` - with a `Cargo.toml` in its root. + pointing to another directory with a `Cargo.toml` and an associated package. +* If `path` and `git` are omitted, then a dependencies will come from crates.io + and use the `version` key to indicate the version requirement. -Dependencies from crates.io are not declared with separate sections: +Dependencies from crates.io can also use a shorthand where just the version +requirement is specified: ```toml [dependencies] hammer = "0.5.0" -color = "0.6.0" +color = "> 0.6.0, < 0.8.0" ``` -The syntax of the requirement strings is described in the [crates.io guide](crates-io.html#using-crates.io-based-crates). +The syntax of the requirement strings is described in the [crates.io +guide](crates-io.html#using-crates.io-based-crates). Platform-specific dependencies take the same format, but are listed under the `target.$triple` section: @@ -179,7 +169,8 @@ openssl = "1.0.1" native = { path = "native/x86_64" } ``` -If you're using a target file, quote the full path and file name: +If you're using a custom target specification, quote the full path and file +name: ```toml [target."x86_64/windows.json".dependencies] @@ -303,29 +294,17 @@ route-recognizer = "=2.1.0" # A list of all of the optional dependencies, some of which # are included in the above "features". They can be opted # into by apps. -[dependencies.jquery] -version = "1.0.2" -optional = true - -[dependencies.uglifier] -version = "1.5.3" -optional = true - -[dependencies.bcrypt] -version = "*" -optional = true - -[dependencies.civet] -version = "*" -optional = true +jquery = { version = "1.0.2", optional = true } +uglifier = { version = "1.5.3", optional = true } +bcrypt = { version = "*", optional = true } +civet = { version = "*", optional = true } ``` To use the package `awesome`: ```toml -[dependencies.awesome] -version = "1.3.5" -features = ["secure-password", "civet"] +[dependencies] +awesome = { version = "1.3.5", features = ["secure-password", "civet"] } # do not include the default features, and optionally # cherry-pick individual features @@ -396,9 +375,9 @@ In almost all cases, it is an antipattern to use these features outside of high-level packages that are designed for curation. If a feature is optional, it can almost certainly be expressed as a separate package. -# The `[dev-dependencies.*]` Sections +# The `[dev-dependencies]` Section -The format of this section is equivalent to `[dependencies.*]`. Dev-dependencies +The format of this section is equivalent to `[dependencies]`. Dev-dependencies are not used when compiling a package for building, but are used for compiling tests and benchmarks. From e343c5169080a29ee9a7cc69b9e0d566a01e4e8f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 2 Oct 2015 22:27:41 +0200 Subject: [PATCH 0042/3888] Do not skip the root path if it's a dotdir When traversing the directory tree, cargo will omit paths that start with a period character to avoid interfering with other software. Unfortunately this also prevents a crate from being located in a directory prefixed with a period. Address this by extending the test against the traversal root that already guards Git submodules. Fixes issue #1999 which was introduced with commit 11144645f.. --- src/cargo/ops/cargo_read_manifest.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 741445510b9..319bf80f210 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -43,15 +43,17 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config) try!(walk(path, &mut |dir| { trace!("looking for child package: {}", dir.display()); - // Don't recurse into hidden/dot directories - let name = dir.file_name().and_then(|s| s.to_str()); - if name.map(|s| s.starts_with(".")) == Some(true) { - return Ok(false) - } - - // Don't automatically discover packages across git submodules - if dir != path && fs::metadata(&dir.join(".git")).is_ok() { - return Ok(false) + // Don't recurse into hidden/dot directories unless we're at the toplevel + if dir != path { + let name = dir.file_name().and_then(|s| s.to_str()); + if name.map(|s| s.starts_with(".")) == Some(true) { + return Ok(false) + } + + // Don't automatically discover packages across git submodules + if fs::metadata(&dir.join(".git")).is_ok() { + return Ok(false) + } } // Don't ever look at target directories From 3c58a7257c01717b844da9f146967e86a8b29062 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sat, 3 Oct 2015 00:19:39 +0200 Subject: [PATCH 0043/3888] Add test case for project root located in dotdir --- tests/test_cargo_compile.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index cd1714c1876..ebef666bf34 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -7,7 +7,7 @@ use tempdir::TempDir; use support::{project, execs, main_file, basic_bin_manifest}; use support::{COMPILING, RUNNING, ProjectBuilder}; use hamcrest::{assert_that, existing_file, is_not}; -use support::paths::CargoPathExt; +use support::paths::{CargoPathExt,root}; use cargo::util::process; fn setup() { @@ -1868,6 +1868,20 @@ test!(ignore_dotdirs { execs().with_status(0)); }); +test!(dotdir_root { + let p = ProjectBuilder::new("foo", root().join(".foo")) + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/bin/a.rs", "fn main() {}"); + p.build(); + assert_that(p.cargo("build"), + execs().with_status(0)); +}); + test!(custom_target_dir { let p = project("foo") From 14f48c4139067cb6322d38aed13f8b7d604061de Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Oct 2015 10:26:33 -0700 Subject: [PATCH 0044/3888] Touch up docs and use inline table syntax This performs a pass over the docs, touching up sections in a few places and also moving everything to using inline table syntax by default (the favorted way to add a dependency) --- src/doc/build-script.md | 12 +++---- src/doc/guide.md | 17 +++++----- src/doc/manifest.md | 71 +++++++++++++++-------------------------- 3 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/doc/build-script.md b/src/doc/build-script.md index 8e28e26004f..7d98d2f90be 100644 --- a/src/doc/build-script.md +++ b/src/doc/build-script.md @@ -80,8 +80,8 @@ Dependencies are declared through the `build-dependencies` section of the manifest. ```toml -[build-dependencies.foo] -git = "https://github.com/your-packages/foo" +[build-dependencies] +foo = { git = "https://github.com/your-packages/foo" } ``` The build script **does not** have access to the dependencies listed in the @@ -424,11 +424,11 @@ authors = ["..."] links = "git2" build = "build.rs" -[dependencies.libssh2-sys] -git = "https://github.com/alexcrichton/ssh2-rs" +[dependencies] +libssh2-sys = { git = "https://github.com/alexcrichton/ssh2-rs" } -[target.x86_64-unknown-linux-gnu.dependencies.openssl-sys] -git = "https://github.com/alexcrichton/openssl-sys" +[target.x86_64-unknown-linux-gnu.dependencies] +openssl-sys = { git = "https://github.com/alexcrichton/openssl-sys" } # ... ``` diff --git a/src/doc/guide.md b/src/doc/guide.md index e714ac9b78e..aed81ae955d 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -233,8 +233,8 @@ name = "hello_world" version = "0.1.0" authors = ["Your Name "] -[dependencies.color] -git = "https://github.com/bjz/color-rs.git" +[dependencies] +color = { git = "https://github.com/bjz/color-rs.git" } ``` This project has a single dependency, on the `color` library. We've stated in @@ -251,9 +251,8 @@ builds. This would be bad, because we want reproducible builds. We could fix this problem by putting a `rev` line in our `Cargo.toml`: ```toml -[dependencies.color] -git = "https://github.com/bjz/color-rs.git" -rev = "bf739419e2d31050615c1ba1a395b474269a4" +[dependencies] +color = { git = "https://github.com/bjz/color-rs.git", rev = "bf739419" } ``` Now, our builds will be the same. But, there's a big drawback: now we have to @@ -270,8 +269,8 @@ name = "hello_world" version = "0.1.0" authors = ["Your Name "] -[dependencies.color] -git = "https://github.com/bjz/color-rs.git" +[dependencies] +color = { git = "https://github.com/bjz/color-rs.git" } ``` Cargo will take the latest commit, and write that information out into our @@ -435,8 +434,8 @@ This will create a new folder `hello_utils` inside of which a `Cargo.toml` and up `hello_world/Cargo.toml` and add these lines: ```toml -[dependencies.hello_utils] -path = "hello_utils" +[dependencies] +hello_utils = { path = "hello_utils" } ``` This tells Cargo that we depend on a crate called `hello_utils` which is found diff --git a/src/doc/manifest.md b/src/doc/manifest.md index c79913587b8..c8ee1e8ad9d 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -116,52 +116,42 @@ search ranking of a crate. It is highly discouraged to omit everything in a published crate. -# The `[dependencies.*]` Sections +# The `[dependencies]` Section -You list dependencies using `[dependencies.]`. For example, if you -wanted to depend on both `hammer` and `color`: +You list dependencies using keys inside of the `[dependencies]` section. For +example, if you wanted to depend on `hammer`, `color`, and `geometry`: ```toml [package] # ... -[dependencies.hammer] -version = "0.5.0" # optional -git = "https://github.com/wycats/hammer.rs" - -[dependencies.color] -git = "https://github.com/bjz/color-rs" - -[dependencies.geometry] -path = "crates/geometry" -``` - -You may prefer to use TOML's inline table syntax: - -```toml [dependencies] hammer = { version = "0.5.0", git = "https://github.com/wycats/hammer.rs" } color = { git = "https://github.com/bjz/color-rs" } geometry = { path = "crates/geometry" } ``` -You can specify the source of a dependency in one of two ways at the moment: +You can specify the source of a dependency in a few ways: -* `git = ""`: A git repository with a `Cargo.toml` in its root. The - `rev`, `tag`, and `branch` options are also recognized to use something other - than the `master` branch. +* `git = ""`: A git repository with a `Cargo.toml` inside it (not + necessarily at the root). The `rev`, `tag`, and `branch` options are also + recognized to use something other than the `master` branch. * `path = ""`: A path relative to the current `Cargo.toml` - with a `Cargo.toml` in its root. + pointing to another directory with a `Cargo.toml` and an associated package. +* If `path` and `git` are omitted, then a dependencies will come from crates.io + and use the `version` key to indicate the version requirement. -Dependencies from crates.io are not declared with separate sections: +Dependencies from crates.io can also use a shorthand where just the version +requirement is specified: ```toml [dependencies] hammer = "0.5.0" -color = "0.6.0" +color = "> 0.6.0, < 0.8.0" ``` -The syntax of the requirement strings is described in the [crates.io guide](crates-io.html#using-crates.io-based-crates). +The syntax of the requirement strings is described in the [crates.io +guide](crates-io.html#using-crates.io-based-crates). Platform-specific dependencies take the same format, but are listed under the `target.$triple` section: @@ -179,7 +169,8 @@ openssl = "1.0.1" native = { path = "native/x86_64" } ``` -If you're using a target file, quote the full path and file name: +If you're using a custom target specification, quote the full path and file +name: ```toml [target."x86_64/windows.json".dependencies] @@ -303,29 +294,17 @@ route-recognizer = "=2.1.0" # A list of all of the optional dependencies, some of which # are included in the above "features". They can be opted # into by apps. -[dependencies.jquery] -version = "1.0.2" -optional = true - -[dependencies.uglifier] -version = "1.5.3" -optional = true - -[dependencies.bcrypt] -version = "*" -optional = true - -[dependencies.civet] -version = "*" -optional = true +jquery = { version = "1.0.2", optional = true } +uglifier = { version = "1.5.3", optional = true } +bcrypt = { version = "*", optional = true } +civet = { version = "*", optional = true } ``` To use the package `awesome`: ```toml -[dependencies.awesome] -version = "1.3.5" -features = ["secure-password", "civet"] +[dependencies] +awesome = { version = "1.3.5", features = ["secure-password", "civet"] } # do not include the default features, and optionally # cherry-pick individual features @@ -396,9 +375,9 @@ In almost all cases, it is an antipattern to use these features outside of high-level packages that are designed for curation. If a feature is optional, it can almost certainly be expressed as a separate package. -# The `[dev-dependencies.*]` Sections +# The `[dev-dependencies]` Section -The format of this section is equivalent to `[dependencies.*]`. Dev-dependencies +The format of this section is equivalent to `[dependencies]`. Dev-dependencies are not used when compiling a package for building, but are used for compiling tests and benchmarks. From b5a8836b68f542662b3b41b8765d6fc481f44e66 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Oct 2015 23:48:47 -0700 Subject: [PATCH 0045/3888] Refactor Cargo's backend, again! This commit started out identifying a relatively simple bug in Cargo. A recent change made it such that the resolution graph included all target-specific dependencies, relying on the structure of the backend to filter out those which don't need to get built. This was unfortunately not accounted for in the portion of the backend that schedules work, mistakenly causing spurious rebuilds if different runs of the graph pulled in new crates. For example if `cargo build` didn't build any target-specific dependencies but then later `cargo test` did (e.g. a dev-dep pulled in a target-specific dep unconditionally) then it would cause a rebuild of the entire graph. This class of bug is certainly not the first in a long and storied history of the backend having multiple points where dependencies are calculated and those often don't quite agree with one another. The purpose of this rewrite is twofold: 1. The `Stage` enum in the backend for scheduling work and ensuring that maximum parallelism is achieved is removed entirely. There is already a function on `Context` which expresses the dependency between targets (`dep_targets`) which takes a much finer grain of dependencies into account as well as already having all the logic for what-depends-on-what. This duplication has caused numerous problems in the past, an unifying these two will truly grant maximum parallelism while ensuring that everyone agrees on what their dependencies are. 2. A large number of locations in the backend have grown to take a (Package, Target, Profile, Kind) tuple, or some subset of this tuple. In general this represents a "unit of work" and is much easier to pass around as one variable, so a `Unit` was introduced which references all of these variables. Almost the entire backend was altered to take a `Unit` instead of these variables specifically, typically providing all of the contextual information necessary for an operation. A crucial part of this change is the inclusion of `Kind` in a `Unit` to ensure that everyone *also* agrees on what architecture they're compiling everything for. There have been many bugs in the past where one part of the backend determined that a package was built for one architecture and then another part thought it was built for another. With the inclusion of `Kind` in dependency management this is handled in a much cleaner fashion as it's only calculated in one location. Some other miscellaneous changes made were: * The `Platform` enumeration has finally been removed. This has been entirely subsumed by `Kind`. * The hokey logic for "build this crate once" even though it may be depended on by both the host/target kinds has been removed. This is now handled in a much nicer fashion where if there's no target then Kind::Target is just never used, and multiple requests for a package are just naturally deduplicated. * There's no longer any need to build up the "requirements" for a package in terms of what platforms it's compiled for, this now just naturally falls out of the dependency graph. * If a build script is overridden then its entire tree of dependencies are not compiled, not just the build script itself. * The `threadpool` dependency has been replaced with one on `crossbeam`. The method of calculating dependencies has quite a few non-static lifetimes and the scoped threads of `crossbeam` are now used instead of a thread pool. * Once any thread fails to execute a command work is no longer scheduled unlike before where some extra pending work may continue to start. * Many functions used early on, such as `compile` and `build_map` have been massively simplified by farming out dependency management to `Context::dep_targets`. * There is now a new profile to represent running a build script. This is used to inject dependencies as well as represent that a library depends on running a build script, not just building it. This change has currently been tested against cross-compiling Servo to Android and passes the test suite (which has quite a few corner cases for build scripts and such), so I'm pretty confident that this refactoring won't have at least too many regressions! --- Cargo.lock | 12 +- Cargo.toml | 4 +- src/cargo/core/manifest.rs | 39 ++ src/cargo/lib.rs | 2 +- src/cargo/ops/cargo_clean.rs | 11 +- src/cargo/ops/cargo_rustc/compilation.rs | 13 +- src/cargo/ops/cargo_rustc/context.rs | 337 +++++------ src/cargo/ops/cargo_rustc/custom_build.rs | 214 +++---- src/cargo/ops/cargo_rustc/fingerprint.rs | 154 +++-- src/cargo/ops/cargo_rustc/job.rs | 14 + src/cargo/ops/cargo_rustc/job_queue.rs | 342 +++++------ src/cargo/ops/cargo_rustc/mod.rs | 654 ++++++++-------------- src/cargo/ops/cargo_test.rs | 51 +- src/cargo/ops/mod.rs | 3 +- src/cargo/util/dependency_queue.rs | 3 +- src/cargo/util/toml.rs | 2 + tests/test_cargo_compile_custom_build.rs | 59 +- tests/test_cargo_compile_plugins.rs | 4 +- tests/test_cargo_cross_compile.rs | 16 +- tests/test_cargo_freshness.rs | 54 ++ tests/test_cargo_test.rs | 32 ++ 21 files changed, 943 insertions(+), 1077 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d78596b9e0..e135c2c43c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,6 +5,7 @@ dependencies = [ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "crates-io 0.1.0", + "crossbeam 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "curl 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.70 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -25,7 +26,6 @@ dependencies = [ "tar 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "threadpool 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -75,6 +75,11 @@ dependencies = [ "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "curl" version = "0.2.11" @@ -374,11 +379,6 @@ dependencies = [ "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "threadpool" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "time" version = "0.1.32" diff --git a/Cargo.toml b/Cargo.toml index 13f389c15c2..943e570a0c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,8 @@ path = "src/cargo/lib.rs" [dependencies] advapi32-sys = "0.1" +crates-io = { path = "src/crates-io", version = "0.1" } +crossbeam = "0.1" curl = "0.2" docopt = "0.6" env_logger = "0.3" @@ -32,12 +34,10 @@ libgit2-sys = "0.2" log = "0.3" num_cpus = "0.2" regex = "0.1" -crates-io = { path = "src/crates-io", version = "0.1" } rustc-serialize = "0.3" semver = "0.1" tar = "0.3" term = "0.2" -threadpool = "0.1" time = "0.1" toml = "0.1" url = "0.2" diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index cc09b2d120e..7d99b7c794d 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -1,4 +1,5 @@ use std::default::Default; +use std::fmt; use std::path::{PathBuf, Path}; use semver::Version; @@ -116,6 +117,7 @@ pub struct Profile { pub rpath: bool, pub test: bool, pub doc: bool, + pub run_custom_build: bool, } #[derive(Default, Clone, Debug)] @@ -125,6 +127,7 @@ pub struct Profiles { pub test: Profile, pub bench: Profile, pub doc: Profile, + pub custom_build: Profile, } /// Informations about a binary, a library, an example, etc. that is part of the @@ -405,6 +408,19 @@ impl Target { } } +impl fmt::Display for Target { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.kind { + TargetKind::Lib(..) => write!(f, "Target(lib)"), + TargetKind::Bin => write!(f, "Target(bin: {})", self.name), + TargetKind::Test => write!(f, "Target(test: {})", self.name), + TargetKind::Bench => write!(f, "Target(bench: {})", self.name), + TargetKind::Example => write!(f, "Target(example: {})", self.name), + TargetKind::CustomBuild => write!(f, "Target(script)"), + } + } +} + impl Profile { pub fn default_dev() -> Profile { Profile { @@ -442,6 +458,13 @@ impl Profile { ..Profile::default_dev() } } + + pub fn default_custom_build() -> Profile { + Profile { + run_custom_build: true, + ..Profile::default_dev() + } + } } impl Default for Profile { @@ -456,6 +479,22 @@ impl Default for Profile { rpath: false, test: false, doc: false, + run_custom_build: false, } } } + +impl fmt::Display for Profile { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.test { + write!(f, "Profile(test)") + } else if self.doc { + write!(f, "Profile(doc)") + } else if self.run_custom_build { + write!(f, "Profile(run)") + } else { + write!(f, "Profile(build)") + } + + } +} diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 669c5d5bf27..949e3c0e6fa 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -4,6 +4,7 @@ #[cfg(test)] extern crate hamcrest; #[macro_use] extern crate log; extern crate crates_io as registry; +extern crate crossbeam; extern crate curl; extern crate docopt; extern crate filetime; @@ -18,7 +19,6 @@ extern crate rustc_serialize; extern crate semver; extern crate tar; extern crate term; -extern crate threadpool; extern crate time; extern crate toml; extern crate url; diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index f9e4107e9f5..7cf9fde0f2a 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -6,7 +6,7 @@ use std::path::Path; use core::{Package, PackageSet, Profiles, Profile}; use core::source::{Source, SourceMap}; use util::{CargoResult, human, ChainError, Config}; -use ops::{self, Layout, Context, BuildConfig, Kind}; +use ops::{self, Layout, Context, BuildConfig, Kind, Unit}; pub struct CleanOptions<'a> { pub spec: &'a [String], @@ -61,8 +61,13 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> { try!(rm_rf(&layout.fingerprint(&pkg))); let profiles = [Profile::default_dev(), Profile::default_test()]; for profile in profiles.iter() { - for filename in try!(cx.target_filenames(&pkg, target, profile, - Kind::Target)).iter() { + let unit = Unit { + pkg: &pkg, + target: target, + profile: profile, + kind: Kind::Target, + }; + for filename in try!(cx.target_filenames(&unit)).iter() { try!(rm_rf(&layout.dest().join(&filename))); try!(rm_rf(&layout.deps().join(&filename))); } diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 2404c1ede96..758da67db32 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -17,7 +17,7 @@ pub struct Compilation<'cfg> { pub libraries: HashMap>, /// An array of all tests created during this compilation. - pub tests: Vec<(Package, Vec<(String, PathBuf)>)>, + pub tests: Vec<(Package, String, PathBuf)>, /// An array of all binaries created. pub binaries: Vec, @@ -37,7 +37,7 @@ pub struct Compilation<'cfg> { /// Extra environment variables that were passed to compilations and should /// be passed to future invocations of programs. - pub extra_env: HashMap, + pub extra_env: HashMap>, pub to_doc_test: Vec, @@ -69,7 +69,8 @@ impl<'cfg> Compilation<'cfg> { } /// See `process`. - pub fn rustdoc_process(&self, pkg: &Package) -> CargoResult { + pub fn rustdoc_process(&self, pkg: &Package) + -> CargoResult { self.process(CommandType::Rustdoc, pkg) } @@ -102,8 +103,10 @@ impl<'cfg> Compilation<'cfg> { util::dylib_path_envvar())); let mut cmd = try!(CommandPrototype::new(cmd, self.config)); cmd.env(util::dylib_path_envvar(), &search_path); - for (k, v) in self.extra_env.iter() { - cmd.env(k, v); + if let Some(env) = self.extra_env.get(pkg.package_id()) { + for &(ref k, ref v) in env { + cmd.env(k, v); + } } cmd.env("CARGO_MANIFEST_DIR", pkg.root()) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 15c5d3dc22e..d6540740691 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -1,4 +1,3 @@ -use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::{HashSet, HashMap}; use std::path::{Path, PathBuf}; use std::str; @@ -13,18 +12,18 @@ use util::{self, CargoResult, ChainError, internal, Config, profile}; use util::human; use super::TargetConfig; -use super::custom_build::BuildState; +use super::custom_build::{BuildState, BuildScripts}; use super::fingerprint::Fingerprint; use super::layout::{Layout, LayoutProxy}; use super::{Kind, Compilation, BuildConfig}; use super::{ProcessEngine, ExecEngine}; -use super::PackagesToBuild; -#[derive(Debug, Clone, Copy)] -pub enum Platform { - Target, - Plugin, - PluginAndTarget, +#[derive(Clone, Copy, Eq, PartialEq, Hash)] +pub struct Unit<'a> { + pub pkg: &'a Package, + pub target: &'a Target, + pub profile: &'a Profile, + pub kind: Kind, } pub struct Context<'a, 'cfg: 'a> { @@ -34,12 +33,10 @@ pub struct Context<'a, 'cfg: 'a> { pub compilation: Compilation<'cfg>, pub build_state: Arc, pub exec_engine: Arc>, - pub fingerprints: HashMap<(&'a PackageId, &'a Target, &'a Profile, Kind), - Fingerprint>, - pub compiled: HashSet<(&'a PackageId, &'a Target, &'a Profile)>, + pub fingerprints: HashMap, Fingerprint>, + pub compiled: HashSet>, pub build_config: BuildConfig, - pub build_scripts: HashMap<(&'a PackageId, &'a Target, &'a Profile, Kind), - Vec<&'a PackageId>>, + pub build_scripts: HashMap, Arc>, host: Layout, target: Option, @@ -49,7 +46,6 @@ pub struct Context<'a, 'cfg: 'a> { package_set: &'a PackageSet, target_dylib: Option<(String, String)>, target_exe: String, - requirements: HashMap<(&'a PackageId, &'a str), Platform>, profiles: &'a Profiles, } @@ -89,7 +85,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { target_exe: target_exe, host_dylib: host_dylib, host_exe: host_exe, - requirements: HashMap::new(), compilation: Compilation::new(config), build_state: Arc::new(BuildState::new(&build_config, deps)), build_config: build_config, @@ -143,8 +138,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Prepare this context, ensuring that all filesystem directories are in /// place. - pub fn prepare(&mut self, root: &Package, - pkgs: &'a PackagesToBuild<'a>) -> CargoResult<()> { + pub fn prepare(&mut self, root: &Package) -> CargoResult<()> { let _p = profile::start("preparing layout"); try!(self.host.prepare().chain_error(|| { @@ -159,15 +153,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { None => {} } - for &(pkg, ref targets) in pkgs { - for &(target, profile) in targets { - self.build_requirements(pkg, target, profile, Kind::from(target)); - } - } - - let jobs = self.jobs(); - self.compilation.extra_env.insert("NUM_JOBS".to_string(), - jobs.to_string()); self.compilation.root_output = self.layout(root, Kind::Target).proxy().dest().to_path_buf(); self.compilation.deps_output = @@ -176,64 +161,24 @@ impl<'a, 'cfg> Context<'a, 'cfg> { return Ok(()); } - fn build_requirements(&mut self, pkg: &'a Package, target: &'a Target, - profile: &Profile, kind: Kind) { - let req = if kind == Kind::Host { Platform::Plugin } else { Platform::Target }; - - match self.requirements.entry((pkg.package_id(), target.name())) { - Occupied(mut entry) => match (*entry.get(), req) { - (Platform::Plugin, Platform::Plugin) | - (Platform::PluginAndTarget, Platform::Plugin) | - (Platform::Target, Platform::Target) | - (Platform::PluginAndTarget, Platform::Target) | - (Platform::PluginAndTarget, Platform::PluginAndTarget) => return, - _ => *entry.get_mut() = entry.get().combine(req), - }, - Vacant(entry) => { entry.insert(req); } - }; - - for (pkg, dep, profile) in self.dep_targets(pkg, target, kind, profile) { - self.build_requirements(pkg, dep, profile, kind.for_target(dep)); - } - - match pkg.targets().iter().find(|t| t.is_custom_build()) { - Some(custom_build) => { - let profile = self.build_script_profile(pkg.package_id()); - self.build_requirements(pkg, custom_build, profile, Kind::Host); - } - None => {} - } - } - - pub fn get_requirement(&self, pkg: &'a Package, - target: &'a Target) -> Platform { - let default = if target.for_host() { - Platform::Plugin - } else { - Platform::Target - }; - self.requirements.get(&(pkg.package_id(), target.name())) - .map(|a| *a).unwrap_or(default) - } - /// Returns the appropriate directory layout for either a plugin or not. pub fn layout(&self, pkg: &Package, kind: Kind) -> LayoutProxy { let primary = pkg.package_id() == self.resolve.root(); match kind { Kind::Host => LayoutProxy::new(&self.host, primary), - Kind::Target => LayoutProxy::new(self.target.as_ref() - .unwrap_or(&self.host), - primary), + Kind::Target => LayoutProxy::new(self.target.as_ref() + .unwrap_or(&self.host), + primary), } } /// Returns the appropriate output directory for the specified package and /// target. - pub fn out_dir(&self, pkg: &Package, kind: Kind, target: &Target) -> PathBuf { - let out_dir = self.layout(pkg, kind); - if target.is_custom_build() { - out_dir.build(pkg) - } else if target.is_example() { + pub fn out_dir(&self, unit: &Unit) -> PathBuf { + let out_dir = self.layout(unit.pkg, unit.kind); + if unit.target.is_custom_build() { + out_dir.build(unit.pkg) + } else if unit.target.is_example() { out_dir.examples().to_path_buf() } else { out_dir.root().to_path_buf() @@ -263,24 +208,24 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Get the metadata for a target in a specific profile - pub fn target_metadata(&self, pkg: &Package, target: &Target, - profile: &Profile) -> Option { - let metadata = target.metadata(); - if target.is_lib() && profile.test { + pub fn target_metadata(&self, unit: &Unit) -> Option { + let metadata = unit.target.metadata(); + if unit.target.is_lib() && unit.profile.test { // Libs and their tests are built in parallel, so we need to make // sure that their metadata is different. metadata.map(|m| m.clone()).map(|mut m| { m.mix(&"test"); m }) - } else if target.is_bin() && profile.test { + } else if unit.target.is_bin() && unit.profile.test { // Make sure that the name of this test executable doesn't // conflict with a library that has the same name and is // being tested - let mut metadata = pkg.generate_metadata(); - metadata.mix(&format!("bin-{}", target.name())); + let mut metadata = unit.pkg.generate_metadata(); + metadata.mix(&format!("bin-{}", unit.target.name())); Some(metadata) - } else if pkg.package_id() == self.resolve.root() && !profile.test { + } else if unit.pkg.package_id() == self.resolve.root() && + !unit.profile.test { // If we're not building a unit test then the root package never // needs any metadata as it's guaranteed to not conflict with any // other output filenames. This means that we'll have predictable @@ -292,38 +237,41 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Returns the file stem for a given target/profile combo - pub fn file_stem(&self, pkg: &Package, target: &Target, - profile: &Profile) -> String { - match self.target_metadata(pkg, target, profile) { - Some(ref metadata) => format!("{}{}", target.crate_name(), + pub fn file_stem(&self, unit: &Unit) -> String { + match self.target_metadata(unit) { + Some(ref metadata) => format!("{}{}", unit.target.crate_name(), metadata.extra_filename), - None if target.allows_underscores() => target.name().to_string(), - None => target.crate_name().to_string(), + None if unit.target.allows_underscores() => { + unit.target.name().to_string() + } + None => unit.target.crate_name().to_string(), } } /// Return the filenames that the given target for the given profile will /// generate. - pub fn target_filenames(&self, pkg: &Package, target: &Target, - profile: &Profile, kind: Kind) - -> CargoResult> { - let stem = self.file_stem(pkg, target, profile); - let suffix = if target.for_host() {&self.host_exe} else {&self.target_exe}; + pub fn target_filenames(&self, unit: &Unit) -> CargoResult> { + let stem = self.file_stem(unit); + let suffix = if unit.target.for_host() { + &self.host_exe + } else { + &self.target_exe + }; let mut ret = Vec::new(); - match *target.kind() { + match *unit.target.kind() { TargetKind::Example | TargetKind::Bin | TargetKind::CustomBuild | TargetKind::Bench | TargetKind::Test => { ret.push(format!("{}{}", stem, suffix)); } - TargetKind::Lib(..) if profile.test => { + TargetKind::Lib(..) if unit.profile.test => { ret.push(format!("{}{}", stem, suffix)); } TargetKind::Lib(ref libs) => { for lib in libs.iter() { match *lib { LibKind::Dylib => { - if let Ok((prefix, suffix)) = self.dylib(kind) { + if let Ok((prefix, suffix)) = self.dylib(unit.kind) { ret.push(format!("{}{}{}", prefix, stem, suffix)); } } @@ -340,89 +288,131 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// For a package, return all targets which are registered as dependencies /// for that package. - pub fn dep_targets(&self, pkg: &Package, target: &Target, kind: Kind, - profile: &Profile) - -> Vec<(&'a Package, &'a Target, &'a Profile)> { - if profile.doc { - return self.doc_deps(pkg, target, kind); + pub fn dep_targets(&self, unit: &Unit<'a>) -> Vec> { + if unit.profile.run_custom_build { + return self.dep_run_custom_build(unit, false) + } else if unit.profile.doc { + return self.doc_deps(unit); } - let deps = match self.resolve.deps(pkg.package_id()) { - None => return Vec::new(), - Some(deps) => deps, - }; + + let id = unit.pkg.package_id(); + let deps = self.resolve.deps(id).into_iter().flat_map(|a| a); let mut ret = deps.map(|id| self.get_package(id)).filter(|dep| { - pkg.dependencies().iter().filter(|d| { + unit.pkg.dependencies().iter().filter(|d| { d.name() == dep.name() }).any(|d| { // If this target is a build command, then we only want build // dependencies, otherwise we want everything *other than* build // dependencies. - let is_correct_dep = target.is_custom_build() == d.is_build(); + if unit.target.is_custom_build() != d.is_build() { + return false + } // If this dependency is *not* a transitive dependency, then it // only applies to test/example targets - let is_actual_dep = d.is_transitive() || - target.is_test() || - target.is_example() || - profile.test; + if !d.is_transitive() && !unit.target.is_test() && + !unit.target.is_example() && !unit.profile.test { + return false + } // If this dependency is only available for certain platforms, // make sure we're only enabling it for that platform. - let is_platform_same = self.dep_platform_activated(d, kind); + if !self.dep_platform_activated(d, unit.kind) { + return false + } // If the dependency is optional, then we're only activating it // if the corresponding feature was activated - let activated = !d.is_optional() || - self.resolve.features(pkg.package_id()).map(|f| { - f.contains(d.name()) - }).unwrap_or(false); + if d.is_optional() { + match self.resolve.features(id) { + Some(f) if f.contains(d.name()) => {} + _ => return false, + } + } - is_correct_dep && is_actual_dep && is_platform_same && activated + // If we've gotten past all that, then this dependency is + // actually used! + true }) }).filter_map(|pkg| { pkg.targets().iter().find(|t| t.is_lib()).map(|t| { - (pkg, t, self.lib_profile(pkg.package_id())) + Unit { + pkg: pkg, + target: t, + profile: self.lib_profile(id), + kind: unit.kind.for_target(t), + } }) }).collect::>(); // If a target isn't actually a build script itself, then it depends on // the build script if there is one. - if target.is_custom_build() { return ret } - let pkg = self.get_package(pkg.package_id()); - if let Some(t) = pkg.targets().iter().find(|t| t.is_custom_build()) { - ret.push((pkg, t, self.build_script_profile(pkg.package_id()))); + if unit.target.is_custom_build() { + return ret } + ret.extend(self.build_script_if_run(unit, false)); // If this target is a binary, test, example, etc, then it depends on // the library of the same package. The call to `resolve.deps` above // didn't include `pkg` in the return values, so we need to special case // it here and see if we need to push `(pkg, pkg_lib_target)`. - if target.is_lib() { return ret } - if let Some(t) = pkg.targets().iter().find(|t| t.linkable()) { - ret.push((pkg, t, self.lib_profile(pkg.package_id()))); + if unit.target.is_lib() { + return ret } + ret.extend(self.maybe_lib(unit)); // Integration tests/benchmarks require binaries to be built - if profile.test && (target.is_test() || target.is_bench()) { - ret.extend(pkg.targets().iter().filter(|t| t.is_bin()) - .map(|t| (pkg, t, self.lib_profile(pkg.package_id())))); + if unit.profile.test && + (unit.target.is_test() || unit.target.is_bench()) { + ret.extend(unit.pkg.targets().iter().filter(|t| t.is_bin()).map(|t| { + Unit { + pkg: unit.pkg, + target: t, + profile: self.lib_profile(id), + kind: unit.kind.for_target(t), + } + })); } return ret } + pub fn dep_run_custom_build(&self, + unit: &Unit<'a>, + include_overridden: bool) -> Vec> { + let not_custom_build = unit.pkg.targets().iter().find(|t| { + !t.is_custom_build() + }).unwrap(); + let tmp = Unit { + target: not_custom_build, + profile: &self.profiles.dev, + ..*unit + }; + let mut ret = self.dep_targets(&tmp).iter().filter_map(|unit| { + if !unit.target.linkable() || unit.pkg.manifest().links().is_none() { + return None + } + self.build_script_if_run(unit, include_overridden) + }).collect::>(); + ret.push(Unit { + profile: self.build_script_profile(unit.pkg.package_id()), + kind: Kind::Host, + ..*unit + }); + return ret + } + /// Returns the dependencies necessary to document a package - fn doc_deps(&self, pkg: &Package, target: &Target, kind: Kind) - -> Vec<(&'a Package, &'a Target, &'a Profile)> { - let pkg = self.get_package(pkg.package_id()); - let deps = self.resolve.deps(pkg.package_id()).into_iter(); + fn doc_deps(&self, unit: &Unit<'a>) -> Vec> { + let deps = self.resolve.deps(unit.pkg.package_id()).into_iter(); let deps = deps.flat_map(|a| a).map(|id| { self.get_package(id) }).filter(|dep| { - pkg.dependencies().iter().filter(|d| { + unit.pkg.dependencies().iter().filter(|d| { d.name() == dep.name() }).any(|dep| { match dep.kind() { - DepKind::Normal => self.dep_platform_activated(dep, kind), + DepKind::Normal => self.dep_platform_activated(dep, + unit.kind), _ => false, } }) @@ -435,26 +425,68 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // the documentation of the library being built. let mut ret = Vec::new(); for (dep, lib) in deps { - ret.push((dep, lib, self.lib_profile(dep.package_id()))); + ret.push(Unit { + pkg: dep, + target: lib, + profile: self.lib_profile(dep.package_id()), + kind: unit.kind.for_target(lib), + }); if self.build_config.doc_all { - ret.push((dep, lib, &self.profiles.doc)); + ret.push(Unit { + pkg: dep, + target: lib, + profile: &self.profiles.doc, + kind: unit.kind.for_target(lib), + }); } } // Be sure to build/run the build script for documented libraries as - if let Some(t) = pkg.targets().iter().find(|t| t.is_custom_build()) { - ret.push((pkg, t, self.build_script_profile(pkg.package_id()))); - } + ret.extend(self.build_script_if_run(unit, false)); // If we document a binary, we need the library available - if target.is_bin() { - if let Some(t) = pkg.targets().iter().find(|t| t.is_lib()) { - ret.push((pkg, t, self.lib_profile(pkg.package_id()))); - } + if unit.target.is_bin() { + ret.extend(self.maybe_lib(unit)); } return ret } + /// Returns the build script for a package if that build script is actually + /// intended to be run for `kind` as part of this compilation. + /// + /// Build scripts are not run if they are overridden by some global + /// configuration. + fn build_script_if_run(&self, unit: &Unit<'a>, + allow_overridden: bool) -> Option> { + let target = match unit.pkg.targets().iter().find(|t| t.is_custom_build()) { + Some(t) => t, + None => return None, + }; + let key = (unit.pkg.package_id().clone(), unit.kind); + if !allow_overridden && + unit.pkg.manifest().links().is_some() && + self.build_state.outputs.lock().unwrap().contains_key(&key) { + return None + } + Some(Unit { + pkg: unit.pkg, + target: target, + profile: &self.profiles.custom_build, + kind: unit.kind, + }) + } + + fn maybe_lib(&self, unit: &Unit<'a>) -> Option> { + unit.pkg.targets().iter().find(|t| t.linkable()).map(|t| { + Unit { + pkg: unit.pkg, + target: t, + profile: self.lib_profile(unit.pkg.package_id()), + kind: unit.kind.for_target(t), + } + }) + } + fn dep_platform_activated(&self, dep: &Dependency, kind: Kind) -> bool { // If this dependency is only available for certain platforms, // make sure we're only enabling it for that platform. @@ -516,22 +548,3 @@ impl<'a, 'cfg> Context<'a, 'cfg> { &self.profiles.dev } } - -impl Platform { - pub fn combine(self, other: Platform) -> Platform { - match (self, other) { - (Platform::Target, Platform::Target) => Platform::Target, - (Platform::Plugin, Platform::Plugin) => Platform::Plugin, - _ => Platform::PluginAndTarget, - } - } - - pub fn includes(self, kind: Kind) -> bool { - match (self, kind) { - (Platform::PluginAndTarget, _) | - (Platform::Target, Kind::Target) | - (Platform::Plugin, Kind::Host) => true, - _ => false, - } - } -} diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index c84bfeaf10b..28348bd6212 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -3,17 +3,16 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::path::PathBuf; use std::str; -use std::sync::Mutex; +use std::sync::{Mutex, Arc}; -use core::{Package, Target, PackageId, PackageSet, Profile}; +use core::{PackageId, PackageSet}; use util::{CargoResult, human, Human}; use util::{internal, ChainError, profile}; use util::Freshness; use super::job::Work; -use super::{fingerprint, process, Kind, Context, Platform}; +use super::{fingerprint, process, Kind, Context, Unit}; use super::CommandType; -use super::PackagesToBuild; /// Contains the parsed output of a custom build script. #[derive(Clone, Debug)] @@ -34,36 +33,41 @@ pub struct BuildState { pub outputs: Mutex, } +#[derive(Default)] +pub struct BuildScripts { + pub to_link: Vec<(PackageId, Kind)>, + pub plugins: Vec, +} + /// Prepares a `Work` that executes the target as a custom build script. /// /// The `req` given is the requirement which this run of the build script will /// prepare work for. If the requirement is specified as both the target and the /// host platforms it is assumed that the two are equal and the build script is /// only run once (not twice). -pub fn prepare(pkg: &Package, target: &Target, req: Platform, - cx: &mut Context) -> CargoResult<(Work, Work, Freshness)> { +pub fn prepare(cx: &mut Context, unit: &Unit) + -> CargoResult<(Work, Work, Freshness)> { let _p = profile::start(format!("build script prepare: {}/{}", - pkg, target.name())); - let kind = match req { Platform::Plugin => Kind::Host, _ => Kind::Target, }; + unit.pkg, unit.target.name())); let (script_output, build_output) = { - (cx.layout(pkg, Kind::Host).build(pkg), - cx.layout(pkg, kind).build_out(pkg)) + (cx.layout(unit.pkg, Kind::Host).build(unit.pkg), + cx.layout(unit.pkg, unit.kind).build_out(unit.pkg)) }; // Building the command to execute - let to_exec = script_output.join(target.name()); + let to_exec = script_output.join(unit.target.name()); // Start preparing the process to execute, starting out with some // environment variables. Note that the profile-related environment // variables are not set with this the build script's profile but rather the // package's library profile. - let profile = cx.lib_profile(pkg.package_id()); + let profile = cx.lib_profile(unit.pkg.package_id()); let to_exec = to_exec.into_os_string(); - let mut p = try!(super::process(CommandType::Host(to_exec), pkg, target, cx)); + let mut p = try!(super::process(CommandType::Host(to_exec), unit.pkg, cx)); p.env("OUT_DIR", &build_output) - .env("CARGO_MANIFEST_DIR", pkg.root()) + .env("CARGO_MANIFEST_DIR", unit.pkg.root()) .env("NUM_JOBS", &cx.jobs().to_string()) - .env("TARGET", &match kind { + .env("TARGET", &match unit.kind { Kind::Host => &cx.config.rustc_info().host[..], Kind::Target => cx.target_triple(), }) @@ -74,13 +78,10 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform, // Be sure to pass along all enabled features for this package, this is the // last piece of statically known information that we have. - match cx.resolve.features(pkg.package_id()) { - Some(features) => { - for feat in features.iter() { - p.env(&format!("CARGO_FEATURE_{}", super::envify(feat)), "1"); - } + if let Some(features) = cx.resolve.features(unit.pkg.package_id()) { + for feat in features.iter() { + p.env(&format!("CARGO_FEATURE_{}", super::envify(feat)), "1"); } - None => {} } // Gather the set of native dependencies that this package has along with @@ -89,27 +90,25 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform, // This information will be used at build-time later on to figure out which // sorts of variables need to be discovered at that time. let lib_deps = { - let not_custom = pkg.targets().iter().find(|t| { - !t.is_custom_build() - }).unwrap(); - cx.dep_targets(pkg, not_custom, kind, profile).iter() - .filter_map(|&(pkg, t, _)| { - if !t.linkable() { return None } - pkg.manifest().links().map(|links| { - (links.to_string(), pkg.package_id().clone()) - }) + cx.dep_run_custom_build(unit, true).iter().filter_map(|unit| { + if unit.profile.run_custom_build { + Some((unit.pkg.manifest().links().unwrap().to_string(), + unit.pkg.package_id().clone())) + } else { + None + } }).collect::>() }; - let pkg_name = pkg.to_string(); + let pkg_name = unit.pkg.to_string(); let build_state = cx.build_state.clone(); - let id = pkg.package_id().clone(); + let id = unit.pkg.package_id().clone(); let all = (id.clone(), pkg_name.clone(), build_state.clone(), build_output.clone()); - let plugin_deps = super::load_build_deps(cx, pkg, target, profile, - Kind::Host); + let build_scripts = super::load_build_deps(cx, unit); + let kind = unit.kind; - try!(fs::create_dir_all(&cx.layout(pkg, Kind::Target).build(pkg))); - try!(fs::create_dir_all(&cx.layout(pkg, Kind::Host).build(pkg))); + try!(fs::create_dir_all(&cx.layout(unit.pkg, Kind::Host).build(unit.pkg))); + try!(fs::create_dir_all(&cx.layout(unit.pkg, unit.kind).build(unit.pkg))); let exec_engine = cx.exec_engine.clone(); @@ -136,14 +135,22 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform, // native dynamic libraries. { let build_state = build_state.outputs.lock().unwrap(); - for &(ref name, ref id) in lib_deps.iter() { - let data = &build_state[&(id.clone(), kind)].metadata; + for (name, id) in lib_deps { + let key = (id.clone(), kind); + let state = try!(build_state.get(&key).chain_error(|| { + internal(format!("failed to locate build state for env \ + vars: {}/{:?}", id, kind)) + })); + let data = &state.metadata; for &(ref key, ref value) in data.iter() { - p.env(&format!("DEP_{}_{}", super::envify(name), + p.env(&format!("DEP_{}_{}", super::envify(&name), super::envify(key)), value); } } - try!(super::add_plugin_deps(&mut p, &build_state, plugin_deps)); + if let Some(build_scripts) = build_scripts { + try!(super::add_plugin_deps(&mut p, &build_state, + &build_scripts)); + } } // And now finally, run the build command itself! @@ -165,7 +172,7 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform, human("build script output was not valid utf-8") })); let parsed_output = try!(BuildOutput::parse(output, &pkg_name)); - build_state.insert(id, req, parsed_output); + build_state.insert(id, kind, parsed_output); try!(File::create(&build_output.parent().unwrap().join("output")) .and_then(|mut f| f.write_all(output.as_bytes())) @@ -187,12 +194,9 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform, // // Also note that a fresh build command needs to let (freshness, dirty, fresh) = - try!(fingerprint::prepare_build_cmd(cx, pkg, kind)); - let dirty = Work::new(move |tx| { - try!(work.call((tx.clone()))); - dirty.call(tx) - }); - let fresh = Work::new(move |tx| { + try!(fingerprint::prepare_build_cmd(cx, unit)); + let dirty = work.then(dirty); + let fresh = Work::new(move |_tx| { let (id, pkg_name, build_state, build_output) = all; let new_loc = build_output.parent().unwrap().join("output"); let mut f = try!(File::open(&new_loc).map_err(|e| { @@ -201,10 +205,9 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform, let mut contents = String::new(); try!(f.read_to_string(&mut contents)); let output = try!(BuildOutput::parse(&contents, &pkg_name)); - build_state.insert(id, req, output); - - fresh.call(tx) - }); + build_state.insert(id, kind, output); + Ok(()) + }).then(fresh); Ok((dirty, fresh, freshness)) } @@ -235,20 +238,8 @@ impl BuildState { BuildState { outputs: Mutex::new(outputs) } } - fn insert(&self, id: PackageId, req: Platform, - output: BuildOutput) { - let mut outputs = self.outputs.lock().unwrap(); - match req { - Platform::Target => { outputs.insert((id, Kind::Target), output); } - Platform::Plugin => { outputs.insert((id, Kind::Host), output); } - - // If this build output was for both the host and target platforms, - // we need to insert it at both places. - Platform::PluginAndTarget => { - outputs.insert((id.clone(), Kind::Host), output.clone()); - outputs.insert((id, Kind::Target), output); - } - } + fn insert(&self, id: PackageId, kind: Kind, output: BuildOutput) { + self.outputs.lock().unwrap().insert((id, kind), output); } } @@ -351,78 +342,55 @@ impl BuildOutput { /// The given set of targets to this function is the initial set of /// targets/profiles which are being built. pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, - pkgs: &'b PackagesToBuild<'b>) { + units: &[Unit<'b>]) { let mut ret = HashMap::new(); - for &(pkg, ref targets) in pkgs { - for &(target, profile) in targets { - build(&mut ret, Kind::Target, pkg, target, profile, cx); - build(&mut ret, Kind::Host, pkg, target, profile, cx); - } + for unit in units { + build(&mut ret, cx, unit); } // Make the output a little more deterministic by sorting all dependencies - for (&(id, target, _, kind), slot) in ret.iter_mut() { - slot.sort(); - slot.dedup(); - debug!("script deps: {}/{}/{:?} => {:?}", id, target.name(), kind, - slot.iter().map(|s| s.to_string()).collect::>()); + for (_, slot) in ret.iter_mut() { + slot.to_link.sort_by(|a, b| a.0.cmp(&b.0)); + slot.to_link.dedup(); + slot.plugins.sort(); + slot.plugins.dedup(); } - cx.build_scripts = ret; + cx.build_scripts.extend(ret.into_iter().map(|(k, v)| { + (k, Arc::new(v)) + })); // Recursive function to build up the map we're constructing. This function // memoizes all of its return values as it goes along. - fn build<'a, 'b, 'cfg>(out: &'a mut HashMap<(&'b PackageId, &'b Target, - &'b Profile, Kind), - Vec<&'b PackageId>>, - kind: Kind, - pkg: &'b Package, - target: &'b Target, - profile: &'b Profile, - cx: &Context<'b, 'cfg>) - -> &'a [&'b PackageId] { - // If this target has crossed into "host-land" we need to change the - // kind that we're compiling for, and otherwise just do a quick - // pre-flight check to see if we've already calculated the set of - // dependencies. - let kind = kind.for_target(target); - let id = pkg.package_id(); - if out.contains_key(&(id, target, profile, kind)) { - return &out[&(id, target, profile, kind)] + fn build<'a, 'b, 'cfg>(out: &'a mut HashMap, BuildScripts>, + cx: &Context<'b, 'cfg>, + unit: &Unit<'b>) + -> &'a BuildScripts { + // Do a quick pre-flight check to see if we've already calculated the + // set of dependencies. + if out.contains_key(unit) { + return &out[unit] } - // This loop is both the recursive and additive portion of this - // function, the key part of the logic being around determining the - // right `kind` to recurse on. If a dependency fits in the kind that - // we've got specified, then we just keep plazing a trail, but otherwise - // we *switch* the kind we're looking at because it must fit into the - // other category. - // - // We always recurse, but only add to our own array if the target is - // linkable to us (e.g. not a binary) and it's for the same original - // `kind`. - let mut ret = Vec::new(); - for (pkg, target, p) in cx.dep_targets(pkg, target, kind, profile) { - let req = cx.get_requirement(pkg, target); - - let dep_kind = if req.includes(kind) { - kind - } else if kind == Kind::Target { - Kind::Host - } else { - Kind::Target - }; - let dep_scripts = build(out, dep_kind, pkg, target, p, cx); + let mut to_link = Vec::new(); + let mut plugins = Vec::new(); - if target.linkable() && kind == dep_kind { - if pkg.has_custom_build() { - ret.push(pkg.package_id()); - } - ret.extend(dep_scripts.iter().cloned()); + if !unit.target.is_custom_build() && unit.pkg.has_custom_build() { + to_link.push((unit.pkg.package_id().clone(), unit.kind)); + } + for unit in cx.dep_targets(unit).iter() { + let dep_scripts = build(out, cx, unit); + + if unit.target.for_host() { + plugins.extend(dep_scripts.to_link.iter() + .map(|p| &p.0).cloned()); + } else if unit.target.linkable() { + to_link.extend(dep_scripts.to_link.iter().cloned()); } } - let prev = out.entry((id, target, profile, kind)).or_insert(Vec::new()); - prev.extend(ret); + let prev = out.entry(*unit).or_insert(BuildScripts::default()); + prev.to_link.extend(to_link); + prev.plugins.extend(plugins); return prev } } diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 4cfd0dcd74e..bc3d0059eaa 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -6,13 +6,12 @@ use std::sync::{Arc, Mutex}; use filetime::FileTime; -use core::{Package, Target, Profile}; +use core::{Package, TargetKind}; use util; use util::{CargoResult, Fresh, Dirty, Freshness, internal, profile, ChainError}; -use super::Kind; use super::job::Work; -use super::context::Context; +use super::context::{Context, Unit}; /// A tuple result of the `prepare_foo` functions in this module. /// @@ -43,31 +42,29 @@ pub type Preparation = (Freshness, Work, Work); /// work necessary to either write the fingerprint or copy over all fresh files /// from the old directories to their new locations. pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, - pkg: &'a Package, - target: &'a Target, - profile: &'a Profile, - kind: Kind) -> CargoResult { + unit: &Unit<'a>) -> CargoResult { let _p = profile::start(format!("fingerprint: {} / {}", - pkg.package_id(), target.name())); - let new = dir(cx, pkg, kind); - let loc = new.join(&filename(target, profile)); + unit.pkg.package_id(), unit.target.name())); + let new = dir(cx, unit); + let loc = new.join(&filename(unit)); - info!("fingerprint at: {}", loc.display()); + debug!("fingerprint at: {}", loc.display()); - let mut fingerprint = try!(calculate(cx, pkg, target, profile, kind)); + let mut fingerprint = try!(calculate(cx, unit)); let is_fresh = try!(is_fresh(&loc, &mut fingerprint)); - let root = cx.out_dir(pkg, kind, target); + + let root = cx.out_dir(unit); let mut missing_outputs = false; - if !profile.doc { - for filename in try!(cx.target_filenames(pkg, target, profile, - kind)).iter() { + if !unit.profile.doc { + for filename in try!(cx.target_filenames(unit)).iter() { missing_outputs |= fs::metadata(root.join(filename)).is_err(); } } - let allow_failure = profile.rustc_args.is_some(); - Ok(prepare(is_fresh && !missing_outputs, allow_failure, loc, fingerprint)) + let allow_failure = unit.profile.rustc_args.is_some(); + Ok(prepare(is_fresh && !missing_outputs, + allow_failure, loc, fingerprint)) } /// A fingerprint can be considered to be a "short string" representing the @@ -144,30 +141,23 @@ impl FingerprintInner { /// /// Information like file modification time is only calculated for path /// dependencies and is calculated in `calculate_target_fresh`. -fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, - pkg: &'a Package, - target: &'a Target, - profile: &'a Profile, - kind: Kind) +fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult { - let key = (pkg.package_id(), target, profile, kind); - match cx.fingerprints.get(&key) { - Some(s) => return Ok(s.clone()), - None => {} + if let Some(s) = cx.fingerprints.get(unit) { + return Ok(s.clone()) } // First, calculate all statically known "salt data" such as the profile // information (compiler flags), the compiler version, activated features, // and target configuration. - let features = cx.resolve.features(pkg.package_id()); + let features = cx.resolve.features(unit.pkg.package_id()); let features = features.map(|s| { - let mut v = s.iter().collect::>(); + let mut v = s.iter().collect::>(); v.sort(); v }); let extra = util::short_hash(&(&cx.config.rustc_info().verbose_version, - target, &features, profile)); - debug!("extra {:?} {:?} {:?} = {}", target, profile, features, extra); + unit.target, &features, unit.profile)); // Next, recursively calculate the fingerprint for all of our dependencies. // @@ -176,20 +166,17 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, // elsewhere. Also skip fingerprints of binaries because they don't actually // induce a recompile, they're just dependencies in the sense that they need // to be built. - let deps = try!(cx.dep_targets(pkg, target, kind, profile).into_iter() - .filter(|&(_, t, _)| !t.is_custom_build() && !t.is_bin()) - .map(|(pkg, target, profile)| { - let kind = match kind { - Kind::Host => Kind::Host, - Kind::Target if target.for_host() => Kind::Host, - Kind::Target => Kind::Target, - }; - calculate(cx, pkg, target, profile, kind) + let deps = try!(cx.dep_targets(unit).iter().filter(|u| { + !u.target.is_custom_build() && !u.target.is_bin() + }).map(|unit| { + calculate(cx, unit).map(|fingerprint| { + fingerprint + }) }).collect::>>()); // And finally, calculate what our own local fingerprint is - let local = if use_dep_info(pkg, profile) { - let dep_info = dep_info_loc(cx, pkg, target, profile, kind); + let local = if use_dep_info(unit) { + let dep_info = dep_info_loc(cx, unit); let mtime = try!(calculate_target_mtime(&dep_info)); // if the mtime listed is not fresh, then remove the `dep_info` file to @@ -199,7 +186,8 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, } LocalFingerprint::MtimeBased(mtime, dep_info) } else { - LocalFingerprint::Precalculated(try!(calculate_pkg_fingerprint(cx, pkg))) + LocalFingerprint::Precalculated(try!(calculate_pkg_fingerprint(cx, + unit.pkg))) }; let fingerprint = Arc::new(FingerprintInner { extra: extra, @@ -207,7 +195,7 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, local: local, resolved: Mutex::new(None), }); - cx.fingerprints.insert(key, fingerprint.clone()); + cx.fingerprints.insert(*unit, fingerprint.clone()); Ok(fingerprint) } @@ -216,9 +204,9 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, // git/registry source, then the mtime of files may fluctuate, but they won't // change so long as the source itself remains constant (which is the // responsibility of the source) -fn use_dep_info(pkg: &Package, profile: &Profile) -> bool { - let path = pkg.summary().source_id().is_path(); - !profile.doc && path +fn use_dep_info(unit: &Unit) -> bool { + let path = unit.pkg.summary().source_id().is_path(); + !unit.profile.doc && path } /// Prepare the necessary work for the fingerprint of a build command. @@ -238,16 +226,16 @@ fn use_dep_info(pkg: &Package, profile: &Profile) -> bool { /// /// The currently implemented solution is option (1), although it is planned to /// migrate to option (2) in the near future. -pub fn prepare_build_cmd(cx: &mut Context, pkg: &Package, kind: Kind) +pub fn prepare_build_cmd(cx: &mut Context, unit: &Unit) -> CargoResult { let _p = profile::start(format!("fingerprint build cmd: {}", - pkg.package_id())); - let new = dir(cx, pkg, kind); + unit.pkg.package_id())); + let new = dir(cx, unit); let loc = new.join("build"); - info!("fingerprint at: {}", loc.display()); + debug!("fingerprint at: {}", loc.display()); - let new_fingerprint = try!(calculate_build_cmd_fingerprint(cx, pkg)); + let new_fingerprint = try!(calculate_pkg_fingerprint(cx, unit.pkg)); let new_fingerprint = Arc::new(FingerprintInner { extra: String::new(), deps: Vec::new(), @@ -261,25 +249,17 @@ pub fn prepare_build_cmd(cx: &mut Context, pkg: &Package, kind: Kind) } /// Prepare work for when a package starts to build -pub fn prepare_init(cx: &mut Context, pkg: &Package, kind: Kind) - -> (Work, Work) { - let new1 = dir(cx, pkg, kind); +pub fn prepare_init(cx: &mut Context, unit: &Unit) -> CargoResult<()> { + let new1 = dir(cx, unit); let new2 = new1.clone(); - let work1 = Work::new(move |_| { - if fs::metadata(&new1).is_err() { - try!(fs::create_dir(&new1)); - } - Ok(()) - }); - let work2 = Work::new(move |_| { - if fs::metadata(&new2).is_err() { - try!(fs::create_dir(&new2)); - } - Ok(()) - }); - - (work1, work2) + if fs::metadata(&new1).is_err() { + try!(fs::create_dir(&new1)); + } + if fs::metadata(&new2).is_err() { + try!(fs::create_dir(&new2)); + } + Ok(()) } /// Given the data to build and write a fingerprint, generate some Work @@ -307,14 +287,13 @@ fn prepare(is_fresh: bool, } /// Return the (old, new) location for fingerprints for a package -pub fn dir(cx: &Context, pkg: &Package, kind: Kind) -> PathBuf { - cx.layout(pkg, kind).proxy().fingerprint(pkg) +pub fn dir(cx: &Context, unit: &Unit) -> PathBuf { + cx.layout(unit.pkg, unit.kind).proxy().fingerprint(unit.pkg) } /// Returns the (old, new) location for the dep info file of a target. -pub fn dep_info_loc(cx: &Context, pkg: &Package, target: &Target, - profile: &Profile, kind: Kind) -> PathBuf { - dir(cx, pkg, kind).join(&format!("dep-{}", filename(target, profile))) +pub fn dep_info_loc(cx: &Context, unit: &Unit) -> PathBuf { + dir(cx, unit).join(&format!("dep-{}", filename(unit))) } fn is_fresh(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult { @@ -382,14 +361,8 @@ fn calculate_target_mtime(dep_info: &Path) -> CargoResult> { Ok(Some(mtime)) } -fn calculate_build_cmd_fingerprint(cx: &Context, pkg: &Package) - -> CargoResult { - // TODO: this should be scoped to just the `build` directory, not the entire - // package. - calculate_pkg_fingerprint(cx, pkg) -} - -fn calculate_pkg_fingerprint(cx: &Context, pkg: &Package) -> CargoResult { +fn calculate_pkg_fingerprint(cx: &Context, + pkg: &Package) -> CargoResult { let source = cx.sources .get(pkg.package_id().source_id()) .expect("BUG: Missing package source"); @@ -397,16 +370,23 @@ fn calculate_pkg_fingerprint(cx: &Context, pkg: &Package) -> CargoResult source.fingerprint(pkg) } -fn filename(target: &Target, profile: &Profile) -> String { - let kind = if target.is_lib() {"lib"} else {"bin"}; - let flavor = if target.is_test() || profile.test { +fn filename(unit: &Unit) -> String { + let kind = match *unit.target.kind() { + TargetKind::Lib(..) => "lib", + TargetKind::Bin => "bin", + TargetKind::Test => "integration-test", + TargetKind::Example => "example", + TargetKind::Bench => "bench", + TargetKind::CustomBuild => "build-script", + }; + let flavor = if unit.profile.test { "test-" - } else if profile.doc { + } else if unit.profile.doc { "doc-" } else { "" }; - format!("{}{}-{}", flavor, kind, target.name()) + format!("{}{}-{}", flavor, kind, unit.target.name()) } // The dep-info files emitted by the compiler all have their listed paths diff --git a/src/cargo/ops/cargo_rustc/job.rs b/src/cargo/ops/cargo_rustc/job.rs index b3d58e1d628..0c270cfdf23 100644 --- a/src/cargo/ops/cargo_rustc/job.rs +++ b/src/cargo/ops/cargo_rustc/job.rs @@ -1,4 +1,5 @@ use std::sync::mpsc::Sender; +use std::fmt; use util::{CargoResult, Fresh, Dirty, Freshness}; @@ -34,6 +35,13 @@ impl Work { pub fn call(self, tx: Sender) -> CargoResult<()> { self.inner.call_box(tx) } + + pub fn then(self, next: Work) -> Work { + Work::new(move |tx| { + try!(self.call(tx.clone())); + next.call(tx) + }) + } } impl Job { @@ -51,3 +59,9 @@ impl Job { } } } + +impl fmt::Debug for Job { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Job {{ ... }}") + } +} diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 3f74e85e98f..554889649ce 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -1,14 +1,16 @@ use std::collections::HashSet; use std::collections::hash_map::HashMap; +use std::fmt; use std::sync::mpsc::{channel, Sender, Receiver}; -use threadpool::ThreadPool; +use crossbeam::{self, Scope}; use term::color::YELLOW; -use core::{Package, PackageId, Resolve, PackageSet}; +use core::{PackageId, Target, Profile}; use util::{Config, DependencyQueue, Fresh, Dirty, Freshness}; -use util::{CargoResult, Dependency, profile}; +use util::{CargoResult, Dependency, profile, internal}; +use super::{Context, Kind, Unit}; use super::job::Job; /// A management structure of the entire dependency graph to compile. @@ -17,75 +19,58 @@ use super::job::Job; /// actual compilation step of each package. Packages enqueue units of work and /// then later on the entire graph is processed and compiled. pub struct JobQueue<'a> { - pool: ThreadPool, - queue: DependencyQueue<(&'a PackageId, Stage), - (&'a Package, Vec<(Job, Freshness)>)>, - tx: Sender, - rx: Receiver, - resolve: &'a Resolve, - packages: &'a PackageSet, - active: u32, - pending: HashMap<(&'a PackageId, Stage), PendingBuild>, - pkgids: HashSet<&'a PackageId>, + jobs: usize, + queue: DependencyQueue, Vec<(Job, Freshness)>>, + tx: Sender>, + rx: Receiver>, + active: usize, + pending: HashMap, PendingBuild>, printed: HashSet<&'a PackageId>, + counts: HashMap<&'a PackageId, usize>, } /// A helper structure for metadata about the state of a building package. struct PendingBuild { /// Number of jobs currently active - amt: u32, + amt: usize, /// Current freshness state of this package. Any dirty target within a /// package will cause the entire package to become dirty. fresh: Freshness, } -/// Current stage of compilation for an individual package. -/// -/// This is the second layer of keys on the dependency queue to track the state -/// of where a particular package is in the compilation pipeline. Each of these -/// stages has a network of dependencies among them, outlined by the -/// `Dependency` implementation found below. -/// -/// Each build step for a package is registered with one of these stages, and -/// each stage has a vector of work to perform in parallel. -#[derive(Hash, PartialEq, Eq, Clone, PartialOrd, Ord, Debug, Copy)] -pub enum Stage { - Start, - BuildCustomBuild, - RunCustomBuild, - Libraries, - Binaries, - LibraryTests, - BinaryTests, - End, +#[derive(Clone, Copy, Eq, PartialEq, Hash)] +struct Key<'a> { + pkg: &'a PackageId, + target: &'a Target, + profile: &'a Profile, + kind: Kind, } -type Message = (PackageId, Stage, Freshness, CargoResult<()>); +struct Message<'a> { + key: Key<'a>, + result: CargoResult<()>, +} impl<'a> JobQueue<'a> { - pub fn new(resolve: &'a Resolve, packages: &'a PackageSet, jobs: u32) - -> JobQueue<'a> { + pub fn new<'cfg>(cx: &Context<'a, 'cfg>) -> JobQueue<'a> { let (tx, rx) = channel(); JobQueue { - pool: ThreadPool::new(jobs as usize), + jobs: cx.jobs() as usize, queue: DependencyQueue::new(), tx: tx, rx: rx, - resolve: resolve, - packages: packages, active: 0, pending: HashMap::new(), - pkgids: HashSet::new(), printed: HashSet::new(), + counts: HashMap::new(), } } - pub fn queue(&mut self, pkg: &'a Package, stage: Stage) - -> &mut Vec<(Job, Freshness)> { - self.pkgids.insert(pkg.package_id()); - &mut self.queue.queue(&(self.resolve, self.packages), Fresh, - (pkg.package_id(), stage), - (pkg, Vec::new())).1 + pub fn enqueue(&mut self, cx: &Context<'a, 'a>, + unit: &Unit<'a>, job: Job, fresh: Freshness) { + let key = Key::new(unit); + self.queue.queue(cx, Fresh, key, Vec::new()).push((job, fresh)); + *self.counts.entry(key.pkg).or_insert(0) += 1; } /// Execute all jobs necessary to build the dependency graph. @@ -96,34 +81,61 @@ impl<'a> JobQueue<'a> { pub fn execute(&mut self, config: &Config) -> CargoResult<()> { let _p = profile::start("executing the job graph"); - // Iteratively execute the dependency graph. Each turn of this loop will - // schedule as much work as possible and then wait for one job to finish, - // possibly scheduling more work afterwards. - while self.queue.len() > 0 { - loop { - match self.queue.dequeue() { - Some((fresh, (_, stage), (pkg, jobs))) => { - info!("start: {} {:?}", pkg, stage); - try!(self.run(pkg, stage, fresh, jobs, config)); - } - None => break, + crossbeam::scope(|scope| { + self.drain_the_queue(config, scope) + }) + } + + fn drain_the_queue(&mut self, config: &Config, scope: &Scope<'a>) + -> CargoResult<()> { + let mut queue = Vec::new(); + trace!("queue: {:#?}", self.queue); + + // Iteratively execute the entire dependency graph. Each turn of the + // loop starts out by scheduling as much work as possible (up to the + // maximum number of parallel jobs). A local queue is maintained + // separately from the main dependency queue as one dequeue may actually + // dequeue quite a bit of work (e.g. 10 binaries in one project). + // + // After a job has finished we update our internal state if it was + // successful and otherwise wait for pending work to finish if it failed + // and then immediately return. + loop { + while self.active < self.jobs { + if queue.len() > 0 { + let (key, job, fresh) = queue.remove(0); + try!(self.run(key, fresh, job, config, scope)); + } else if let Some((fresh, key, jobs)) = self.queue.dequeue() { + let total_fresh = jobs.iter().fold(fresh, |fresh, &(_, f)| { + f.combine(fresh) + }); + self.pending.insert(key, PendingBuild { + amt: jobs.len(), + fresh: total_fresh, + }); + queue.extend(jobs.into_iter().map(|(job, f)| { + (key, job, f.combine(fresh)) + })); + } else { + break } } + if self.active == 0 { + break + } // Now that all possible work has been scheduled, wait for a piece // of work to finish. If any package fails to build then we stop // scheduling work as quickly as possibly. - let (id, stage, fresh, result) = self.rx.recv().unwrap(); - info!(" end: {} {:?}", id, stage); - let id = *self.pkgids.iter().find(|&k| *k == &id).unwrap(); + let msg = self.rx.recv().unwrap(); + info!("end: {:?}", msg.key); self.active -= 1; - match result { + match msg.result { Ok(()) => { - let state = self.pending.get_mut(&(id, stage)).unwrap(); + let state = self.pending.get_mut(&msg.key).unwrap(); state.amt -= 1; - state.fresh = state.fresh.combine(fresh); if state.amt == 0 { - self.queue.finish(&(id, stage), state.fresh); + self.queue.finish(&msg.key, state.fresh); } } Err(e) => { @@ -138,62 +150,42 @@ impl<'a> JobQueue<'a> { } } - trace!("rustc jobs completed"); - - Ok(()) + if self.queue.len() == 0 { + Ok(()) + } else { + debug!("queue: {:#?}", self.queue); + Err(internal("finished with jobs still left in the queue")) + } } - /// Execute a stage of compilation for a package. - /// - /// The input freshness is from `dequeue()` and indicates the combined - /// freshness of all upstream dependencies. This function will schedule all - /// work in `jobs` to be executed. - fn run(&mut self, pkg: &'a Package, stage: Stage, fresh: Freshness, - jobs: Vec<(Job, Freshness)>, config: &Config) -> CargoResult<()> { - let njobs = jobs.len(); - let amt = if njobs == 0 {1} else {njobs as u32}; - let id = pkg.package_id().clone(); - - // While the jobs are all running, we maintain some metadata about how - // many are running, the current state of freshness (of all the combined - // jobs), and the stage to pass to finish() later on. - self.active += amt; - self.pending.insert((pkg.package_id(), stage), PendingBuild { - amt: amt, - fresh: fresh, - }); + /// Executes a job in the `scope` given, pushing the spawned thread's + /// handled onto `threads`. + fn run(&mut self, + key: Key<'a>, + fresh: Freshness, + job: Job, + config: &Config, + scope: &Scope<'a>) -> CargoResult<()> { + info!("start: {:?}", key); - let mut total_fresh = fresh; - let mut running = Vec::new(); - debug!("start {:?} at {:?} for {}", total_fresh, stage, pkg); - for (job, job_freshness) in jobs.into_iter() { - debug!("job: {:?} ({:?})", job_freshness, total_fresh); - let fresh = job_freshness.combine(fresh); - total_fresh = total_fresh.combine(fresh); - let my_tx = self.tx.clone(); - let id = id.clone(); - let (desc_tx, desc_rx) = channel(); - self.pool.execute(move|| { - my_tx.send((id, stage, fresh, job.run(fresh, desc_tx))).unwrap(); - }); - // only the first message of each job is processed - match desc_rx.recv() { - Ok(msg) => running.push(msg), - Err(..) => {} - } - } + self.active += 1; + *self.counts.get_mut(key.pkg).unwrap() -= 1; - // If no work was scheduled, make sure that a message is actually send - // on this channel. - if njobs == 0 { - self.tx.send((id, stage, fresh, Ok(()))).unwrap(); - } + let my_tx = self.tx.clone(); + let (desc_tx, desc_rx) = channel(); + scope.spawn(move || { + my_tx.send(Message { + key: key, + result: job.run(fresh, desc_tx), + }).unwrap(); + }); // Print out some nice progress information - try!(self.note_working_on(config, pkg.package_id(), stage, total_fresh, - running.len())); - for msg in running.iter() { - try!(config.shell().verbose(|c| c.status("Running", msg))); + try!(self.note_working_on(config, key.pkg, fresh)); + + // only the first message of each job is processed + if let Ok(msg) = desc_rx.recv() { + try!(config.shell().verbose(|c| c.status("Running", &msg))); } Ok(()) } @@ -208,19 +200,19 @@ impl<'a> JobQueue<'a> { // run for a package, regardless of when that is. We then don't print // out any more information for a package after we've printed it once. fn note_working_on(&mut self, config: &Config, pkg: &'a PackageId, - stage: Stage, fresh: Freshness, cmds_run: usize) - -> CargoResult<()> { - if self.printed.contains(&pkg) { return Ok(()) } + fresh: Freshness) -> CargoResult<()> { + if self.printed.contains(&pkg) { + return Ok(()) + } match fresh { // Any dirty stage which runs at least one command gets printed as // being a compiled package - Dirty if cmds_run == 0 => {} Dirty => { self.printed.insert(pkg); try!(config.shell().status("Compiling", pkg)); } - Fresh if stage == Stage::End => { + Fresh if self.counts[pkg] == 0 => { self.printed.insert(pkg); try!(config.shell().verbose(|c| c.status("Fresh", pkg))); } @@ -230,88 +222,42 @@ impl<'a> JobQueue<'a> { } } -impl<'a> Dependency for (&'a PackageId, Stage) { - type Context = (&'a Resolve, &'a PackageSet); - - fn dependencies(&self, &(resolve, packages): &(&'a Resolve, &'a PackageSet)) - -> Vec<(&'a PackageId, Stage)> { - // This implementation of `Dependency` is the driver for the structure - // of the dependency graph of packages to be built. The "key" here is - // a pair of the package being built and the stage that it's at. - // - // Each stage here lists dependencies on the previous stages except for - // the start state which depends on the ending state of all dependent - // packages (as determined by the resolve context). - let (id, stage) = *self; - let pkg = packages.iter().find(|p| p.package_id() == id).unwrap(); - let deps = resolve.deps(id).into_iter().flat_map(|a| a) - .filter(|dep| *dep != id); - match stage { - Stage::Start => Vec::new(), - - // Building the build command itself starts off pretty easily,we - // just need to depend on all of the library stages of our own build - // dependencies (making them available to us). - Stage::BuildCustomBuild => { - let mut base = vec![(id, Stage::Start)]; - base.extend(deps.filter(|id| { - pkg.dependencies().iter().any(|d| { - d.name() == id.name() && d.is_build() - }) - }).map(|id| (id, Stage::Libraries))); - base - } - - // When running a custom build command, we need to be sure that our - // own custom build command is actually built, and then we need to - // wait for all our dependencies to finish their custom build - // commands themselves (as they may provide input to us). - Stage::RunCustomBuild => { - let mut base = vec![(id, Stage::BuildCustomBuild)]; - base.extend(deps.filter(|id| { - pkg.dependencies().iter().any(|d| { - d.name() == id.name() && d.is_transitive() - }) - }).map(|id| (id, Stage::RunCustomBuild))); - base - } - - // Building a library depends on our own custom build command plus - // all our transitive dependencies. - Stage::Libraries => { - let mut base = vec![(id, Stage::RunCustomBuild)]; - base.extend(deps.filter(|id| { - pkg.dependencies().iter().any(|d| { - d.name() == id.name() && d.is_transitive() - }) - }).map(|id| (id, Stage::Libraries))); - base - } - - // Binaries only depend on libraries being available. Note that they - // do not depend on dev-dependencies. - Stage::Binaries => vec![(id, Stage::Libraries)], +impl<'a> Dependency for Key<'a> { + type Context = Context<'a, 'a>; - // Tests depend on all dependencies (including dev-dependencies) in - // addition to the library stage for this package. Note, however, - // that library tests only need to depend the custom build command - // being run, not the libraries themselves. - Stage::BinaryTests | Stage::LibraryTests => { - let mut base = if stage == Stage::BinaryTests { - vec![(id, Stage::Libraries)] - } else { - vec![(id, Stage::RunCustomBuild)] - }; - base.extend(deps.map(|id| (id, Stage::Libraries))); - base + fn dependencies(&self, cx: &Context<'a, 'a>) -> Vec> { + let unit = Unit { + pkg: cx.get_package(self.pkg), + target: self.target, + profile: self.profile, + kind: self.kind, + }; + cx.dep_targets(&unit).iter().filter_map(|unit| { + // Binaries aren't actually needed to *compile* tests, just to run + // them, so we don't include this dependency edge in the job graph. + if self.target.is_test() && unit.target.is_bin() { + None + } else { + Some(Key::new(unit)) } + }).collect() + } +} - // A marker stage to indicate when a package has entirely finished - // compiling, nothing is actually built as part of this stage. - Stage::End => { - vec![(id, Stage::Binaries), (id, Stage::BinaryTests), - (id, Stage::LibraryTests)] - } +impl<'a> Key<'a> { + fn new(unit: &Unit<'a>) -> Key<'a> { + Key { + pkg: unit.pkg.package_id(), + target: unit.target, + profile: unit.profile, + kind: unit.kind, } } } + +impl<'a> fmt::Debug for Key<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} => {}/{} => {:?}", self.pkg, self.target, self.profile, + self.kind) + } +} diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 55ef3dcc0cf..5e5655bf8a5 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -1,4 +1,4 @@ -use std::collections::{HashSet, HashMap}; +use std::collections::HashMap; use std::env; use std::ffi::{OsStr, OsString}; use std::fs; @@ -9,17 +9,16 @@ use std::sync::Arc; use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve}; use core::{Profile, Profiles}; use util::{self, CargoResult, human}; -use util::{Config, internal, ChainError, Fresh, profile, join_paths}; +use util::{Config, internal, ChainError, profile, join_paths}; use self::job::{Job, Work}; -use self::job_queue::{JobQueue, Stage}; +use self::job_queue::JobQueue; pub use self::compilation::Compilation; -pub use self::context::Context; -pub use self::context::Platform; +pub use self::context::{Context, Unit}; pub use self::engine::{CommandPrototype, CommandType, ExecEngine, ProcessEngine}; pub use self::layout::{Layout, LayoutProxy}; -pub use self::custom_build::{BuildOutput, BuildMap}; +pub use self::custom_build::{BuildOutput, BuildMap, BuildScripts}; mod context; mod compilation; @@ -64,7 +63,21 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a PackagesToBuild<'a>, build_config: BuildConfig, profiles: &'a Profiles) -> CargoResult> { - + let units = pkg_targets.iter().flat_map(|&(pkg, ref targets)| { + let default_kind = if build_config.requested_target.is_some() { + Kind::Target + } else { + Kind::Host + }; + targets.iter().map(move |&(target, profile)| { + Unit { + pkg: pkg, + target: target, + profile: profile, + kind: if target.for_host() {Kind::Host} else {default_kind}, + } + }) + }).collect::>(); try!(links::validate(deps)); let dest = if build_config.release {"release"} else {"debug"}; @@ -78,79 +91,61 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a PackagesToBuild<'a>, host_layout, target_layout, build_config, profiles)); - let mut queue = JobQueue::new(cx.resolve, deps, cx.jobs()); + let mut queue = JobQueue::new(&cx); - { - let _p = profile::start("preparing build directories"); - // Prep the context's build requirements and see the job graph for all - // packages initially. - - - try!(cx.prepare(root, pkg_targets)); - let mut visited = HashSet::new(); - for &(pkg, _) in pkg_targets { - prepare_init(&mut cx, pkg, &mut queue, &mut visited); - } - custom_build::build_map(&mut cx, pkg_targets); - } + try!(cx.prepare(root)); + custom_build::build_map(&mut cx, &units); - for &(pkg, ref targets) in pkg_targets { + for unit in units.iter() { // Build up a list of pending jobs, each of which represent // compiling a particular package. No actual work is executed as // part of this, that's all done next as part of the `execute` // function which will run everything in order with proper // parallelism. - try!(compile(targets, pkg, &mut cx, &mut queue)); + try!(compile(&mut cx, &mut queue, unit)); } // Now that we've figured out everything that we're going to do, do it! try!(queue.execute(cx.config)); - for &(pkg, ref targets) in pkg_targets.iter() { - let out_dir = cx.layout(pkg, Kind::Target).build_out(pkg) + for unit in units.iter() { + let out_dir = cx.layout(unit.pkg, unit.kind).build_out(unit.pkg) .display().to_string(); - cx.compilation.extra_env.insert("OUT_DIR".to_string(), out_dir); - - let mut tests = vec![]; - - for &(target, profile) in targets { - let kind = Kind::from(target); - for filename in try!(cx.target_filenames(pkg, target, profile, - kind)).iter() { - let dst = cx.out_dir(pkg, kind, target).join(filename); - if profile.test { - tests.push((target.name().to_string(), dst)); - } else if target.is_bin() || target.is_example() { - cx.compilation.binaries.push(dst); - } else if target.is_lib() { - let pkgid = pkg.package_id().clone(); - cx.compilation.libraries.entry(pkgid).or_insert(Vec::new()) - .push((target.clone(), dst)); + cx.compilation.extra_env.entry(unit.pkg.package_id().clone()) + .or_insert(Vec::new()) + .push(("OUT_DIR".to_string(), out_dir)); + + for filename in try!(cx.target_filenames(unit)).iter() { + let dst = cx.out_dir(unit).join(filename); + if unit.profile.test { + cx.compilation.tests.push((unit.pkg.clone(), + unit.target.name().to_string(), + dst)); + } else if unit.target.is_bin() || unit.target.is_example() { + cx.compilation.binaries.push(dst); + } else if unit.target.is_lib() { + let pkgid = unit.pkg.package_id().clone(); + cx.compilation.libraries.entry(pkgid).or_insert(Vec::new()) + .push((unit.target.clone(), dst)); + } + if !unit.target.is_lib() { continue } + + // Include immediate lib deps as well + for unit in cx.dep_targets(unit).iter() { + let pkgid = unit.pkg.package_id(); + if !unit.target.is_lib() { continue } + if unit.profile.doc { continue } + if cx.compilation.libraries.contains_key(&pkgid) { + continue } - if !target.is_lib() { continue } - - // Include immediate lib deps as well - for dep in &cx.dep_targets(pkg, target, kind, profile) { - let (pkg, target, profile) = *dep; - let pkgid = pkg.package_id(); - if !target.is_lib() { continue } - if profile.doc { continue } - if cx.compilation.libraries.contains_key(&pkgid) { - continue - } - let kind = kind.for_target(target); - let v = try!(cx.target_filenames(pkg, target, profile, kind)); - let v = v.into_iter().map(|f| { - (target.clone(), cx.out_dir(pkg, kind, target).join(f)) - }).collect::>(); - cx.compilation.libraries.insert(pkgid.clone(), v); - } + let v = try!(cx.target_filenames(unit)); + let v = v.into_iter().map(|f| { + (unit.target.clone(), cx.out_dir(unit).join(f)) + }).collect::>(); + cx.compilation.libraries.insert(pkgid.clone(), v); } } - - cx.compilation.tests.push((pkg.clone(), tests)); - } if let Some(feats) = cx.resolve.features(root.package_id()) { @@ -169,276 +164,152 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a PackagesToBuild<'a>, Ok(cx.compilation) } -fn compile<'a, 'cfg>(targets: &[(&'a Target, &'a Profile)], - pkg: &'a Package, - cx: &mut Context<'a, 'cfg>, - jobs: &mut JobQueue<'a>) -> CargoResult<()> { - debug!("compile_pkg; pkg={}", pkg); - - // For each target/profile run the compiler or rustdoc accordingly. After - // having done so we enqueue the job in the right portion of the dependency - // graph and then move on to the next. - // - // This loop also takes care of enqueueing the work needed to actually run - // the custom build commands as well. - for &(target, profile) in targets { - if !cx.compiled.insert((pkg.package_id(), target, profile)) { - continue - } +fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, + jobs: &mut JobQueue<'a>, + unit: &Unit<'a>) -> CargoResult<()> { + if !cx.compiled.insert(*unit) { + return Ok(()) + } - let profiling_marker = profile::start(format!("preparing: {}/{}", - pkg, target.name())); - let work = if profile.doc { - let rustdoc = try!(rustdoc(pkg, target, profile, cx)); - vec![(rustdoc, Kind::Target)] + // Build up the work to be done to compile this unit, enqueuing it once + // we've got everything constructed. + let p = profile::start(format!("preparing: {}/{}", unit.pkg, + unit.target.name())); + try!(fingerprint::prepare_init(cx, unit)); + + let (dirty, fresh, freshness) = if unit.profile.run_custom_build { + try!(custom_build::prepare(cx, unit)) + } else { + let (freshness, dirty, fresh) = try!(fingerprint::prepare_target(cx, + unit)); + let work = if unit.profile.doc { + try!(rustdoc(cx, unit)) } else { - let req = cx.get_requirement(pkg, target); - try!(rustc(pkg, target, profile, cx, req)) + try!(rustc(cx, unit)) }; + let dirty = work.then(dirty); + (dirty, fresh, freshness) + }; + jobs.enqueue(cx, unit, Job::new(dirty, fresh), freshness); + drop(p); - let kinds = work.iter().map(|&(_, kind)| kind).collect::>(); - - for (work, kind) in work { - let (freshness, dirty, fresh) = - try!(fingerprint::prepare_target(cx, pkg, target, profile, kind)); - - let dirty = Work::new(move |desc_tx| { - try!(work.call(desc_tx.clone())); - dirty.call(desc_tx) - }); - - // Figure out what stage this work will go into - let dst = match (target.is_lib(), - profile.test, - target.is_custom_build()) { - (_, _, true) => jobs.queue(pkg, Stage::BuildCustomBuild), - (true, true, _) => jobs.queue(pkg, Stage::LibraryTests), - (false, true, _) => jobs.queue(pkg, Stage::BinaryTests), - (true, false, _) => jobs.queue(pkg, Stage::Libraries), - (false, false, _) if !target.is_bin() => { - jobs.queue(pkg, Stage::BinaryTests) - } - (false, false, _) => jobs.queue(pkg, Stage::Binaries), - }; - dst.push((Job::new(dirty, fresh), freshness)); - - } - drop(profiling_marker); - - // Be sure to compile all dependencies of this target as well. - for kind in kinds { - for (pkg, target, p) in cx.dep_targets(pkg, target, kind, profile) { - try!(compile(&[(target, p)], pkg, cx, jobs)); - } - } - - // If this is a custom build command, we need to not only build the - // script but we also need to run it. Note that this is a little nuanced - // because we may need to run the build script multiple times. If the - // package is needed in both a host and target context, we need to run - // it once per context. - if !target.is_custom_build() { continue } - let mut reqs = Vec::new(); - let requirement = pkg.targets().iter().filter(|t| !t.is_custom_build()) - .fold(None::, |req, t| { - let r2 = cx.get_requirement(pkg, t); - req.map(|r| r.combine(r2)).or(Some(r2)) - }).unwrap_or(Platform::Target); - match requirement { - Platform::Target => reqs.push(Platform::Target), - Platform::Plugin => reqs.push(Platform::Plugin), - Platform::PluginAndTarget => { - if cx.requested_target().is_some() { - reqs.push(Platform::Plugin); - reqs.push(Platform::Target); - } else { - reqs.push(Platform::PluginAndTarget); - } - } - } - let before = jobs.queue(pkg, Stage::RunCustomBuild).len(); - for &req in reqs.iter() { - let kind = match req { - Platform::Plugin => Kind::Host, - _ => Kind::Target, - }; - let key = (pkg.package_id().clone(), kind); - if pkg.manifest().links().is_some() && - cx.build_state.outputs.lock().unwrap().contains_key(&key) { - continue - } - let (dirty, fresh, freshness) = - try!(custom_build::prepare(pkg, target, req, cx)); - let run_custom = jobs.queue(pkg, Stage::RunCustomBuild); - run_custom.push((Job::new(dirty, fresh), freshness)); - } - - // If we didn't actually run the custom build command, then there's no - // need to compile it. - if jobs.queue(pkg, Stage::RunCustomBuild).len() == before { - jobs.queue(pkg, Stage::BuildCustomBuild).pop(); - } + // Be sure to compile all dependencies of this target as well. + for unit in cx.dep_targets(unit).iter() { + try!(compile(cx, jobs, unit)); } - Ok(()) } -fn prepare_init<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, - pkg: &'a Package, - jobs: &mut JobQueue<'a>, - visited: &mut HashSet<&'a PackageId>) { - if !visited.insert(pkg.package_id()) { return } - - // Set up all dependencies - for dep in cx.resolve.deps(pkg.package_id()).into_iter().flat_map(|a| a) { - let dep = cx.get_package(dep); - prepare_init(cx, dep, jobs, visited); +fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { + let crate_types = unit.target.rustc_crate_types(); + let mut rustc = try!(prepare_rustc(cx, crate_types, unit)); + + let name = unit.pkg.name().to_string(); + let is_path_source = unit.pkg.package_id().source_id().is_path(); + let allow_warnings = unit.pkg.package_id() == cx.resolve.root() || + is_path_source; + if !allow_warnings { + if cx.config.rustc_info().cap_lints { + rustc.arg("--cap-lints").arg("allow"); + } else { + rustc.arg("-Awarnings"); + } } + let has_custom_args = unit.profile.rustc_args.is_some(); + let exec_engine = cx.exec_engine.clone(); - // Initialize blank queues for each stage - jobs.queue(pkg, Stage::BuildCustomBuild); - jobs.queue(pkg, Stage::RunCustomBuild); - jobs.queue(pkg, Stage::Libraries); - jobs.queue(pkg, Stage::Binaries); - jobs.queue(pkg, Stage::LibraryTests); - jobs.queue(pkg, Stage::BinaryTests); - jobs.queue(pkg, Stage::End); - - // Prepare the fingerprint directory as the first step of building a package - let (target1, target2) = fingerprint::prepare_init(cx, pkg, Kind::Target); - let init = jobs.queue(pkg, Stage::Start); - if cx.requested_target().is_some() { - let (plugin1, plugin2) = fingerprint::prepare_init(cx, pkg, - Kind::Host); - init.push((Job::new(plugin1, plugin2), Fresh)); - } - init.push((Job::new(target1, target2), Fresh)); -} + let filenames = try!(cx.target_filenames(unit)); + let root = cx.out_dir(unit); -fn rustc(package: &Package, target: &Target, profile: &Profile, - cx: &mut Context, req: Platform) - -> CargoResult >{ - let crate_types = target.rustc_crate_types(); - let rustcs = try!(prepare_rustc(package, target, profile, crate_types, - cx, req)); - - let plugin_deps = load_build_deps(cx, package, target, profile, Kind::Host); - - return rustcs.into_iter().map(|(mut rustc, kind)| { - let name = package.name().to_string(); - let is_path_source = package.package_id().source_id().is_path(); - let allow_warnings = package.package_id() == cx.resolve.root() || - is_path_source; - if !allow_warnings { - if cx.config.rustc_info().cap_lints { - rustc.arg("--cap-lints").arg("allow"); - } else { - rustc.arg("-Awarnings"); - } - } - let has_custom_args = profile.rustc_args.is_some(); - let exec_engine = cx.exec_engine.clone(); - - let filenames = try!(cx.target_filenames(package, target, profile, - kind)); - let root = cx.out_dir(package, kind, target); - - // Prepare the native lib state (extra -L and -l flags) - let build_state = cx.build_state.clone(); - let current_id = package.package_id().clone(); - let plugin_deps = plugin_deps.clone(); - let mut native_lib_deps = load_build_deps(cx, package, target, profile, - kind); - if package.has_custom_build() && !target.is_custom_build() { - native_lib_deps.insert(0, current_id.clone()); - } + // Prepare the native lib state (extra -L and -l flags) + let build_state = cx.build_state.clone(); + let current_id = unit.pkg.package_id().clone(); + let build_deps = load_build_deps(cx, unit); - // If we are a binary and the package also contains a library, then we - // don't pass the `-l` flags. - let pass_l_flag = target.is_lib() || !package.targets().iter().any(|t| { - t.is_lib() - }); - let do_rename = target.allows_underscores() && !profile.test; - let real_name = target.name().to_string(); - let crate_name = target.crate_name(); + // If we are a binary and the package also contains a library, then we + // don't pass the `-l` flags. + let pass_l_flag = unit.target.is_lib() || + !unit.pkg.targets().iter().any(|t| t.is_lib()); + let do_rename = unit.target.allows_underscores() && !unit.profile.test; + let real_name = unit.target.name().to_string(); + let crate_name = unit.target.crate_name(); - let rustc_dep_info_loc = if do_rename { - root.join(&crate_name) - } else { - root.join(&cx.file_stem(package, target, profile)) - }.with_extension("d"); - let dep_info_loc = fingerprint::dep_info_loc(cx, package, target, - profile, kind); - let cwd = cx.config.cwd().to_path_buf(); - - Ok((Work::new(move |desc_tx| { - debug!("about to run: {}", rustc); - - // Only at runtime have we discovered what the extra -L and -l - // arguments are for native libraries, so we process those here. We - // also need to be sure to add any -L paths for our plugins to the - // dynamic library load path as a plugin's dynamic library may be - // located somewhere in there. + let rustc_dep_info_loc = if do_rename { + root.join(&crate_name) + } else { + root.join(&cx.file_stem(unit)) + }.with_extension("d"); + let dep_info_loc = fingerprint::dep_info_loc(cx, unit); + let cwd = cx.config.cwd().to_path_buf(); + + return Ok(Work::new(move |desc_tx| { + debug!("about to run: {}", rustc); + + // Only at runtime have we discovered what the extra -L and -l + // arguments are for native libraries, so we process those here. We + // also need to be sure to add any -L paths for our plugins to the + // dynamic library load path as a plugin's dynamic library may be + // located somewhere in there. + if let Some(build_deps) = build_deps { let build_state = build_state.outputs.lock().unwrap(); - add_native_deps(&mut rustc, &build_state, native_lib_deps, - kind, pass_l_flag, ¤t_id); - try!(add_plugin_deps(&mut rustc, &build_state, plugin_deps)); - drop(build_state); - - // FIXME(rust-lang/rust#18913): we probably shouldn't have to do - // this manually - for filename in filenames.iter() { - let dst = root.join(filename); - if fs::metadata(&dst).is_ok() { - try!(fs::remove_file(&dst)); - } - } - - desc_tx.send(rustc.to_string()).ok(); - try!(exec_engine.exec(rustc).chain_error(|| { - human(format!("Could not compile `{}`.", name)) - })); + try!(add_native_deps(&mut rustc, &build_state, &build_deps, + pass_l_flag, ¤t_id)); + try!(add_plugin_deps(&mut rustc, &build_state, &build_deps)); + } - if do_rename && real_name != crate_name { - let dst = root.join(&filenames[0]); - let src = dst.with_file_name(dst.file_name().unwrap() - .to_str().unwrap() - .replace(&real_name, &crate_name)); - if !has_custom_args || fs::metadata(&src).is_ok() { - try!(fs::rename(&src, &dst).chain_error(|| { - internal(format!("could not rename crate {:?}", src)) - })); - } + // FIXME(rust-lang/rust#18913): we probably shouldn't have to do + // this manually + for filename in filenames.iter() { + let dst = root.join(filename); + if fs::metadata(&dst).is_ok() { + try!(fs::remove_file(&dst)); } + } - if !has_custom_args || fs::metadata(&rustc_dep_info_loc).is_ok() { - try!(fs::rename(&rustc_dep_info_loc, &dep_info_loc).chain_error(|| { - internal(format!("could not rename dep info: {:?}", - rustc_dep_info_loc)) + desc_tx.send(rustc.to_string()).ok(); + try!(exec_engine.exec(rustc).chain_error(|| { + human(format!("Could not compile `{}`.", name)) + })); + + if do_rename && real_name != crate_name { + let dst = root.join(&filenames[0]); + let src = dst.with_file_name(dst.file_name().unwrap() + .to_str().unwrap() + .replace(&real_name, &crate_name)); + if !has_custom_args || fs::metadata(&src).is_ok() { + try!(fs::rename(&src, &dst).chain_error(|| { + internal(format!("could not rename crate {:?}", src)) })); - try!(fingerprint::append_current_dir(&dep_info_loc, &cwd)); } + } - Ok(()) + if !has_custom_args || fs::metadata(&rustc_dep_info_loc).is_ok() { + try!(fs::rename(&rustc_dep_info_loc, &dep_info_loc).chain_error(|| { + internal(format!("could not rename dep info: {:?}", + rustc_dep_info_loc)) + })); + try!(fingerprint::append_current_dir(&dep_info_loc, &cwd)); + } - }), kind)) - }).collect(); + Ok(()) + })); // Add all relevant -L and -l flags from dependencies (now calculated and // present in `state`) to the command provided fn add_native_deps(rustc: &mut CommandPrototype, build_state: &BuildMap, - native_lib_deps: Vec, - kind: Kind, + build_scripts: &BuildScripts, pass_l_flag: bool, - current_id: &PackageId) { - for id in native_lib_deps.into_iter() { - debug!("looking up {} {:?}", id, kind); - let output = &build_state[&(id.clone(), kind)]; + current_id: &PackageId) -> CargoResult<()> { + for key in build_scripts.to_link.iter() { + let output = try!(build_state.get(key).chain_error(|| { + internal(format!("couldn't find build state for {}/{:?}", + key.0, key.1)) + })); for path in output.library_paths.iter() { rustc.arg("-L").arg(path); } - if id == *current_id { + if key.0 == *current_id { for cfg in &output.cfgs { rustc.arg("--cfg").arg(cfg); } @@ -449,15 +320,12 @@ fn rustc(package: &Package, target: &Target, profile: &Profile, } } } + Ok(()) } } -fn load_build_deps(cx: &Context, pkg: &Package, target: &Target, - profile: &Profile, kind: Kind) -> Vec { - let pkg = cx.get_package(pkg.package_id()); - cx.build_scripts.get(&(pkg.package_id(), target, profile, kind)).map(|deps| { - deps.iter().map(|&d| d.clone()).collect::>() - }).unwrap_or(Vec::new()) +fn load_build_deps(cx: &Context, unit: &Unit) -> Option> { + cx.build_scripts.get(unit).cloned() } // For all plugin dependencies, add their -L paths (now calculated and @@ -465,14 +333,16 @@ fn load_build_deps(cx: &Context, pkg: &Package, target: &Target, // execute. fn add_plugin_deps(rustc: &mut CommandPrototype, build_state: &BuildMap, - plugin_deps: Vec) + build_scripts: &BuildScripts) -> CargoResult<()> { let var = util::dylib_path_envvar(); let search_path = rustc.get_env(var).unwrap_or(OsString::new()); let mut search_path = env::split_paths(&search_path).collect::>(); - for id in plugin_deps.into_iter() { - debug!("adding libs for plugin dep: {}", id); - let output = &build_state[&(id, Kind::Host)]; + for id in build_scripts.plugins.iter() { + let key = (id.clone(), Kind::Host); + let output = try!(build_state.get(&key).chain_error(|| { + internal(format!("couldn't find libs for plugin dep {}", id)) + })); for path in output.library_paths.iter() { search_path.push(path.clone()); } @@ -482,39 +352,22 @@ fn add_plugin_deps(rustc: &mut CommandPrototype, Ok(()) } -fn prepare_rustc(package: &Package, target: &Target, profile: &Profile, +fn prepare_rustc(cx: &Context, crate_types: Vec<&str>, - cx: &Context, req: Platform) - -> CargoResult> { - let mut base = try!(process(CommandType::Rustc, package, target, cx)); - build_base_args(cx, &mut base, package, target, profile, &crate_types); - - let mut targ_cmd = base.clone(); - let mut host_cmd = base; - build_plugin_args(&mut targ_cmd, cx, package, target, Kind::Target); - build_plugin_args(&mut host_cmd, cx, package, target, Kind::Host); - try!(build_deps_args(&mut targ_cmd, target, profile, package, cx, Kind::Target)); - try!(build_deps_args(&mut host_cmd, target, profile, package, cx, Kind::Host)); - - Ok(match req { - Platform::Target => vec![(targ_cmd, Kind::Target)], - Platform::Plugin => vec![(host_cmd, Kind::Host)], - Platform::PluginAndTarget if cx.requested_target().is_none() => { - vec![(targ_cmd, Kind::Target)] - } - Platform::PluginAndTarget => vec![(targ_cmd, Kind::Target), - (host_cmd, Kind::Host)], - }) + unit: &Unit) -> CargoResult { + let mut base = try!(process(CommandType::Rustc, unit.pkg, cx)); + build_base_args(cx, &mut base, unit, &crate_types); + build_plugin_args(&mut base, cx, unit); + try!(build_deps_args(&mut base, cx, unit)); + Ok(base) } -fn rustdoc(package: &Package, target: &Target, profile: &Profile, - cx: &mut Context) -> CargoResult { - let kind = Kind::Target; - let mut rustdoc = try!(process(CommandType::Rustdoc, package, target, cx)); - rustdoc.arg(&root_path(cx, package, target)) +fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { + let mut rustdoc = try!(process(CommandType::Rustdoc, unit.pkg, cx)); + rustdoc.arg(&root_path(cx, unit)) .cwd(cx.config.cwd()) - .arg("--crate-name").arg(&target.crate_name()); + .arg("--crate-name").arg(&unit.target.crate_name()); let mut doc_dir = cx.config.target_dir(cx.get_package(cx.resolve.root())); if let Some(target) = cx.requested_target() { @@ -525,24 +378,20 @@ fn rustdoc(package: &Package, target: &Target, profile: &Profile, doc_dir.push("doc"); rustdoc.arg("-o").arg(doc_dir); - match cx.resolve.features(package.package_id()) { - Some(features) => { - for feat in features { - rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); - } + if let Some(features) = cx.resolve.features(unit.pkg.package_id()) { + for feat in features { + rustdoc.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); } - None => {} } - try!(build_deps_args(&mut rustdoc, target, profile, package, cx, kind)); + try!(build_deps_args(&mut rustdoc, cx, unit)); - if package.has_custom_build() { - rustdoc.env("OUT_DIR", &cx.layout(package, kind).build_out(package)); + if unit.pkg.has_custom_build() { + rustdoc.env("OUT_DIR", &cx.layout(unit.pkg, unit.kind) + .build_out(unit.pkg)); } - trace!("commands={}", rustdoc); - - let name = package.name().to_string(); + let name = unit.pkg.name().to_string(); let desc = rustdoc.to_string(); let exec_engine = cx.exec_engine.clone(); @@ -563,8 +412,8 @@ fn rustdoc(package: &Package, target: &Target, profile: &Profile, // path is only actually relative if the current directory is an ancestor if it. // This means that non-path dependencies (git/registry) will likely be shown as // absolute paths instead of relative paths. -fn root_path(cx: &Context, pkg: &Package, target: &Target) -> PathBuf { - let absolute = pkg.root().join(target.src_path()); +fn root_path(cx: &Context, unit: &Unit) -> PathBuf { + let absolute = unit.pkg.root().join(unit.target.src_path()); let cwd = cx.config.cwd(); if absolute.starts_with(cwd) { util::without_prefix(&absolute, cwd).map(|s| { @@ -577,30 +426,29 @@ fn root_path(cx: &Context, pkg: &Package, target: &Target) -> PathBuf { fn build_base_args(cx: &Context, cmd: &mut CommandPrototype, - pkg: &Package, - target: &Target, - profile: &Profile, + unit: &Unit, crate_types: &[&str]) { let Profile { - opt_level, lto, codegen_units, ref rustc_args, debuginfo, debug_assertions, - rpath, test, doc: _doc, - } = *profile; + opt_level, lto, codegen_units, ref rustc_args, debuginfo, + debug_assertions, rpath, test, doc: _doc, run_custom_build, + } = *unit.profile; + assert!(!run_custom_build); // Move to cwd so the root_path() passed below is actually correct cmd.cwd(cx.config.cwd()); - // TODO: Handle errors in converting paths into args - cmd.arg(&root_path(cx, pkg, target)); + cmd.arg(&root_path(cx, unit)); - cmd.arg("--crate-name").arg(&target.crate_name()); + cmd.arg("--crate-name").arg(&unit.target.crate_name()); for crate_type in crate_types.iter() { cmd.arg("--crate-type").arg(crate_type); } - let prefer_dynamic = (target.for_host() && !target.is_custom_build()) || + let prefer_dynamic = (unit.target.for_host() && + !unit.target.is_custom_build()) || (crate_types.contains(&"dylib") && - pkg.package_id() != cx.resolve.root()); + unit.pkg.package_id() != cx.resolve.root()); if prefer_dynamic { cmd.arg("-C").arg("prefer-dynamic"); } @@ -611,14 +459,13 @@ fn build_base_args(cx: &Context, // Disable LTO for host builds as prefer_dynamic and it are mutually // exclusive. - if target.can_lto() && lto && !target.for_host() { + if unit.target.can_lto() && lto && !unit.target.for_host() { cmd.args(&["-C", "lto"]); } else { // There are some restrictions with LTO and codegen-units, so we // only add codegen units when LTO is not used. - match codegen_units { - Some(n) => { cmd.arg("-C").arg(&format!("codegen-units={}", n)); } - None => {}, + if let Some(n) = codegen_units { + cmd.arg("-C").arg(&format!("codegen-units={}", n)); } } @@ -636,25 +483,19 @@ fn build_base_args(cx: &Context, cmd.args(&["-C", "debug-assertions=off"]); } - if test && target.harness() { + if test && unit.target.harness() { cmd.arg("--test"); } - match cx.resolve.features(pkg.package_id()) { - Some(features) => { - for feat in features.iter() { - cmd.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); - } + if let Some(features) = cx.resolve.features(unit.pkg.package_id()) { + for feat in features.iter() { + cmd.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); } - None => {} } - match cx.target_metadata(pkg, target, profile) { - Some(m) => { - cmd.arg("-C").arg(&format!("metadata={}", m.metadata)); - cmd.arg("-C").arg(&format!("extra-filename={}", m.extra_filename)); - } - None => {} + if let Some(m) = cx.target_metadata(unit) { + cmd.arg("-C").arg(&format!("metadata={}", m.metadata)); + cmd.arg("-C").arg(&format!("extra-filename={}", m.extra_filename)); } if rpath { @@ -663,8 +504,7 @@ fn build_base_args(cx: &Context, } -fn build_plugin_args(cmd: &mut CommandPrototype, cx: &Context, pkg: &Package, - target: &Target, kind: Kind) { +fn build_plugin_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) { fn opt(cmd: &mut CommandPrototype, key: &str, prefix: &str, val: Option<&OsStr>) { if let Some(val) = val { @@ -674,25 +514,20 @@ fn build_plugin_args(cmd: &mut CommandPrototype, cx: &Context, pkg: &Package, } } - cmd.arg("--out-dir").arg(&cx.out_dir(pkg, kind, target)); + cmd.arg("--out-dir").arg(&cx.out_dir(unit)); cmd.arg("--emit=dep-info,link"); - if kind == Kind::Target { + if unit.kind == Kind::Target { opt(cmd, "--target", "", cx.requested_target().map(|s| s.as_ref())); } - opt(cmd, "-C", "ar=", cx.ar(kind).map(|s| s.as_ref())); - opt(cmd, "-C", "linker=", cx.linker(kind).map(|s| s.as_ref())); + opt(cmd, "-C", "ar=", cx.ar(unit.kind).map(|s| s.as_ref())); + opt(cmd, "-C", "linker=", cx.linker(unit.kind).map(|s| s.as_ref())); } -fn build_deps_args(cmd: &mut CommandPrototype, - target: &Target, - profile: &Profile, - package: &Package, - cx: &Context, - kind: Kind) +fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) -> CargoResult<()> { - let layout = cx.layout(package, kind); + let layout = cx.layout(unit.pkg, unit.kind); cmd.arg("-L").arg(&{ let mut root = OsString::from("dependency="); root.push(layout.root()); @@ -704,27 +539,26 @@ fn build_deps_args(cmd: &mut CommandPrototype, deps }); - if package.has_custom_build() { - cmd.env("OUT_DIR", &layout.build_out(package)); + if unit.pkg.has_custom_build() { + cmd.env("OUT_DIR", &layout.build_out(unit.pkg)); } - for (pkg, target, p) in cx.dep_targets(package, target, kind, profile) { - if target.linkable() { - try!(link_to(cmd, pkg, target, p, cx, kind)); + for unit in cx.dep_targets(unit).iter() { + if unit.target.linkable() { + try!(link_to(cmd, cx, unit)); } } return Ok(()); - fn link_to(cmd: &mut CommandPrototype, pkg: &Package, target: &Target, - profile: &Profile, cx: &Context, kind: Kind) -> CargoResult<()> { - let kind = kind.for_target(target); - let layout = cx.layout(pkg, kind); + fn link_to(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) + -> CargoResult<()> { + let layout = cx.layout(unit.pkg, unit.kind); - for filename in try!(cx.target_filenames(pkg, target, profile, kind)).iter() { + for filename in try!(cx.target_filenames(unit)) { if filename.ends_with(".a") { continue } let mut v = OsString::new(); - v.push(&target.crate_name()); + v.push(&unit.target.crate_name()); v.push("="); v.push(layout.root()); v.push(&path::MAIN_SEPARATOR.to_string()); @@ -735,7 +569,7 @@ fn build_deps_args(cmd: &mut CommandPrototype, } } -pub fn process(cmd: CommandType, pkg: &Package, _target: &Target, +pub fn process(cmd: CommandType, pkg: &Package, cx: &Context) -> CargoResult { // When invoking a tool, we need the *host* deps directory in the dynamic // library search path for plugins and such which have dynamic dependencies. @@ -759,10 +593,6 @@ fn envify(s: &str) -> String { } impl Kind { - fn from(target: &Target) -> Kind { - if target.for_host() {Kind::Host} else {Kind::Target} - } - fn for_target(&self, target: &Target) -> Kind { // Once we start compiling for the `Host` kind we continue doing so, but // if we are a `Target` kind and then we start compiling for a target diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index a34556dd890..ff2b6b41739 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -61,11 +61,11 @@ pub fn run_benches(manifest_path: &Path, fn compile_tests<'a>(manifest_path: &Path, options: &TestOptions<'a>) -> CargoResult> { - let mut compilation = try!(ops::compile(manifest_path, &options.compile_opts)); - for tests in compilation.tests.iter_mut() { - tests.1.sort(); - } - + let mut compilation = try!(ops::compile(manifest_path, + &options.compile_opts)); + compilation.tests.sort_by(|a, b| { + (a.0.package_id(), &a.1).cmp(&(b.0.package_id(), &b.1)) + }); Ok(compilation) } @@ -79,26 +79,24 @@ fn run_unit_tests(options: &TestOptions, let mut errors = Vec::new(); - for &(ref pkg, ref tests) in &compilation.tests { - for &(_, ref exe) in tests { - let to_display = match util::without_prefix(exe, &cwd) { - Some(path) => path, - None => &**exe, - }; - let mut cmd = try!(compilation.target_process(exe, pkg)); - cmd.args(test_args); - try!(config.shell().concise(|shell| { - shell.status("Running", to_display.display().to_string()) - })); - try!(config.shell().verbose(|shell| { - shell.status("Running", cmd.to_string()) - })); - - if let Err(e) = ExecEngine::exec(&mut ProcessEngine, cmd) { - errors.push(e); - if !options.no_fail_fast { - break - } + for &(ref pkg, _, ref exe) in &compilation.tests { + let to_display = match util::without_prefix(exe, &cwd) { + Some(path) => path, + None => &**exe, + }; + let mut cmd = try!(compilation.target_process(exe, pkg)); + cmd.args(test_args); + try!(config.shell().concise(|shell| { + shell.status("Running", to_display.display().to_string()) + })); + try!(config.shell().verbose(|shell| { + shell.status("Running", cmd.to_string()) + })); + + if let Err(e) = ExecEngine::exec(&mut ProcessEngine, cmd) { + errors.push(e); + if !options.no_fail_fast { + break } } } @@ -123,8 +121,7 @@ fn run_doc_tests(options: &TestOptions, try!(config.shell().status("Doc-tests", name)); let mut p = try!(compilation.rustdoc_process(package)); p.arg("--test").arg(lib) - .arg("--crate-name").arg(&crate_name) - .cwd(package.root()); + .arg("--crate-name").arg(&crate_name); for &rust_dep in &[&compilation.deps_output, &compilation.root_output] { let mut arg = OsString::from("dependency="); diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index e5736071eb7..f408b093aa9 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -2,9 +2,8 @@ pub use self::cargo_clean::{clean, CleanOptions}; pub use self::cargo_compile::{compile, compile_pkg, CompileOptions}; pub use self::cargo_compile::{CompileFilter, CompileMode}; pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages}; -pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind}; +pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind, Unit}; pub use self::cargo_rustc::{Context, LayoutProxy}; -pub use self::cargo_rustc::Platform; pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig}; pub use self::cargo_rustc::{CommandType, CommandPrototype, ExecEngine, ProcessEngine}; pub use self::cargo_run::run; diff --git a/src/cargo/util/dependency_queue.rs b/src/cargo/util/dependency_queue.rs index f66e503d37d..499521bb3ae 100644 --- a/src/cargo/util/dependency_queue.rs +++ b/src/cargo/util/dependency_queue.rs @@ -10,7 +10,8 @@ use std::hash::Hash; pub use self::Freshness::{Fresh, Dirty}; -pub struct DependencyQueue { +#[derive(Debug)] +pub struct DependencyQueue { /// A list of all known keys to build. /// /// The value of the hash map is list of dependencies which still need to be diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 7e0115e0418..430bdde9a9d 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -926,6 +926,7 @@ fn build_profiles(profiles: &Option) -> Profiles { profiles.and_then(|p| p.bench.as_ref())), doc: merge(Profile::default_doc(), profiles.and_then(|p| p.doc.as_ref())), + custom_build: Profile::default_custom_build(), }; fn merge(profile: Profile, toml: Option<&TomlProfile>) -> Profile { @@ -945,6 +946,7 @@ fn build_profiles(profiles: &Option) -> Profiles { rpath: rpath.unwrap_or(profile.rpath), test: profile.test, doc: profile.doc, + run_custom_build: profile.run_custom_build, } } } diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index cb352e16b88..7f35237b93a 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -1,5 +1,4 @@ -use std::env; -use std::fs::{self, File}; +use std::fs::File; use std::io::prelude::*; use support::{project, execs}; @@ -267,8 +266,10 @@ test!(overrides_and_links { .file("build.rs", r#" use std::env; fn main() { - assert_eq!(env::var("DEP_FOO_FOO").unwrap(), "bar"); - assert_eq!(env::var("DEP_FOO_BAR").unwrap(), "baz"); + assert_eq!(env::var("DEP_FOO_FOO").ok().expect("FOO missing"), + "bar"); + assert_eq!(env::var("DEP_FOO_BAR").ok().expect("BAR missing"), + "baz"); } "#) .file(".cargo/config", &format!(r#" @@ -419,6 +420,7 @@ test!(rebuild_continues_to_pass_env_vars { fn main() { println!("cargo:foo=bar"); println!("cargo:bar=baz"); + std::thread::sleep_ms(500); } "#); a.build(); @@ -565,12 +567,7 @@ test!(propagation_of_l_flags { assert_that(p.cargo_process("build").arg("-v").arg("-j1"), execs().with_status(0) - .with_stdout(&format!("\ -[..] -[..] -[..] -[..] -{running} `[..]a-[..]build-script-build[..]` + .with_stdout_contains(&format!("\ {running} `rustc [..] --crate-name a [..]-L bar[..]-L foo[..]` {compiling} foo v0.5.0 (file://[..]) {running} `rustc [..] --crate-name foo [..] -L bar -L foo` @@ -623,12 +620,7 @@ test!(propagation_of_l_flags_new { assert_that(p.cargo_process("build").arg("-v").arg("-j1"), execs().with_status(0) - .with_stdout(&format!("\ -[..] -[..] -[..] -[..] -{running} `[..]a-[..]build-script-build[..]` + .with_stdout_contains(&format!("\ {running} `rustc [..] --crate-name a [..]-L bar[..]-L foo[..]` {compiling} foo v0.5.0 (file://[..]) {running} `rustc [..] --crate-name foo [..] -L bar -L foo` @@ -991,7 +983,7 @@ test!(shared_dep_with_a_build_script { path = "../b" "#) .file("b/src/lib.rs", ""); - assert_that(p.cargo_process("build"), + assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0)); }); @@ -1117,15 +1109,6 @@ test!(build_script_with_dynamic_native_dependency { "#); assert_that(build.cargo_process("build"), execs().with_status(0)); - let src = build.root().join("target/debug"); - let lib = fs::read_dir(&src).unwrap().map(|s| s.unwrap().path()).find(|lib| { - let lib = lib.file_name().unwrap().to_str().unwrap(); - lib.starts_with(env::consts::DLL_PREFIX) && - lib.ends_with(env::consts::DLL_SUFFIX) - }).unwrap(); - let libname = lib.file_name().unwrap().to_str().unwrap(); - let libname = &libname[env::consts::DLL_PREFIX.len().. - libname.len() - env::consts::DLL_SUFFIX.len()]; let foo = project("foo") .file("Cargo.toml", r#" @@ -1156,19 +1139,19 @@ test!(build_script_with_dynamic_native_dependency { fn main() { let src = PathBuf::from(env::var("SRC").unwrap()); - println!("cargo:rustc-flags=-L {}", src.parent().unwrap() - .display()); + println!("cargo:rustc-link-search={}/target/debug", + src.display()); } "#) - .file("bar/src/lib.rs", &format!(r#" - pub fn bar() {{ - #[link(name = "{}")] - extern {{ fn foo(); }} - unsafe {{ foo() }} - }} - "#, libname)); + .file("bar/src/lib.rs", r#" + pub fn bar() { + #[link(name = "builder")] + extern { fn foo(); } + unsafe { foo() } + } + "#); - assert_that(foo.cargo_process("build").env("SRC", &lib), + assert_that(foo.cargo_process("build").env("SRC", build.root()), execs().with_status(0)); }); @@ -1268,7 +1251,7 @@ test!(cfg_feedback { println!("cargo:rustc-cfg=foo"); } "#); - assert_that(build.cargo_process("build"), + assert_that(build.cargo_process("build").arg("-v"), execs().with_status(0)); }); @@ -1355,9 +1338,9 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured assert_that(p.cargo("test").arg("-v").arg("-pb").arg("--lib"), execs().with_status(0).with_stdout(&format!("\ +{fresh} a v0.5.0 ([..] {compiling} b v0.5.0 ([..] {running} `rustc b[..]src[..]lib.rs [..] -L test[..]` -{fresh} a v0.5.0 ([..] {running} `[..]b-[..]` running 0 tests diff --git a/tests/test_cargo_compile_plugins.rs b/tests/test_cargo_compile_plugins.rs index 3d90bd10645..670f4a63bad 100644 --- a/tests/test_cargo_compile_plugins.rs +++ b/tests/test_cargo_compile_plugins.rs @@ -167,7 +167,7 @@ test!(plugin_with_dynamic_native_dependency { }} "#, libname)); - assert_that(foo.cargo_process("build").env("SRC", &lib), + assert_that(foo.cargo_process("build").env("SRC", &lib).arg("-v"), execs().with_status(0)); }); @@ -189,7 +189,7 @@ test!(plugin_integration { .file("src/lib.rs", "") .file("tests/it_works.rs", ""); - assert_that(p.cargo_process("test"), + assert_that(p.cargo_process("test").arg("-v"), execs().with_status(0)); }); diff --git a/tests/test_cargo_cross_compile.rs b/tests/test_cargo_cross_compile.rs index a7c42b216cd..cb9725763d7 100644 --- a/tests/test_cargo_cross_compile.rs +++ b/tests/test_cargo_cross_compile.rs @@ -70,7 +70,7 @@ test!(simple_cross { "#, alternate_arch())); let target = alternate(); - assert_that(p.cargo_process("build").arg("--target").arg(&target), + assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"), execs().with_status(0)); assert_that(&p.target_bin(&target, "foo"), existing_file()); @@ -570,10 +570,8 @@ test!(build_script_needed_for_host_and_target { {running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]` {running} `{dir}[..]target[..]build[..]d1-[..]build-script-build` {running} `{dir}[..]target[..]build[..]d1-[..]build-script-build` -{running} `rustc d1[..]src[..]lib.rs [..] --target {target} [..] \ - -L /path/to/{target}` -{running} `rustc d1[..]src[..]lib.rs [..] \ - -L /path/to/{host}` +{running} `rustc d1[..]src[..]lib.rs [..]` +{running} `rustc d1[..]src[..]lib.rs [..]` {compiling} d2 v0.0.0 ({url}) {running} `rustc d2[..]src[..]lib.rs [..] \ -L /path/to/{host}` @@ -830,8 +828,10 @@ test!(platform_specific_variables_reflected_in_build_scripts { _ => panic!("unknown platform") }}; - env::var(expected).unwrap(); - env::var(not_expected).unwrap_err(); + env::var(expected).ok() + .expect(&format!("missing {{}}", expected)); + env::var(not_expected).err() + .expect(&format!("found {{}}", not_expected)); }} "#, host = host, target = target)) .file("src/lib.rs", "") @@ -863,4 +863,4 @@ test!(platform_specific_variables_reflected_in_build_scripts { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0)); assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target), execs().with_status(0)); -}); \ No newline at end of file +}); diff --git a/tests/test_cargo_freshness.rs b/tests/test_cargo_freshness.rs index 1a79f14c9a0..e694bb67e0e 100644 --- a/tests/test_cargo_freshness.rs +++ b/tests/test_cargo_freshness.rs @@ -203,3 +203,57 @@ test!(rebuild_tests_if_lib_changes { assert_that(p.cargo("test").arg("-v"), execs().with_status(101)); }); + +test!(no_rebuild_transitive_target_deps { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a" } + [dev-dependencies] + b = { path = "b" } + "#) + .file("src/lib.rs", "") + .file("tests/foo.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [target.foo.dependencies] + c = { path = "../c" } + "#) + .file("a/src/lib.rs", "") + .file("b/Cargo.toml", r#" + [package] + name = "b" + version = "0.0.1" + authors = [] + + [dependencies] + c = { path = "../c" } + "#) + .file("b/src/lib.rs", "") + .file("c/Cargo.toml", r#" + [package] + name = "c" + version = "0.0.1" + authors = [] + "#) + .file("c/src/lib.rs", ""); + + assert_that(p.cargo_process("build"), + execs().with_status(0)); + assert_that(p.cargo("test").arg("--no-run"), + execs().with_status(0) + .with_stdout(&format!("\ +{compiling} c v0.0.1 ([..]) +{compiling} b v0.0.1 ([..]) +{compiling} foo v0.0.1 ([..]) +", compiling = COMPILING))); +}); diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 587aa448d5b..9e9cd678e66 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -1,4 +1,7 @@ +use std::fs::File; +use std::io::prelude::*; use std::str; +use std::thread; use support::{project, execs, basic_bin_manifest, basic_lib_manifest}; use support::{COMPILING, RUNNING, DOCTEST}; @@ -1989,3 +1992,32 @@ running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ", running = RUNNING))); }); + +test!(bin_does_not_rebuild_tests { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/lib.rs", "") + .file("src/main.rs", "fn main() {}") + .file("tests/foo.rs", ""); + p.build(); + + assert_that(p.cargo("test").arg("-v"), + execs().with_status(0)); + + thread::sleep_ms(1000); + File::create(&p.root().join("src/main.rs")).unwrap() + .write_all(b"fn main() { 3; }").unwrap(); + + assert_that(p.cargo("test").arg("-v").arg("--no-run"), + execs().with_status(0) + .with_stdout(&format!("\ +{compiling} foo v0.0.1 ([..]) +{running} `rustc src/main.rs [..]` +{running} `rustc src/main.rs [..]` +", compiling = COMPILING, running = RUNNING))); +}); From a733249e371fd3ccdec971f33a31c5064546a2ae Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Oct 2015 23:48:47 -0700 Subject: [PATCH 0046/3888] Add helper functions for reading/writing whole files Adds some helpful error text if an error happens as well --- src/cargo/ops/cargo_new.rs | 19 +++++++---------- src/cargo/ops/cargo_rustc/custom_build.rs | 21 ++++++------------- src/cargo/ops/lockfile.rs | 4 ++-- src/cargo/ops/registry.rs | 14 +++---------- src/cargo/sources/registry.rs | 8 +++----- src/cargo/util/config.rs | 10 ++++----- src/cargo/util/paths.rs | 25 ++++++++++++++++++++++- 7 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 5b36097b394..c3a6e5acb55 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -1,7 +1,6 @@ use std::env; -use std::fs::{self, File}; +use std::fs; use std::io::prelude::*; -use std::io; use std::path::Path; use rustc_serialize::{Decodable, Decoder}; @@ -11,7 +10,7 @@ use git2::Config as GitConfig; use term::color::BLACK; use util::{GitRepo, HgRepo, CargoResult, human, ChainError, internal}; -use util::Config; +use util::{Config, paths}; use toml; @@ -102,10 +101,6 @@ fn existing_vcs_repo(path: &Path) -> bool { GitRepo::discover(path).is_ok() || HgRepo::discover(path).is_ok() } -fn file(p: &Path, contents: &[u8]) -> io::Result<()> { - try!(File::create(p)).write_all(contents) -} - fn mk(config: &Config, path: &Path, name: &str, opts: &NewOptions) -> CargoResult<()> { let cfg = try!(global_config(config)); @@ -125,11 +120,11 @@ fn mk(config: &Config, path: &Path, name: &str, match vcs { VersionControl::Git => { try!(GitRepo::init(path)); - try!(file(&path.join(".gitignore"), ignore.as_bytes())); + try!(paths::write(&path.join(".gitignore"), ignore.as_bytes())); }, VersionControl::Hg => { try!(HgRepo::init(path)); - try!(file(&path.join(".hgignore"), ignore.as_bytes())); + try!(paths::write(&path.join(".hgignore"), ignore.as_bytes())); }, VersionControl::NoVcs => { try!(fs::create_dir(path)); @@ -147,7 +142,7 @@ fn mk(config: &Config, path: &Path, name: &str, (None, None, name, None) => name, }; - try!(file(&path.join("Cargo.toml"), format!( + try!(paths::write(&path.join("Cargo.toml"), format!( r#"[package] name = "{}" version = "0.1.0" @@ -157,13 +152,13 @@ authors = [{}] try!(fs::create_dir(&path.join("src"))); if opts.bin { - try!(file(&path.join("src/main.rs"), b"\ + try!(paths::write(&path.join("src/main.rs"), b"\ fn main() { println!(\"Hello, world!\"); } ")); } else { - try!(file(&path.join("src/lib.rs"), b"\ + try!(paths::write(&path.join("src/lib.rs"), b"\ #[test] fn it_works() { } diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 28348bd6212..7967a1a4d36 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -1,5 +1,5 @@ use std::collections::HashMap; -use std::fs::{self, File}; +use std::fs; use std::io::prelude::*; use std::path::PathBuf; use std::str; @@ -7,7 +7,7 @@ use std::sync::{Mutex, Arc}; use core::{PackageId, PackageSet}; use util::{CargoResult, human, Human}; -use util::{internal, ChainError, profile}; +use util::{internal, ChainError, profile, paths}; use util::Freshness; use super::job::Work; @@ -174,13 +174,8 @@ pub fn prepare(cx: &mut Context, unit: &Unit) let parsed_output = try!(BuildOutput::parse(output, &pkg_name)); build_state.insert(id, kind, parsed_output); - try!(File::create(&build_output.parent().unwrap().join("output")) - .and_then(|mut f| f.write_all(output.as_bytes())) - .map_err(|e| { - human(format!("failed to write output of custom build command: {}", - e)) - })); - + try!(paths::write(&build_output.parent().unwrap().join("output"), + output.as_bytes())); Ok(()) }); @@ -198,12 +193,8 @@ pub fn prepare(cx: &mut Context, unit: &Unit) let dirty = work.then(dirty); let fresh = Work::new(move |_tx| { let (id, pkg_name, build_state, build_output) = all; - let new_loc = build_output.parent().unwrap().join("output"); - let mut f = try!(File::open(&new_loc).map_err(|e| { - human(format!("failed to read cached build command output: {}", e)) - })); - let mut contents = String::new(); - try!(f.read_to_string(&mut contents)); + let contents = try!(paths::read(&build_output.parent().unwrap() + .join("output"))); let output = try!(BuildOutput::parse(&contents, &pkg_name)); build_state.insert(id, kind, output); Ok(()) diff --git a/src/cargo/ops/lockfile.rs b/src/cargo/ops/lockfile.rs index 12e08c0715c..da8aac7a108 100644 --- a/src/cargo/ops/lockfile.rs +++ b/src/cargo/ops/lockfile.rs @@ -6,7 +6,7 @@ use rustc_serialize::{Encodable, Decodable}; use toml::{self, Encoder, Value}; use core::{Resolve, resolver, Package, SourceId}; -use util::{CargoResult, ChainError, human}; +use util::{CargoResult, ChainError, human, paths}; use util::toml as cargo_toml; pub fn load_pkg_lockfile(pkg: &Package) -> CargoResult> { @@ -68,7 +68,7 @@ pub fn write_lockfile(dst: &Path, resolve: &Resolve) -> CargoResult<()> { None => {} } - try!(try!(File::create(dst)).write_all(out.as_bytes())); + try!(paths::write(dst, out.as_bytes())); Ok(()) } diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index d526dc7fc36..75ee24c2d15 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use std::env; -use std::fs::{self, File}; +use std::fs; use std::io::prelude::*; use std::iter::repeat; use std::path::{Path, PathBuf}; @@ -17,6 +17,7 @@ use core::manifest::ManifestMetadata; use ops; use sources::{RegistrySource}; use util::config; +use util::paths; use util::{CargoResult, human, ChainError, ToUrl}; use util::config::{Config, ConfigValue, Location}; use util::important_paths::find_root_manifest_for_cwd; @@ -92,16 +93,7 @@ fn transmit(pkg: &Package, tarball: &Path, registry: &mut Registry) ref keywords, ref readme, ref repository, ref license, ref license_file, } = *manifest.metadata(); let readme = match *readme { - Some(ref readme) => { - let path = pkg.root().join(readme); - let mut contents = String::new(); - try!(File::open(&path).and_then(|mut f| { - f.read_to_string(&mut contents) - }).chain_error(|| { - human("failed to read the specified README") - })); - Some(contents) - } + Some(ref readme) => Some(try!(paths::read(&pkg.root().join(readme)))), None => None, }; match *license_file { diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index b9754852d11..3d0c67dca7f 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -175,7 +175,7 @@ use core::{Source, SourceId, PackageId, Package, Summary, Registry}; use core::dependency::{Dependency, DependencyInner, Kind}; use sources::{PathSource, git}; use util::{CargoResult, Config, internal, ChainError, ToUrl, human}; -use util::{hex, Sha256}; +use util::{hex, Sha256, paths}; use ops; static DEFAULT: &'static str = "https://github.com/rust-lang/crates.io-index"; @@ -265,9 +265,7 @@ impl<'cfg> RegistrySource<'cfg> { /// /// This requires that the index has been at least checked out. pub fn config(&self) -> CargoResult { - let mut f = try!(File::open(&self.checkout_path.join("config.json"))); - let mut contents = String::new(); - try!(f.read_to_string(&mut contents)); + let contents = try!(paths::read(&self.checkout_path.join("config.json"))); let config = try!(json::decode(&contents)); Ok(config) } @@ -331,7 +329,7 @@ impl<'cfg> RegistrySource<'cfg> { pkg))) } - try!(try!(File::create(&dst)).write_all(resp.get_body())); + try!(paths::write(&dst, resp.get_body())); Ok(dst) } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 88d0aacc695..21aa840b7eb 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -12,7 +12,7 @@ use std::path::{Path, PathBuf}; use rustc_serialize::{Encodable,Encoder}; use toml; use core::{MultiShell, Package}; -use util::{CargoResult, ChainError, Rustc, internal, human}; +use util::{CargoResult, ChainError, Rustc, internal, human, paths}; use util::toml as cargo_toml; @@ -509,11 +509,11 @@ pub fn set_config(cfg: &Config, loc: Location, key: &str, Location::Project => unimplemented!(), }; try!(fs::create_dir_all(file.parent().unwrap())); - let mut contents = String::new(); - let _ = File::open(&file).and_then(|mut f| f.read_to_string(&mut contents)); + let contents = paths::read(&file).unwrap_or(String::new()); let mut toml = try!(cargo_toml::parse(&contents, &file)); toml.insert(key.to_string(), value.into_toml()); - let mut out = try!(File::create(&file)); - try!(out.write_all(toml::Value::Table(toml).to_string().as_bytes())); + + let contents = toml::Value::Table(toml).to_string(); + try!(paths::write(&file, contents.as_bytes())); Ok(()) } diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 7cc7d619e83..1f08ea6dd7d 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -1,5 +1,7 @@ use std::env; use std::ffi::{OsStr, OsString}; +use std::fs::File; +use std::io::prelude::*; use std::path::{Path, PathBuf, Component}; use util::{human, internal, CargoResult, ChainError}; @@ -58,12 +60,33 @@ pub fn without_prefix<'a>(a: &'a Path, b: &'a Path) -> Option<&'a Path> { Some(y) => match a.next() { Some(x) if x == y => continue, _ => return None, - }, + }, None => return Some(a.as_path()), } } } +pub fn read(path: &Path) -> CargoResult { + (|| -> CargoResult { + let mut ret = String::new(); + let mut f = try!(File::open(path)); + try!(f.read_to_string(&mut ret)); + Ok(ret) + }).chain_error(|| { + internal(format!("failed to read `{}`", path.display())) + }) +} + +pub fn write(path: &Path, contents: &[u8]) -> CargoResult<()> { + (|| -> CargoResult<()> { + let mut f = try!(File::create(path)); + try!(f.write_all(contents)); + Ok(()) + }).chain_error(|| { + internal(format!("failed to write `{}`", path.display())) + }) +} + #[cfg(unix)] pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> { use std::os::unix::prelude::*; From d758b65e5dc83df51bfbcbea65c025ceeaaae51d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 4 Oct 2015 11:52:58 -0700 Subject: [PATCH 0047/3888] Add better diagnostics for rebuilding This commit overhauls how a `Fingerprint` is stored on the filesystem and in-memory to help provide much better diagnostics as to why crates are being rebuilt. This involves storing more structured data on the filesystem in order to have a finer-grained comparison with the previous state. This is not currently surfaced in the output of cargo and still requires `RUST_LOG=cargo::ops::cargo_rustc::fingerprint=info` but if it turns out to be useful we can perhaps surface the output. There are performance considerations here to ensure that a noop build is still quite speedy for a few reasons: 1. JSON decoding is slow (these are just big structures to decode) 2. Each fingerprint stores all recursive fingerprints, so we can't just "vanilla decode" as it would decode O(n^2) items 3. Hashing is actually somewhat nontrivial for this many items here and there, so we still need as much memoization as possible. To ensure that builds are just as speedy tomorrow as they are today, a few strategies are taken: * The same fingerprint strategy is used today as a "first line of defense" where a small text file with a string contains the "total fingerprint" hash. A separately stored file then contains the more detailed JSON structure of the old fingerprint, and that's only decoded if there's a mismatch of the short hashes. The rationale here is that most crates don't need to be rebuilt so we shouldn't decode JSON, but if it does need to be rebuilt then the work of compiling far dwarfs the work of decoding the JSON. * When encoding a full fingerprint as JSON we don't actually include any dependencies, just the resolved u64 of them. This helps the O(n^2) problem in terms of decoding time and storage space on the filesystem. * Short hashes continue to be memoized to ensure we don't recompute a hash if we've already done so (e.g. shared dependencies). Overall, when profiling with Servo, this commit does not regress noop build times, but should help diagnose why crates are being rebuilt hopefully! Closes #2011 --- Cargo.lock | 6 +- src/cargo/ops/cargo_rustc/context.rs | 2 +- src/cargo/ops/cargo_rustc/fingerprint.rs | 301 ++++++++++++++++++----- src/cargo/util/hex.rs | 8 +- src/cargo/util/mod.rs | 2 +- 5 files changed, 244 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e135c2c43c3..3f94ce0680b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,7 @@ dependencies = [ "curl 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.70 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -125,7 +125,7 @@ dependencies = [ [[package]] name = "filetime" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -358,7 +358,7 @@ name = "tar" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "filetime 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index d6540740691..50c44635d34 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -33,7 +33,7 @@ pub struct Context<'a, 'cfg: 'a> { pub compilation: Compilation<'cfg>, pub build_state: Arc, pub exec_engine: Arc>, - pub fingerprints: HashMap, Fingerprint>, + pub fingerprints: HashMap, Arc>, pub compiled: HashSet>, pub build_config: BuildConfig, pub build_scripts: HashMap, Arc>, diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index bc3d0059eaa..817e7894a91 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -1,14 +1,17 @@ use std::fs::{self, File, OpenOptions}; +use std::hash::{Hash, Hasher, SipHasher}; use std::io::prelude::*; use std::io::{BufReader, SeekFrom}; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use filetime::FileTime; +use rustc_serialize::{json, Encodable, Decodable, Encoder, Decoder}; use core::{Package, TargetKind}; use util; use util::{CargoResult, Fresh, Dirty, Freshness, internal, profile, ChainError}; +use util::paths; use super::job::Work; use super::context::{Context, Unit}; @@ -50,9 +53,9 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, debug!("fingerprint at: {}", loc.display()); - let mut fingerprint = try!(calculate(cx, unit)); - let is_fresh = try!(is_fresh(&loc, &mut fingerprint)); - + let fingerprint = try!(calculate(cx, unit)); + let compare = compare_old_fingerprint(&loc, &fingerprint); + log_compare(unit, &compare); let root = cx.out_dir(unit); let mut missing_outputs = false; @@ -63,7 +66,7 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, } let allow_failure = unit.profile.rustc_args.is_some(); - Ok(prepare(is_fresh && !missing_outputs, + Ok(prepare(compare.is_ok() && !missing_outputs, allow_failure, loc, fingerprint)) } @@ -88,44 +91,181 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, /// `DependencyQueue`, but it also needs to be retained here because Cargo can /// be interrupted while executing, losing the state of the `DependencyQueue` /// graph. -pub type Fingerprint = Arc; -struct FingerprintInner { - extra: String, - deps: Vec, +pub struct Fingerprint { + rustc: u64, + features: String, + target: u64, + profile: u64, + deps: Vec<(String, Arc)>, local: LocalFingerprint, - resolved: Mutex>, + resolved: Mutex>, } -#[derive(Clone)] +#[derive(RustcEncodable, RustcDecodable, Hash)] enum LocalFingerprint { Precalculated(String), - MtimeBased(Option, PathBuf), + MtimeBased(MtimeSlot, PathBuf), } -impl FingerprintInner { - fn resolve(&self, force: bool) -> CargoResult { +struct MtimeSlot(Mutex>); + +impl Fingerprint { + fn resolve(&self, force: bool) -> CargoResult { if !force { - if let Some(ref s) = *self.resolved.lock().unwrap() { - return Ok(s.clone()) + if let Some(s) = *self.resolved.lock().unwrap() { + return Ok(s) } } - let mut deps: Vec<_> = try!(self.deps.iter().map(|s| { - s.resolve(force) - }).collect()); - deps.sort(); - let known = match self.local { - LocalFingerprint::Precalculated(ref s) => s.clone(), - LocalFingerprint::MtimeBased(Some(n), _) if !force => n.to_string(), - LocalFingerprint::MtimeBased(_, ref p) => { - debug!("resolving: {}", p.display()); - let meta = try!(fs::metadata(p)); - FileTime::from_last_modification_time(&meta).to_string() + let mut s = SipHasher::new_with_keys(0, 0); + self.rustc.hash(&mut s); + self.features.hash(&mut s); + self.target.hash(&mut s); + self.profile.hash(&mut s); + match self.local { + LocalFingerprint::MtimeBased(ref slot, ref path) => { + let mut slot = slot.0.lock().unwrap(); + if force || slot.is_none() { + let meta = try!(fs::metadata(path).chain_error(|| { + internal(format!("failed to stat {:?}", path)) + })); + *slot = Some(FileTime::from_last_modification_time(&meta)); + } + slot.hash(&mut s); } - }; - let resolved = util::short_hash(&(&known, &self.extra, &deps)); - debug!("inputs: {} {} {:?} => {}", known, self.extra, deps, resolved); - *self.resolved.lock().unwrap() = Some(resolved.clone()); - Ok(resolved) + LocalFingerprint::Precalculated(ref p) => p.hash(&mut s), + } + + for &(_, ref dep) in self.deps.iter() { + try!(dep.resolve(force)).hash(&mut s); + } + let ret = s.finish(); + *self.resolved.lock().unwrap() = Some(ret); + Ok(ret) + } + + fn compare(&self, old: &Fingerprint) -> CargoResult<()> { + if self.rustc != old.rustc { + return Err(internal("rust compiler has changed")) + } + if self.features != old.features { + return Err(internal(format!("features have changed: {} != {}", + self.features, old.features))) + } + if self.target != old.target { + return Err(internal("target configuration has changed")) + } + if self.profile != old.profile { + return Err(internal("profile configuration has changed")) + } + match (&self.local, &old.local) { + (&LocalFingerprint::Precalculated(ref a), + &LocalFingerprint::Precalculated(ref b)) => { + if a != b { + return Err(internal(format!("precalculated components have \ + changed: {} != {}", a, b))) + } + } + (&LocalFingerprint::MtimeBased(ref a, ref ap), + &LocalFingerprint::MtimeBased(ref b, ref bp)) => { + let a = a.0.lock().unwrap(); + let b = b.0.lock().unwrap(); + if *a != *b { + return Err(internal(format!("mtime based components have \ + changed: {:?} != {:?}, paths \ + are {:?} and {:?}", + *a, *b, ap, bp))) + } + } + _ => return Err(internal("local fingerprint type has changed")), + } + + if self.deps.len() != old.deps.len() { + return Err(internal("number of dependencies has changed")) + } + for (a, b) in self.deps.iter().zip(old.deps.iter()) { + let new = *a.1.resolved.lock().unwrap(); + let old = *b.1.resolved.lock().unwrap(); + if new != old { + return Err(internal(format!("new ({}) != old ({})", a.0, b.0))) + } + } + Ok(()) + } +} + +impl Encodable for Fingerprint { + fn encode(&self, e: &mut E) -> Result<(), E::Error> { + e.emit_struct("Fingerprint", 6, |e| { + try!(e.emit_struct_field("rustc", 0, |e| self.rustc.encode(e))); + try!(e.emit_struct_field("target", 1, |e| self.target.encode(e))); + try!(e.emit_struct_field("profile", 2, |e| self.profile.encode(e))); + try!(e.emit_struct_field("local", 3, |e| self.local.encode(e))); + try!(e.emit_struct_field("features", 4, |e| { + self.features.encode(e) + })); + try!(e.emit_struct_field("deps", 5, |e| { + self.deps.iter().map(|&(ref a, ref b)| { + (a, b.resolve(false).unwrap()) + }).collect::>().encode(e) + })); + Ok(()) + }) + } +} + +impl Decodable for Fingerprint { + fn decode(d: &mut D) -> Result { + fn decode(d: &mut D) -> Result { + Decodable::decode(d) + } + d.read_struct("Fingerprint", 6, |d| { + Ok(Fingerprint { + rustc: try!(d.read_struct_field("rustc", 0, decode)), + target: try!(d.read_struct_field("target", 1, decode)), + profile: try!(d.read_struct_field("profile", 2, decode)), + local: try!(d.read_struct_field("local", 3, decode)), + features: try!(d.read_struct_field("features", 4, decode)), + resolved: Mutex::new(None), + deps: { + let decode = decode::, D>; + let v = try!(d.read_struct_field("deps", 5, decode)); + v.into_iter().map(|(name, resolved)| { + (name, Arc::new(Fingerprint { + rustc: 0, + target: 0, + profile: 0, + local: LocalFingerprint::Precalculated(String::new()), + features: String::new(), + deps: Vec::new(), + resolved: Mutex::new(Some(resolved)), + })) + }).collect() + } + }) + }) + } +} + +impl Hash for MtimeSlot { + fn hash(&self, h: &mut H) { + self.0.lock().unwrap().hash(h) + } +} + +impl Encodable for MtimeSlot { + fn encode(&self, e: &mut E) -> Result<(), E::Error> { + self.0.lock().unwrap().map(|ft| { + (ft.seconds_relative_to_1970(), ft.nanoseconds()) + }).encode(e) + } +} + +impl Decodable for MtimeSlot { + fn decode(e: &mut D) -> Result { + let kind: Option<(u64, u32)> = try!(Decodable::decode(e)); + Ok(MtimeSlot(Mutex::new(kind.map(|(s, n)| { + FileTime::from_seconds_since_1970(s, n) + })))) } } @@ -142,7 +282,7 @@ impl FingerprintInner { /// Information like file modification time is only calculated for path /// dependencies and is calculated in `calculate_target_fresh`. fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) - -> CargoResult { + -> CargoResult> { if let Some(s) = cx.fingerprints.get(unit) { return Ok(s.clone()) } @@ -156,8 +296,6 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) v.sort(); v }); - let extra = util::short_hash(&(&cx.config.rustc_info().verbose_version, - unit.target, &features, unit.profile)); // Next, recursively calculate the fingerprint for all of our dependencies. // @@ -170,7 +308,7 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) !u.target.is_custom_build() && !u.target.is_bin() }).map(|unit| { calculate(cx, unit).map(|fingerprint| { - fingerprint + (unit.pkg.package_id().to_string(), fingerprint) }) }).collect::>>()); @@ -184,13 +322,18 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) if mtime.is_none() { let _ = fs::remove_file(&dep_info); } - LocalFingerprint::MtimeBased(mtime, dep_info) + LocalFingerprint::MtimeBased(MtimeSlot(Mutex::new(mtime)), dep_info) } else { - LocalFingerprint::Precalculated(try!(calculate_pkg_fingerprint(cx, - unit.pkg))) + let fingerprint = try!(calculate_pkg_fingerprint(cx, unit.pkg)); + LocalFingerprint::Precalculated(fingerprint) }; - let fingerprint = Arc::new(FingerprintInner { - extra: extra, + let mut deps = deps; + deps.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b)); + let fingerprint = Arc::new(Fingerprint { + rustc: util::hash_u64(&cx.config.rustc_info().verbose_version), + target: util::hash_u64(&unit.target), + profile: util::hash_u64(&unit.profile), + features: format!("{:?}", features), deps: deps, local: local, resolved: Mutex::new(None), @@ -236,16 +379,19 @@ pub fn prepare_build_cmd(cx: &mut Context, unit: &Unit) debug!("fingerprint at: {}", loc.display()); let new_fingerprint = try!(calculate_pkg_fingerprint(cx, unit.pkg)); - let new_fingerprint = Arc::new(FingerprintInner { - extra: String::new(), + let new_fingerprint = Arc::new(Fingerprint { + rustc: 0, + target: 0, + profile: 0, + features: String::new(), deps: Vec::new(), local: LocalFingerprint::Precalculated(new_fingerprint), resolved: Mutex::new(None), }); - let is_fresh = try!(is_fresh(&loc, &new_fingerprint)); - - Ok(prepare(is_fresh, false, loc, new_fingerprint)) + let compare = compare_old_fingerprint(&loc, &new_fingerprint); + log_compare(unit, &compare); + Ok(prepare(compare.is_ok(), false, loc, new_fingerprint)) } /// Prepare work for when a package starts to build @@ -267,19 +413,20 @@ pub fn prepare_init(cx: &mut Context, unit: &Unit) -> CargoResult<()> { fn prepare(is_fresh: bool, allow_failure: bool, loc: PathBuf, - fingerprint: Fingerprint) -> Preparation { + fingerprint: Arc) -> Preparation { let write_fingerprint = Work::new(move |_| { debug!("write fingerprint: {}", loc.display()); - let fingerprint = fingerprint.resolve(true).chain_error(|| { - internal("failed to resolve a pending fingerprint") - }); - let fingerprint = match fingerprint { - Ok(f) => f, + let hash = match fingerprint.resolve(true) { + Ok(e) => e, Err(..) if allow_failure => return Ok(()), - Err(e) => return Err(e), + Err(e) => return Err(e).chain_error(|| { + internal("failed to resolve a pending fingerprint") + }) + }; - let mut f = try!(File::create(&loc)); - try!(f.write_all(fingerprint.as_bytes())); + try!(paths::write(&loc, util::to_hex(hash).as_bytes())); + try!(paths::write(&loc.with_extension("json"), + json::encode(&fingerprint).unwrap().as_bytes())); Ok(()) }); @@ -296,23 +443,41 @@ pub fn dep_info_loc(cx: &Context, unit: &Unit) -> PathBuf { dir(cx, unit).join(&format!("dep-{}", filename(unit))) } -fn is_fresh(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult { - let mut file = match File::open(loc) { - Ok(file) => file, - Err(..) => return Ok(false), - }; +fn compare_old_fingerprint(loc: &Path, + new_fingerprint: &Fingerprint) + -> CargoResult<()> { + let old_fingerprint_short = try!(paths::read(loc)); + let new_hash = try!(new_fingerprint.resolve(false).chain_error(|| { + internal(format!("failed to resolve new fingerprint")) + })); - let mut old_fingerprint = String::new(); - try!(file.read_to_string(&mut old_fingerprint)); - let new_fingerprint = match new_fingerprint.resolve(false) { - Ok(s) => s, - Err(..) => return Ok(false), - }; + if util::to_hex(new_hash) == old_fingerprint_short { + return Ok(()) + } - trace!("old fingerprint: {}", old_fingerprint); - trace!("new fingerprint: {}", new_fingerprint); + let old_fingerprint_json = try!(paths::read(&loc.with_extension("json"))); - Ok(old_fingerprint == new_fingerprint) + let old_fingerprint = try!(json::decode(&old_fingerprint_json).chain_error(|| { + internal(format!("failed to deserialize json")) + })); + new_fingerprint.compare(&old_fingerprint) +} + +fn log_compare(unit: &Unit, compare: &CargoResult<()>) { + let mut e = match *compare { + Ok(..) => return, + Err(ref e) => &**e, + }; + info!("fingerprint error for {}: {}", unit.pkg, e); + while let Some(cause) = e.cargo_cause() { + info!(" cause: {}", cause); + e = cause; + } + let mut e = e.cause(); + while let Some(cause) = e { + info!(" cause: {}", cause); + e = cause.cause(); + } } fn calculate_target_mtime(dep_info: &Path) -> CargoResult> { diff --git a/src/cargo/util/hex.rs b/src/cargo/util/hex.rs index 7530c5472f2..43687b75dfb 100644 --- a/src/cargo/util/hex.rs +++ b/src/cargo/util/hex.rs @@ -15,8 +15,12 @@ pub fn to_hex(num: u64) -> String { ].to_hex() } -pub fn short_hash(hashable: &H) -> String { +pub fn hash_u64(hashable: &H) -> u64 { let mut hasher = SipHasher::new_with_keys(0, 0); hashable.hash(&mut hasher); - to_hex(hasher.finish()) + hasher.finish() +} + +pub fn short_hash(hashable: &H) -> String { + to_hex(hash_u64(hashable)) } diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 95b01a72395..49963201d92 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -6,7 +6,7 @@ pub use self::errors::{CliError, ProcessError, CargoTestError}; pub use self::errors::{Human, caused_human}; pub use self::errors::{process_error, internal_error, internal, human}; pub use self::graph::Graph; -pub use self::hex::{to_hex, short_hash}; +pub use self::hex::{to_hex, short_hash, hash_u64}; pub use self::lev_distance::{lev_distance}; pub use self::paths::{join_paths, path2bytes, bytes2path, dylib_path}; pub use self::paths::{normalize_path, dylib_path_envvar, without_prefix}; From ef3da106217cf0c64e8cf825f0aa3f41e7d3e0c4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 4 Oct 2015 12:02:33 -0700 Subject: [PATCH 0048/3888] Don't bother sorting build scripts Turns out the tests don't actually need this "more deterministic" output and it was also showing up relatively high in profiles (e.g. ~15% of a noop runtime) so if this is necessary let's find a better way! --- src/cargo/ops/cargo_rustc/custom_build.rs | 8 -------- tests/test_cargo_test.rs | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 7967a1a4d36..1232fa9c21a 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -338,14 +338,6 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, for unit in units { build(&mut ret, cx, unit); } - - // Make the output a little more deterministic by sorting all dependencies - for (_, slot) in ret.iter_mut() { - slot.to_link.sort_by(|a, b| a.0.cmp(&b.0)); - slot.to_link.dedup(); - slot.plugins.sort(); - slot.plugins.dedup(); - } cx.build_scripts.extend(ret.into_iter().map(|(k, v)| { (k, Arc::new(v)) })); diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 9e9cd678e66..7a269f26adc 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -2017,7 +2017,7 @@ test!(bin_does_not_rebuild_tests { execs().with_status(0) .with_stdout(&format!("\ {compiling} foo v0.0.1 ([..]) -{running} `rustc src/main.rs [..]` -{running} `rustc src/main.rs [..]` +{running} `rustc src[..]main.rs [..]` +{running} `rustc src[..]main.rs [..]` ", compiling = COMPILING, running = RUNNING))); }); From 7cb01edbaa7a823e9d708313fe266818c1946750 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 5 Oct 2015 23:27:26 -0700 Subject: [PATCH 0049/3888] Drop 1.1.0 as crossbeam needs `const fn` To parse at least --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e743edaff59..e21c9e18d48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: rust rust: - - 1.1.0 - 1.2.0 - stable - beta From 9bf8485f432401d3e1cf97379961a12c359d7835 Mon Sep 17 00:00:00 2001 From: Carlos Liam Date: Tue, 6 Oct 2015 11:42:20 -0400 Subject: [PATCH 0050/3888] regex-synatx -> regex-syntax --- src/doc/guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index aed81ae955d..03f0d4df2cc 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -170,13 +170,13 @@ dependencies, compile them all, and update the `Cargo.lock`: Updating registry `https://github.com/rust-lang/crates.io-index` Downloading memchr v0.1.5 Downloading libc v0.1.10 - Downloading regex-synatx v0.2.1 + Downloading regex-syntax v0.2.1 Downloading memchr v0.1.5 Downloading aho-corasick v0.3.0 Downloading regex v0.1.41 Compiling memchr v0.1.5 Compiling libc v0.1.10 - Compiling regex-synatx v0.2.1 + Compiling regex-syntax v0.2.1 Compiling memchr v0.1.5 Compiling aho-corasick v0.3.0 Compiling regex v0.1.41 From f996cb6d3cf1ea7f979d6d524502c226c6e3f43c Mon Sep 17 00:00:00 2001 From: Carlos Liam Date: Tue, 6 Oct 2015 13:15:40 -0400 Subject: [PATCH 0051/3888] Clean whitespace Remove leading newlines; replace lines containing only whitespace with empty lines; replace multiple trailing newlines with a single newline --- LICENSE-THIRD-PARTY | 16 ++++++++-------- Makefile.in | 1 - src/bin/fetch.rs | 1 - src/bin/new.rs | 1 - src/bin/owner.rs | 1 - src/bin/rustc.rs | 1 - src/bin/yank.rs | 2 -- 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/LICENSE-THIRD-PARTY b/LICENSE-THIRD-PARTY index 42db8c192b3..c9897b96fbe 100644 --- a/LICENSE-THIRD-PARTY +++ b/LICENSE-THIRD-PARTY @@ -589,7 +589,7 @@ distributions of Cargo: that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. - + Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a @@ -645,7 +645,7 @@ distributions of Cargo: "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. - + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -692,7 +692,7 @@ distributions of Cargo: You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - + 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 @@ -750,7 +750,7 @@ distributions of Cargo: ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. - + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -801,7 +801,7 @@ distributions of Cargo: distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. - + 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -863,7 +863,7 @@ distributions of Cargo: accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. - + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -904,7 +904,7 @@ distributions of Cargo: restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. - + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -956,7 +956,7 @@ distributions of Cargo: the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. - + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is diff --git a/Makefile.in b/Makefile.in index 6d0d0625fe9..c42afa9bb05 100644 --- a/Makefile.in +++ b/Makefile.in @@ -235,4 +235,3 @@ uninstall: $(foreach target,$(CFG_TARGET), uninstall-$(target)) # Disable unnecessary built-in rules .SUFFIXES: - diff --git a/src/bin/fetch.rs b/src/bin/fetch.rs index 94087f026c3..6b2cb9d91a8 100644 --- a/src/bin/fetch.rs +++ b/src/bin/fetch.rs @@ -43,4 +43,3 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { Ok(None) } - diff --git a/src/bin/new.rs b/src/bin/new.rs index ee53ebe8cb8..cc72b74111a 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -52,4 +52,3 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }) } - diff --git a/src/bin/owner.rs b/src/bin/owner.rs index 38bb4ae41c6..74cf39e2e37 100644 --- a/src/bin/owner.rs +++ b/src/bin/owner.rs @@ -57,4 +57,3 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { Ok(None) } - diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 54c0dd36bcf..924cfb6365e 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -92,4 +92,3 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }) } - diff --git a/src/bin/yank.rs b/src/bin/yank.rs index d5322eb55a5..e672898a3a5 100644 --- a/src/bin/yank.rs +++ b/src/bin/yank.rs @@ -52,5 +52,3 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { Ok(None) } - - From 3b72df8c9da020e14cfddb950fc6bf4412fb0c20 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Oct 2015 09:23:32 -0700 Subject: [PATCH 0052/3888] Write the build script output ASAP This can help debug some situations if an error happens parsing the output. --- src/cargo/ops/cargo_rustc/custom_build.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 1232fa9c21a..26d8f6341b6 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -160,6 +160,8 @@ pub fn prepare(cx: &mut Context, unit: &Unit) pkg_name, e.desc); Human(e) })); + try!(paths::write(&build_output.parent().unwrap().join("output"), + &output.stdout)); // After the build command has finished running, we need to be sure to // remember all of its output so we can later discover precisely what it @@ -173,9 +175,6 @@ pub fn prepare(cx: &mut Context, unit: &Unit) })); let parsed_output = try!(BuildOutput::parse(output, &pkg_name)); build_state.insert(id, kind, parsed_output); - - try!(paths::write(&build_output.parent().unwrap().join("output"), - output.as_bytes())); Ok(()) }); From af9648fdb77a3f96d6fa265973df83af6325c0f8 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Oct 2015 10:37:56 -0700 Subject: [PATCH 0053/3888] Update TOML dependency Closes #2031 Closes #2033 --- Cargo.lock | 4 ++-- tests/test_bad_config.rs | 28 +++++++++++++++++++++++++++- tests/test_cargo_compile.rs | 13 +++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f94ce0680b..e3652630a0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -391,7 +391,7 @@ dependencies = [ [[package]] name = "toml" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/tests/test_bad_config.rs b/tests/test_bad_config.rs index 069783906a3..0854b4e4bcf 100644 --- a/tests/test_bad_config.rs +++ b/tests/test_bad_config.rs @@ -190,7 +190,7 @@ Caused by: Caused by: could not parse input as TOML -[..]config:2:1 expected `=`, but found eof +[..]config:1:2 expected `=`, but found eof ")); }); @@ -258,3 +258,29 @@ test!(bad_crate_type { warning: crate-type \"bad_type\" was not one of lib|rlib|dylib|staticlib ")); }); + +test!(malformed_override { + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.0" + authors = [] + + [target.x86_64-apple-darwin.freetype] + native = { + foo: "bar" + } + "#) + .file("src/lib.rs", ""); + + assert_that(foo.cargo_process("build"), + execs().with_status(101).with_stderr("\ +failed to parse manifest at `[..]` + +Caused by: + could not parse input as TOML +Cargo.toml:[..] + +")); +}); diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index ebef666bf34..646b50651d3 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -2039,3 +2039,16 @@ test!(invalid_spec { "could not find package matching spec `notAValidDep`".to_string())); }); + +test!(manifest_with_bom_is_ok { + let p = project("foo") + .file("Cargo.toml", "\u{FEFF} + [package] + name = \"foo\" + version = \"0.0.1\" + authors = [] + ") + .file("src/lib.rs", ""); + assert_that(p.cargo_process("build").arg("-v"), + execs().with_status(0)); +}); From 3e253abdb8806adb6c2dcf0ee0ffbd3e206367be Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Oct 2015 11:26:14 -0700 Subject: [PATCH 0054/3888] Update some build tools and libgit2 * Updates git2-rs back to 0.3 now that the distribution issue on OSX has been fixed. * Updates libgit2-sys to using the `cmake` crate so building with VS 2015 can work. * Update pkg-config to totally disable it on MSVC (basically guaranteed to never work) --- Cargo.lock | 33 ++++++++++++++-------------- Cargo.toml | 6 ++--- src/cargo/sources/git/utils.rs | 9 ++++---- tests/support/git.rs | 5 ++--- tests/test_cargo_build_auth.rs | 6 +++-- tests/test_cargo_compile_git_deps.rs | 10 ++++----- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f94ce0680b..797fdf4faa1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,13 +11,13 @@ dependencies = [ "env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "git2-curl 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2-curl 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -61,7 +61,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cmake" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -101,7 +101,7 @@ dependencies = [ "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -153,22 +153,22 @@ dependencies = [ [[package]] name = "git2" -version = "0.2.14" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "git2-curl" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -202,14 +202,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.2.20" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "cmake 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -225,11 +226,11 @@ name = "libssh2-sys" version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cmake 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -239,7 +240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -297,12 +298,12 @@ dependencies = [ "gcc 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pkg-config" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] diff --git a/Cargo.toml b/Cargo.toml index 943e570a0c0..7422dbad88d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,12 +25,12 @@ docopt = "0.6" env_logger = "0.3" filetime = "0.1" flate2 = "0.2" -git2 = "0.2" -git2-curl = "0.2" +git2 = "0.3" +git2-curl = "0.3" glob = "0.2" kernel32-sys = "0.1" libc = "0.1" -libgit2-sys = "0.2" +libgit2-sys = "0.3" log = "0.3" num_cpus = "0.2" regex = "0.1" diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index f51b9dc97b9..9973cd8a2bd 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -427,10 +427,11 @@ pub fn fetch(repo: &git2::Repository, url: &str, with_authentication(url, &try!(repo.config()), |f| { let mut cb = git2::RemoteCallbacks::new(); cb.credentials(f); - let mut remote = try!(repo.remote_anonymous(&url, Some(refspec))); - try!(remote.add_fetch("refs/tags/*:refs/tags/*")); - remote.set_callbacks(cb); - try!(remote.fetch(&["refs/tags/*:refs/tags/*", refspec], None)); + let mut remote = try!(repo.remote_anonymous(&url)); + let mut opts = git2::FetchOptions::new(); + opts.remote_callbacks(cb) + .download_tags(git2::AutotagOption::All); + try!(remote.fetch(&[refspec], Some(&mut opts), None)); Ok(()) }) } diff --git a/tests/support/git.rs b/tests/support/git.rs index 082f07fab6a..a84e5287dee 100644 --- a/tests/support/git.rs +++ b/tests/support/git.rs @@ -97,10 +97,9 @@ pub fn add_submodule<'a>(repo: &'a git2::Repository, url: &str, let path = path.to_str().unwrap().replace(r"\", "/"); let mut s = repo.submodule(url, Path::new(&path), false).unwrap(); let subrepo = s.open().unwrap(); + subrepo.remote_add_fetch("origin", "refs/heads/*:refs/heads/*").unwrap(); let mut origin = subrepo.find_remote("origin").unwrap(); - origin.add_fetch("refs/heads/*:refs/heads/*").unwrap(); - origin.fetch(&[], None).unwrap(); - origin.save().unwrap(); + origin.fetch(&[], None, None).unwrap(); subrepo.checkout_head(None).unwrap(); s.add_finalize().unwrap(); return s; diff --git a/tests/test_cargo_build_auth.rs b/tests/test_cargo_build_auth.rs index 0416c477cd8..9dcf1293ce8 100644 --- a/tests/test_cargo_build_auth.rs +++ b/tests/test_cargo_build_auth.rs @@ -40,7 +40,7 @@ test!(http_auth_offered { assert_eq!(req, vec![ "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Accept: */*", - "User-Agent: git/1.0 (libgit2 0.22.0)", + "User-Agent: git/1.0 (libgit2 0.23.0)", ].into_iter().map(|s| s.to_string()).collect()); drop(s); @@ -55,7 +55,7 @@ test!(http_auth_offered { "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Authorization: Basic Zm9vOmJhcg==", "Accept: */*", - "User-Agent: git/1.0 (libgit2 0.22.0)", + "User-Agent: git/1.0 (libgit2 0.23.0)", ].into_iter().map(|s| s.to_string()).collect()); }); @@ -155,6 +155,8 @@ Caused by: addr = addr, errmsg = if cfg!(windows) { "[[..]] failed to send request: [..]\n" + } else if cfg!(target_os = "macos") { + "[[..]] unexpected return value from ssl handshake [..]" } else { "[[..]] SSL error: [..]" }))); diff --git a/tests/test_cargo_compile_git_deps.rs b/tests/test_cargo_compile_git_deps.rs index 3cf30a2f27e..fcab5d846a3 100644 --- a/tests/test_cargo_compile_git_deps.rs +++ b/tests/test_cargo_compile_git_deps.rs @@ -931,12 +931,12 @@ test!(dep_with_changed_submodule { sub.sync().unwrap(); { let subrepo = sub.open().unwrap(); + subrepo.remote_add_fetch("origin", + "refs/heads/*:refs/heads/*").unwrap(); + subrepo.remote_set_url("origin", + &git_project3.url().to_string()).unwrap(); let mut origin = subrepo.find_remote("origin").unwrap(); - origin.set_url(&git_project3.url().to_string()).unwrap(); - origin.add_fetch("refs/heads/*:refs/heads/*").unwrap();; - origin.fetch(&[], None).unwrap(); - origin.save().unwrap(); - + origin.fetch(&[], None, None).unwrap(); let id = subrepo.refname_to_id("refs/remotes/origin/master").unwrap(); let obj = subrepo.find_object(id, None).unwrap(); subrepo.reset(&obj, git2::ResetType::Hard, None).unwrap(); From c9873c538cbaccbd930e97946713e3f6255717e4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Oct 2015 10:49:00 -0700 Subject: [PATCH 0055/3888] Enable optimizations by default This change mirrors the compiler by enabling optimizations by default rather than by default producing an unoptimized Cargo build. I was curious why #2033 hit a debug assertion when we don't ship any binaries with debug assertions enabled, but it looked like Cargo was installed via Homebrew which [does not currently enable optimizations][homebrew]. I'll also send a PR over there, but I figured it'd be also good to nip this in the bud and just start enabling optimizations by default. [homebrew]: https://github.com/Homebrew/homebrew/blob/5d09dd/Library/Formula/rust.rb#L69 --- .travis.yml | 2 +- Makefile.in | 6 +++--- configure | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e21c9e18d48..1cc9ac0e238 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ rust: - nightly sudo: false script: - - ./configure --prefix=$HOME/cargo-install --disable-cross-tests + - ./configure --prefix=$HOME/cargo-install --disable-cross-tests --disable-optimize - make - make test - make distcheck diff --git a/Makefile.in b/Makefile.in index c42afa9bb05..db8ccb65f30 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,10 +34,10 @@ else MAYBE_DISABLE_VERIFY= endif -ifdef CFG_ENABLE_OPTIMIZE -OPT_FLAG=--release -else +ifdef CFG_DISABLE_OPTIMIZE OPT_FLAG= +else +OPT_FLAG=--release endif ifdef VERBOSE diff --git a/configure b/configure index 5c2f8b3e235..c61a44b6017 100755 --- a/configure +++ b/configure @@ -293,7 +293,7 @@ BOOL_OPTIONS="" VAL_OPTIONS="" opt debug 1 "build with extra debug fun" -opt optimize 0 "build with optimizations" +opt optimize 1 "build with optimizations" opt nightly 0 "build nightly packages" opt verify-install 1 "verify installed binaries work" opt cross-tests 1 "run cross-compilation tests" From 88d412741f06240ad5d97d8c79517bc5e463799f Mon Sep 17 00:00:00 2001 From: zv Date: Wed, 7 Oct 2015 18:13:25 -0700 Subject: [PATCH 0056/3888] Replace --git with --vcs [git|hg] --- src/etc/_cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/_cargo b/src/etc/_cargo index a1c43aff8c0..672227c87c4 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -131,7 +131,7 @@ case $state in new) _arguments \ '--bin[use binary template]' \ - '--git[initialize new git repo]' \ + '--vcs:initialize a new repo with a given VCS:(git hg)' \ '(-h, --help)'{-h,--help}'[show help message]' \ '--hg[initialize new mercurial repo]' \ '--no-git[no new git repo]' \ From 3db7116a625320dc27bc68be96b32c2fc5e0af3c Mon Sep 17 00:00:00 2001 From: zv Date: Wed, 7 Oct 2015 18:15:30 -0700 Subject: [PATCH 0057/3888] Remove deprecated --no-git & --hg options --- src/etc/_cargo | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/etc/_cargo b/src/etc/_cargo index 672227c87c4..75a588acbb9 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -133,8 +133,6 @@ case $state in '--bin[use binary template]' \ '--vcs:initialize a new repo with a given VCS:(git hg)' \ '(-h, --help)'{-h,--help}'[show help message]' \ - '--hg[initialize new mercurial repo]' \ - '--no-git[no new git repo]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--color=[colorization option]' \ ;; From c604bc26a9a2d0fe673bfe04b6ef198958dfcc0b Mon Sep 17 00:00:00 2001 From: zv Date: Wed, 7 Oct 2015 18:17:46 -0700 Subject: [PATCH 0058/3888] Added `none` option to --vcs --- src/etc/_cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/_cargo b/src/etc/_cargo index 75a588acbb9..197cdb4222b 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -131,7 +131,7 @@ case $state in new) _arguments \ '--bin[use binary template]' \ - '--vcs:initialize a new repo with a given VCS:(git hg)' \ + '--vcs:initialize a new repo with a given VCS:(git hg none)' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--color=[colorization option]' \ From ae9ecdbf0a5839b656e2f06410310e2b2138e073 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Oct 2015 23:26:05 -0700 Subject: [PATCH 0059/3888] Auto de-dupe build scripts to link I removed this in 68014ab8 thinking it wasn't necessary, which it technically isn't for correctness but it ends up leading to absurdly long command lines to the compiler for larger projects. This also changes the `Vec` to be a `BTreeSet` to have sorting and deduplication as we go along which should be much faster than waiting to sort until the very end. --- src/cargo/ops/cargo_rustc/custom_build.rs | 12 ++--- src/cargo/ops/cargo_rustc/mod.rs | 2 +- tests/test_cargo_compile_custom_build.rs | 62 +++++++++++++++++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 1232fa9c21a..83ab98787ad 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{HashMap, BTreeSet}; use std::fs; use std::io::prelude::*; use std::path::PathBuf; @@ -35,8 +35,8 @@ pub struct BuildState { #[derive(Default)] pub struct BuildScripts { - pub to_link: Vec<(PackageId, Kind)>, - pub plugins: Vec, + pub to_link: BTreeSet<(PackageId, Kind)>, + pub plugins: BTreeSet, } /// Prepares a `Work` that executes the target as a custom build script. @@ -354,11 +354,11 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, return &out[unit] } - let mut to_link = Vec::new(); - let mut plugins = Vec::new(); + let mut to_link = BTreeSet::new(); + let mut plugins = BTreeSet::new(); if !unit.target.is_custom_build() && unit.pkg.has_custom_build() { - to_link.push((unit.pkg.package_id().clone(), unit.kind)); + to_link.insert((unit.pkg.package_id().clone(), unit.kind)); } for unit in cx.dep_targets(unit).iter() { let dep_scripts = build(out, cx, unit); diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 5e5655bf8a5..91892918756 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -30,7 +30,7 @@ mod job_queue; mod layout; mod links; -#[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)] +#[derive(PartialEq, Eq, Hash, Debug, Clone, Copy, PartialOrd, Ord)] pub enum Kind { Host, Target } #[derive(Default, Clone)] diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index 7f35237b93a..3f2788d0624 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -1349,3 +1349,65 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ", compiling = COMPILING, running = RUNNING, fresh = FRESH))); }); + +test!(diamond_passes_args_only_once { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.5.0" + authors = [] + + [dependencies] + a = { path = "a" } + b = { path = "b" } + "#) + .file("src/lib.rs", "") + .file("tests/foo.rs", "") + .file("a/Cargo.toml", r#" + [project] + name = "a" + version = "0.5.0" + authors = [] + [dependencies] + b = { path = "../b" } + c = { path = "../c" } + "#) + .file("a/src/lib.rs", "") + .file("b/Cargo.toml", r#" + [project] + name = "b" + version = "0.5.0" + authors = [] + [dependencies] + c = { path = "../c" } + "#) + .file("b/src/lib.rs", "") + .file("c/Cargo.toml", r#" + [project] + name = "c" + version = "0.5.0" + authors = [] + build = "build.rs" + "#) + .file("c/build.rs", r#" + fn main() { + println!("cargo:rustc-link-search=native=test"); + } + "#) + .file("c/src/lib.rs", ""); + + assert_that(p.cargo_process("build").arg("-v"), + execs().with_status(0).with_stdout(&format!("\ +{compiling} c v0.5.0 ([..] +{running} `rustc [..]` +{running} `[..]` +{running} `rustc [..]` +{compiling} b v0.5.0 ([..] +{running} `rustc [..]` +{compiling} a v0.5.0 ([..] +{running} `rustc [..]` +{compiling} foo v0.5.0 ([..] +{running} `[..]rlib -L native=test` +", compiling = COMPILING, running = RUNNING))); +}); From 8f19a1bc70bbcd0c305c769bd64e033f9b773bcf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 8 Oct 2015 13:14:14 -0700 Subject: [PATCH 0060/3888] Don't test SSL errors on OSX Due to libgit2 perhaps using different frameworks it's a little too onerous to test there. It's also pretty unlikely that libgit2 is configure to *not* have SSL on OSX by mistake. --- tests/test_cargo_build_auth.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_cargo_build_auth.rs b/tests/test_cargo_build_auth.rs index 9dcf1293ce8..e7afb776507 100644 --- a/tests/test_cargo_build_auth.rs +++ b/tests/test_cargo_build_auth.rs @@ -156,7 +156,10 @@ Caused by: errmsg = if cfg!(windows) { "[[..]] failed to send request: [..]\n" } else if cfg!(target_os = "macos") { - "[[..]] unexpected return value from ssl handshake [..]" + // OSX is difficult to tests as some builds may use + // Security.framework and others may use OpenSSL. In that case let's + // just not verify the error message here. + "[..]" } else { "[[..]] SSL error: [..]" }))); From b77e408ecc48d269f8bd46d40160c727a0cf82d6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 8 Oct 2015 21:30:33 -0700 Subject: [PATCH 0061/3888] Include filename in path fingerprint This helps diagnose "why did this rebuild" situations so not only the mtime is known but also the file in question. --- src/cargo/sources/path.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 60915a881de..1da040f1a1b 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -1,4 +1,3 @@ -use std::cmp; use std::fmt::{self, Debug, Formatter}; use std::fs; use std::io::prelude::*; @@ -313,19 +312,23 @@ impl<'cfg> Source for PathSource<'cfg> { } let mut max = FileTime::zero(); - for file in try!(self.list_files(pkg)).iter() { + let mut max_path = PathBuf::from(""); + for file in try!(self.list_files(pkg)) { // An fs::stat error here is either because path is a // broken symlink, a permissions error, or a race // condition where this path was rm'ed - either way, // we can ignore the error and treat the path's mtime // as 0. - let mtime = fs::metadata(file).map(|meta| { + let mtime = fs::metadata(&file).map(|meta| { FileTime::from_last_modification_time(&meta) }).unwrap_or(FileTime::zero()); warn!("{} {}", mtime, file.display()); - max = cmp::max(max, mtime); + if mtime > max { + max = mtime; + max_path = file; + } } trace!("fingerprint {}: {}", self.path.display(), max); - Ok(max.to_string()) + Ok(format!("{} ({})", max, max_path.display())) } } From cd3dddc5df9c92266c7c2d5534af025261c6aef3 Mon Sep 17 00:00:00 2001 From: zv Date: Thu, 8 Oct 2015 23:37:06 -0700 Subject: [PATCH 0062/3888] `_arguments` util. function for build scope specs Includes a shared and mutally exclusive build scope specifier for: * --bin * --example * --test * --lib * --bench --- src/etc/_cargo | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/etc/_cargo b/src/etc/_cargo index 197cdb4222b..b650fea5051 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -341,6 +341,15 @@ _get_names_from_array() } +# Returns the shared argument style for build specifiers +_build_scope_spec() { + '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names' \ + '(--bench --bin --test --lib)--example=[example name]' \ + '(--bench --example --test --lib)--bin=[binary name]' \ + '(--bench --bin --example --test)--lib=[library name]' \ + '(--bench --bin --example --test)--test=[test name]' \ +} + #Gets the test names from the manifest file _test_names() { From 8c3dec5362bf80a2bcef363873991d11c8324ce9 Mon Sep 17 00:00:00 2001 From: zv Date: Fri, 9 Oct 2015 00:32:41 -0700 Subject: [PATCH 0063/3888] Replace repeat options w/ command_scope_spec spec Multiple commands accept these 'command scope specifiers', all of which have had their argument completion definitions consolidated in this variable which is expanded into the argument matchspec where appropriate. --- src/etc/_cargo | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/etc/_cargo b/src/etc/_cargo index b650fea5051..6e1f25d908d 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -23,13 +23,14 @@ case $state in '--features=[space separated feature list]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of jobs to run in parallel]' \ - '--manifest-path=[path to manifest]' \ - '--bench=[benchmark name]: :_benchmark_names' \ + "${command_scope_spec[@]}" \ + '--manifest-path=[path to manifest]: :_files -/' \ '--no-default-features[do not build the default features]' \ '--no-run[compile but do not run]' \ '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \ '--target=[target triple]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--color=[colorization option]' \ ;; @@ -38,12 +39,14 @@ case $state in '--features=[space separated feature list]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of jobs to run in parallel]' \ - '--manifest-path=[path to manifest]' \ + "${command_scope_spec[@]}" \ + '--manifest-path=[path to manifest]: :files -/' \ '--no-default-features[do not build the default features]' \ '(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \ '--release=[build in release mode]' \ '--target=[target triple]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--color=[colorization option]' \ ;; @@ -341,15 +344,6 @@ _get_names_from_array() } -# Returns the shared argument style for build specifiers -_build_scope_spec() { - '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names' \ - '(--bench --bin --test --lib)--example=[example name]' \ - '(--bench --example --test --lib)--bin=[binary name]' \ - '(--bench --bin --example --test)--lib=[library name]' \ - '(--bench --bin --example --test)--test=[test name]' \ -} - #Gets the test names from the manifest file _test_names() { @@ -362,5 +356,17 @@ _benchmark_names() _get_names_from_array "bench" } +# These flags are mutally exclusive specifiers for the scope of a command; as +# they are used in multiple places without change, they are expanded into the +# appropriate command's `_arguments` where appropriate. +set command_scope_spec +command_scope_spec=( + '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names' + '(--bench --bin --test --lib)--example=[example name]' + '(--bench --example --test --lib)--bin=[binary name]' + '(--bench --bin --example --test)--lib=[library name]' + '(--bench --bin --example --test)--test=[test name]' +) + _cargo From be6314a56c727bb7bb6c67a90c0fbdf8ac2a8f89 Mon Sep 17 00:00:00 2001 From: zv Date: Fri, 9 Oct 2015 00:46:32 -0700 Subject: [PATCH 0064/3888] zsh compdef should supply color options ZSH compdef should prompt to complete the options of --color (auto|always|never) --- src/etc/_cargo | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/etc/_cargo b/src/etc/_cargo index 197cdb4222b..e6ce7c230cb 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -30,7 +30,7 @@ case $state in '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \ '--target=[target triple]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; build) @@ -44,7 +44,7 @@ case $state in '--release=[build in release mode]' \ '--target=[target triple]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; clean) @@ -54,7 +54,7 @@ case $state in '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \ '--target=[target triple(default:all)]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; config-for-key) @@ -80,7 +80,7 @@ case $state in '--no-default-features[do not build the default features]' \ '--open[oen docs in browser after the build]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; fetch) @@ -88,7 +88,7 @@ case $state in '(-h, --help)'{-h,--help}'[show help message]' \ '--manifest-path=[path to manifest]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; generate-lockfile) @@ -96,7 +96,7 @@ case $state in '(-h, --help)'{-h,--help}'[show help message]' \ '--manifest-path=[path to manifest]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; git-checkout) @@ -105,7 +105,7 @@ case $state in '--reference=[REF]' \ '--url=[URL]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; help) @@ -125,7 +125,7 @@ case $state in '(-h, --help)'{-h,--help}'[show help message]' \ '--host=[Host to set the token for]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; new) @@ -134,7 +134,7 @@ case $state in '--vcs:initialize a new repo with a given VCS:(git hg none)' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; owner) @@ -145,7 +145,7 @@ case $state in '(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \ '--token[API token]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; package) @@ -154,7 +154,7 @@ case $state in '--manifest-path=[path to manifest]' \ '--no-verify[do not build to verify contents]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; pkgid) @@ -162,7 +162,7 @@ case $state in '(-h, --help)'{-h,--help}'[show help message]' \ '--manifest-path=[path to manifest]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; publish) @@ -173,7 +173,7 @@ case $state in '--no-verify[Do not verify tarball until before publish]' \ '--token[Token to use when uploading]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; read-manifest) @@ -181,7 +181,7 @@ case $state in '(-h, --help)'{-h,--help}'[show help message]' \ '--manifest-path=[path to manifest]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; run) @@ -196,7 +196,7 @@ case $state in '--release=[build in release mode]' \ '--target=[target triple]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ '*: :_normal' \ ;; @@ -212,7 +212,7 @@ case $state in '(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \ '--target=[target triple]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ '1: :_test_names' \ ;; @@ -224,7 +224,7 @@ case $state in '(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \ '--precise=[update single dependency to PRECISE]: :' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; verify-project) @@ -232,14 +232,14 @@ case $state in '(-h, --help)'{-h,--help}'[show help message]' \ '--manifest-path=[path to manifest]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; version) _arguments \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ ;; yank) @@ -249,7 +249,7 @@ case $state in '--token[API token]' \ '--undo[undo yank]' \ '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ - '--color=[colorization option]' \ + '--color=:colorization option:(auto always never)' \ '--vers[yank version]' \ ;; esac From a972a9dd99eb0f8546c624a0d06e725646eaca1d Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Fri, 9 Oct 2015 17:43:12 +0300 Subject: [PATCH 0065/3888] Use the more portable `find -perm` syntax This is an improvement of fd781a12 adopted by rustc in https://github.com/rust-lang/rust/commit/f001f9a7 See also #822 --- Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index db8ccb65f30..bec356904b3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -105,7 +105,8 @@ style: sh tests/check-style.sh no-exes: - find $$(git ls-files) -perm +a+x -type f \ + find $$(git ls-files) -type f \ + \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ -not -name configure -not -name '*.sh' -not -name '*.rs' \ -not -wholename "*/rust-installer/*" | \ grep '.*' \ From f2352b82f7b1aade9c40376e34cba085d35664ee Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Fri, 9 Oct 2015 16:01:13 +0000 Subject: [PATCH 0066/3888] Fix the usage of CFG_xxxABLE_OPTIMIZE variables in Makefiles Until now, there was a CFG_DISABLE_OPTIMIZE that controlled whether `--release` is passed to cargo during the build, and a CFG_ENABLE_OPTIMIZE that controlled where `make install` (among others) looked for the already built cargo executable. Unfortunately, if none of these were specified, `make all` built a release cargo but `make install` looked for it under `$(CFG_TARGET)/debug` (and aborted with "Please run `make` first"). This patch keeps CFG_DISABLE_OPTIMIZE only and uses it consistently. --- Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index db8ccb65f30..b9f98755f62 100644 --- a/Makefile.in +++ b/Makefile.in @@ -59,10 +59,10 @@ BIN_TARGETS := $(BIN_TARGETS:src/bin/%.rs=%) BIN_TARGETS := $(filter-out cargo,$(BIN_TARGETS)) define DIST_TARGET -ifdef CFG_ENABLE_OPTIMIZE -TARGET_$(1) = $$(TARGET_ROOT)/$(1)/release -else +ifdef CFG_DISABLE_OPTIMIZE TARGET_$(1) = $$(TARGET_ROOT)/$(1)/debug +else +TARGET_$(1) = $$(TARGET_ROOT)/$(1)/release endif DISTDIR_$(1) = $$(TARGET_$(1))/dist IMGDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)-image From 0d886af34917411ede0ab5f6462ebd40f15e9e4d Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Fri, 9 Oct 2015 20:24:24 +0300 Subject: [PATCH 0067/3888] Ignore `*.py` in `make no-exes` --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index bec356904b3..7d883ef096f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -108,7 +108,7 @@ no-exes: find $$(git ls-files) -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ -not -name configure -not -name '*.sh' -not -name '*.rs' \ - -not -wholename "*/rust-installer/*" | \ + -not -name '*.py' -not -wholename "*/rust-installer/*" | \ grep '.*' \ && exit 1 || exit 0 From 38ad444446cea24e36e84af66ba4437504e535a1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 9 Oct 2015 14:15:25 -0700 Subject: [PATCH 0068/3888] Fix recompiles where overrides changed This commit causes a recompile to be triggered if the overridden version of a build script changed since it was last run. Previously this wasn't tracked very well due to fingerprints not accounting for the right data. There are a few architectural changes here which were made to prepare for this: * The unit of work for "running a build script" is now emitted as dependency regardless of whether a build script is overridden or not. Previously it was omitted if overridden. * This unit of work has 0 dependencies if it is overridden (as we know the output) and otherwise has the normal set of dependencies. * The fingerprint calculation was updated to recognize when a build script execution is overridden and instead consider the overridden value as input to the fingerprint. This means that if the overridden values change they will trigger a recompile. * The "prepare a build script to run" step now emits a noop if the execution of the build script is overridden. After putting all that together, this commit ... Closes #2042 --- src/cargo/ops/cargo_rustc/context.rs | 79 ++++++++++++----------- src/cargo/ops/cargo_rustc/custom_build.rs | 36 +++++++---- src/cargo/ops/cargo_rustc/fingerprint.rs | 15 ++++- tests/test_cargo_compile_custom_build.rs | 75 +++++++++++++++++++++ 4 files changed, 154 insertions(+), 51 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 50c44635d34..89a2c1a08ec 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -290,7 +290,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// for that package. pub fn dep_targets(&self, unit: &Unit<'a>) -> Vec> { if unit.profile.run_custom_build { - return self.dep_run_custom_build(unit, false) + return self.dep_run_custom_build(unit) } else if unit.profile.doc { return self.doc_deps(unit); } @@ -345,12 +345,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> { }) }).collect::>(); - // If a target isn't actually a build script itself, then it depends on - // the build script if there is one. + // If this target is a build script, then what we've collected so far is + // all we need. If this isn't a build script, then it depends on the + // build script if there is one. if unit.target.is_custom_build() { return ret } - ret.extend(self.build_script_if_run(unit, false)); + ret.extend(self.dep_build_script(unit)); // If this target is a binary, test, example, etc, then it depends on // the library of the same package. The call to `resolve.deps` above @@ -376,9 +377,24 @@ impl<'a, 'cfg> Context<'a, 'cfg> { return ret } - pub fn dep_run_custom_build(&self, - unit: &Unit<'a>, - include_overridden: bool) -> Vec> { + /// Returns the dependencies needed to run a build script. + /// + /// The `unit` provided must represent an execution of a build script, and + /// the returned set of units must all be run before `unit` is run. + pub fn dep_run_custom_build(&self, unit: &Unit<'a>) -> Vec> { + // If this build script's execution has been overridden then we don't + // actually depend on anything, we've reached the end of the dependency + // chain as we've got all the info we're gonna get. + let key = (unit.pkg.package_id().clone(), unit.kind); + if self.build_state.outputs.lock().unwrap().contains_key(&key) { + return Vec::new() + } + + // When not overridden, then the dependencies to run a build script are: + // + // 1. Compiling the build script itself + // 2. For each immediate dependency of our package which has a `links` + // key, the execution of that build script. let not_custom_build = unit.pkg.targets().iter().find(|t| { !t.is_custom_build() }).unwrap(); @@ -387,18 +403,16 @@ impl<'a, 'cfg> Context<'a, 'cfg> { profile: &self.profiles.dev, ..*unit }; - let mut ret = self.dep_targets(&tmp).iter().filter_map(|unit| { + self.dep_targets(&tmp).iter().filter_map(|unit| { if !unit.target.linkable() || unit.pkg.manifest().links().is_none() { return None } - self.build_script_if_run(unit, include_overridden) - }).collect::>(); - ret.push(Unit { + self.dep_build_script(unit) + }).chain(Some(Unit { profile: self.build_script_profile(unit.pkg.package_id()), - kind: Kind::Host, + kind: Kind::Host, // build scripts always compiled for the host ..*unit - }); - return ret + })).collect() } /// Returns the dependencies necessary to document a package @@ -442,7 +456,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } // Be sure to build/run the build script for documented libraries as - ret.extend(self.build_script_if_run(unit, false)); + ret.extend(self.dep_build_script(unit)); // If we document a binary, we need the library available if unit.target.is_bin() { @@ -451,28 +465,21 @@ impl<'a, 'cfg> Context<'a, 'cfg> { return ret } - /// Returns the build script for a package if that build script is actually - /// intended to be run for `kind` as part of this compilation. + /// If a build script is scheduled to be run for the package specified by + /// `unit`, this function will return the unit to run that build script. /// - /// Build scripts are not run if they are overridden by some global - /// configuration. - fn build_script_if_run(&self, unit: &Unit<'a>, - allow_overridden: bool) -> Option> { - let target = match unit.pkg.targets().iter().find(|t| t.is_custom_build()) { - Some(t) => t, - None => return None, - }; - let key = (unit.pkg.package_id().clone(), unit.kind); - if !allow_overridden && - unit.pkg.manifest().links().is_some() && - self.build_state.outputs.lock().unwrap().contains_key(&key) { - return None - } - Some(Unit { - pkg: unit.pkg, - target: target, - profile: &self.profiles.custom_build, - kind: unit.kind, + /// Overriding a build script simply means that the running of the build + /// script itself doesn't have any dependencies, so even in that case a unit + /// of work is still returned. `None` is only returned if the package has no + /// build script. + fn dep_build_script(&self, unit: &Unit<'a>) -> Option> { + unit.pkg.targets().iter().find(|t| t.is_custom_build()).map(|t| { + Unit { + pkg: unit.pkg, + target: t, + profile: &self.profiles.custom_build, + kind: unit.kind, + } }) } diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index fa5d689f709..8431e81c5f9 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -15,7 +15,7 @@ use super::{fingerprint, process, Kind, Context, Unit}; use super::CommandType; /// Contains the parsed output of a custom build script. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Hash)] pub struct BuildOutput { /// Paths to pass to rustc with the `-L` flag pub library_paths: Vec, @@ -49,6 +49,23 @@ pub fn prepare(cx: &mut Context, unit: &Unit) -> CargoResult<(Work, Work, Freshness)> { let _p = profile::start(format!("build script prepare: {}/{}", unit.pkg, unit.target.name())); + let key = (unit.pkg.package_id().clone(), unit.kind); + let overridden = cx.build_state.outputs.lock().unwrap().contains_key(&key); + let (work_dirty, work_fresh) = if overridden { + (Work::new(|_| Ok(())), Work::new(|_| Ok(()))) + } else { + try!(build_work(cx, unit)) + }; + + // Now that we've prep'd our work, build the work needed to manage the + // fingerprint and then start returning that upwards. + let (freshness, dirty, fresh) = + try!(fingerprint::prepare_build_cmd(cx, unit)); + + Ok((work_dirty.then(dirty), work_fresh.then(fresh), freshness)) +} + +fn build_work(cx: &mut Context, unit: &Unit) -> CargoResult<(Work, Work)> { let (script_output, build_output) = { (cx.layout(unit.pkg, Kind::Host).build(unit.pkg), cx.layout(unit.pkg, unit.kind).build_out(unit.pkg)) @@ -90,7 +107,7 @@ pub fn prepare(cx: &mut Context, unit: &Unit) // This information will be used at build-time later on to figure out which // sorts of variables need to be discovered at that time. let lib_deps = { - cx.dep_run_custom_build(unit, true).iter().filter_map(|unit| { + cx.dep_run_custom_build(unit).iter().filter_map(|unit| { if unit.profile.run_custom_build { Some((unit.pkg.manifest().links().unwrap().to_string(), unit.pkg.package_id().clone())) @@ -117,7 +134,7 @@ pub fn prepare(cx: &mut Context, unit: &Unit) // // Note that this has to do some extra work just before running the command // to determine extra environment variables and such. - let work = Work::new(move |desc_tx| { + let dirty = Work::new(move |desc_tx| { // Make sure that OUT_DIR exists. // // If we have an old build directory, then just move it into place, @@ -181,15 +198,6 @@ pub fn prepare(cx: &mut Context, unit: &Unit) // Now that we've prepared our work-to-do, we need to prepare the fresh work // itself to run when we actually end up just discarding what we calculated // above. - // - // Note that the freshness calculation here is the build_cmd freshness, not - // target specific freshness. This is because we don't actually know what - // the inputs are to this command! - // - // Also note that a fresh build command needs to - let (freshness, dirty, fresh) = - try!(fingerprint::prepare_build_cmd(cx, unit)); - let dirty = work.then(dirty); let fresh = Work::new(move |_tx| { let (id, pkg_name, build_state, build_output) = all; let contents = try!(paths::read(&build_output.parent().unwrap() @@ -197,9 +205,9 @@ pub fn prepare(cx: &mut Context, unit: &Unit) let output = try!(BuildOutput::parse(&contents, &pkg_name)); build_state.insert(id, kind, output); Ok(()) - }).then(fresh); + }); - Ok((dirty, fresh, freshness)) + Ok((dirty, fresh)) } impl BuildState { diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 817e7894a91..945b42f23e4 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -378,7 +378,20 @@ pub fn prepare_build_cmd(cx: &mut Context, unit: &Unit) debug!("fingerprint at: {}", loc.display()); - let new_fingerprint = try!(calculate_pkg_fingerprint(cx, unit.pkg)); + // If this build script execution has been overridden, then the fingerprint + // is just a hash of what it was overridden with. Otherwise the fingerprint + // is that of the entire package itself as we just consider everything as + // input to the build script. + let new_fingerprint = { + let state = cx.build_state.outputs.lock().unwrap(); + match state.get(&(unit.pkg.package_id().clone(), unit.kind)) { + Some(output) => { + format!("overridden build state with hash: {}", + util::hash_u64(output)) + } + None => try!(calculate_pkg_fingerprint(cx, unit.pkg)), + } + }; let new_fingerprint = Arc::new(Fingerprint { rustc: 0, target: 0, diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index 3f2788d0624..a28bd463301 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -1411,3 +1411,78 @@ test!(diamond_passes_args_only_once { {running} `[..]rlib -L native=test` ", compiling = COMPILING, running = RUNNING))); }); + +test!(adding_an_override_invalidates { + let target = ::rustc_host(); + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.5.0" + authors = [] + links = "foo" + build = "build.rs" + "#) + .file("src/lib.rs", "") + .file(".cargo/config", "") + .file("build.rs", r#" + fn main() { + println!("cargo:rustc-link-search=native=foo"); + } + "#); + + assert_that(p.cargo_process("build").arg("-v"), + execs().with_status(0).with_stdout(&format!("\ +{compiling} foo v0.5.0 ([..] +{running} `rustc [..]` +{running} `[..]` +{running} `rustc [..] -L native=foo` +", compiling = COMPILING, running = RUNNING))); + + File::create(p.root().join(".cargo/config")).unwrap().write_all(format!(" + [target.{}.foo] + rustc-link-search = [\"native=bar\"] + ", target).as_bytes()).unwrap(); + + assert_that(p.cargo("build").arg("-v"), + execs().with_status(0).with_stdout(&format!("\ +{compiling} foo v0.5.0 ([..] +{running} `rustc [..] -L native=bar` +", compiling = COMPILING, running = RUNNING))); +}); + +test!(changing_an_override_invalidates { + let target = ::rustc_host(); + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.5.0" + authors = [] + links = "foo" + build = "build.rs" + "#) + .file("src/lib.rs", "") + .file(".cargo/config", &format!(" + [target.{}.foo] + rustc-link-search = [\"native=foo\"] + ", target)) + .file("build.rs", ""); + + assert_that(p.cargo_process("build").arg("-v"), + execs().with_status(0).with_stdout(&format!("\ +{compiling} foo v0.5.0 ([..] +{running} `rustc [..] -L native=foo` +", compiling = COMPILING, running = RUNNING))); + + File::create(p.root().join(".cargo/config")).unwrap().write_all(format!(" + [target.{}.foo] + rustc-link-search = [\"native=bar\"] + ", target).as_bytes()).unwrap(); + + assert_that(p.cargo("build").arg("-v"), + execs().with_status(0).with_stdout(&format!("\ +{compiling} foo v0.5.0 ([..] +{running} `rustc [..] -L native=bar` +", compiling = COMPILING, running = RUNNING))); +}); From abb600a96332407e8301e4c3bd606ae49c200e12 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Fri, 9 Oct 2015 21:37:53 +0300 Subject: [PATCH 0069/3888] Add tests for passing cfg directives when building tests and rustdoc Reproduces #1980 --- tests/test_cargo_compile_custom_build.rs | 233 ++++++++++++++++++++++- 1 file changed, 232 insertions(+), 1 deletion(-) diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index a28bd463301..b37dd1ae0c2 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -4,7 +4,7 @@ use std::io::prelude::*; use support::{project, execs}; use support::{COMPILING, RUNNING, DOCTEST, FRESH}; use support::paths::CargoPathExt; -use hamcrest::{assert_that}; +use hamcrest::{assert_that, existing_file, existing_dir}; fn setup() { } @@ -1281,6 +1281,237 @@ test!(cfg_override { execs().with_status(0)); }); +test!(cfg_test { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + build = "build.rs" + "#) + .file("build.rs", r#" + fn main() { + println!("cargo:rustc-cfg=foo"); + } + "#) + .file("src/lib.rs", r#" + /// + /// ``` + /// extern crate foo; + /// + /// fn main() { + /// foo::foo() + /// } + /// ``` + /// + #[cfg(foo)] + pub fn foo() {} + + #[cfg(foo)] + #[test] + fn test_foo() { + foo() + } + "#) + .file("tests/test.rs", r#" + #[cfg(foo)] + #[test] + fn test_bar() {} + "#); + assert_that(p.cargo_process("test").arg("-v"), + execs().with_stdout(format!("\ +{compiling} foo v0.0.1 ({dir}) +{running} [..] build.rs [..] +{running} [..]build-script-build[..] +{running} [..] src[..]lib.rs [..] --cfg foo[..] +{running} [..] src[..]lib.rs [..] --cfg foo[..] +{running} [..] tests[..]test.rs [..] --cfg foo[..] +{running} [..]foo-[..] + +running 1 test +test test_foo ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +{running} [..]test-[..] + +running 1 test +test test_bar ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +{doctest} foo +{running} [..] --cfg foo[..] + +running 1 test +test foo_0 ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +", +compiling = COMPILING, dir = p.url(), running = RUNNING, doctest = DOCTEST))); +}); + +test!(cfg_doc { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + build = "build.rs" + + [dependencies.bar] + path = "bar" + "#) + .file("build.rs", r#" + fn main() { + println!("cargo:rustc-cfg=foo"); + } + "#) + .file("src/lib.rs", r#" + #[cfg(foo)] + pub fn foo() {} + "#) + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + build = "build.rs" + "#) + .file("bar/build.rs", r#" + fn main() { + println!("cargo:rustc-cfg=bar"); + } + "#) + .file("bar/src/lib.rs", r#" + #[cfg(bar)] + pub fn bar() {} + "#); + assert_that(p.cargo_process("doc"), + execs().with_status(0)); + assert_that(&p.root().join("target/doc"), existing_dir()); + assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file()); + assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file()); +}); + +test!(cfg_override_test { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + build = "build.rs" + links = "a" + "#) + .file("build.rs", "") + .file(".cargo/config", &format!(r#" + [target.{}.a] + rustc-cfg = ["foo"] + "#, ::rustc_host())) + .file("src/lib.rs", r#" + /// + /// ``` + /// extern crate foo; + /// + /// fn main() { + /// foo::foo() + /// } + /// ``` + /// + #[cfg(foo)] + pub fn foo() {} + + #[cfg(foo)] + #[test] + fn test_foo() { + foo() + } + "#) + .file("tests/test.rs", r#" + #[cfg(foo)] + #[test] + fn test_bar() {} + "#); + assert_that(p.cargo_process("test").arg("-v"), + execs().with_stdout(format!("\ +{compiling} foo v0.0.1 ({dir}) +{running} [..] src[..]lib.rs [..] --cfg foo[..] +{running} [..] src[..]lib.rs [..] --cfg foo[..] +{running} [..] tests[..]test.rs [..] --cfg foo[..] +{running} [..]foo-[..] + +running 1 test +test test_foo ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +{running} [..]test-[..] + +running 1 test +test test_bar ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +{doctest} foo +{running} [..] --cfg foo[..] + +running 1 test +test foo_0 ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +", +compiling = COMPILING, dir = p.url(), running = RUNNING, doctest = DOCTEST))); +}); + +test!(cfg_override_doc { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + build = "build.rs" + links = "a" + + [dependencies.bar] + path = "bar" + "#) + .file(".cargo/config", &format!(r#" + [target.{target}.a] + rustc-cfg = ["foo"] + [target.{target}.b] + rustc-cfg = ["bar"] + "#, target = ::rustc_host())) + .file("build.rs", "") + .file("src/lib.rs", r#" + #[cfg(foo)] + pub fn foo() {} + "#) + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + build = "build.rs" + links = "b" + "#) + .file("bar/build.rs", "") + .file("bar/src/lib.rs", r#" + #[cfg(bar)] + pub fn bar() {} + "#) ; + assert_that(p.cargo_process("doc"), + execs().with_status(0)); + assert_that(&p.root().join("target/doc"), existing_dir()); + assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file()); + assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file()); +}); + test!(flags_go_into_tests { let p = project("foo") .file("Cargo.toml", r#" From 1cedb616dd07e258e102ffcb637171a2f542cf4b Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Sat, 10 Oct 2015 17:20:21 +0300 Subject: [PATCH 0070/3888] Add features test to cardo doc tests --- tests/test_cargo_doc.rs | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 93517837978..232be534c2d 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -477,3 +477,46 @@ test!(doc_multiple_deps { assert_that(&p.root().join("target/doc/bar/index.html"), existing_file()); assert_that(&p.root().join("target/doc/baz/index.html"), existing_file()); }); + +test!(features { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "bar" + + [features] + foo = ["bar/bar"] + "#) + .file("src/lib.rs", r#" + #[cfg(feature = "foo")] + pub fn foo() {} + "#) + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + + [features] + bar = [] + "#) + .file("bar/build.rs", r#" + fn main() { + println!("cargo:rustc-cfg=bar"); + } + "#) + .file("bar/src/lib.rs", r#" + #[cfg(feature = "bar")] + pub fn bar() {} + "#); + assert_that(p.cargo_process("doc").arg("--features").arg("foo"), + execs().with_status(0)); + assert_that(&p.root().join("target/doc"), existing_dir()); + assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file()); + assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file()); +}); From 09513e89c71faaf2c1d92e97089546c2bf6589e3 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Sat, 10 Oct 2015 16:11:45 +0300 Subject: [PATCH 0071/3888] Store all cfgs in Compilation instead of features only --- src/cargo/ops/cargo_rustc/compilation.rs | 4 ++-- src/cargo/ops/cargo_rustc/mod.rs | 10 ++++++++-- src/cargo/ops/cargo_test.rs | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 758da67db32..9e15288e434 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -42,7 +42,7 @@ pub struct Compilation<'cfg> { pub to_doc_test: Vec, /// Features enabled during this compilation. - pub features: HashSet, + pub cfgs: HashSet, config: &'cfg Config, } @@ -58,7 +58,7 @@ impl<'cfg> Compilation<'cfg> { binaries: Vec::new(), extra_env: HashMap::new(), to_doc_test: Vec::new(), - features: HashSet::new(), + cfgs: HashSet::new(), config: config, } } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 91892918756..fab000d179e 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -148,11 +148,17 @@ pub fn compile_targets<'a, 'cfg: 'a>(pkg_targets: &'a PackagesToBuild<'a>, } } - if let Some(feats) = cx.resolve.features(root.package_id()) { - cx.compilation.features.extend(feats.iter().cloned()); + let root_pkg = root.package_id(); + if let Some(feats) = cx.resolve.features(root_pkg) { + cx.compilation.cfgs.extend(feats.iter().map(|feat| { + format!("feature=\"{}\"", feat) + })); } for (&(ref pkg, _), output) in cx.build_state.outputs.lock().unwrap().iter() { + if pkg == root_pkg { + cx.compilation.cfgs.extend(output.cfgs.iter().cloned()); + } let any_dylib = output.library_links.iter().any(|l| { !l.starts_with("static=") && !l.starts_with("framework=") }); diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index ff2b6b41739..e443748314a 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -136,8 +136,8 @@ fn run_doc_tests(options: &TestOptions, p.arg("--test-args").arg(&test_args.connect(" ")); } - for feat in compilation.features.iter() { - p.arg("--cfg").arg(&format!("feature=\"{}\"", feat)); + for cfg in compilation.cfgs.iter() { + p.arg("--cfg").arg(cfg); } for (_, libs) in compilation.libraries.iter() { From cc27c2543ed7b2d85f63bf92de0bad6b736be989 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Sat, 10 Oct 2015 17:39:19 +0300 Subject: [PATCH 0072/3888] Propagate custom cfg directives to rustdoc, fixes #1980 --- src/cargo/ops/cargo_rustc/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index fab000d179e..8461f483783 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -398,11 +398,17 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { } let name = unit.pkg.name().to_string(); - let desc = rustdoc.to_string(); + let build_state = cx.build_state.clone(); + let key = (unit.pkg.package_id().clone(), unit.kind); let exec_engine = cx.exec_engine.clone(); Ok(Work::new(move |desc_tx| { - desc_tx.send(desc).unwrap(); + if let Some(output) = build_state.outputs.lock().unwrap().get(&key) { + for cfg in output.cfgs.iter() { + rustdoc.arg("--cfg").arg(cfg); + } + } + desc_tx.send(rustdoc.to_string()).unwrap(); exec_engine.exec(rustdoc).chain_error(|| { human(format!("Could not document `{}`.", name)) }) From 8515bffad4bbfb43bed3ebaeb825a5742fb74727 Mon Sep 17 00:00:00 2001 From: Robert Gardner Date: Mon, 12 Oct 2015 12:31:56 -0400 Subject: [PATCH 0073/3888] Add crates.io wildcard end date to FAQ This adds a bolded message to the FAQ clarifying the last date crates.io will accept crates with wildcard dependencies. Closes rust-lang/crates.io#200 --- src/doc/faq.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/faq.md b/src/doc/faq.md index fc1d9416ebc..a3b45477794 100644 --- a/src/doc/faq.md +++ b/src/doc/faq.md @@ -130,6 +130,9 @@ picture to decide what versions of dependencies should be used. # Can libraries use `*` as a version for their dependencies? +**Starting December 11th, 2015, crates.io will begin rejecting packages with +wildcard dependency constraints.** + While they _can_, strictly speaking, they should not. A version requirement of `*` says “This will work with every version ever,” which is never going to be true. Libraries should always specifiy the range that they do work with, From a3905b58d7cc0a9037196c7811ce3dd31a0255a2 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Tue, 13 Oct 2015 03:30:44 +0300 Subject: [PATCH 0074/3888] Add `cargo run` exit_code_verbose test --- tests/test_cargo_run.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index a85e7bc2816..3ad49c41854 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -105,6 +105,26 @@ test!(exit_code { execs().with_status(2)); }); +test!(exit_code_verbose { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/main.rs", r#" + fn main() { std::process::exit(2); } + "#); + + assert_that(p.cargo_process("run").arg("-v"), + execs().with_status(2) + .with_stderr(&format!("\ +Process didn't exit successfully: `target[..]foo` (exit code: 2) +", + ))); +}); + test!(no_main_file { let p = project("foo") .file("Cargo.toml", r#" From 45f4e3cb90ba976094b6cf273f24e8d51fe78df4 Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Tue, 13 Oct 2015 03:31:57 +0300 Subject: [PATCH 0075/3888] Clarify the default `cargo run` error message on a non-zero exit code The behavior is the same in the default and verbose modes now: - the default mode will not suggest re-running with `--verbose` - the verbose mode will not print the binary name. --- src/bin/run.rs | 7 +++++-- tests/test_cargo_run.rs | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bin/run.rs b/src/bin/run.rs index 2483dcc8dfc..838ac4655f9 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -1,5 +1,5 @@ use cargo::ops; -use cargo::util::{CliResult, CliError, Config}; +use cargo::util::{CliResult, CliError, Config, human}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] @@ -92,7 +92,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { None => Ok(None), Some(err) => { Err(match err.exit.as_ref().and_then(|e| e.code()) { - Some(i) => CliError::from_error(err, i), + Some(code) => { + let desc = format!("Process finished with exit status {}", code); + CliError::from_boxed(human(desc), code) + } None => CliError::from_error(err, 101), }) } diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index 3ad49c41854..f2dab301cb3 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -102,7 +102,11 @@ test!(exit_code { "#); assert_that(p.cargo_process("run"), - execs().with_status(2)); + execs().with_status(2) + .with_stderr(&format!("\ +Process finished with exit status 2 +", + ))); }); test!(exit_code_verbose { @@ -120,7 +124,7 @@ test!(exit_code_verbose { assert_that(p.cargo_process("run").arg("-v"), execs().with_status(2) .with_stderr(&format!("\ -Process didn't exit successfully: `target[..]foo` (exit code: 2) +Process finished with exit status 2 ", ))); }); From 0fbe5db434312510d0fa0fcda4879f210fe43c8d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 13 Oct 2015 10:31:40 -0700 Subject: [PATCH 0076/3888] Pre-create the output doc directory Cargo will run rustdoc concurrently if it can, and rustdoc is instructed to place output in a central location. Rustdoc itself knows how to handle concurrent invocations, but it requires that the output location exists for this to work correctly (as otherwise the rustdoc processes will race to create the directory). While this may also be fixable upstream, for now just precreate the doc directory to ensure that rustdoc doesn't race trying to create it. --- src/cargo/ops/cargo_rustc/mod.rs | 7 ++++++- tests/test_cargo_doc.rs | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 8461f483783..5feb3359195 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -380,8 +380,13 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { rustdoc.arg("--target").arg(target); doc_dir.push(target); } - doc_dir.push("doc"); + + // Create the documentation directory ahead of time as rustdoc currently has + // a bug where concurrent invocations will race to create this directory if + // it doesn't already exist. + try!(fs::create_dir_all(&doc_dir)); + rustdoc.arg("-o").arg(doc_dir); if let Some(features) = cx.resolve.features(unit.pkg.package_id()) { diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 232be534c2d..031870c55a9 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -470,7 +470,10 @@ test!(doc_multiple_deps { pub fn baz() {} "#); - assert_that(p.cargo_process("doc").arg("-p").arg("bar").arg("-p").arg("baz"), + assert_that(p.cargo_process("doc") + .arg("-p").arg("bar") + .arg("-p").arg("baz") + .arg("-v"), execs().with_status(0)); assert_that(&p.root().join("target/doc"), existing_dir()); From 9d76851e799733a6d229b5275934fd064f62f66f Mon Sep 17 00:00:00 2001 From: Gleb Kozyrev Date: Wed, 14 Oct 2015 23:08:29 +0300 Subject: [PATCH 0077/3888] Wrap `cargo run` `ProcessError` in `Human` if the exit code is non-zero --- src/bin/run.rs | 7 ++----- tests/test_cargo_run.rs | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/bin/run.rs b/src/bin/run.rs index 838ac4655f9..d765967ddda 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -1,5 +1,5 @@ use cargo::ops; -use cargo::util::{CliResult, CliError, Config, human}; +use cargo::util::{CliResult, CliError, Config, Human}; use cargo::util::important_paths::{find_root_manifest_for_cwd}; #[derive(RustcDecodable)] @@ -92,10 +92,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { None => Ok(None), Some(err) => { Err(match err.exit.as_ref().and_then(|e| e.code()) { - Some(code) => { - let desc = format!("Process finished with exit status {}", code); - CliError::from_boxed(human(desc), code) - } + Some(code) => CliError::from_error(Human(err), code), None => CliError::from_error(err, 101), }) } diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index f2dab301cb3..11a9d931142 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -104,7 +104,7 @@ test!(exit_code { assert_that(p.cargo_process("run"), execs().with_status(2) .with_stderr(&format!("\ -Process finished with exit status 2 +Process didn't exit successfully: `target[..]foo[..]` (exit code: 2) ", ))); }); @@ -124,7 +124,7 @@ test!(exit_code_verbose { assert_that(p.cargo_process("run").arg("-v"), execs().with_status(2) .with_stderr(&format!("\ -Process finished with exit status 2 +Process didn't exit successfully: `target[..]foo[..]` (exit code: 2) ", ))); }); From 210b9b4b9bbc5000d1322a8c72677f439532b6b3 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Sun, 11 Oct 2015 13:33:55 -0500 Subject: [PATCH 0078/3888] Differentiates documentation and compilation in user output Fix tests to work with new jobqueue --- src/cargo/ops/cargo_rustc/job_queue.rs | 28 +++++++++++------- tests/support/mod.rs | 1 + tests/test_cargo_compile_custom_build.rs | 6 ++-- tests/test_cargo_cross_compile.rs | 36 +++++++++++++----------- tests/test_cargo_doc.rs | 32 +++++++++++---------- 5 files changed, 59 insertions(+), 44 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 554889649ce..5966ca3edbf 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -25,7 +25,8 @@ pub struct JobQueue<'a> { rx: Receiver>, active: usize, pending: HashMap, PendingBuild>, - printed: HashSet<&'a PackageId>, + compiled: HashSet<&'a PackageId>, + documented: HashSet<&'a PackageId>, counts: HashMap<&'a PackageId, usize>, } @@ -61,7 +62,8 @@ impl<'a> JobQueue<'a> { rx: rx, active: 0, pending: HashMap::new(), - printed: HashSet::new(), + compiled: HashSet::new(), + documented: HashSet::new(), counts: HashMap::new(), } } @@ -181,7 +183,7 @@ impl<'a> JobQueue<'a> { }); // Print out some nice progress information - try!(self.note_working_on(config, key.pkg, fresh)); + try!(self.note_working_on(config, &key, fresh)); // only the first message of each job is processed if let Ok(msg) = desc_rx.recv() { @@ -199,9 +201,10 @@ impl<'a> JobQueue<'a> { // In general, we try to print "Compiling" for the first nontrivial task // run for a package, regardless of when that is. We then don't print // out any more information for a package after we've printed it once. - fn note_working_on(&mut self, config: &Config, pkg: &'a PackageId, + fn note_working_on(&mut self, config: &Config, key: &Key<'a>, fresh: Freshness) -> CargoResult<()> { - if self.printed.contains(&pkg) { + if (self.compiled.contains(key.pkg) && !key.profile.doc) || + (self.documented.contains(key.pkg) && key.profile.doc) { return Ok(()) } @@ -209,12 +212,17 @@ impl<'a> JobQueue<'a> { // Any dirty stage which runs at least one command gets printed as // being a compiled package Dirty => { - self.printed.insert(pkg); - try!(config.shell().status("Compiling", pkg)); + if key.profile.doc { + self.documented.insert(key.pkg); + try!(config.shell().status("Documenting", key.pkg)); + } else { + self.compiled.insert(key.pkg); + try!(config.shell().status("Compiling", key.pkg)); + } } - Fresh if self.counts[pkg] == 0 => { - self.printed.insert(pkg); - try!(config.shell().verbose(|c| c.status("Fresh", pkg))); + Fresh if self.counts[key.pkg] == 0 => { + self.compiled.insert(key.pkg); + try!(config.shell().verbose(|c| c.status("Fresh", key.pkg))); } Fresh => {} } diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 55589f35054..38e4348705d 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -552,6 +552,7 @@ pub fn path2url(p: PathBuf) -> Url { pub static RUNNING: &'static str = " Running"; pub static COMPILING: &'static str = " Compiling"; +pub static DOCUMENTING: &'static str = " Documenting"; pub static FRESH: &'static str = " Fresh"; pub static UPDATING: &'static str = " Updating"; pub static ADDING: &'static str = " Adding"; diff --git a/tests/test_cargo_compile_custom_build.rs b/tests/test_cargo_compile_custom_build.rs index a28bd463301..e21718a22a3 100644 --- a/tests/test_cargo_compile_custom_build.rs +++ b/tests/test_cargo_compile_custom_build.rs @@ -2,7 +2,7 @@ use std::fs::File; use std::io::prelude::*; use support::{project, execs}; -use support::{COMPILING, RUNNING, DOCTEST, FRESH}; +use support::{COMPILING, RUNNING, DOCTEST, FRESH, DOCUMENTING}; use support::paths::CargoPathExt; use hamcrest::{assert_that}; @@ -506,9 +506,9 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured assert_that(p.cargo("doc").arg("-v"), execs().with_status(0) .with_stdout(&format!("\ -{compiling} foo v0.5.0 (file://[..]) +{documenting} foo v0.5.0 (file://[..]) {running} `rustdoc [..]` -", compiling = COMPILING, running = RUNNING))); +", documenting = DOCUMENTING, running = RUNNING))); File::create(&p.root().join("src/main.rs")).unwrap() .write_all(b"fn main() {}").unwrap(); diff --git a/tests/test_cargo_cross_compile.rs b/tests/test_cargo_cross_compile.rs index cb9725763d7..ca75fac3548 100644 --- a/tests/test_cargo_cross_compile.rs +++ b/tests/test_cargo_cross_compile.rs @@ -565,25 +565,29 @@ test!(build_script_needed_for_host_and_target { assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"), execs().with_status(0) - .with_stdout(&format!("\ -{compiling} d1 v0.0.0 ({url}) -{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]` -{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build` -{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build` -{running} `rustc d1[..]src[..]lib.rs [..]` -{running} `rustc d1[..]src[..]lib.rs [..]` -{compiling} d2 v0.0.0 ({url}) + .with_stdout_contains(&format!("\ +{compiling} d1 v0.0.0 ({url})", compiling = COMPILING, url = p.url())) + .with_stdout_contains(&format!("\ +{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`", + running = RUNNING, dir = p.root().display())) + .with_stdout_contains(&format!("\ +{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`", running = RUNNING, + dir = p.root().display())) + .with_stdout_contains(&format!("\ +{running} `rustc d1[..]src[..]lib.rs [..]`", running = RUNNING)) + .with_stdout_contains(&format!("\ +{compiling} d2 v0.0.0 ({url})", compiling = COMPILING, url = p.url())) + .with_stdout_contains(&format!("\ {running} `rustc d2[..]src[..]lib.rs [..] \ - -L /path/to/{host}` -{compiling} foo v0.0.0 ({url}) + -L /path/to/{host}`", running = RUNNING, host = host)) + .with_stdout_contains(&format!("\ +{compiling} foo v0.0.0 ({url})", compiling = COMPILING, url = p.url())) + .with_stdout_contains(&format!("\ {running} `rustc build.rs [..] --out-dir {dir}[..]target[..]build[..]foo-[..] \ - -L /path/to/{host}` -{running} `{dir}[..]target[..]build[..]foo-[..]build-script-build` + -L /path/to/{host}`", running = RUNNING, dir = p.root().display(), host = host)) + .with_stdout_contains(&format!("\ {running} `rustc src[..]main.rs [..] --target {target} [..] \ - -L /path/to/{target}` -", compiling = COMPILING, running = RUNNING, target = target, host = host, - url = p.url(), - dir = p.root().display()))); + -L /path/to/{target}`", running = RUNNING, target = target))); }); test!(build_deps_for_the_right_arch { diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 93517837978..24628d28af9 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -1,7 +1,7 @@ use std::str; use support::{project, execs, path2url}; -use support::{COMPILING, RUNNING}; +use support::{COMPILING, DOCUMENTING, RUNNING}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; fn setup() { @@ -23,9 +23,9 @@ test!(simple { assert_that(p.cargo_process("doc"), execs().with_status(0).with_stdout(&format!("\ -{compiling} foo v0.0.1 ({dir}) +[..] foo v0.0.1 ({dir}) +[..] foo v0.0.1 ({dir}) ", - compiling = COMPILING, dir = path2url(p.root())))); assert_that(&p.root().join("target/doc"), existing_dir()); assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); @@ -65,9 +65,9 @@ test!(doc_twice { assert_that(p.cargo_process("doc"), execs().with_status(0).with_stdout(&format!("\ -{compiling} foo v0.0.1 ({dir}) +{documenting} foo v0.0.1 ({dir}) ", - compiling = COMPILING, + documenting = DOCUMENTING, dir = path2url(p.root())))); assert_that(p.cargo("doc"), @@ -101,10 +101,11 @@ test!(doc_deps { assert_that(p.cargo_process("doc"), execs().with_status(0).with_stdout(&format!("\ -{compiling} bar v0.0.1 ({dir}) -{compiling} foo v0.0.1 ({dir}) +[..] bar v0.0.1 ({dir}) +[..] bar v0.0.1 ({dir}) +{documenting} foo v0.0.1 ({dir}) ", - compiling = COMPILING, + documenting = DOCUMENTING, dir = path2url(p.root())))); assert_that(&p.root().join("target/doc"), existing_dir()); @@ -148,9 +149,9 @@ test!(doc_no_deps { assert_that(p.cargo_process("doc").arg("--no-deps"), execs().with_status(0).with_stdout(&format!("\ {compiling} bar v0.0.1 ({dir}) -{compiling} foo v0.0.1 ({dir}) +{documenting} foo v0.0.1 ({dir}) ", - compiling = COMPILING, + documenting = DOCUMENTING, compiling = COMPILING, dir = path2url(p.root())))); assert_that(&p.root().join("target/doc"), existing_dir()); @@ -243,9 +244,10 @@ test!(doc_dash_p { assert_that(p.cargo_process("doc").arg("-p").arg("a"), execs().with_status(0) .with_stdout(&format!("\ -{compiling} b v0.0.1 (file://[..]) -{compiling} a v0.0.1 (file://[..]) -", compiling = COMPILING))); +[..] b v0.0.1 (file://[..]) +[..] b v0.0.1 (file://[..]) +{documenting} a v0.0.1 (file://[..]) +", documenting = DOCUMENTING))); }); test!(doc_same_name { @@ -428,9 +430,9 @@ test!(doc_release { assert_that(p.cargo("doc").arg("--release").arg("-v"), execs().with_status(0) .with_stdout(&format!("\ -{compiling} foo v0.0.1 ([..]) +{documenting} foo v0.0.1 ([..]) {running} `rustdoc src[..]lib.rs [..]` -", compiling = COMPILING, running = RUNNING))); +", documenting = DOCUMENTING, running = RUNNING))); }); test!(doc_multiple_deps { From 41cac6cd8393723b939ef3955cd97e4489d2af90 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Sun, 18 Oct 2015 02:54:13 -0700 Subject: [PATCH 0079/3888] Fix broken links in documentation --- src/doc/build-script.md | 4 +++- src/doc/crates-io.md | 2 +- src/doc/environment-variables.md | 2 +- src/doc/faq.md | 4 ++-- src/doc/manifest.md | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/doc/build-script.md b/src/doc/build-script.md index 7d98d2f90be..7f1016d29a2 100644 --- a/src/doc/build-script.md +++ b/src/doc/build-script.md @@ -73,6 +73,8 @@ Any other element is a user-defined metadata that will be passed to dependencies. More information about this can be found in the [`links`][links] section. +[links]: #the-links-manifest-key + ## Build Dependencies Build scripts are also allowed to have dependencies on other Cargo-based crates. @@ -115,7 +117,7 @@ In other words, it's forbidden to have two packages link to the same native library. Note, however, that there are [conventions in place][star-sys] to alleviate this. -[star-sys]: #*-sys-packages +[star-sys]: #-sys-packages As mentioned above in the output format, each build script can generate an arbitrary set of metadata in the form of key-value pairs. This metadata is diff --git a/src/doc/crates-io.md b/src/doc/crates-io.md index 4a8f5c433f7..570b4456c69 100644 --- a/src/doc/crates-io.md +++ b/src/doc/crates-io.md @@ -34,7 +34,7 @@ num = "0.0.4" The string value for each key in this table is a [semver][semver] version requirement. -[semver]: http://doc.rust-lang.org/semver/semver/#requirements +[semver]: https://github.com/steveklabnik/semver#requirements **Caret requirements** allow SemVer compatible updates to a specified version. diff --git a/src/doc/environment-variables.md b/src/doc/environment-variables.md index 83ff8c8c2a8..3ffc2c3fb10 100644 --- a/src/doc/environment-variables.md +++ b/src/doc/environment-variables.md @@ -54,7 +54,7 @@ Here are a list of the variables Cargo sets, organized by when it sets them: variables, see build script documentation about [`links`][links]. [links]: build-script.html#the-links-manifest-key -[profile]: manifest.html#the-[profile.*]-sections +[profile]: manifest.html#the-profile-sections [clang]:http://clang.llvm.org/docs/CrossCompilation.html#target-triple # Environment variables Cargo sets for crates diff --git a/src/doc/faq.md b/src/doc/faq.md index a3b45477794..1c6963ac258 100644 --- a/src/doc/faq.md +++ b/src/doc/faq.md @@ -74,7 +74,7 @@ on the platform. Cargo also supports [platform-specific dependencies][target-deps], and we plan to support more per-platform configuration in `Cargo.toml` in the future. -[target-deps]: manifest.html#the-[dependencies.*]-sections +[target-deps]: manifest.html#the-dependencies-section In the longer-term, we're looking at ways to conveniently cross-compile projects using Cargo. @@ -83,7 +83,7 @@ projects using Cargo. We support environments through the use of [profiles][profile] to support: -[profile]: manifest.html#the-[profile.*]-sections +[profile]: manifest.html#the-profile-sections * environment-specific flags (like `-g --opt-level=0` for development and `--opt-level=3` for production). diff --git a/src/doc/manifest.md b/src/doc/manifest.md index c8ee1e8ad9d..c00f33c0241 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -25,7 +25,7 @@ basic rules: * Use version numbers with three numeric parts such as 1.0.0 rather than 1.0. For more on versions, see [this -documentation](crates-io.html#using-crates.io-based-crates). +documentation](crates-io.html#using-cratesio-based-crates). ## The `build` Field (optional) @@ -151,7 +151,7 @@ color = "> 0.6.0, < 0.8.0" ``` The syntax of the requirement strings is described in the [crates.io -guide](crates-io.html#using-crates.io-based-crates). +guide](crates-io.html#using-cratesio-based-crates). Platform-specific dependencies take the same format, but are listed under the `target.$triple` section: From 218cd6701c3e2bae5d0dd22b19bd4b3a11fbece3 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 23 Feb 2015 00:06:12 +0100 Subject: [PATCH 0080/3888] Basic work for cargo install --- src/bin/cargo.rs | 1 + src/bin/install.rs | 89 ++++++++++++++++++++++++++++++++++ src/cargo/ops/cargo_install.rs | 17 +++++++ src/cargo/ops/mod.rs | 2 + tests/support/mod.rs | 1 + 5 files changed, 110 insertions(+) create mode 100644 src/bin/install.rs create mode 100644 src/cargo/ops/cargo_install.rs diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index bfa763852e0..11019d1ead4 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -69,6 +69,7 @@ macro_rules! each_subcommand{ ($mac:ident) => ({ $mac!(generate_lockfile); $mac!(git_checkout); $mac!(help); + $mac!(install); $mac!(locate_project); $mac!(login); $mac!(new); diff --git a/src/bin/install.rs b/src/bin/install.rs new file mode 100644 index 00000000000..8f443341b84 --- /dev/null +++ b/src/bin/install.rs @@ -0,0 +1,89 @@ +use cargo::ops; +use cargo::util::{CliResult, CliError, Config}; +use std::path::Path; + +#[allow(dead_code)] // for now until all options are implemented + +#[derive(RustcDecodable)] +struct Options { + flag_jobs: Option, + flag_features: Vec, + flag_no_default_features: bool, + flag_debug: bool, + flag_bin: Option, + flag_example: Vec, + flag_package: Vec, + flag_verbose: bool, + flag_root: Option, +} + +pub const USAGE: &'static str = " +Install a crate onto the local system + +Installing new crates: + cargo install [options] + cargo install [options] [-p CRATE | --package CRATE] [--vers VERS] + cargo install [options] --git URL [--branch BRANCH | --tag TAG | --rev SHA] + cargo install [options] --path PATH + +Managing installed crates: + cargo install [options] --list + +Options: + -h, --help Print this message + -j N, --jobs N The number of jobs to run in parallel + --features FEATURES Space-separated list of features to activate + --no-default-features Do not build the `default` feature + --debug Build in debug mode instead of release mode + --bin NAME Only install the binary NAME + --example EXAMPLE Install the example EXAMPLE instead of binaries + -p, --package CRATE Install this crate from crates.io or select the + package in a repository/path to install. + -v, --verbose Use verbose output + --root DIR Directory to install packages into + +This command manages Cargo's local set of install binary crates. Only packages +which have [[bin]] targets can be installed, and all binaries are installed into +`$HOME/.cargo/bin` by default (or `$CARGO_HOME/bin` if you change the home +directory). + +There are multiple methods of installing a new crate onto the system. The +`cargo install` command with no arguments will install the current crate (as +specifed by the current directory). Otherwise the `-p`, `--package`, `--git`, +and `--path` options all specify the source from which a crate is being +installed. The `-p` and `--package` options will download crates from crates.io. + +Crates from crates.io can optionally specify the version they wish to install +via the `--vers` flags, and similarly packages from git repositories can +optionally specify the branch, tag, or revision that should be installed. If a +crate has multiple binaries, the `--bin` argument can selectively install only +one of them, and if you'd rather install examples the `--example` argument can +be used as well. + +The `--list` option will list all installed packages (and their versions). +"; + +pub fn execute(options: Options, config: &Config) -> CliResult> { + config.shell().set_verbose(options.flag_verbose); + + let compile_opts = ops::CompileOptions { + config: config, + jobs: options.flag_jobs, + target: None, + features: &options.flag_features, + no_default_features: options.flag_no_default_features, + spec: None, + exec_engine: None, + mode: ops::CompileMode::Build, + release: true, + filter: ops::CompileFilter::Everything, + target_rustc_args: None, + }; + + let root = &Path::new("$HOME/.cargo/bin"); + + ops::install(&root, + &compile_opts).map_err(|err| { + CliError::from_boxed(err, 101) + }).map(|_| None) +} diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs new file mode 100644 index 00000000000..2bd65cc0dd6 --- /dev/null +++ b/src/cargo/ops/cargo_install.rs @@ -0,0 +1,17 @@ +use ops; +use util::CargoResult; +use sources::PathSource; +use std::path::Path; + +pub fn install(manifest_path: &Path, + opts: &ops::CompileOptions) -> CargoResult<()> { + let config = opts.config; + let src = try!(PathSource::for_path(manifest_path.parent().unwrap(), + config)); + let _root = try!(src.root_package()); + + println!("Compiling"); + try!(ops::compile(manifest_path, opts)); + + Ok(()) +} diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index f408b093aa9..5aa156cd61f 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -7,6 +7,7 @@ pub use self::cargo_rustc::{Context, LayoutProxy}; pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig}; pub use self::cargo_rustc::{CommandType, CommandPrototype, ExecEngine, ProcessEngine}; pub use self::cargo_run::run; +pub use self::cargo_install::install; pub use self::cargo_new::{new, NewOptions, VersionControl}; pub use self::cargo_doc::{doc, DocOptions}; pub use self::cargo_generate_lockfile::{generate_lockfile}; @@ -28,6 +29,7 @@ mod cargo_compile; mod cargo_doc; mod cargo_fetch; mod cargo_generate_lockfile; +mod cargo_install; mod cargo_new; mod cargo_package; mod cargo_pkgid; diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 38e4348705d..90b1dfac81f 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -563,3 +563,4 @@ pub static DOWNLOADING: &'static str = " Downloading"; pub static UPLOADING: &'static str = " Uploading"; pub static VERIFYING: &'static str = " Verifying"; pub static ARCHIVING: &'static str = " Archiving"; +pub static INSTALLED: &'static str = " Installed"; From 3935b57794a05ce117543f411221ba35058dccf0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 5 Oct 2015 15:29:15 -0700 Subject: [PATCH 0081/3888] Finish implementing `cargo install` This commit is an implementation of [RFC 1200][rfc] which brings two new subcommands: `cargo install` and `cargo uninstall`. Most of this is a straight implementation of the RFC, but a few tweaks were made: * The `-p` or `--package` arguments are no longer needed as you just pass `crate` as a bare argument to the command, this means `cargo install foo` works and downloads from crates.io by default. * Some logic around selecting which crate in a multi-crate repo is installed has been tweaked slightly, but mostly in the realm of "let's do the thing that makes sense" rather than the literal "let's do what's in the RFC". Specifically, we don't pick a crate with examples if there are multiple crates with binaries (instead an error is generated saying there are multiple binary crates). [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1200-cargo-install.md --- src/bin/cargo.rs | 1 + src/bin/install.rs | 123 +++++--- src/bin/uninstall.rs | 43 +++ src/cargo/core/package_id_spec.rs | 56 ++++ src/cargo/core/registry.rs | 13 +- src/cargo/core/resolver/mod.rs | 52 +--- src/cargo/core/source.rs | 12 +- src/cargo/ops/cargo_compile.rs | 7 +- src/cargo/ops/cargo_install.rs | 341 +++++++++++++++++++- src/cargo/ops/cargo_package.rs | 2 +- src/cargo/ops/cargo_pkgid.rs | 2 +- src/cargo/ops/mod.rs | 2 +- src/cargo/ops/resolve.rs | 4 +- src/cargo/sources/git/source.rs | 7 + src/cargo/sources/path.rs | 2 +- src/cargo/sources/registry.rs | 11 +- src/cargo/util/config.rs | 14 +- tests/support/mod.rs | 2 +- tests/support/registry.rs | 8 +- tests/test_cargo_install.rs | 500 ++++++++++++++++++++++++++++++ tests/tests.rs | 1 + 21 files changed, 1080 insertions(+), 123 deletions(-) create mode 100644 src/bin/uninstall.rs create mode 100644 tests/test_cargo_install.rs diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 11019d1ead4..f21ffb1d5c5 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -82,6 +82,7 @@ macro_rules! each_subcommand{ ($mac:ident) => ({ $mac!(rustc); $mac!(search); $mac!(test); + $mac!(uninstall); $mac!(update); $mac!(verify_project); $mac!(version); diff --git a/src/bin/install.rs b/src/bin/install.rs index 8f443341b84..7ae2a130aff 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -1,8 +1,8 @@ -use cargo::ops; -use cargo::util::{CliResult, CliError, Config}; use std::path::Path; -#[allow(dead_code)] // for now until all options are implemented +use cargo::ops; +use cargo::core::{SourceId, GitReference}; +use cargo::util::{CliResult, Config, ToUrl, human}; #[derive(RustcDecodable)] struct Options { @@ -10,48 +10,65 @@ struct Options { flag_features: Vec, flag_no_default_features: bool, flag_debug: bool, - flag_bin: Option, + flag_bin: Vec, flag_example: Vec, - flag_package: Vec, flag_verbose: bool, + flag_quiet: bool, + flag_color: Option, flag_root: Option, + flag_list: bool, + + arg_crate: Option, + flag_vers: Option, + + flag_git: Option, + flag_branch: Option, + flag_tag: Option, + flag_rev: Option, + + flag_path: Option, } pub const USAGE: &'static str = " -Install a crate onto the local system +Install a Rust binary -Installing new crates: - cargo install [options] - cargo install [options] [-p CRATE | --package CRATE] [--vers VERS] - cargo install [options] --git URL [--branch BRANCH | --tag TAG | --rev SHA] - cargo install [options] --path PATH - -Managing installed crates: +Usage: + cargo install [options] [] cargo install [options] --list -Options: - -h, --help Print this message - -j N, --jobs N The number of jobs to run in parallel - --features FEATURES Space-separated list of features to activate - --no-default-features Do not build the `default` feature - --debug Build in debug mode instead of release mode - --bin NAME Only install the binary NAME - --example EXAMPLE Install the example EXAMPLE instead of binaries - -p, --package CRATE Install this crate from crates.io or select the - package in a repository/path to install. - -v, --verbose Use verbose output - --root DIR Directory to install packages into +Specifying what crate to install: + --vers VERS Specify a version to install from crates.io + --git URL Git URL to install the specified crate from + --branch BRANCH Branch to use when installing from git + --tag TAG Tag to use when installing from git + --rev SHA Specific commit to use when installing from git + --path PATH Filesystem path to local crate to install + +Build and install options: + -h, --help Print this message + -j N, --jobs N The number of jobs to run in parallel + --features FEATURES Space-separated list of features to activate + --no-default-features Do not build the `default` feature + --debug Build in debug mode instead of release mode + --bin NAME Only install the binary NAME + --example EXAMPLE Install the example EXAMPLE instead of binaries + --root DIR Directory to install packages into + -v, --verbose Use verbose output + -q, --quiet Less output printed to stdout + --color WHEN Coloring: auto, always, never This command manages Cargo's local set of install binary crates. Only packages which have [[bin]] targets can be installed, and all binaries are installed into -`$HOME/.cargo/bin` by default (or `$CARGO_HOME/bin` if you change the home -directory). +the installation root's `bin` folder. The installation root is determined, in +order of precedence, by `--root`, `$CARGO_INSTALL_ROOT`, the `install.root` +configuration key, and finally the home directory (which is either +`$CARGO_HOME` if set or `$HOME/.cargo` by default). -There are multiple methods of installing a new crate onto the system. The -`cargo install` command with no arguments will install the current crate (as -specifed by the current directory). Otherwise the `-p`, `--package`, `--git`, -and `--path` options all specify the source from which a crate is being -installed. The `-p` and `--package` options will download crates from crates.io. +There are multiple sources from which a crate can be installed. The default +location is crates.io but the `--git` and `--path` flags can change this source. +If the source contains more than one package (such as crates.io or a git +repository with multiple crates) the `` argument is required to indicate +which crate should be installed. Crates from crates.io can optionally specify the version they wish to install via the `--vers` flags, and similarly packages from git repositories can @@ -64,7 +81,8 @@ The `--list` option will list all installed packages (and their versions). "; pub fn execute(options: Options, config: &Config) -> CliResult> { - config.shell().set_verbose(options.flag_verbose); + try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); + try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); let compile_opts = ops::CompileOptions { config: config, @@ -72,18 +90,41 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target: None, features: &options.flag_features, no_default_features: options.flag_no_default_features, - spec: None, + spec: &[], exec_engine: None, mode: ops::CompileMode::Build, - release: true, - filter: ops::CompileFilter::Everything, + release: !options.flag_debug, + filter: ops::CompileFilter::new(false, &options.flag_bin, &[], + &options.flag_example, &[]), target_rustc_args: None, }; - let root = &Path::new("$HOME/.cargo/bin"); + let source = if let Some(url) = options.flag_git { + let url = try!(url.to_url().map_err(human)); + let gitref = if let Some(branch) = options.flag_branch { + GitReference::Branch(branch) + } else if let Some(tag) = options.flag_tag { + GitReference::Tag(tag) + } else if let Some(rev) = options.flag_rev { + GitReference::Rev(rev) + } else { + GitReference::Branch("master".to_string()) + }; + SourceId::for_git(&url, gitref) + } else if let Some(path) = options.flag_path { + try!(SourceId::for_path(Path::new(&path))) + } else { + try!(SourceId::for_central(config)) + }; + + let krate = options.arg_crate.as_ref().map(|s| &s[..]); + let vers = options.flag_vers.as_ref().map(|s| &s[..]); + let root = options.flag_root.as_ref().map(|s| &s[..]); - ops::install(&root, - &compile_opts).map_err(|err| { - CliError::from_boxed(err, 101) - }).map(|_| None) + if options.flag_list { + try!(ops::install_list(root, config)); + } else { + try!(ops::install(root, krate, &source, vers, &compile_opts)); + } + Ok(None) } diff --git a/src/bin/uninstall.rs b/src/bin/uninstall.rs new file mode 100644 index 00000000000..20d4b579914 --- /dev/null +++ b/src/bin/uninstall.rs @@ -0,0 +1,43 @@ +use cargo::ops; +use cargo::util::{CliResult, Config}; + +#[derive(RustcDecodable)] +struct Options { + flag_bin: Vec, + flag_root: Option, + flag_verbose: bool, + flag_quiet: bool, + flag_color: Option, + + arg_spec: String, +} + +pub const USAGE: &'static str = " +Remove a Rust binary + +Usage: + cargo uninstall [options] + +Options: + -h, --help Print this message + --root DIR Directory to uninstall packages from + --bin NAME Only uninstall the binary NAME + -v, --verbose Use verbose output + -q, --quiet Less output printed to stdout + --color WHEN Coloring: auto, always, never + +The argument SPEC is a package id specification (see `cargo help pkgid`) to +specify which crate should be uninstalled. By default all binaries are +uninstalled for a crate but the `--bin` and `--example` flags can be used to +only uninstall particular binaries. +"; + +pub fn execute(options: Options, config: &Config) -> CliResult> { + try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet)); + try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); + + let root = options.flag_root.as_ref().map(|s| &s[..]); + try!(ops::uninstall(root, &options.arg_spec, &options.flag_bin, config)); + Ok(None) +} + diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index a950e6006bc..15b191e9697 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -1,4 +1,6 @@ +use std::collections::HashMap; use std::fmt; + use semver::Version; use url::{self, Url, UrlParser}; @@ -45,6 +47,15 @@ impl PackageIdSpec { }) } + pub fn query_str<'a, I>(spec: &str, i: I) -> CargoResult<&'a PackageId> + where I: IntoIterator + { + let spec = try!(PackageIdSpec::parse(spec).chain_error(|| { + human(format!("invalid package id specification: `{}`", spec)) + })); + spec.query(i) + } + pub fn from_package_id(package_id: &PackageId) -> PackageIdSpec { PackageIdSpec { name: package_id.name().to_string(), @@ -115,6 +126,51 @@ impl PackageIdSpec { None => true } } + + pub fn query<'a, I>(&self, i: I) -> CargoResult<&'a PackageId> + where I: IntoIterator + { + let mut ids = i.into_iter().filter(|p| self.matches(*p)); + let ret = match ids.next() { + Some(id) => id, + None => return Err(human(format!("package id specification `{}` \ + matched no packages", self))), + }; + return match ids.next() { + Some(other) => { + let mut msg = format!("There are multiple `{}` packages in \ + your project, and the specification \ + `{}` is ambiguous.\n\ + Please re-run this command \ + with `-p ` where `` is one \ + of the following:", + self.name(), self); + let mut vec = vec![ret, other]; + vec.extend(ids); + minimize(&mut msg, vec, self); + Err(human(msg)) + } + None => Ok(ret) + }; + + fn minimize(msg: &mut String, + ids: Vec<&PackageId>, + spec: &PackageIdSpec) { + let mut version_cnt = HashMap::new(); + for id in ids.iter() { + *version_cnt.entry(id.version()).or_insert(0) += 1; + } + for id in ids.iter() { + if version_cnt[id.version()] == 1 { + msg.push_str(&format!("\n {}:{}", spec.name(), + id.version())); + } else { + msg.push_str(&format!("\n {}", + PackageIdSpec::from_package_id(*id))); + } + } + } + } } fn url(s: &str) -> url::ParseResult { diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 1c21e0d9607..037c5d4174e 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -154,6 +154,16 @@ impl<'cfg> PackageRegistry<'cfg> { Ok(()) } + pub fn add_preloaded(&mut self, id: &SourceId, source: Box) { + self.add_source(id, source, Kind::Locked); + } + + fn add_source(&mut self, id: &SourceId, source: Box, + kind: Kind) { + self.sources.insert(id, source); + self.source_ids.insert(id.clone(), (id.clone(), kind)); + } + pub fn add_overrides(&mut self, ids: Vec) -> CargoResult<()> { for id in ids.iter() { try!(self.load(id, Kind::Override)); @@ -183,8 +193,7 @@ impl<'cfg> PackageRegistry<'cfg> { } // Save off the source - self.sources.insert(source_id, source); - self.source_ids.insert(source_id.clone(), (source_id.clone(), kind)); + self.add_source(source_id, source, kind); Ok(()) }).chain_error(|| human(format!("Unable to update {}", source_id))) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index bd9ba548ac9..bfade996269 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -55,7 +55,7 @@ use semver; use core::{PackageId, Registry, SourceId, Summary, Dependency}; use core::PackageIdSpec; -use util::{CargoResult, Graph, human, ChainError, CargoError}; +use util::{CargoResult, Graph, human, CargoError}; use util::profile; use util::graph::{Nodes, Edges}; @@ -118,55 +118,13 @@ impl Resolve { self.graph.edges(pkg) } - pub fn query(&self, spec: &str) -> CargoResult<&PackageId> { - let spec = try!(PackageIdSpec::parse(spec).chain_error(|| { - human(format!("invalid package id specification: `{}`", spec)) - })); - let mut ids = self.iter().filter(|p| spec.matches(*p)); - let ret = match ids.next() { - Some(id) => id, - None => return Err(human(format!("package id specification `{}` \ - matched no packages", spec))), - }; - return match ids.next() { - Some(other) => { - let mut msg = format!("There are multiple `{}` packages in \ - your project, and the specification \ - `{}` is ambiguous.\n\ - Please re-run this command \ - with `-p ` where `` is one \ - of the following:", - spec.name(), spec); - let mut vec = vec![ret, other]; - vec.extend(ids); - minimize(&mut msg, vec, &spec); - Err(human(msg)) - } - None => Ok(ret) - }; - - fn minimize(msg: &mut String, - ids: Vec<&PackageId>, - spec: &PackageIdSpec) { - let mut version_cnt = HashMap::new(); - for id in ids.iter() { - *version_cnt.entry(id.version()).or_insert(0) += 1; - } - for id in ids.iter() { - if version_cnt[id.version()] == 1 { - msg.push_str(&format!("\n {}:{}", spec.name(), - id.version())); - } else { - msg.push_str(&format!("\n {}", - PackageIdSpec::from_package_id(*id))); - } - } - } - } - pub fn features(&self, pkg: &PackageId) -> Option<&HashSet> { self.features.get(pkg) } + + pub fn query(&self, spec: &str) -> CargoResult<&PackageId> { + PackageIdSpec::query_str(spec, self.iter()) + } } impl fmt::Debug for Resolve { diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index d18010a36ef..d258b9f160f 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -129,17 +129,19 @@ impl SourceId { SourceId::new(Kind::Registry, url) .with_precise(Some("locked".to_string())) } - "path" => SourceId::for_path(Path::new(&url[5..])).unwrap(), + "path" => { + let url = url.to_url().unwrap(); + SourceId::new(Kind::Path, url) + } _ => panic!("Unsupported serialized SourceId") } } pub fn to_url(&self) -> String { match *self.inner { - SourceIdInner { kind: Kind::Path, .. } => { - panic!("Path sources are not included in the lockfile, \ - so this is unimplemented") - }, + SourceIdInner { kind: Kind::Path, ref url, .. } => { + format!("path+{}", url) + } SourceIdInner { kind: Kind::Git(ref reference), ref url, ref precise, .. } => { diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index b52cae00213..e9263a69d1b 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -92,11 +92,12 @@ pub fn compile<'a>(manifest_path: &Path, for key in package.manifest().warnings().iter() { try!(options.config.shell().warn(key)) } - compile_pkg(&package, options) + compile_pkg(&package, None, options) } #[allow(deprecated)] // connect => join in 1.3 pub fn compile_pkg<'a>(root_package: &Package, + source: Option>, options: &CompileOptions<'a>) -> CargoResult> { let CompileOptions { config, jobs, target, spec, features, @@ -122,6 +123,10 @@ pub fn compile_pkg<'a>(root_package: &Package, let (packages, resolve_with_overrides, sources) = { let mut registry = PackageRegistry::new(options.config); + if let Some(source) = source { + registry.add_preloaded(root_package.package_id().source_id(), source); + } + // First, resolve the root_package's *listed* dependencies, as well as // downloading and updating all remotes and such. let resolve = try!(ops::resolve_pkg(&mut registry, root_package)); diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 2bd65cc0dd6..4d1f8370a91 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -1,17 +1,338 @@ -use ops; -use util::CargoResult; -use sources::PathSource; -use std::path::Path; +use std::collections::btree_map::Entry; +use std::collections::{BTreeMap, BTreeSet}; +use std::env; +use std::ffi::OsString; +use std::fs::{self, File}; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; -pub fn install(manifest_path: &Path, +use toml; + +use core::{SourceId, Source, Package, Registry, Dependency, PackageIdSpec}; +use core::PackageId; +use ops::{self, CompileFilter}; +use sources::{GitSource, PathSource, RegistrySource}; +use util::{CargoResult, ChainError, Config, human, internal}; + +#[derive(RustcDecodable, RustcEncodable)] +enum CrateListing { + V1(CrateListingV1), +} + +#[derive(RustcDecodable, RustcEncodable)] +struct CrateListingV1 { + v1: BTreeMap>, +} + +struct Transaction { + bins: Vec, +} + +impl Drop for Transaction { + fn drop(&mut self) { + for bin in self.bins.iter() { + let _ = fs::remove_file(bin); + } + } +} + +pub fn install(root: Option<&str>, + krate: Option<&str>, + source_id: &SourceId, + vers: Option<&str>, opts: &ops::CompileOptions) -> CargoResult<()> { let config = opts.config; - let src = try!(PathSource::for_path(manifest_path.parent().unwrap(), - config)); - let _root = try!(src.root_package()); + let root = try!(resolve_root(root, config)); + let (pkg, source) = if source_id.is_git() { + try!(select_pkg(GitSource::new(source_id, config), source_id, + krate, vers, &mut |git| git.read_packages())) + } else if source_id.is_path() { + let path = source_id.url().to_file_path().ok() + .expect("path sources must have a valid path"); + try!(select_pkg(PathSource::new(&path, source_id, config), + source_id, krate, vers, + &mut |path| path.read_packages())) + } else { + try!(select_pkg(RegistrySource::new(source_id, config), + source_id, krate, vers, + &mut |_| Err(human("must specify a crate to install from \ + crates.io")))) + }; + + let mut list = try!(read_crate_list(&root)); + let dst = root.join("bin"); + try!(check_overwrites(&dst, &pkg, &opts.filter, &list)); + + let target_dir = config.cwd().join("target-install"); + config.set_target_dir(&target_dir); + let compile = try!(ops::compile_pkg(&pkg, Some(source), opts).chain_error(|| { + human(format!("failed to compile `{}`, intermediate artifacts can be \ + found at `{}`", pkg, target_dir.display())) + })); + + let mut t = Transaction { bins: Vec::new() }; + try!(fs::create_dir_all(&dst)); + for bin in compile.binaries.iter() { + let dst = dst.join(bin.file_name().unwrap()); + try!(config.shell().status("Installing", dst.display())); + try!(fs::copy(&bin, &dst).chain_error(|| { + human(format!("failed to copy `{}` to `{}`", bin.display(), + dst.display())) + })); + t.bins.push(dst); + } + try!(fs::remove_dir_all(&target_dir)); + + list.v1.entry(pkg.package_id().clone()).or_insert_with(|| { + BTreeSet::new() + }).extend(t.bins.iter().map(|t| { + t.file_name().unwrap().to_string_lossy().into_owned() + })); + try!(write_crate_list(&root, list)); + + t.bins.truncate(0); + + // Print a warning that if this directory isn't in PATH that they won't be + // able to run these commands. + let path = env::var_os("PATH").unwrap_or(OsString::new()); + for path in env::split_paths(&path) { + if path == dst { + return Ok(()) + } + } + + try!(config.shell().warn(&format!("be sure to add `{}` to your PATH to be \ + able to run the installed binaries", + dst.display()))); + Ok(()) +} + +fn select_pkg<'a, T>(mut source: T, + source_id: &SourceId, + name: Option<&str>, + vers: Option<&str>, + list_all: &mut FnMut(&mut T) -> CargoResult>) + -> CargoResult<(Package, Box)> + where T: Source + 'a +{ + try!(source.update()); + match name { + Some(name) => { + let dep = try!(Dependency::parse(name, vers, source_id)); + let deps = try!(source.query(&dep)); + match deps.iter().map(|p| p.package_id()).max() { + Some(pkgid) => { + try!(source.download(&[pkgid.clone()])); + Ok((try!(source.get(&[pkgid.clone()])).remove(0), + Box::new(source))) + } + None => { + let vers_info = vers.map(|v| format!(" with version `{}`", v)) + .unwrap_or(String::new()); + Err(human(format!("could not find `{}` in `{}`{}", name, + source_id, vers_info))) + } + } + } + None => { + let candidates = try!(list_all(&mut source)); + let binaries = candidates.iter().filter(|cand| { + cand.targets().iter().filter(|t| t.is_bin()).count() > 0 + }); + let examples = candidates.iter().filter(|cand| { + cand.targets().iter().filter(|t| t.is_example()).count() > 0 + }); + let pkg = match try!(one(binaries, |v| multi_err("binaries", v))) { + Some(p) => p, + None => { + match try!(one(examples, |v| multi_err("examples", v))) { + Some(p) => p, + None => return Err(human("no packages found with \ + binaries or examples")), + } + } + }; + return Ok((pkg.clone(), Box::new(source))); - println!("Compiling"); - try!(ops::compile(manifest_path, opts)); + #[allow(deprecated)] // connect => join in 1.3 + fn multi_err(kind: &str, mut pkgs: Vec<&Package>) -> String { + pkgs.sort_by(|a, b| a.name().cmp(b.name())); + format!("multiple packages with {} found: {}", kind, + pkgs.iter().map(|p| p.name()).collect::>() + .connect(", ")) + } + } + } +} + +fn one(mut i: I, f: F) -> CargoResult> + where I: Iterator, + F: FnOnce(Vec) -> String +{ + match (i.next(), i.next()) { + (Some(i1), Some(i2)) => { + let mut v = vec![i1, i2]; + v.extend(i); + Err(human(f(v))) + } + (Some(i), None) => Ok(Some(i)), + (None, _) => Ok(None) + } +} + +fn check_overwrites(dst: &Path, + pkg: &Package, + filter: &ops::CompileFilter, + prev: &CrateListingV1) -> CargoResult<()> { + let check = |name| { + let name = format!("{}{}", name, env::consts::EXE_SUFFIX); + if fs::metadata(dst.join(&name)).is_err() { + return Ok(()) + } + let mut msg = format!("binary `{}` already exists in destination", name); + if let Some((p, _)) = prev.v1.iter().find(|&(_, v)| v.contains(&name)) { + msg.push_str(&format!(" as part of `{}`", p)); + } + Err(human(msg)) + }; + match *filter { + CompileFilter::Everything => { + // If explicit --bin or --example flags were passed then those'll + // get checked during cargo_compile, we only care about the "build + // everything" case here + if pkg.targets().iter().filter(|t| t.is_bin()).next().is_none() { + return Err(human("specified package has no binaries")) + } + + for target in pkg.targets().iter().filter(|t| t.is_bin()) { + try!(check(target.name())); + } + } + CompileFilter::Only { bins, examples, .. } => { + for bin in bins.iter().chain(examples) { + try!(check(bin)); + } + } + } + Ok(()) +} + +fn read_crate_list(path: &Path) -> CargoResult { + let metadata = path.join(".crates.toml"); + let mut f = match File::open(&metadata) { + Ok(f) => f, + Err(..) => return Ok(CrateListingV1 { v1: BTreeMap::new() }), + }; + (|| -> CargoResult<_> { + let mut contents = String::new(); + try!(f.read_to_string(&mut contents)); + let listing = try!(toml::decode_str(&contents).chain_error(|| { + internal("invalid TOML found for metadata") + })); + match listing { + CrateListing::V1(v1) => Ok(v1), + } + }).chain_error(|| { + human(format!("failed to parse crate metadata at `{}`", + metadata.display())) + }) +} + +fn write_crate_list(path: &Path, listing: CrateListingV1) -> CargoResult<()> { + let metadata = path.join(".crates.toml"); + (|| -> CargoResult<_> { + let mut f = try!(File::create(&metadata)); + let data = toml::encode_str::(&CrateListing::V1(listing)); + try!(f.write_all(data.as_bytes())); + Ok(()) + }).chain_error(|| { + human(format!("failed to write crate metadata at `{}`", + metadata.display())) + }) +} + +pub fn install_list(dst: Option<&str>, config: &Config) -> CargoResult<()> { + let dst = try!(resolve_root(dst, config)); + let list = try!(read_crate_list(&dst)); + let mut shell = config.shell(); + let out = shell.out(); + for (k, v) in list.v1.iter() { + try!(writeln!(out, "{}:", k)); + for bin in v { + try!(writeln!(out, " {}", bin)); + } + } + Ok(()) +} + +pub fn uninstall(root: Option<&str>, + spec: &str, + bins: &[String], + config: &Config) -> CargoResult<()> { + let root = try!(resolve_root(root, config)); + let mut metadata = try!(read_crate_list(&root)); + let mut to_remove = Vec::new(); + { + let result = try!(PackageIdSpec::query_str(spec, metadata.v1.keys())) + .clone(); + let mut installed = match metadata.v1.entry(result.clone()) { + Entry::Occupied(e) => e, + Entry::Vacant(..) => panic!("entry not found: {}", result), + }; + let dst = root.join("bin"); + for bin in installed.get() { + let bin = dst.join(bin); + if fs::metadata(&bin).is_err() { + return Err(human(format!("corrupt metadata, `{}` does not \ + exist when it should", + bin.display()))) + } + } + + let bins = bins.iter().map(|s| { + if s.ends_with(env::consts::EXE_SUFFIX) { + s.to_string() + } else { + format!("{}{}", s, env::consts::EXE_SUFFIX) + } + }).collect::>(); + + for bin in bins.iter() { + if !installed.get().contains(bin) { + return Err(human(format!("binary `{}` not installed as part \ + of `{}`", bin, result))) + } + } + + if bins.len() == 0 { + to_remove.extend(installed.get().iter().map(|b| dst.join(b))); + installed.get_mut().clear(); + } else { + for bin in bins.iter() { + to_remove.push(dst.join(bin)); + installed.get_mut().remove(bin); + } + } + if installed.get().len() == 0 { + installed.remove(); + } + } + try!(write_crate_list(&root, metadata)); + for bin in to_remove { + try!(config.shell().status("Removing", bin.display())); + try!(fs::remove_file(bin)); + } Ok(()) } + +fn resolve_root(flag: Option<&str>, config: &Config) -> CargoResult { + let config_root = try!(config.get_string("install.root")); + Ok(flag.map(PathBuf::from).or_else(|| { + env::var_os("CARGO_INSTALL_ROOT").map(PathBuf::from) + }).or_else(|| { + config_root.clone().map(|(v, _)| PathBuf::from(v)) + }).unwrap_or_else(|| { + config.home().to_owned() + })) +} diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index a1b3cd5afd5..e08281814b1 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -208,7 +208,7 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path) let new_pkg = Package::new(new_manifest, &manifest_path); // Now that we've rewritten all our path dependencies, compile it! - try!(ops::compile_pkg(&new_pkg, &ops::CompileOptions { + try!(ops::compile_pkg(&new_pkg, None, &ops::CompileOptions { config: config, jobs: None, target: None, diff --git a/src/cargo/ops/cargo_pkgid.rs b/src/cargo/ops/cargo_pkgid.rs index ab5cfe6911d..48fad309ec0 100644 --- a/src/cargo/ops/cargo_pkgid.rs +++ b/src/cargo/ops/cargo_pkgid.rs @@ -17,7 +17,7 @@ pub fn pkgid(manifest_path: &Path, }; let pkgid = match spec { - Some(spec) => try!(resolve.query(spec)), + Some(spec) => try!(PackageIdSpec::query_str(spec, resolve.iter())), None => package.package_id(), }; Ok(PackageIdSpec::from_package_id(pkgid)) diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 5aa156cd61f..92141afb439 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -7,7 +7,7 @@ pub use self::cargo_rustc::{Context, LayoutProxy}; pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig}; pub use self::cargo_rustc::{CommandType, CommandPrototype, ExecEngine, ProcessEngine}; pub use self::cargo_run::run; -pub use self::cargo_install::install; +pub use self::cargo_install::{install, install_list, uninstall}; pub use self::cargo_new::{new, NewOptions, VersionControl}; pub use self::cargo_doc::{doc, DocOptions}; pub use self::cargo_generate_lockfile::{generate_lockfile}; diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index e7afbcbca07..f1dbb0f8154 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -17,7 +17,9 @@ pub fn resolve_pkg(registry: &mut PackageRegistry, package: &Package) let resolve = try!(resolve_with_previous(registry, package, Method::Everything, prev.as_ref(), None)); - try!(ops::write_pkg_lockfile(package, &resolve)); + if package.package_id().source_id().is_path() { + try!(ops::write_pkg_lockfile(package, &resolve)); + } Ok(resolve) } diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 1863e8fd237..eaf66adccfb 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -67,6 +67,13 @@ impl<'cfg> GitSource<'cfg> { } pub fn url(&self) -> &Url { self.remote.url() } + + pub fn read_packages(&mut self) -> CargoResult> { + if self.path_source.is_none() { + try!(self.update()); + } + self.path_source.as_mut().unwrap().read_packages() + } } fn ident(url: &Url) -> String { diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 1da040f1a1b..eedb88303bf 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -56,7 +56,7 @@ impl<'cfg> PathSource<'cfg> { } } - fn read_packages(&self) -> CargoResult> { + pub fn read_packages(&self) -> CargoResult> { if self.updated { Ok(self.packages.clone()) } else if self.id.is_path() && self.id.precise().is_some() { diff --git a/src/cargo/sources/registry.rs b/src/cargo/sources/registry.rs index 3d0c67dca7f..49d9cf20796 100644 --- a/src/cargo/sources/registry.rs +++ b/src/cargo/sources/registry.rs @@ -187,7 +187,7 @@ pub struct RegistrySource<'cfg> { src_path: PathBuf, config: &'cfg Config, handle: Option, - sources: Vec>, + sources: HashMap>, hashes: HashMap<(String, String), String>, // (name, vers) => cksum cache: HashMap>, updated: bool, @@ -239,7 +239,7 @@ impl<'cfg> RegistrySource<'cfg> { config: config, source_id: source_id.clone(), handle: None, - sources: Vec::new(), + sources: HashMap::new(), hashes: HashMap::new(), cache: HashMap::new(), updated: false, @@ -366,7 +366,7 @@ impl<'cfg> RegistrySource<'cfg> { } /// Parse the on-disk metadata for the package provided - fn summaries(&mut self, name: &str) -> CargoResult<&Vec<(Summary, bool)>> { + pub fn summaries(&mut self, name: &str) -> CargoResult<&Vec<(Summary, bool)>> { if self.cache.contains_key(name) { return Ok(self.cache.get(name).unwrap()); } @@ -537,6 +537,7 @@ impl<'cfg> Source for RegistrySource<'cfg> { let url = try!(config.dl.to_url().map_err(internal)); for package in packages.iter() { if self.source_id != *package.source_id() { continue } + if self.sources.contains_key(package) { continue } let mut url = url.clone(); url.path_mut().unwrap().push(package.name().to_string()); @@ -551,14 +552,14 @@ impl<'cfg> Source for RegistrySource<'cfg> { })); let mut src = PathSource::new(&path, &self.source_id, self.config); try!(src.update()); - self.sources.push(src); + self.sources.insert(package.clone(), src); } Ok(()) } fn get(&self, packages: &[PackageId]) -> CargoResult> { let mut ret = Vec::new(); - for src in self.sources.iter() { + for src in self.sources.values() { ret.extend(try!(src.get(packages)).into_iter()); } return Ok(ret); diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 21aa840b7eb..de5302f6fdd 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -27,7 +27,7 @@ pub struct Config { cwd: PathBuf, rustc: PathBuf, rustdoc: PathBuf, - target_dir: Option, + target_dir: RefCell>, } impl Config { @@ -48,7 +48,7 @@ impl Config { values_loaded: Cell::new(false), rustc: PathBuf::from("rustc"), rustdoc: PathBuf::from("rustdoc"), - target_dir: None, + target_dir: RefCell::new(None), }; try!(cfg.scrape_tool_config()); @@ -101,11 +101,15 @@ impl Config { pub fn cwd(&self) -> &Path { &self.cwd } pub fn target_dir(&self, pkg: &Package) -> PathBuf { - self.target_dir.clone().unwrap_or_else(|| { + self.target_dir.borrow().clone().unwrap_or_else(|| { pkg.root().join("target") }) } + pub fn set_target_dir(&self, path: &Path) { + *self.target_dir.borrow_mut() = Some(path.to_owned()); + } + pub fn get(&self, key: &str) -> CargoResult> { let vals = try!(self.values()); let mut parts = key.split('.').enumerate(); @@ -237,9 +241,9 @@ impl Config { path.pop(); path.pop(); path.push(dir); - self.target_dir = Some(path); + *self.target_dir.borrow_mut() = Some(path); } else if let Some(dir) = env::var_os("CARGO_TARGET_DIR") { - self.target_dir = Some(self.cwd.join(dir)); + *self.target_dir.borrow_mut() = Some(self.cwd.join(dir)); } Ok(()) } diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 90b1dfac81f..b345f245033 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -563,4 +563,4 @@ pub static DOWNLOADING: &'static str = " Downloading"; pub static UPLOADING: &'static str = " Uploading"; pub static VERIFYING: &'static str = " Verifying"; pub static ARCHIVING: &'static str = " Archiving"; -pub static INSTALLED: &'static str = " Installed"; +pub static INSTALLING: &'static str = " Installing"; diff --git a/tests/support/registry.rs b/tests/support/registry.rs index 861bc5a11dc..be48cb7845e 100644 --- a/tests/support/registry.rs +++ b/tests/support/registry.rs @@ -55,7 +55,11 @@ pub fn mock_archive(name: &str, version: &str, deps: &[(&str, &str, &str)]) { } let p = project(name) .file("Cargo.toml", &manifest) - .file("src/lib.rs", ""); + .file("src/lib.rs", "") + .file("src/main.rs", &format!("\ + extern crate {}; + fn main() {{}} + ", name)); p.build(); let dst = mock_archive_dst(name, version); @@ -66,6 +70,8 @@ pub fn mock_archive(name: &str, version: &str, deps: &[(&str, &str, &str)]) { &mut File::open(&p.root().join("Cargo.toml")).unwrap()).unwrap(); a.append_file(&format!("{}-{}/src/lib.rs", name, version), &mut File::open(&p.root().join("src/lib.rs")).unwrap()).unwrap(); + a.append_file(&format!("{}-{}/src/main.rs", name, version), + &mut File::open(&p.root().join("src/main.rs")).unwrap()).unwrap(); a.finish().unwrap(); } diff --git a/tests/test_cargo_install.rs b/tests/test_cargo_install.rs new file mode 100644 index 00000000000..c2835792ce7 --- /dev/null +++ b/tests/test_cargo_install.rs @@ -0,0 +1,500 @@ +use std::fmt; +use std::fs::{self, File}; +use std::io::prelude::*; +use std::path::{Path, PathBuf}; + +use cargo::util::{process, ProcessBuilder}; +use hamcrest::{assert_that, existing_file, is_not, Matcher, MatchResult}; + +use support::{project, execs, cargo_dir}; +use support::{UPDATING, DOWNLOADING, COMPILING, INSTALLING, REMOVING}; +use support::paths; +use support::registry as r; +use support::git; + +use self::InstalledExe as has_installed_exe; + +fn setup() { + r::init(); +} + +fn cargo_process(s: &str) -> ProcessBuilder { + let mut p = process(&cargo_dir().join("cargo")).unwrap(); + p.arg(s).cwd(&paths::root()) + .env("HOME", &paths::home()) + .env_remove("CARGO_HOME"); + return p; +} + +fn exe(name: &str) -> String { + if cfg!(windows) {format!("{}.exe", name)} else {name.to_string()} +} + +fn cargo_home() -> PathBuf { + paths::home().join(".cargo") +} + +struct InstalledExe(&'static str); + +impl> Matcher

for InstalledExe { + fn matches(&self, path: P) -> MatchResult { + let path = path.as_ref().join("bin").join(exe(self.0)); + existing_file().matches(&path) + } +} + +impl fmt::Display for InstalledExe { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "installed exe `{}`", self.0) + } +} + +test!(simple { + r::mock_pkg("foo", "0.0.1", &[]); + + assert_that(cargo_process("install").arg("foo"), + execs().with_status(0).with_stdout(&format!("\ +{updating} registry `[..]` +{downloading} foo v0.0.1 (registry file://[..]) +{compiling} foo v0.0.1 (registry file://[..]) +{installing} {home}[..]bin[..]foo[..] +", + updating = UPDATING, + downloading = DOWNLOADING, + compiling = COMPILING, + installing = INSTALLING, + home = cargo_home().display()))); + assert_that(cargo_home(), has_installed_exe("foo")); + + assert_that(cargo_process("uninstall").arg("foo"), + execs().with_status(0).with_stdout(&format!("\ +{removing} {home}[..]bin[..]foo[..] +", + removing = REMOVING, + home = cargo_home().display()))); + assert_that(cargo_home(), is_not(has_installed_exe("foo"))); +}); + +test!(pick_max_version { + r::mock_pkg("foo", "0.0.1", &[]); + r::mock_pkg("foo", "0.0.2", &[]); + + assert_that(cargo_process("install").arg("foo"), + execs().with_status(0).with_stdout(&format!("\ +{updating} registry `[..]` +{downloading} foo v0.0.2 (registry file://[..]) +{compiling} foo v0.0.2 (registry file://[..]) +{installing} {home}[..]bin[..]foo[..] +", + updating = UPDATING, + downloading = DOWNLOADING, + compiling = COMPILING, + installing = INSTALLING, + home = cargo_home().display()))); + assert_that(cargo_home(), has_installed_exe("foo")); +}); + +test!(missing { + r::mock_pkg("foo", "0.0.1", &[]); + assert_that(cargo_process("install").arg("bar"), + execs().with_status(101).with_stderr("\ +could not find `bar` in `registry file://[..]` +")); +}); + +test!(bad_version { + r::mock_pkg("foo", "0.0.1", &[]); + assert_that(cargo_process("install").arg("foo").arg("--vers=0.2.0"), + execs().with_status(101).with_stderr("\ +could not find `foo` in `registry file://[..]` with version `0.2.0` +")); +}); + +test!(no_crate { + assert_that(cargo_process("install"), + execs().with_status(101).with_stderr("\ +must specify a crate to install from crates.io +")); +}); + +test!(install_location_precedence { + r::mock_pkg("foo", "0.0.1", &[]); + + let root = paths::root(); + let t1 = root.join("t1"); + let t2 = root.join("t2"); + let t3 = root.join("t3"); + let t4 = cargo_home(); + + fs::create_dir(root.join(".cargo")).unwrap(); + File::create(root.join(".cargo/config")).unwrap().write_all(format!("\ + [install] + root = '{}' + ", t3.display()).as_bytes()).unwrap(); + + println!("install --root"); + + assert_that(cargo_process("install").arg("foo") + .arg("--root").arg(&t1) + .env("CARGO_INSTALL_ROOT", &t2), + execs().with_status(0)); + assert_that(&t1, has_installed_exe("foo")); + assert_that(&t2, is_not(has_installed_exe("foo"))); + + println!("install CARGO_INSTALL_ROOT"); + + assert_that(cargo_process("install").arg("foo") + .env("CARGO_INSTALL_ROOT", &t2), + execs().with_status(0)); + assert_that(&t2, has_installed_exe("foo")); + assert_that(&t3, is_not(has_installed_exe("foo"))); + + println!("install install.root"); + + assert_that(cargo_process("install").arg("foo"), + execs().with_status(0)); + assert_that(&t3, has_installed_exe("foo")); + assert_that(&t4, is_not(has_installed_exe("foo"))); + + fs::remove_file(root.join(".cargo/config")).unwrap(); + + println!("install cargo home"); + + assert_that(cargo_process("install").arg("foo"), + execs().with_status(0)); + assert_that(&t4, has_installed_exe("foo")); +}); + +test!(install_path { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(0)); + assert_that(cargo_home(), has_installed_exe("foo")); +}); + +test!(multiple_crates_error { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", "fn main() {}") + .file("a/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("a/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(101).with_stderr("\ +multiple packages with binaries found: bar, foo +")); +}); + +test!(multiple_crates_select { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", "fn main() {}") + .file("a/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("a/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("foo"), + execs().with_status(0)); + assert_that(cargo_home(), has_installed_exe("foo")); + assert_that(cargo_home(), is_not(has_installed_exe("bar"))); + + assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("bar"), + execs().with_status(0)); + assert_that(cargo_home(), has_installed_exe("bar")); +}); + +test!(multiple_crates_auto_binaries { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "a" } + "#) + .file("src/main.rs", "extern crate bar; fn main() {}") + .file("a/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("a/src/lib.rs", ""); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(0)); + assert_that(cargo_home(), has_installed_exe("foo")); +}); + +test!(multiple_crates_auto_examples { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "a" } + "#) + .file("src/lib.rs", "extern crate bar;") + .file("examples/foo.rs", " + extern crate bar; + extern crate foo; + fn main() {} + ") + .file("a/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("a/src/lib.rs", ""); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()) + .arg("--example=foo"), + execs().with_status(0)); + assert_that(cargo_home(), has_installed_exe("foo")); +}); + +test!(no_binaries_or_examples { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "a" } + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("a/src/lib.rs", ""); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(101).with_stderr("\ +no packages found with binaries or examples +")); +}); + +test!(no_binaries { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", "") + .file("examples/foo.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("foo"), + execs().with_status(101).with_stderr("\ +specified package has no binaries +")); +}); + +test!(examples { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", "") + .file("examples/foo.rs", "extern crate foo; fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()) + .arg("--example=foo"), + execs().with_status(0)); + assert_that(cargo_home(), has_installed_exe("foo")); +}); + +test!(install_twice { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(0)); + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(101).with_stderr("\ +binary `foo[..]` already exists in destination as part of `foo v0.1.0 ([..])` +")); +}); + +test!(compile_failure { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", ""); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(101).with_stderr("\ +error: main function not found +error: aborting due to previous error +failed to compile `foo v0.1.0 (file://[..])`, intermediate artifacts can be \ + found at `[..]target-install` + +Caused by: + Could not compile `foo`. + +To learn more, run the command again with --verbose. +")); +}); + +test!(git_repo { + let p = git::repo(&paths::root().join("foo")) + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()), + execs().with_status(0).with_stdout(&format!("\ +{updating} git repository `[..]` +{compiling} foo v0.1.0 ([..]) +{installing} {home}[..]bin[..]foo[..] +", + updating = UPDATING, + compiling = COMPILING, + installing = INSTALLING, + home = cargo_home().display()))); + assert_that(cargo_home(), has_installed_exe("foo")); + assert_that(cargo_home(), has_installed_exe("foo")); +}); + +test!(list { + r::mock_pkg("foo", "0.0.1", &[]); + r::mock_pkg("bar", "0.2.1", &[]); + r::mock_pkg("bar", "0.2.2", &[]); + + assert_that(cargo_process("install").arg("--list"), + execs().with_status(0).with_stdout("")); + + assert_that(cargo_process("install").arg("bar").arg("--vers").arg("=0.2.1"), + execs().with_status(0)); + assert_that(cargo_process("install").arg("foo"), + execs().with_status(0)); + assert_that(cargo_process("install").arg("--list"), + execs().with_status(0).with_stdout("\ +bar v0.2.1 (registry [..]): + bar[..] +foo v0.0.1 (registry [..]): + foo[..] +")); +}); + +test!(uninstall_pkg_does_not_exist { + assert_that(cargo_process("uninstall").arg("foo"), + execs().with_status(101).with_stderr("\ +package id specification `foo` matched no packages +")); +}); + +test!(uninstall_bin_does_not_exist { + r::mock_pkg("foo", "0.0.1", &[]); + + assert_that(cargo_process("install").arg("foo"), + execs().with_status(0)); + assert_that(cargo_process("uninstall").arg("foo").arg("--bin=bar"), + execs().with_status(101).with_stderr("\ +binary `bar[..]` not installed as part of `foo v0.0.1 ([..])` +")); +}); + +test!(uninstall_piecemeal { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("src/bin/foo.rs", "fn main() {}") + .file("src/bin/bar.rs", "fn main() {}"); + p.build(); + + assert_that(cargo_process("install").arg("--path").arg(p.root()), + execs().with_status(0)); + assert_that(cargo_home(), has_installed_exe("foo")); + assert_that(cargo_home(), has_installed_exe("bar")); + + assert_that(cargo_process("uninstall").arg("foo").arg("--bin=bar"), + execs().with_status(0).with_stdout(&format!("\ +{removing} [..]bar[..] +", removing = REMOVING))); + + assert_that(cargo_home(), has_installed_exe("foo")); + assert_that(cargo_home(), is_not(has_installed_exe("bar"))); + + assert_that(cargo_process("uninstall").arg("foo").arg("--bin=foo"), + execs().with_status(0).with_stdout(&format!("\ +{removing} [..]foo[..] +", removing = REMOVING))); + assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + + assert_that(cargo_process("uninstall").arg("foo"), + execs().with_status(101).with_stderr("\ +package id specification `foo` matched no packages +")); +}); diff --git a/tests/tests.rs b/tests/tests.rs index ad6d9abb883..612d11e0344 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -48,6 +48,7 @@ mod test_cargo_features; mod test_cargo_fetch; mod test_cargo_freshness; mod test_cargo_generate_lockfile; +mod test_cargo_install; mod test_cargo_new; mod test_cargo_package; mod test_cargo_profiles; From 42ddfb2df5b58ea88b3e485a2bb0903888071569 Mon Sep 17 00:00:00 2001 From: Carlos Liam Date: Mon, 19 Oct 2015 11:17:53 -0400 Subject: [PATCH 0082/3888] Clean whitespace Remove leading newlines; replace lines containing only whitespace with empty lines; replace multiple trailing newlines with a single newline; remove trailing whitespace in lines --- src/cargo/ops/cargo_rustc/job_queue.rs | 2 +- src/etc/_cargo | 6 +++--- tests/test_cargo_cross_compile.rs | 4 ++-- tests/test_cargo_run.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 5966ca3edbf..6dea0a60df7 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -203,7 +203,7 @@ impl<'a> JobQueue<'a> { // out any more information for a package after we've printed it once. fn note_working_on(&mut self, config: &Config, key: &Key<'a>, fresh: Freshness) -> CargoResult<()> { - if (self.compiled.contains(key.pkg) && !key.profile.doc) || + if (self.compiled.contains(key.pkg) && !key.profile.doc) || (self.documented.contains(key.pkg) && key.profile.doc) { return Ok(()) } diff --git a/src/etc/_cargo b/src/etc/_cargo index f7015de8bae..2f8a2c824b9 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -306,7 +306,7 @@ regexp-replace manifest '\{"root":"|"\}' '' echo $manifest } -# Extracts the values of "name" from the array given in $1 and shows them as +# Extracts the values of "name" from the array given in $1 and shows them as # command line options for completion _get_names_from_array() { @@ -325,7 +325,7 @@ _get_names_from_array() do if [[ $last_line == "[[$block_name]]" ]]; then in_block=true - else + else if [[ $last_line =~ '.*\[\[.*' ]]; then in_block=false fi @@ -336,7 +336,7 @@ _get_names_from_array() regexp-replace line '^.*name *= *|"' "" names+=$line fi - fi + fi last_line=$line done < $manifest diff --git a/tests/test_cargo_cross_compile.rs b/tests/test_cargo_cross_compile.rs index ca75fac3548..623de021b3f 100644 --- a/tests/test_cargo_cross_compile.rs +++ b/tests/test_cargo_cross_compile.rs @@ -568,10 +568,10 @@ test!(build_script_needed_for_host_and_target { .with_stdout_contains(&format!("\ {compiling} d1 v0.0.0 ({url})", compiling = COMPILING, url = p.url())) .with_stdout_contains(&format!("\ -{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`", +{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`", running = RUNNING, dir = p.root().display())) .with_stdout_contains(&format!("\ -{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`", running = RUNNING, +{running} `{dir}[..]target[..]build[..]d1-[..]build-script-build`", running = RUNNING, dir = p.root().display())) .with_stdout_contains(&format!("\ {running} `rustc d1[..]src[..]lib.rs [..]`", running = RUNNING)) diff --git a/tests/test_cargo_run.rs b/tests/test_cargo_run.rs index 11a9d931142..1cb3550aaf6 100644 --- a/tests/test_cargo_run.rs +++ b/tests/test_cargo_run.rs @@ -501,7 +501,7 @@ test!(run_from_executable_folder { let cwd = p.root().join("target").join("debug"); p.cargo_process("build").exec_with_output().unwrap(); - assert_that(p.cargo("run").cwd(cwd), + assert_that(p.cargo("run").cwd(cwd), execs().with_status(0).with_stdout(&format!("\ {running} `.{sep}foo[..]` hello From 57ef59cc36c2e6a26f56fc46df316aaf8955b349 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Tue, 20 Oct 2015 13:26:16 -0400 Subject: [PATCH 0083/3888] Correct spelling in docs --- src/cargo/core/manifest.rs | 4 ++-- src/cargo/core/resolver/mod.rs | 2 +- src/doc/build-script.md | 2 +- src/doc/faq.md | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 7d99b7c794d..68f3d2d4c1d 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -10,7 +10,7 @@ use core::package_id::Metadata; use core::dependency::SerializedDependency; use util::{CargoResult, human}; -/// Contains all the informations about a package, as loaded from a Cargo.toml. +/// Contains all the information about a package, as loaded from a Cargo.toml. #[derive(Clone, Debug)] pub struct Manifest { summary: Summary, @@ -130,7 +130,7 @@ pub struct Profiles { pub custom_build: Profile, } -/// Informations about a binary, a library, an example, etc. that is part of the +/// Information about a binary, a library, an example, etc. that is part of the /// package. #[derive(Clone, Hash, PartialEq, Eq, Debug)] pub struct Target { diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index bfade996269..465bc1a73d4 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -24,7 +24,7 @@ //! * Never try to activate a crate version which is incompatible. This means we //! only try crates which will actually satisfy a dependency and we won't ever //! try to activate a crate that's semver compatible with something else -//! activatd (as we're only allowed to have one). +//! activated (as we're only allowed to have one). //! * Always try to activate the highest version crate first. The default //! dependency in Cargo (e.g. when you write `foo = "0.1.2"`) is //! semver-compatible, so selecting the highest version possible will allow us diff --git a/src/doc/build-script.md b/src/doc/build-script.md index 7f1016d29a2..8874bf91260 100644 --- a/src/doc/build-script.md +++ b/src/doc/build-script.md @@ -304,7 +304,7 @@ fn main() { } ``` -This build script starts out by compiling out C file into an object file (by +This build script starts out by compiling our C file into an object file (by invoking `gcc`) and then converting this object file into a static library (by invoking `ar`). The final step is feedback to Cargo itself to say that our output was in `out_dir` and the compiler should link the crate to `libhello.a` diff --git a/src/doc/faq.md b/src/doc/faq.md index 1c6963ac258..61e0e8d61fc 100644 --- a/src/doc/faq.md +++ b/src/doc/faq.md @@ -135,7 +135,7 @@ wildcard dependency constraints.** While they _can_, strictly speaking, they should not. A version requirement of `*` says “This will work with every version ever,” which is never going -to be true. Libraries should always specifiy the range that they do work with, +to be true. Libraries should always specify the range that they do work with, even if it’s something as general as “every 1.x.y version.” # Why `Cargo.toml`? From fafb77ec916fd45ef8dae136587c3831e06a7a86 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 20 Oct 2015 15:50:58 -0700 Subject: [PATCH 0084/3888] Always use the root package's set of profiles When testing or building multiple packages via the `-p` argument the root package's profiles should always be used instead of the sub-package's set of profiles. --- src/cargo/ops/cargo_compile.rs | 18 ++++++++++------- tests/test_cargo_test.rs | 36 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index e9263a69d1b..d4c4fef47d1 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -29,7 +29,7 @@ use std::sync::Arc; use core::registry::PackageRegistry; use core::{Source, SourceId, PackageSet, Package, Target}; -use core::{Profile, TargetKind}; +use core::{Profile, TargetKind, Profiles}; use core::resolver::Method; use ops::{self, BuildOutput, ExecEngine}; use util::config::{ConfigValue, Config}; @@ -145,10 +145,11 @@ pub fn compile_pkg<'a>(root_package: &Package, }; let resolved_with_overrides = - try!(ops::resolve_with_previous(&mut registry, root_package, method, - Some(&resolve), None)); + try!(ops::resolve_with_previous(&mut registry, root_package, + method, Some(&resolve), None)); - let packages = try!(ops::get_resolved_packages(&resolved_with_overrides, &mut registry)); + let packages = try!(ops::get_resolved_packages(&resolved_with_overrides, + &mut registry)); (packages, resolved_with_overrides, registry.move_sources()) }; @@ -176,10 +177,12 @@ pub fn compile_pkg<'a>(root_package: &Package, let mut general_targets = Vec::new(); let mut package_targets = Vec::new(); + let profiles = root_package.manifest().profiles(); match *target_rustc_args { Some(args) => { if to_builds.len() == 1 { - let targets = try!(generate_targets(to_builds[0], mode, filter, release)); + let targets = try!(generate_targets(to_builds[0], profiles, + mode, filter, release)); if targets.len() == 1 { let (target, profile) = targets[0]; let mut profile = profile.clone(); @@ -199,7 +202,8 @@ pub fn compile_pkg<'a>(root_package: &Package, } None => { for &to_build in to_builds.iter() { - let targets = try!(generate_targets(to_build, mode, filter, release)); + let targets = try!(generate_targets(to_build, profiles, mode, + filter, release)); package_targets.push((to_build, targets)); } } @@ -273,11 +277,11 @@ impl<'a> CompileFilter<'a> { /// Given the configuration for a build, this function will generate all /// target/profile combinations needed to be built. fn generate_targets<'a>(pkg: &'a Package, + profiles: &'a Profiles, mode: CompileMode, filter: &CompileFilter, release: bool) -> CargoResult> { - let profiles = pkg.manifest().profiles(); let build = if release {&profiles.release} else {&profiles.dev}; let test = if release {&profiles.bench} else {&profiles.test}; let profile = match mode { diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 7a269f26adc..f5ebe9dcc63 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -2021,3 +2021,39 @@ test!(bin_does_not_rebuild_tests { {running} `rustc src[..]main.rs [..]` ", compiling = COMPILING, running = RUNNING))); }); + +test!(selective_test_wonky_profile { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [profile.release] + opt-level = 2 + + [dependencies] + a = { path = "a" } + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("test").arg("-v").arg("--no-run").arg("--release") + .arg("-p").arg("foo").arg("-p").arg("a"), + execs().with_status(0).with_stdout(&format!("\ +{compiling} a v0.0.1 ([..]) +{running} `rustc a[..]src[..]lib.rs [..]` +{running} `rustc a[..]src[..]lib.rs [..]` +{compiling} foo v0.0.1 ([..]) +{running} `rustc src[..]lib.rs [..]` +{running} `rustc src[..]lib.rs [..]` +", compiling = COMPILING, running = RUNNING))); +}); From 0954c807fde6298f440f35128b15f7d8920aaa2b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 20 Oct 2015 17:19:56 -0700 Subject: [PATCH 0085/3888] Allow testing optional dependencies Previously a warning was issued if both -p and --features were passed as flags, and the rationale for this was that if --features modified the activated set of features in the package selected by -p it would alter Cargo.lock, which is undesirable as Cargo.lock should be stable. This commit, however, interprets --features as changing the resolved graph of the top-level package, and then -p is a query on that resolved graph. This way the Cargo.lock file never changes and you're allowed to test optional dependencies. --- src/cargo/ops/cargo_compile.rs | 4 ---- tests/test_cargo_test.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index d4c4fef47d1..a00b86ff912 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -110,10 +110,6 @@ pub fn compile_pkg<'a>(root_package: &Package, s.split(' ') }).map(|s| s.to_string()).collect::>(); - if spec.len() > 0 && (no_default_features || features.len() > 0) { - return Err(human("features cannot be modified when the main package \ - is not being built")) - } if jobs == Some(0) { return Err(human("jobs must be at least 1")) } diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index f5ebe9dcc63..3cfb35cd2bb 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -2057,3 +2057,33 @@ test!(selective_test_wonky_profile { {running} `rustc src[..]lib.rs [..]` ", compiling = COMPILING, running = RUNNING))); }); + +test!(selective_test_optional_dep { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a", optional = true } + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("test").arg("-v").arg("--no-run") + .arg("--features").arg("a").arg("-p").arg("a"), + execs().with_status(0).with_stdout(&format!("\ +{compiling} a v0.0.1 ([..]) +{running} `rustc a[..]src[..]lib.rs [..]` +{running} `rustc a[..]src[..]lib.rs [..]` +", compiling = COMPILING, running = RUNNING))); +}); From 9d9db23e6cee0558fd31f7a11e6ac21cd64771f1 Mon Sep 17 00:00:00 2001 From: Carlos Liam Date: Wed, 21 Oct 2015 12:57:20 -0400 Subject: [PATCH 0086/3888] Cleanup Whitespace: remove leading newlines; replace lines containing only whitespace with empty lines; replace multiple trailing newlines with a single newline; remove trailing whitespace in lines. Images: Compress PNG files with zopflipng, JPG files with mozjpeg jpegtran, and GIF files with gifsicle. --- src/doc/images/Cargo-Logo-Small.png | Bin 68186 -> 58168 bytes src/doc/images/auth-level-acl.png | Bin 199296 -> 90300 bytes src/doc/images/circle-with-i.png | Bin 1484 -> 496 bytes src/doc/images/forkme.png | Bin 5333 -> 4725 bytes src/doc/images/noise.png | Bin 12873 -> 3190 bytes src/doc/images/org-level-acl.png | Bin 181878 -> 76572 bytes src/doc/images/search.png | Bin 411 -> 312 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/doc/images/Cargo-Logo-Small.png b/src/doc/images/Cargo-Logo-Small.png index eca9665f62e05e5c1c6be6a28c97617e7548da68..e3a99208c287bc3fba67de085255df1b4ad22c0a 100644 GIT binary patch literal 58168 zcmV)>K!d-DP)qr?$rj3;+NC0000000000000000000000000000000001hnzLgMuo5Ie z9LB$Y&#cb2ZQHhO+eU1k;+$>Uwr%_Qofp$pw>lf)>tFIMW;+{KYG(L>!)F=1=YYco z?%MmI&+gp!tbuzDS!v|KqqBDWU!_w2|DUE(kDOQ;df=$_2JSxa!ht*Y8XdTO7azQR zCm*yQtG_?ACkn(<}F&^?kH>QB5N*+wZICZ zMXVhXK^b|TgUXo7!zxv-4_Wp6tWmh?jSW54_pqX|uE*vi zcngc|%*cZXp?}sKZx=$q6$l|GWF=fBS5|pSdG(@@SFZ*>CrSRkw2>wMoDoE9F6ptc ztE|4gTXRk;niNF~VFWn>%zN+d;Piw5k}z|k^*-l$jzXsrrqURpdP82Wp0BL(@ZZ_e zl0@z28T?I2+P`}FT1P!oQLW~%BxobpOPehK!Xn+N0R&zNjcVBh1l5LV`EDz>eK%)yn+nj zxI0C3BnUwS3HScsqC*6Mq;}wdJK&%ILYO;0a6||hkP-3{rt-M5%1t4!UO*^42((C& zpP-?KemlsLWU#dIoKrMk-mcpGVAocwv9uLUGDUy^(LvmvPWnRZ0NByxdeEDn?Zm35)eWFf%k`wyVDVZy5Z1@2K+R* ztbaxlZjJ+a9uQ#WboAel9Jh!No=-+;^4Z$WPF9nOk@hUAokZQb0-f% z649I=NPz!zJ8ACyVI@j=z}+$b=^TPAfSX|!QC20?X6O#EtTr949FI+~76?LC>YizN zmAX$_yz=hYV>jRR#Dxz%`t%LJ5EDwGWtLrzi6^PW&!^gYoq0FgX@mLqDC@g5EjG%+ zDT)HK2oCPnyRDNb%)0O2vvXEaawN%`{>l32OZeZ=<28FI`eZHN9ps6eBfB9mjDZZa-qCdp-ZzNr5Z{Be>~?F`x1VQq>uJ(( zi&-noX8qZk(f2c^>^D>NUxw@cy}JG@feo+6+6Q7^k2$h^O(C`^?tZ3Y`t8KsFOJi2 z1p>s$ETfjbRVhHGkA^bS7>Eq-Zut1r%J{k ziXf;fVO!UtuKjR!{kzca9l(cp-PFG1<~RHqURSlBcl?wbcE2Ho-ET^9c$4G_Qt5k< zaV6e>K(0M3A!h2SWJ*whgpkX=h@uKLI+3#dTuv2Wl+#IDF+`kXT-)Pj595BwI`$8s z&Osa?4M+|KrlD9z5ux#}K*@t^Q9mP#vRmEdyLkH@SP`X@=96Xk^F1ys;*KMyiq& z0V%H$gVa4x6N7RM?%ICNWgh@V)P8M5yIs=uYeD|q?6F_?#lVVvy=F>QAN@S`_1dZC z@>36<{@}m-m0?)_wsbb{nB(Y$fRe~586a{|NR5;7j~Plv)k;OG3Zw3U*fMYtVvSSS zJ|ZQ!N-dRy0aF_2?x+2s(CWd%){HlBg&mTtac|af3W=0WebF@Dmii9oW~Sh_+ZCrb zpJQ|9IhgJ;?}XW`11az->3@-XCIAX>soymv123Wma8$(hGSutT!wLit5@IUN`Id}- zroHb??`a?UF>eQcfPG!~lI`qI51;tj=7Asa@7o7|%opx+X&1L-y7NKyb-_zq z`_i}nlYcaBm%pQN=}O~4b0CJD0mDfKa+$y&C*dGANhdlVYC{ zLQ+#_uIcTtL7Iaf?5_RPp9S1xUl*=q^YJfWUl+UF!6VmKA9~Mwx5IdOx4z4?J;7;W z)^~X4$Y~^(CsGIoA!05O2?VN|qMRr~oeYwydTd84*o2g#*+LPIpWSD(j=H#tx}KaS z;$(??R19A1#z?f@moV>Ji%p<5N<@-|aoDlG`y%Vx&l0w`n6=5&m-oJ^tCVW5?%tvF z3LC7X44(r8v#eBbiBMpc%6F{$2I*8GE%ki^djb`QZ(6%&ZRaFuvS=eIv&_TE*QT&L zcE0)Ctld6ndx1(`{hB|*zAkoMdeiSbUjE>}cyAUx^6i3gg57q_c6H0FT;KJ~=QD&v z2xd78lz^K1s!j4@rE0^!^pXTM03>V314y%=J3KCl`yne00oW>F%|2JODG?dEUQ zrvGwa$^XyVKk9lPzqsf%fAUuz-}$b8{N6C_j=XQd&uQoPk)*Q-!|LP~)9w_nFq_SB z-Xl3c8X-r_W+^q_1)!p3&)`K)2}pKw=w}b02aj6jOSCn`Cuu+kk3|+whpAnQS&aPpH z1KK@}wx5Ca?*zV=ef@t>WMBKIxY)I?!%zLS$G5-Z@4Pn*r$-88JWYQ<){bU&ANU1m z%VvGbc6pmLZRz{Y#&pb1g#l6kA_^5|_hn9QJcA|fbz(7Zt;uhR`&?jZQ4TrRWY5&5KAbyIG&Na3 zr*$Ab#@g2^CzR=IuE8~3j?$yP2T_S(BFDj&WCNI4>ktFvgex%= z6{$cpNNQ1YVu~)P@4gA`-X^a5{QXln{@<0{*gqlm!q>qk|ElBL-~M;rJ8kbAd5MIS zXqt|g1m7)4w6wF!&>SMo0U<=z%iD~b6O_n&KBwzigI1ab1Dn@~Yv$Of(Be^Cf1g2s zw1c=aHIib$P8~~LtZlq4QI9&aVdSh>uxZ2n+&3xO_I_r53UgA)72K%IaRzIU@P0dPSf-=}O~ zOm$dZREPztBK02XeMbYUL!CEkjkY($^`9$eP{Z}#0tEhV);`()7rEHAulZBI?D+P# z{p~Z5-97Re3{>8G>t%W05)!nXHKx&Kfi{P@{xWFCcC%);zRk2-(RVHL#eqSqIeZMa zxMrWpVPgPF(}oyFrfFgvCsKr_Q7kf1tfRrtHB7^n)7vj__tmFK!)+E_wsE1RB<`z) zt%K&AfBbc|fPjHn0Fk;^rweLxU&Iz-iVnLsFJ#pBX%IBe;s3K$>&e`-p64!lSlI|Vi`p*EK zWnZ6&ifmttPx_U|x6Xkq#$;fbreKg6r)asW7zOnWrk4C1Z4YqWC0u*SKC@ZgqPzN& zXdn3DbdAI3HF3C08kfXz!?4>hO#?!t^n2q;qXUzoDVHLdTQR%>`(iJh;UDOKVoC>bT8`2HwMbIGD1 zkR(il_4KO zt;^;OUj=O0*Z+}{r@!@IaItG&4?X&31KG4Y1DTj2GYc~e0Yqs$c&9~8D7g$sXKAf> zrOm=DXVV?fJ@WHdrz4gpw-7S(-s2>Yr!}N4UM7@W<`G+i!fw0df(HVt@OpP&x=q&>z$%fXFBa#-eLRHJ-f&9 zYbd7FL;{H0qoGA8(OYbj8mfP8ZOP}^o@WByUi)fGkC3TeVn*? zmDWuh^({@)lM@KlO4Yf`l&KG2EIhM)5vh;KE@MTuNcLV;L16u~3a@i2s5IBH>pQQ+ zEFg}AAkOEeyORCEbzy#;>@JBqNYk1$j=1iK*+V~)w7W}KK2KV|h)$1(B2=QRc~{9kj@2+5vct-i@BsStC~5}(;>*sQ@YhO=1^1$)UZ~dERitOab%T$7%j`x0iNlNgB$L1_% z4P%IiD3D9;ijwHp`e>f+v0qGg=`q5%!h)aL5w&N%6?Q=xhJp19--Zh}X?0}LL+3#x zL9v4=W-{k1<5WRPA1qWmR>!2y+dvhmpN-{OA{0wnPayBOl*DtbL9A|g% zxaj<eZG!Nt~MKMXuowZ);h*p(p zP)|zB8Hj<63{DkQD%gRVeXBh+s@2AOho~c?_8Ql}G`3HC_O^Nat@+B2{VpJ~um7Qv zk9^?!x!AR@YX_&tH@@X>zBdkckCb2_yLB3Q`sFQTc;Z^ewfkq*2UB(SzN>wzjKM7@ zgHe0^=hGctBW!QuG?Nf~cNy*Oqggz}%Qx=w$_Kuf%iW0PiCN#$^*w3;8;M~A5_--q zrUD(awECYl!|U_?h5F2}`dS1)>R6O3Dh8wmVY4YY>(|k=vrIG3F*i8hs2silcj-yX zr={_PG@Ov972~jBx7`xLgh-}u)rQp(2ihRb993_5vABMjY4se_<~BmYId3Yh+TjG= z%e}+rKuQ>V5&H}X=K)-;YltP&rr?T2K0i98W>pm}2Nd9<%#Xk0+unEc?f>kZ-}u?U zOYG~vS?=RM@a25j7rtk|F7WzwzxG!hZl3#^KN7;OS4qTZy)7U!Oc?<#A2byxKnaUN zrbZQP!(Dp9dS7Y0W2cqlZiS|i6nBU~oCf-Qg9jhFW+$KHlvu4!8OIUPhNhe0v@u9! zGSsI}XdTEdRi_1jI{#R#Bm$J%Esgzp0$Eg?fOxytrdwp~E@jsr<>cm)6Pm+D&S1>u z#t(4v!gsT}^E@dgTr)EuILWjgx<*JjG1v%Iu;#u>MAAr31BkQWZ+rQ1dv2O@jlnHU zTPOz(>I8*4<5?gD^@O!%)$rweoIiC{HQ<%+MJ-jaWpGQW{hvFSLYqG_F4QqXV;^mlEO~L&25Nf%Aj07<^<#dYDYht(dEoIov^$4J>0zU zUYfW8jyg6Gb*rbA~wB-&_G0^qxNRAt_Ht6hO{K0knxFW1xAZ=bE z4kzRkNtFNN5CLkh59i8Zff~eZWwZ4BXAuqnQR<_{Q?Z#LW*R4WgIzYjZZ<1c>ov2c zebXDRw|{q7-T2FB|JB-bZxz>n>3+@=*)~of>8t)7^VH$u0^+^*Ha2eDJxRi{= z5wf^h)@G3rFF8k@#x>zTvUe82k|bSr{;sw&Z^Az-ys(~1QOr{G>Om0EDe4pjR59#L@c)P_tq=A$o$K%K_PK5(!wnN^7 zH-^4Fw`EC(*XZtZ((VOu+L4l=_>+AF25R}9s?vaRp3myugEt*)aUv(@PAJZ}nNE!J z*-m+kEta4N-4PIX z>ak{|-8^&O%L2#JB&-`Tj2^XFAUpKh7jde}en?ddKW1{Fe8g z|BFBMKjY!{!pq1wR*8}^`-jPx{VAnFA8^hA#lAW(j3p`8&m(Dp0T&k5Zn>U&cg?6V}Q@q%S(O)!9q zDUk>o+F5e#0`L;2!KHDB7JHy96*2%-1nRc)JlO`G5%TV*Jas%im+a{pCFN}b-G7|AJu{Q>VB35Sv=vc7v6n*Ohg@Bfne?q32E z-|z^|2kztR9twF8ZZ0l>;v|tvlH%%GnDv$VB;{|4XE^RnwxmWsXc0ifBfbS0YELbH zj(jNzK@2c;+LI<_(j!xHr0xdwy}4+dpFcn^o^aT2*l%w*3+`nX8e~Rv387Mnr z^gCiY0kA>{)}#gO5KfIRg*sGFh$#Uenc_kLNX`EaigyXpM2yGB!?^oh;+x+YLjPY~ z)BhDD{4ns0Z)gOG2mb$v`$(E_1!fc{3P9aQspWSiXDkYk&+*)S@=uU>VEO*9pu7BO z4C71s*#f7Sj0txHw16K}hX+lNDrf?e9S|ewI1-aX#ygUJ zbUI3kX3U5~h|Xi5(+Gg`Qr%sZl67UeLw-&ys@WpM>Q-TA!5e_QA$O8O#uekGtr}3> zGi?7i*Ec^(>K-w>_=x4jQ~KEop9Vtir`ZCPablQ`csJ4nZ=i;FTxe~$&@A3JGVZi} zZYl!C8@wopFZSY!;7{&74+~u7+yQkM;vjfe9B!xjJk{wogPkgxUu(dPUy_A(!};{@Rs!* z2lHt|Q!GZ7X&MmU*g&N@``CUabxa0^M_j$nlY6g{rdo=k6tF`e)&4)OW}5i|anzDq zT;}0*D4xS{YB!tB2gkcF9$xdwbP-|&F=fa0t)^!qQ6DYE~59fj@fnkhP(*%^z~+Sv-H6PhNHU8w+T z6WocIoD+gAL``TGgE!8Vexgb$&*Z&OJ;y3&8>9tKAka367;hM^UvqQyzgf?p*s!Eu zJ)&tBR$4ag!NB-1WNzAFA~ZtRG?;=QYeU`qJ!Z=f=!Okx|2fm<3#P+eE~$MnqO|+O zeip@p764CV%c4x}FckzMt(CViDx2+&{o#oCo__I&%d>NcMR5Utq#z$@GQww`qOM!spZf2AW850ufw)Nq6y+ zY0iE!-TV=bNIc##9yeBEk|HkmssthB>_UK$%OW%yYkoX#Vcg<~c;6wev-db635WU_ z66VI6a?TfRW=eX}Yf@mGa%N*CXrZ9k1ycHIO~}4u`T2@A60x&X_Fpze~GhnBev6D_&pUGRd5? z$3KyG-usxvOwj!o47cAkJ!#xu0qGle1xS3o<31Dx(n)3{C<5hmDu#awoB~+sqnu

(FRB<^BZBe12=hny_8co;;$Z!+F&ec3CyL8pQ7w7u&P>&l4M=5LCn&}> zGmt#sGZ9ss$7SUK2)G`cLOf#9B2hH6;jLfiodFb3rg^pWs?Hh-psc?u+Q@vrQuhV` zT0zY~xotbTR*7-X{`P-!b^UF8|B%_`$1KjD5==obFb@Z2-N-na9E!W`5ibL6>*>1@ zNjp>;T=x(^e?qv}lXhPccb_vIu9(J1#Kh$0((42g0?C1I@V>QY*=+Y5jz?UWF*|>s ze!jpnnFGjh+?r`7YNb2s8eqmZF#=!rxR1PstqQMCjSBUo`~wOQQJVY)S_KeOa>NAQ z7kNzqM+N&EDca}6R-|3fE=+HUcM!*c>2QN;%H>?XHzoITvV{*6f~uT)-4jd3Q?`AV z(lf?^G!A7;k+|FeAwin(O-o80)3C=$!uz~o9hfS30YVcb--DL2F>4x0DL*SIXF=|i zn5rO-OqmdOlkUxxFUgnJpf0d3kR4$h2kL ze8x2G%!>^sSOG8Pv4&gE%Epq9~Ou?hMcXu{WNS zqXp2?g!A4&tC>Hfon4w7W*i6Nutg=}%M?u+CoQF2aK_^*U_kX5t7Tly#-LCN@_#3T zVxHVN1KEk;I2ECFXqT{jAHVw8%Fl8A%!sJduqHBr=6eA^NIA8J_{#u9OTkL9o)ZYg^PNna{ZU~DZ zr^t3cqB_#G6I~Z^X+lDen>{9+eN3y7Y5T%JZP>nGv%WUvfeUk%4?d#rXNVpd_pdk( zYkb<<9!^grjsw!TlFb(BR=NkW`*@pS0F_QAhMbg^<@X}eb^!TIq`qI^w6x6S8@{1g zJf@vL!Zk|-%|h}$q6vp)!f9E;Q9#T=byRgm+AKV-+>poH2Qqg`VT>8PygS*1KIL;S zk;V)7r8Ua^>LZg0;ToKCH1kKs**e}m$L~HffqR;cBu(WRC41*9U_gx$GT4adP^r8*`0R!};&@>GXIw7SE``iD{iuJ&ztg!byT@!?b>Z#+~U#H6Dp1m`2pO zELA&Q!Dk`&Kz1K*H56A(yik-1MwH$dfRM8?5vYanW}>BcQhmefen|r%$)%)5?4CvgJFxeY0V>lb+TaXKav58O7T$qJ5f@1` zFnfY+dzwE67mzeqvsyJF&J(pE`8n?Fr!s%^Gf9UlhTHF>yU&ogGmaN&%0q@ccsO0& zOO`v83Fk1SB1m_x-n&8}=9U3MDr$-oH`vL}z4gPoPSNxg`>&pJ_vM@>i`N&+3);@% zjC+?z2$6>9W<;H_-74$dOOr{><}3Q;IkTz94KF$FZt;3BZkiB5C!|b=?Kv&m>m*q= z3{v@p_ds?ZZ#ydeA(5iX+_0Pl<+8F~phB^EE}u^}c|@GIzE_w%Fd!4a>3}tbQzWKz zl67T+z{25byyTvemfe*}wE%|0GA^d6W;(%xIw1G5Vg^A6pc63)v@87C`}C_1Y#Nu+ zL>%^@1CB(Dkzs@>8Rv_>S6aZy8SR6g%>2nOV14x|>u3Lv#=pV^#i!9q=BNot{?Q`tixIYSl11r~Fdo6!3^Y(DuOx8VWZ z`Ny0+`j~!siARY;VzV9DY}W*@W?z1GF{5pTyH__1ci$s8MaMl!6phn~>jzYyw9jAe z&3yBtr*l*@Nfvo)DcL=c-N&i?$g(L20i+BAltjv4qm>V()g8jX%LhWYq+dNH^cVQh zWJdbV{yu4f!Zdd%RHCK;Dp()PDJZpsbr29zqVS(IQwTsHpG`?~#(PYcm0|j(MW5lFEV_tC51eUXo&~!FEm8Lgf29U4_824Q4R=gq$FzS6 z`GL8z66T~h+I~%R#OZ`NX&fgT1bFY5_l@5!gcZaCnx;Ik;El*xxdH6;?Z9zJ zh`{xFWVPtBlBr`)CIgSxj%%*6u=#7dYuCweds^j+NnwwYu!#u${+4FGb zX%`JhmjP%*H4>*Ih|xH367X$@8VAl?A~0HlM4VHEBIhclrgJspNhm_4WT0Azxk)RD z6(D6zrp+O2Q1YT<&5Cl^K!Ic)D}!VW(Urm{%KYebKvsE97|Gev+5u#^l7 zdtJ{#xm}O6L3sLT#?yx#sk9sJGqU@5i*b8<3sM0EI3cp4ieNT4I6q@{_73wOyV}_q zPSk9BblM>##7d(~0L?%Zf>9*OM9#7+YR^c4Y0A??SEv)U5njE(@Xi5to^5%exkR+H z2e`!txcR%5OmERxq(QDGh*q9;A|LqgIi&NTICQl`~Vj0Hz4e zn;V8@U{g#c89EHn79`IuK489B*d$oT*Nodc#={m_eng}(oAESma70iC8VmVZL{3Ub z6hx|L86tMSAHTbxYlSBGVjHA@3SXDF2eNyuWo7bP_QOa@YM%P5vnMuvbiT1N%~;)% z2$HjgMD-f8y^4YXSJcc6tD@=zb}m`(XXb{vgi_#ip)EK81IDO065fGpdTjD|_93Bv zfFMRaV7P@eGE5`G5K9)+XQ$qvC8ziMZhm`ETPsC9^&S*E9PC=M2CB`Am!nw(vZF@b{fg3p{2Ax~fJ zytTfah~scLvb()OrD3*w#DfP*+C~`nw~TkMY-JtkfYC+9$$k=nG=WAagBt82m;c^V z%3Uh&xv&Pkw|$u?C9|v)l6xR~+i?$KDfgS4SmU0k3eqsYc*<<`jy3TGh|__1+~b`> zp;-ut+-Mhvl10@KM5Iy*^81riss#vW$;Pq^L)CO9O=yDP!C`wf%}&}`@9U{aXN1WN z6sKqaVZbwtk(ku7hS{tu;_=YTP}kbVrt2@h&GzaUo!)XWgZ@E_^NS3=;N*m}mY=t} zTp(E$k+Ma2p-&`IIx-$dbU4ri10X9oQ|iHwNHS1knnsdF$Qh^eb;G)f18nOP-Zl1I zo6Qa*33p4*9zV6ggiA-J<5vuuooP`m3rzz;LQ{kUq6tv25bAakZ&#T-7hs}T5EWxh zr2d{DNya;&uH#d^2eSKkJ0U270T|9F+W95R%l8TWC2iA!PR5&3jSwR#mCe^hOPGu{ zpy0qsX5mY*z9~)%T~i%Rb19pB_NA1hF#%{6ekTlK-5kGoYIZlizeK@k0`YK_dtcG| zUgMY$XJrqIwy~zX(Hwd2thMZ`tW(PpsQksmuIwCJ{K-aF^a3L<(-%t$9-LCjt0w%r)ENE;FXRrt!=s|P7wqr;IqX|`SN?} z&O{M%U#pN=ozyQtL_x~*E;HPfl&FrZnkSFyk^V95>I2glitDVoo`yR}BPkhef^o9! z%SxWbqN52mc{C%(L}0z%aP#V09Pd7*=Z=TH&|EesGgRwlA@LLt6;}Z&71~6-M+=)I zlJ6b7oPsgM{~x?%X#>-7K-}H{#QBb{U!c0QOjq?lXdFJ+o&QUxxmOLl!W zRa@BXy*F)VQu|x^JNiuoGUYzL=Ak4rEo?#$p+||3A{ry07$>Vt+#tnNJixpM0mi5R zG@g_FiepR&P?yG1ogk=R{wbHV8i6pUy?EcUFWNH<=%zgyH#ms~a))8E=Dp&Wbpgx1 znilaL;(N=^UVin0?dxZx!&fZZk&8vZ`z{kWL4bsw7$fFkLh+Aj9-R%+==vVL3&*peWrsECM-Nv>| zIY#1e00%k^;60iWIA6TQfKxK73znHmoZ(dPZHo}luwc8nB_?onZTp*A+@kgXmt|K- zbswpPtME+>$9;V5Bc;UZ;ZI=o=wpUSxxHPp*&R^d;oBAX8IyXz;hiIRheBoBi&R-q zK95POzkP5h)*LU)@Q^2TDVb*&D7JNI_TDdL`SEX}efV=w*OQKS=x~k1txZR7Zg<>n zj-&*u#f;1Ig-L9De}OjVM$-J`d;gnH|JOg{`21gT?!Ms3x!8L{XiCO7#Z;66wO@yU zSJrfvXBDYtgpf0}98rrHJg;LbtK{;el?--5QXv`>zcKgPcD6DQlQ1J2Cpq7r$FoNt z@$m7x^dTDkW4!x5aq}5Eys~W6CX#6c%`E@mAln#`UyI#`6kxLqwOtbWGZX9Y2S@ZP zHm{$t{`LIc3?}rd<)1@7v|t zGt`Cz2ShiBPK?9E{x}vX(tOs^b`3&6Gw*AhBDb$zuzvM@vwL2&6Hk^c-p>#yP828z zRSr}aa{yVSjRA0N;)_t4@G;ftY<1GG*VS+`zu$XEO7uospm@0}Ll{&jAy{a>Q1X$~vQx7HK;*thb{}sugf#9LcP|l=xq_}1mn>F4 zk>l~e?(Q|4s~g(J8Ar*tJ!u+AX~av)xdg;m#L~HB)SM+y{P(?6+Rz~VQ)K=D&Eg%z zgycue-879%#`}s`>8Q|m!B(t^Wa4QvBWYl}zT@WAciG>3!pv>CoO$|(Eg~%`ReA&{ zJ_DC3#^e{5@3WM<6ssLCS?7tJWw#6|U?*gbTq0*~Lfd2q++x?`usxOHGq0=zKSzCo z!QXLh+nK(+TIn16lw;aRwrZAOf>9-26Suz9cMx zgrq$T8#GOf(_~HVF{uH`tZ!+IHqjuVw`&|GuD^WF?Thcj@g?W;#N!7oB6Cv%7)V(L zM75$W8Cmt?hbnUdiX%mElKE;>w};Yq(we0qAQZoTdsYE)9xu+64k{huXSjBrWmyAp z_X3G~rsEpX!RQ%k;ON0Qus-3zfL(~0Yvusqbie3nJFEQuW*CScKl}T%;}^`l4Oo!S zLIRLVx8TjF{~wAmW=a$Zo74f1UH8oXw;uN{u^J;9k61H59uc=;9B(Z{lV-_s{(#xy zCov8K+q+lnZfudk!U1>?=Y+7)kkJyE#mEqnx?x<42?`iok##i zn^^V1`dKb?mVL$KxVyXN>Z@-tZ9Zr2cf2$6G^;lExk|1gg(gEzziy5{;mqob5Rh4#Yqg*Dk>|MBCuBVcgw7+>^#NHo+VYnF28Z z4G1V8R7A4BbGjw`%d3OARy;ThSk%mmT;k?u1ux_smlKQhoR~L;M+MKDQN4iw-{G7T zAP32>PfJ<2=aJpV+lkWON(zz<7F`-iam2*L!w&Jc=<$Z+dUJKXc<>J5-)D1o&31Fe zX0v87pVM`712bt>gylyzd35apoerd7Lz>oBl1AIGZGvrr@yh~T*W!F*v)1?H))x^t&~UnBvP?9N&}|8>;DZIfDJ z)}EPj;048@5+L+6%^ZxACQR{w47UtBE9IDmEslhyf#e-AnzX8xX{TUfQK<|9x!?Bk z=E(JW;9_}(uOF`reQM9F{`|7_fSAaH)xx4L7TGaoVYV|F63KyT_6)1m*(lj0Q9Py;$l#@}C8o)ytW23E zVZ5;&4uv!#-V-zFELV$Y1a-Wb6_x2B`4Tq!iNhf>rNpb7fu|1xoJPLC>V=k|WT-i6 zAFTX*Gc-{mYd-7XrU6y4b56id?=!Odc)L-|5>sXjY4*g5DRZb2s-uxQeVV|WN_R}! z(9O>XVadZsPhtKMoc(03ZeAfeF>9f9b4DhP1hwl04E4Q6`c!}Vv)116J>O$+&Ah5alv^p$9Z75%G3odc#e2jk^ku3Fm0 zRhJ6tdxcXXD^N7Br)H15u?7%M%fu;y_u#xBycwz$=zx1;#rt@>Q5aI9fL(Y8DJ7nL zdEmn*GkYyX&J-EPi1m7+GONwJdmh;tPIzOQrQN$Ye zw>K}jd-Xq(viUnWsr|7CnoG=_ zbrr=zOrYZMKG23H_X_8z1VoZe9+@`AwolUmlI@KIa(V6?;wn~^DWgypl$?T=T~!gO znm=bYNGxW7cOUhfEjk{Yx5NmbR4~fS`cw7pc)_Wc< zJEld)et_$3B7_+}?bzLX!tUw^`0)jcE;76DIGLg3jA^Rwum%WFms|*$kO@u=@C?*E zRG+fqT&r1LLtdJz)Qw9Ng@P)@*bxz2Xz;!PZ?uWLDoqg`jpHS0XFM--AWd1Itto?# z!$NAA=;Y1pM+(5yP%MfwMoHKZK6olsnl48DhFVu1|JBhge!`@W@H?nKX){H5% zn9cHD{>;qG%*@Qp%*@P87alV+!{x_s8M1eiY+^fxnUVDEuIZ{%Du0Fx&#F2#9*suP zW}|kWqt=mD7NHd4Dgt+ngU?dknPO~t&N>7y(#U>oV2<}3QfduQOhb=Zx1^Okd8|_F+{K}g{W|v*vk7) z%NPgK>L%l3K%M5N+3HXMpSAV@oi*eOhk(2RSM^Z!E>7$m)%Mk31J!s3JYk6YK7-ha zb^?ecB@Bl3D)#VWD>OCRxeQ&?|AAqeF!}OBU>#%;dd92jYH(8>jh}VTt9b@K1MAhF z*>`FWQjsY5F=yGMV32d;1!id-bkCMLIn(D{?@t5tq-xTKX`%|y5Nb9PgQvX07ky@? zAfWXxV6=S>ej2<-AIFdE$8GQWK4`8S#a4HOjm;g5%Q#I8$PLobwNQmjnP8cXR9Yn; zOun-`<28WX3l4U2fkAQa)gD@f6wq-}HyTs$YVnkDpRFLaS1A|CJA1h};fIs)@0>%` zyMSu2&g`nb=rac95b7+hTFui{+A68uA<)vKuK`;OQlQ0qHdfXl2CjOer%TvKvY9+x9MW!whkd{J+_jvSV4}Z1Fzqys9&BM$1S~J) zRLL*2GaD&pt}x~Ew+EE~fi9S5GQX(}Q3cPuTP|<#gliwiSnTY_%HCTr8V)h+Uq}D? z4%*FW{;&nKTMLvbRK=Js8{J3Cv$ddg24yK+AjREi&#z4uV_6Zb4 z?-Gig)9}4B$U`3oR@ZRw=&fih9>Pw4gslmv4aX6U_8uN+G6kF}X3DZr1C_QMF^~^} ziq!mMj=lzHojI9vYg52fXuAi^sZe)fXe<*n!|*CX{~XHR1u`)|zRvNIeZdn<1scvE zg0g~GeU+Kyd~RY@0-m8_~7Y+(sXe`R^Ve427iwYV)O(l)# z(crYO0DG8n&KzqW`H>&-n6vB=KghZ17&s*iG;WXyfWxTAYnLtfG{3)=;-!Hytb?Bd zLg2A!h-IJpGC#PAqI(YG?YF}Zu28kUdgLbTUAqZYY!T3U{SkFqtfClOz)!~D2bU4XoA9G9-Q(yh zO;!~MuT|{tDQPJH0n#8pf!K;oZJXe=pOR)?vhB6EQe#jX$t+a#+|Ty=6x-74ih)@- zS*2!u0z3h&09iGdX5Wny!(+*^NB$t^77d#a8?&d62LT+W*I*`+U1c*$beGH62s)c7 zU0ety0u}!~_~9n1-ld71p*3S4`wp(+;IUf?KHYwSt?e$eVC2nZG}kwFCm`a2;juEUNwmX3Pl1_Qa;_t04P=+0QsLH&?V$34y6) zVq#O6S!-{h4cNGpPJ35O5>WuB&Jk3f#M^8!uAfpb1>nUqog@ z6RMx*Bb%3pqc})gWZ4x#498cStQWv(#V`dvnai_@QRE7jF%tzDl*tWWgFr+Sqfs_m zzYEV5&xcTU&!d>Iv^ZMF;z9!lk4*EW-H35$P5`Zk{_Y6Dwa{MJgJye??5YY55lkn| zMT5q|L4sFvag`gdQSPAXok!U{%aunz+TbCz@Wc8{$7r-?vvpBvy%rW?`W$NKXmNIb zijN65+^7f(WKdC+W+l-sE(?$ZdVp4y4SIjg6_EK)~dS?Y+qAgp7{+CKu|=tu4Scj9yI>PZ=`;r3_Tc z7hU+_2CCj=6x-8S+F3MX5Bm=s!lC20F*#s&cZ|&dNkF#0>s^dW#{`hA&K}ApTxX3o ziLWu6M;NZd*X(QJ%94Fm#Q^XH5WQifMvVF&v8c2@ra&k6G3p)rJ4-ft+h?vB2|OB) zn4y3l7S!0UR*h|pQzc8lNQWHjomp%%sI%lS5{Zay+9SJo@o;0=9LVOyY)uMcTslxh zz$TNMX(pdxYoS7S{eD!t*QSAcvZ8znC=KpOoLCDiHR}kbZx!BCXj@R~5JrlnUEl&i zU@WbHwPQD9`M@cZv5np+gIhd;eDMJCMviK@iLyUsU*{&*%kZO3#G=PUkqDJCUC_jC zEMtM24fyt1Oh8~Z@L5TNG+bu2FN5}uN(8F~3uR&Dl?Nj8Stbn_KLbu#cy0Dpu|Zo$ z(-^c5HG;-^$2#_}jI$h%78}z3P~Tgdr@DTa%bb&$6-z`wOu&FusKL(JcY<*(T?1wB zB1Y$)irq^uMmfBW{?0Y-GHxua@>Hg*xmeF^bADzpU|H7%0b0F4z{5GFENyTN)$S#X zCxBLT&!9n;c94grL|?-1u7jf0{zZi0HH2b^Nh1+Tg0ys6nz*uzdBth~NhYx@Pwvyy z&w5XN+iOHR;p^m+y01S=^lAW7`N#Cxuwd2kJ-%;(@usbc>I{PufI~$95AbIKrcX02 zjaP5YV`L9^nHTS)3jvNG5(G|0^eV-qkyhv$XzGWje-jk^xQG7fr=qy@JPg-g2OewI z+u+I}kk^O*#yUU_gkHe=JE56xd#1YKGr35BW^V}| z8Mbo<+i&`3bl-9ZMi1T3(|l|^#+-02GjSMAasg2!utr}|sOraE6oW04gPmG3F(muS z5K=r4gAs7f1}2kjg5!v+NQ&5uZeaS-xtENQ)gWP36OG2pes-!5*w_*iV1!Fqme~U< zR%geg-znRvM)5Q4mPpcE8-PzYw_D|*0oynSvWK(G%gXXXReB$ila&+;qXmHsKkJVl z(DaN(MC44!C zXW%|%IyRtf*n^brNH8l5Tvt7#Axc{&Q@_UDeHb^3&w*@S9(cmH-SX{U{*j+j z_~un+5KZG{krPI-F)O=}zRYAz2ngmKUxgZ|cnlg)=kCh$$fR zXV!-pm!Sr~Q1>5st*XeEBcO2#JXC1_7k~i~jaNXRk_P;3y#+G8$DU0;$v%AJvWu-+ zz=SD^OKG46(7eDy3j+e$1VqfLr}>(ZKUtgI&snGWR_m0RF}`P6y2b_pngDkWWdDC< zUhcl@+m`OW{p&vao`3m@$CZO?_kPrSAN=d3#m-G3Mzf_xAVfn5Mxvp1iFj73dVWq8 z1LUe{=CW@cXklV**0haht5@RsPRTPX!Tpp|3v@B%3dh9h5<9eRoL!~VxWzPP%Pf*@ zL}v4OZy2!Muh`Gkt%Ci8`e&McQihj;rcuyGfe20P%Er#rLPe>(lf^>0_-6G|=Th33 zn{hP_INM!H8neC`bg!{F80kozbyx2{)@+`}=MiMDyZsyAql<53 zOv!^Qn`2IpM^5Gq?W(yZ7qNbF6lmlG(+Io4P~rVpQhPi$o`8?tP$%p$Rlp_^M5vZCMAPJ)E%pvp?(FDg*4n zl?EDQK^}u~Fsw}|kggJnskqtTr2UG984*~MOs!&M!y;g-SCJ83-WcP}6TsS@-1l}p z!7PM`H(wZHqg!G)4mf>fh@uP(yxV>_Di`fWZ9O*|z$yCx&78ZbGdMHp%CrJ&(q zs^P|i0T4^@0zB5&5)I(so(7gX8IJ64p{gv9v45*XHw?n8Pzty*tBtTZ#OM|!07GNB zwq4>a7X}l68nJE)R&*l`AdgDVXK%YS#Kv~X{z{*$j4EgjXHGGPVpmqXrF>=9rPJ61 zxHW*JE1+h@Q2=R*&8{D1uqAEJ{!*=&>TMz5{m;uB$mRfc*Eb)(=k~Apt_gU(vK(x@ z)Q`5l)s@{NSr{OT1tNu|zD{FIWj6pYSnh+wsrL9Z>$dUWGks2CQ4>q!Wr-^q7$*}u zGyRzToircf%_cRrx=SEkz!?2GqE5@N5%Kl#xM*U=#D1a16L+#nlM!e3hXN_P;!6@pV$ei zVgl868vT029xCzHO9L{nY5PtyN2i^$`**ov3GZ@X2mJ` ze^kbfXx;Mp7NvRluaxIM=?~ud6?c5!PglFw?hd2Pr=#5dQdGUY<+zWc7{S-zmE}qk z4Y4i>C*iU*SRAZNNwWeW7=da8S)4LP7yv3Iup4{>Y`Wb^XOC;#J~7vA;rU;N5{`i7_P?>_tP&hU*t6N=uu z_@a-h7$Q_9nNL$$QUeqR<9+TpDF{FW3d<5;SMLF=~$#etJtR|jo4nq;r+QeMrCl0kB99Z8RbD^N!boOVa2iw}Q z%sQq`AZP*H0-+unNr?e0$P5!hG@37y-6B&45|gC^)@`)$N7d^ms(!v|Im71m)Tcf* zd)^a%_XA$`FW>pwYdd#7xU&0-f5}GYKXo)3EEMIKdk-@gU_2HAgZ@yPbv6S}B|QJ~ zSf|x6&$c$ePh)#8R+Krzv;;=edIkSQAuQ{XgdTcVK&Wj-X62DgP{w;P0IPRWEKF07 zjL8|-3N(RI3Sf59+T+-0VyQ6_oTf%M{I(N|6L4xz>$&J~>+uCN8V=Wc)g-V#BIv#O z!T{ZYN0x)^EX&A%+26`SuJqgr?h6EHX_=i8$L8LL1tI;4X#A04j_VuK{Km6i5e)5|S_wIP{!Tz&f*&4j%dq$)FiK*L2 z<`pYsH7Jx7*$k9HK@+u-UMqqrUmCgCSbz?;Rlwis!0c8du`#(|dd6a0J%N}QmDP5M z1!#5B`=FIcwg&+%&;Xke!^YfHCzn&%YwP=zWoUXO8>-bp^#b0i0xoYB6B{E$0uGtj z;R7voML=5LD)8Xh0UkKBiz^#rY;`Lx3QSfjxs7U2cq}hu6ZY2P7r@!8V+Q^O9DsFs z<<1F=RHt$3-ngJquw$#>q}H`h76`NilLY@|%HV;7@c~AQHV3kK`Rl*@ zv*wGR^t&JTs@uQ)uh+UycwlMw)qfIpuYCAuJkAkIG~kifY^4f;<{Xa*tJwtW5dp1C z>KnFpfr3`oII$uDLx1Ej0e&0bs##MVs|u=1Rw-?^3e{^*qy5 z1za*QHn}r~iKGE;RVEb%RECAe>B~c0*(|t1d2F?fldCNR9~tX9cXc$0kL^+~HU+PU zSi9xmX-0!lsMY?StZe^EL%G)Y*}9f#98C4rMRv(%bi2S}4-p|NHh^ueM%?P)ZFUXF z1&4}QtP&{lnwHG;Ez2}swU2WkdxtHr`lqkI`OkmylYjVq7M}mw2!?X9|rN z6+iflS6C1q4HZ7%e71 zV+Lq*qDkBSnvVPHl}guO46a4z+4I zFR#DjTbA#>`Yj7xVmmJ2JI5O~9}y1=fI&OCT6Rsz+s8BY2HK;(DrB?BE!M zT}h10GAaA6DFRNmPZ_O`a^rbb>m+*!Z4PAb2<3IRfBk#C`X9dhm&?J%z13jj@v+$c zT<7~s!$A+x6TBuycZ`73$TG#12s~yK_6{jo*MHB;7FgAfOXy#kg!{ zSkTPa2vh_pr z@D;$7j!9rAdXLKM? z0-LEJT@5xx_sRAqnr&lU?TV+U`_>T@2R;@E!RpyKexMdkBhCa@{hOoN)A|@Fb0B-$ zeJ?zD&r^Q#d&=R~tHN;e#VD_TGpgQUU+ki)M(`A^Dg_P{wAN|aG`WnPOiHVgig!uO z3f47hcZuy|w5}6lS!G!u#2l@a6IeR-p;$WkF=*|7R|K?qm`5zO5Q;tz_)sych(f#TX)zNEf~Dv+B46qd7R-oEFJFaL+nxaSGq_s`p}{j~?mYp?n3=y%`09Cb6EpXf^fL91%^)S!C# z-T{&9iXfF|WK#7?lXb})>)Bo)7-P-q2!bFBstO*b=30BPxc1&yJ~aWawGRY3s|e)? zD6Rul7v*>t-QEB@{prLEVqF3un#z9LAMC#MNq3dK zb6*l&V-Hu}LWM>apl@7R<^)Fdb|FuovU)I1h*F|evofizMJ|Hxi^=#HP;rrw zG**33y-j+cdw~!j`GitF>piniQrR#9LCJ1P_i|T}W@$(mWEwYjVuv&LD01u2zLh3g z4Toc^Eq)pB->r4lSvo4`E6SJxE%f_@ zin9#UrkG9@_bTjr=ni6teaH`g1oof&AnZNzES_y7$(;0T4}zaqT@|=M;9`Ylo};zAhR)&lN9*WEqq+Lt$Xj~=KY**Y5sDrL{atMD z4AAY5dD!dnVh4Mc7tvl=M%La3WG(wgD8Z>_67-D>tL!%}AjfWkOXkcQx$&d!@pMEK zoR0!THP$=Z$Lbtdgmea^Y*@%)CJet#b&^Ei#4Z3X3DPrq?Qg@%qkkCPZX0Q`k5ryO zys&zN6sJI{Ifv6RflsAaXXLs$@f<3fl*ypvSz7sdyVbgw8!nT1Zd^`Fu^P1VxU{mm z+UYM}#Viy!IUQjDkkB!drzodGTwE-?uc_p0+U)|%OI`H(eYCnO$a@<= z*2DSn9!BSf@ZMVuGRpLr5YaY~1GY$D`y;IaUsABNe6AEpDbQ&@%59@0kXJCY-Yvuu z49CgzQ95dAHHKxpI-EfUnxuqTnegalM>NJ5p7QcRK|rx5!-}=l8_y&t{ELgXpU3B%X^R0afZ)!v-FFdrSf2QbKG0M zJ6%~_DOy>z*)9;~hRbB08<*2!C{a&OP!0DmIeCWJ=~sy3SLn8YE7!I$Sig1O8M#?5B69&QC7`v6eEnPK-um0nyZ(nL2AeXFHca23 znw(-bUF5!|xEPlLBHd04OG{n!2TN%8){u4AQ6tBjz2|uL@n6L5Z~rXf*{9g(&2V+2 zk0Q@Bu})yCv_7l%1#*t~s{!27^g7h96!)?vDHuYLy zIa*~UfD83*5NsX`4y-I5omKeFvoW6SP2^{K9WNx;DEC0T6X~&BfR|p9gq39-=~02n zeLAVUW{V!AJiyLOX%r%&mDVAkc}FZtL1;E9R03X500THfz#Bdqe>Rs?hew?<>>PXi z{6#B#ak4p$-TRaK_aCPB?rn6omL~mnz31b2A1O@T+;EvJU;O71FY-XjFGoF*hrX^x z;vFS-h`hZFm-n%@#qAT$w6u z1-xsqqUY43U>_#KJ@M6Sb9mGzCV>S459NlDb`D)Ag>6{s+^3)j=bN+1h$;j~kQl7Z z(-Mjs=6Q(xZbI(#1h&y6;>%ZK?ca0^RhdXPmD=NBjk2t|g&GG{1 z!3y~cURbtXwn+;~Dh?_BH_j&xuTLBlQhn;OYJz%tj_85Z z4FZ&xZOQGIy3BwE06}OEC~L_tAdHbvAXO(wu7h@W1MT&z;)RWerVw9x8w zP|t=4$)h#6iO%vpWW8&E%aOtap&Y@f?tWF(DCZVKM4m6et2JLQz^euL4v-a?j)ypZ z^EpPxFW~Dlw2Op|L4iE$!m1U3YM=mRbyP9d>r*X2rBsldU;}3X3(7!8jNI0$k18H7WDjVa{^+J4S>mN0iA2>ZISJ%>WG>4LS9UQ z3>%^LmzhyX0D;5y)i!QzIY}WbrYVi5QO@N>jIoPr8*TajB*h%&<5@W2w{E?RC`X;PiMOJD+_IuRr}Wm>&EBOT{@h79r1|D?cOLE(jno zCzpGDz@t8_0%)@45L^q|RtlTj*6iHM1kTIUpR=R`rvT-6EM;#@rPLTZ4G0h%BEm{$ zWOKU|Q8vXZRS#_%rBVEsUk!yI3pfQw4&E&aFOobm_W+P{v~njLvrfxn(Diy>At7ah z55^RjY5%ef*Qvq4r%Ht!-O%y33q3y0#Z*-GIgqvBv$mu*vZ5oNd)Deno;AxnhEtC( z4s!hLMX!D}x;|OG`e^q4qwVbRt#=RdjgJw^AwoTsE)^gly<_&j zm5UwNkqqrXl^$xzqlMWB)%XNqe1PiWC1%H8p}u&IJWa5&wt>OMU1V2&7sulc-keM@ zt0BK=(X}v|I*ez4&vKzmtgbGj+h0c3UPH>4Fquqo@Z#5a`SG8@$+N$TY`TMuC17*C zk6yP0$!|nay3j^%hfFJ9bxkoure4^2keFpAc<^CsXo^L?R!>4-+h%ZvL@+YiB#Y`k z2iVUxiGQ(%GK3|Gf>3E`1H${7)iQrlB(C>PDpA1D`Z1z{U$?aoO6=gnJ3ZXL-i3Dr z;Ifv_ll|?&3%IQgGPDYhXl8phy(sSe=1J#?6-}cs3&-PlQtLgMCPbv7&RPVU`*7(aZt*}1u1cl+4S-DC%0{0eb$fLNXZ zVFIV(o_5;MI~kw1a^XWx5QEM_98Ch8?gyf@g@kH?dUke+1XQ+r(X%Tr@#;^ z-5ROB!13`hcHc~JK5e5rxPrBfEew`7;5!>|#X3UDadP+)JHP$Q^Thq1L4EQG*1C(t zeGh9ZJ!DxXz*X1m(`@A)34ju71>EvnxNPbr5iFc+3cxk0mX0|uJ3YyO8K4V`2E0Ge z6{rr&_nalW>Kc&l19{ChE&x^$gASm1#`y-D&HL>PYyDh5mmnec3r@VRhc~)1De3-= z4wielambzW{3d0@mpfxokDa$SiN62ZAcIb+B8QCEV-zj;9jvM?_c zeTDHJ;`A7?8X-v6NMM-mG&lEl>-f9_GTU1ytaN!uj?N;^h5>LKXU0${0I8B+jCyv4 zYJ7-txPyAQ2Ui|osTgB(Ibo$6M48~|BI2~{V~SPrzILDg3eP|OvpC=R5xVIJTWc+> zul6O`KdTa|I*_QSWqp8vqg?^W9H5;AHZ&s`aTqT{Jp*8>x?x+2fM)9u&uK!^5V+42 z06?^`6+C&xYl!sDn(-Al!HA4fsMsVP-0YyIqK9yaxwEwv9^UGTR{zb-4!Uh;CZDUk zk9cD{2Q%^J_D?I>R^Fe&y~QFvVltOU`bt*x(C%MBDpv7g zZ;0>z@E7stKmAcT8y?K=-CBzuJiOMrxfVLTc#vn)mq_DRNV7wv@=PcjF-Y!<95*P} zEIN2+xoxo}8c>?PGfOLc-3X zKEy_^5{^@=)58~Ee1R{1wwV0(HMZ8exPE;LgQaB&8-kKZ+lBDc?2JO~#q@q*lm~KN zXdlec*rB{eD~xLzDm>klb|a)n0L-*E_IzB+;E{u~3Jwr4#W?^WdV zA3VI8J>FjFtapa3R{6@u;R}Sx9_on*2_V%oAO({)q35bViNx>uPR8f$UI_p_}0ItFKmo@!J3&{Ez3cT`y4_HR_yYrS6uf47M9*?_sy(^?u5mnTr|GZsE?~#Xi zS-FD_YME~@a%(dgK(f&1&$JkDeWQ&J@Ac(e)X*wDqPhbCXc6+N6-+!>#y0huqeH>+&yhJ^Gg?e&` zFgpioDJ+pfV=A_KojRQ!+BOH+Hn4Y-#@|9aKR?yh9!fE9E<5x)5EX?GICO*IRU}a~ zQ5G5q2r&rjT4q&FPZ6d^s742pPpgKzLbmm3hVEbut^O7&*T=;qVO#<+>!N5cNs%Bq zky{3}r93pZr7}RAJPzn&Bansfz=VJN#)Ljiy(kXQ)iq!%ynGHBjymN=vCL-1(NUj2 zSuaes*}Sfad=qxjt0ZiQCH10iZnils9f0J{I?`H%+yi^ZGFfS%d?5h$%dbSnM`f{r zc1u7*s+LWe9(uaucA5N@@xmO~QNU5jK$cNmR#k4fEt+)%+M>uXtus7-Q{dOHd-coV z)mi__gZjz6jk)(VXm9q%MN#g!G+9(0cM+z?(w%}(0tiq~9kLM1cwNzcCpN)zNtf`S zPq^Iw{`{Z+3+VOwq!u74I037DkCmQfygRbdxi%^&s%aks5G%xLhPoUHu*LFBz^pub ziu(L($zgOm1^O$S(h@bTTNq9wLMl+S`eHs44?)2cZ~*d*+Gbh^P||3lcp=7xy_cM* zlXxtel0KB{VQ2_MzEAQi&(X~Jh%xjepfav$JYWqf0$ZF2a^tDo6v>BqHtLJ?^|^A& zzSx<{NVhqtNpGfx!vZ3YZ}#y1oj#U&nMvY15DXY{6HwXQZSWh89+?S^88+Jck|}*A z!Q=44>O-C7T=9*(j_kLUNj}8&uTd_wN z-W$Vx6*$m^oIUTHx#r7eo*S3bQnK>Xk>mS0`ius^60(%51xYqT^KJmAAR!8kt4mxlR;NjB@2binigLuK_0iH3a5+x^R*bKZn;L*Cnl7c4`v{hz+j?TnuUQ zipMXN$7BT*VZBGQBx+hW0kfd!yD`4WJC4@R4hFYYlV>Oh-Y&Cq1>FG1f=AafQ`@-VyEv=*IU%@nXF)lqK zS^{XTP9M$}5HQftHuI`L3k$gPToMB1t^qqTPV;?Qwe@Y(DOXt-^)3_i{@CPw0+G`( z7svO-qRH9GqH7goBv>(|Yb+*7PRCRGTpj8FX(_sMwIlyeIxWd18ikJ~Rk2tU1Dwe2lC%iylgmX=;FZZ5whf!|`b0edXzs{k8hcZI@SX-B0g5 z*eY(Xht|LyWKJrNuMwx>eF^U?#abnqT*K4jBrJxsV4IiyK41|jMylNMxXWjr8<*3- zFv@sm8%sbd6YdiZ(bCDIw+kND%4&XA#d_+zQx0DDHQ~}TkzJO9p z>-NI?YHhU7@?ydJ8ZW%BeN^K&l8z9Wo)iEJlDf_6DfB(d zZL^Z$nP-tfizi^(z`qq+mBOg5JU4fV42GP2H!u&!Ov zhc9}<#1=-j%jf0+0w5Fb8hW}kLoC%x8!gDT&oMpz3TeEH!p+d@uOREJqjCd`t3q0u ze9=dDuqu6W%aT2plaPhJsXP$DIS|9 z_8Cr6*PjbNC?)eArN3cSX>G{f41L+JNe>8#Y8yo^-v@(kh9|dsSm_r+ZoPk_D;i{X zt_kN%82sI~C$CM6iTs#YZzUKw=C&B>n(5wPhz>|1A6j{IIGtqpY;TeKTCRuLow@h* zaGv|x%(pjUtCtSEn=TUfuMnn(qV^ifF;Wok%gFpN%x)^mQoPZEsD3xyumX?JB9Ffe zQ^w!5D3P(QVUP)vkSuRZrJD_xO8%vQljlFg*^9p>V3zl`;M?nS8z2)v>mrHw6nS1d zT8-BbMU6ws>GfpMLGVhvwCemB((Da7?EIzbLn{$?`v0tG~;ZDP|hIQ z{GQh&YujldAu|_qpLCdW6X;T;hwdE+exCOZa{N0&?AvJ)3Q$9gpw;lwSoI@2UCp5? zrx@@2MU3};jM3|#;^N?QOwV7V-M@;Ww*}W;hVwaphJ$g%KtNH8Kng&dNr6Dfw&Q)2 z=Pyv6evNSP5``P1-Ra?%pM2dvKRXo?0QmDJsjG~3jS?AdQUfbN!B2*oRFgNDp6`lg z+xpFqu(AF7=wAP0WXq3G`&IE6c)d#E1n(Wgpd@Prf0Li_&QZD63|Hg>9BrkN0IA#j z5vtSL>L_@Sv*DI&d>&u(4X$h<0)QhuB+G%llUlk#UK}BPcDNc&({{CW^Fe%kZ)@&- zg<{|ieHsaPAx@8w$_r)POZX12$jIw$RzA_V4(`l6)ObA4#YCR$GSb&n<8|+NWN)jn z5@#!v^u8!UDBhapB=`_(rBkF-95RgdeuUZXU&i>=_b@(vhT~ViM3@aF3l~ca{)q5!Dklj#!?fo*rSgP~$jzf%0M(w>C1jzS0-nvy}A!fF2l?T$#^8c|-YG$Zo zj!u6AsaQ?L(#`tby*q9`&Aiy`UgRz5d3=R5-A9-mBUM8{SocDk07=f!P|sdtW-IL^ z>GGQ3EI&=wWZo%%jq1B>QIa*yXYNw^EB>-OWaK>A)*G10AEyJ!F)_k=PDI8Cs1AE3 ziQ0=V{|Ahp|Iax8^1nfxov8p`wA2WwN0`9#>h-``aXqAfSXT(skrW8Zx%Jx-8|!OW zzw{ToXrG9Uc=@D6*O%R$~F+YI=ckvdGlSxZR%9N%aOgki`BUgfph^HOdd^*J$JfIKx82y%W{m5 zzXFcFhb$}5%qLlo5MbChn${?*03g|(Nf$*!DpZwv6BT?o!`gBOo7>+)T>B#&`;Tx^ zZ=s3>JtDn+T^e~U9up9Q0GjAk#d?Ce9HXwraEOQiJxb4H4MT6XB{9!qWpSJs0g##W z2C3F8%nCGfNA`i|xnTE`LSgrtHZJnV#E^;JeTI`^!lyeGe)&AdNxX^Wtq0iLyaFGm zs76O3l~a$^`>IExv7fZ(Q9a0p3I=;IZAG%VFrPP^L{VsoG2!rZM!H3l>&D!gYoH@5 zue|S<&OA3RsTq%i#++F+00!___9*f_2a-eqF?uPe^gU{bX^*0I1elOZ?A1{%+VKp> z^x9%HQ=AZMV6ul+xr5F28{EH^KqHK-BIWIp#f zlPu3Nnfi_@db~WW@ylm5zC7%sz4io8-v0csfH|md z@~rFvIi4!K)b$^Z^><-d3y^*GVvMsVe*w2nG0fBWj{r8Ccs%V{6n+rqT0RM)E!;_13U_%vP{6;z|{<3L-IU-=MQiU++R zsOdgYXK>ERFYt6G=T^{^wVsnzbEukaJsUx!Tqb*1aFqJ-6|VJ<@#tn7x3}-3xbg=$ zZT&tD>upTZK$_+qI2B2Vy?F~+UH~qK_c`FanWoQ>m|-}9iHZFX&;&Yi!OVSa=-BIq z_at-jJfsaUv?NHudU)&v@a&Cj0+}>zBf#V3QH`H}UE%YCCFCoQ@!p5u!3U3SV6#7k zo4%0of%R}#+JUF zFpPdmC#xZnFv{>$e~H*7U_)9eYUr4LTwl+y+!JD@{FPNN#$F%jVgvv|L$xG2Y0@!( zdVGjDdW}}KgH^wWdsj-_-`>FL+)FE${|Ni>3C_Z%sMh){6C!UWn(#f*gLiowS=NHf z1ki*uO8Fpyu}V6#5(+4xSYeGnK=3xi*u*>$pZ-SfMnOxflMSzmxiSl8tUkiDSE)u> zCMqPKye#pvuRV^c8@PJsTXXO0iKxqV;~|20Uppdq9%m;)i;<9W2HUK{_}pZeLQGtZ4nX#yIKjVGp0(KKQc*bIxCfX47sUMJfM1aJt5yvJ}=feiwX zk*XR}am*ZWV?9H!rBc!SEJ!}e3d9@6zIbhtdn*y^A!OLZcn^N|3jOd3x0X)v@J0)_ zwjUth{6if2@8V#xfobK@9$XR9ZPs2w-daM|>I=Ae-;&QE@Dhv|>Jq5Dvy=;ZVNGcu zR@u}5OX!5nk$v-G<*a!=0z~d*<|qORnf3USFG_s6zXZSZ7*9UM_&0dN~ z=A4wQIj{?%r?@0}OIB|A$-F*RQAxsO`apAV?Aas@M8H^nH=pfJ@x{&rlbPIa8A99_ z5L-0M_weoeeSCDUhk2Wm2zWZkBHr2IS&4SxP3MLELqQb}egjBIdf6;r{0Enx+0QV= zhJTG|s&=xF4G$f)=;1yZA@ zg@@)nb61{~RAzYq@2F6#PqnOk(}^Ovn8zSA6jVvt<)_Jm-v~FU6NbinnTtpnFsui7 zJ-&)l{|FApxW0Xkt&Jt19>Rr1?&};8i!gnxC|bkGgCF6%X6L|=j0=afXkHZFDEKP( zEjGb81cKmb7A2(+A`q0Cvfj(3@N;xl;{NrX%;SXj$bE*@L5`K4!`?~2i-U=_ZF#9` ze)(#OTbnI(+dwdL7Z&V8^i0yN!r0!|r$;KR^BeKfm}BOqTy9Y(M-K-n)Ml*Ow>AXFCYP z7l@O6$uXvSsMLw5VCp2Fcydv(lOTb7H_)qsY|B1|+LnyUYm{T;+>%BZO@k=de!V+I z6hLx#aHES4?hY2SHf6@c^($>8If0XKQjROU%<9}0Z8iXq&{SlN+O3S_SJQVX#9{K~ zWd9{JZd^_Sz+6^@r3WO^2>8&Usb?=C6xfm@1|`eViz8U^wS!ng3{j~S7_=iY5G+k@ z%nIZgu9m610(Mfilk0_qeX-W*=V#K_>1TWB#XVf_pW@#780+n0oa}#z&p!VW&v%EI z#wAhpD6$0a^^ZX!s5rpri&@b|hBopx+hQnzZMbBn2%w}}dSYg2YJ(|tBF7|j@!9Du z{P5^^@kRMZSi1H*`0j^y@q6#B;La7G2#2UIUP|aF!#b4on_{%e9Xh@0>FXiRM-_4^ zNFafWrGPkUlhJ#(*9^z-&pDMgPblY>dEn8_E^b_D$#vY`YR|Vja{Spvjjvx%@Y|gU zKHnKj#S#fJ@3Y9H(H-8)G%2l&GYmGrBh3QDr8Ccs%V`N5Zw9CN9IG|o?7@spA}s)h zqmE^>1Sb0Bc&%(IFp*Oxr-=e!lnaXJ~*Sj~)) z=ag*?+hPPmUNPH7MG8oOcb37wD(m; zxJl*ld;)y(qQ;ND^4Oc*#M-qd`0lsf!ymlAj_vglow$!Me2Lj`7q!lM6iv7gI8>#f z!oh;#(b)_Da6Xi|r;zJmieHQc3qr5~WDUWcmGH*JB;dC%C)htJ<+E;I?T9B<2MDL| z>FWu8_0@3heNAz4ULhsuTvLdRrx6#ETBd((EEl4h8)HIQMJW;#g`DEMhKJPvV9mkN z^D`c%HY?6hh3V9`^=-rbHwEF>P^Itzl@k`ej)T9;n8~^;@eNQaCb9c zqc?>w4^WR@&+P!^3|pxq zokHeM^^jdSv8yc^G;_b5b{fL?MXeS4rfnQY@HwXLv<$-)Re6qBj&xv01qWf0a$Z5Aw!f3aJJE@~ ziXQLXUB=2FN4J$hkEhHvJ$L58*mMpH#FRMl4ic^&oR)|>qRl(Z0csvyl?gL4#?>JGn9mGTY7*V z$3#5|kL04sagC;M>S&R##(bD51`zl-_(Q22j{G$B-b`-Bel9s#1QAw0Ls*zeQnLub zuc6n4JQ%L$vE%Y~*`*uyKwj+g)tkc#Mng@8Wfsdug+)n8gBsdTFj1 z9&0$t$>T=Jf<=Tp&(!;>#ryi%&Jt$rN4WoR4q#8VaBF3ZPW>8bv?G;AlqWhWZ3e_j z2f##tX#s+y2e>1#N(zRS?Uok+Q|}6_N?4+6WLT=+9vUGlE3uOIl7#(>{TZ~FB+UGa zaeybm7YPuR+gn@hc?GkN?fIIblFBjbW-?6Wz3m=uY_y@pC)wX?XT0P@bzldA_&Xqb zI~NweQ!)vA2NSMYH4Fd@*#JB6159LV(%yuSja-*{S>lC(+j^`fXzA4?D^Mt}C7)zN z8-5;-g98Hl>p0$y&Vyc`79-?Zj7B}fWdX$+K{V1XkY>m5vwbXK7q^#>@WIU*5AIxt zTl*IF@Vj_5yN9!KAj4QP&(PYL#6AOgeOtT?VckzLPi`-~uN+^WUBl|!`}+3#ck$ls z0&DpJ^2tK5@Bm;ypT9Mv=TRz;69F$<34!vsJOB?kH8_G$qp{loe8@@1Nk&M5Rbvr2 zv>~Q!keWdq|4ed)Qem8fOoO=VoeleMT#+HdxPPs)$bqTkIOKENMJB)|^4c0=)`1@Q z{5=6;d^4$-``*Uook!LT_3By-`sku&zRJuFv^=S3R8sku(t245S|Oxb1_XdSLoHh& z)$>w*N7Y{=C~BBM0npUc&sU>lGq)W;fR50dkQ^l2w!4AnQeKsMfkCG@TOpxm4tc(hz6mA3yDS+;O2V`&QLQy#jI?{~GN+t+0(Rg37 z-x5z{pStT-?IA`A7_un9bHixp>v=WwB(*`0jo?oh9v8m{7joX9$5Ud6(|FiQ#Pd;< zQQ7U5;A-=Y;-!fa2g+mQ)jn4I9_}o^!MAQDY~Q{HxB6}Dgzw<_Xd4&RKp!mV;7ua8PYb8(r-jKdem ziZ*=Sfy=sLKJNj}i-*XH9dl1+(dyUcT1WaDnTk+jk=ZN;9Bep?X&LeBuSYmKtCjo= zVd-zJwoIh!92Pk)X;=F7)3G#SkBi7EzkILyVQ)?vf~WSCa0Vk8huVLedb zogUfSX&liO5y6BrLn|;R1xxNEP$aejp-~thK!U(U7C&q_8Iw_LXy(nB=yy#i8P&jS0HxwJ3Qg>mK!N2=M}01#K)* zOOVbNGRev>z$@<~YYk-5Rmys(lLuVEDk7_o91a6Jd5V3t&BfA9?7}vkLnAC9*&IM-=@|HV?tOXcx|K++yPS z9l`b;{o-vj11Oy6!vsFZmubFB_FD-b=C@!yAz9OJN@@l`xL3&IcgtEL)gIBC!=nCKuM=?r}f= zK-M8i@nB_;3zg&cRtLE<^5qzNKF&8lVyMJ$SiHMA`Bh|m&c{K)i33Tjw4Rm*_w&D0)lWh?4RwWBiI)an9ih9(rF9Ol zeI?-0tpT>zrdYzhD0IZhp^TbgTzo-`XgI|xvjwWu3<7B;{5r% zJK^bH0?t1{Cmo{|j*whN00s~f0a6zhRao@UZD&T*kw0hWiG~0H4|XUln!HOKpH~8E zpFSUoq*KZD~JKSa6zLv-Q+I@8~xZxGxVikl7u*q%o74MI$kgs(#qtLliyx4P(cNwwz%LHaDeeSaV!=(WYf^yR!E zAH<$cR!whSkz;`b1z#Q)BVdP+yc-AiwwfK3OGdtF;i2cneoQ9*IY5KnPBUNT05IJu z`)KSG&_---XSxkXu;TGRFqK6ZY6h>z^5R0UY=1Z#R(j7H1Oi{9f75~tKiAS$csyW3 zrMeC}4?sP&dJJgp%UR(++k*wW?U}eHa0t@YIQ!~PAsc=S_vZU(#Zw6*6LQ4F&?+TT zBN`3pO)!G@%n@=S;5jqgMXymnkwa;U+{qAO=LFPnZLN)7+j9VkNz6ldVwrc6^sj^D zzF?u9+%PRrVbIM4_=?WtplJT z5+6_pCZYAS3ETwN28$oO4zk`s9sLvqyh!(O)+zB0`^OVWj9agwIiQ18U5^fq(V2cK z3b%RQ0-QJGW(7fg@YP_3@7m$LFl1Q67c-20-d|hYgfrgHtc-@QC->VC5CNX&&3T27 zpO5hM-V{lb_`)0G@0<{3m-{*Nr-Z68nnqi#B$J`Lo8{_!A zgaezMzj<+ne!+#GV^wDj_FB)f*(PPWC-ke3XXxenH0<=U?a1GP?w9-i{9p#}JOH*q zc@78$K>e`2W0Ac^2#|f<&O%VJfb)K_7R|B`@AlDYWr)eic{(j`=6~un=smZE5%0Xd z##?9aJTjPHM6sIc5Ulor-U!1x!}rqHOxRm(ez1zgsw2;%fW+JzJt3RxvO`jspCWLY zN}0q(;It<`fbu=Rcvazi5-^@6yg82mfWz}3p!(vd!t3LOtW2#Qn@)Wai>5CV2GqE% zU_+3%9?imXz<%aOf>#)n(XfCEDUdQ&ho4G@?p;bRL0q*pX( z5bWtAnliV@D&!_0Sayw9+zBm|Aa(Fhv?+pyRd^+caFKnS z6{;a401GywiBv8z=oNUpy(FzTff;cC)`RlQPnji|^XeKro{QDlC*1`ES|gNb!*+0? zw6z>&_s^;*4E+!j#OoZ^QpKE*qBf(~ z0R0%@(coFJ9f+xR!^zUT z7F8`8)5;Bi$a@TFU>X19^*HMJH-rfpj*$wYlnM}}bPhnHX&eyg7nyUocTyws=0Op# zdVC|tqq*I?n&I)y0-MWTys=K<0retw4l8{2s>IniBKHIVeouS9jAu)YGbn{9Z?ZPwN!Kqm)1yo6;a(=Av(TsOY z05_qu8Dhp(<>QVe)`SYcz}<)Nwqq@jLVM&{}W(v6}+2s|dxC59tx!!;0z=DkC!$do>y zB7~VHsl7>9i?J$eO%v$c_F~||1ic!sMn023m=e#Gd7fV@kMR69%?VGQ-u42-9^dN8 zIx#0J-q-3N!@XoeX8bh=iqQ^Vi+BmyosBar7buAlV(z z7!C}Em~|c8-0<+>L)^G=!_5tEyZOuTB~DLITW4oyE8hF1xfNNKVQvmCCw;X65L~NU zZZ*RQ0MxVMVsd7JQSv8UwqX;{*4QdVuv0J2gulEtm~r@kgL;Upq#~Iix@!Xg1=NvE zQ>dZu5 zEBjOd(1T=N&<+{_KraR&L1Yr~7B{H_rrxHRd~U0c4DYof2$k3|15&gCX}l={Tyvq< z2_&LAB8jNXRq1y)8`U@))`lvxwv^8StcOV%v3p!Xlvwm6dRnF4KpMrL?N9X{iR8Dw zCq@sG19}_R3MB9k1FPLtRk?P%jlp2xrqk)d@V1(Nn=k(3k3Y^o{q)miuK+eTEG)}1 zpXa&vbCbtjA9}0VZvctaG;*a3iPkE?sz+rtyvV1D&ECw!hHgH{4q{D$Z8YAT37DJ> zX`JPDNs@ozjTJetKJb7x4{H?@hi3s_yejeaekJ^}LC4|RnwRtR+io6u7Fg;6vpV5? zlrWl6DMarFrzCMY6lHQ4KAKRpNkY}P!0Otyjjrf!2|!toqFHG)EO$!c@K}c!Y~`2N zz@KMDn&`!_6`sJO}lTZNWjoSwhD}IH+j~nO*tY7vlxUNw`>3NmfHoU^J7$ z0G_^{A_T~FURlZU(Y-!yUFk6Q)%;$DbH_1t=DTEbgP$+XIbYYcTV7svy+Q|8<&z?#=WZxr3Hs>+y12w z5u!x#*-nYig!Xzyh*WlV!Un^N=$a8S%gAg?Z1Ef%hJc9}XQoXp`&$k`9~8E!?}&Q+B`X z7f-Cy^3smvGmrCeko$ZwNx~!h;?)Gd{%Rz=G7W>}UM_WWp>y=R9xO7@7+N!omS%ET zZ!MLBdSYTlQDk{h zf#_9K_oQF`09M2{9E^WELU-u!0v&Q#d7e%wJ`OUhGk1(%*V}VyQ{YH0J>) znv=7p=UweNbP7ntZ0AiasCV4k~Kn)pJ?uA|RTAkikHiHAo8)FCrLqh<=J&+2~^vq&{@&Q?;P;DypiI@odgT*s7h?GZSONh!w{`$_6EaEdPulEsO+_30oNp zLl2N&{-*~4RSj8=hXH_iStv4cr$`xL`TlGa1kgTvSzV$_DoQoff#hE1 z@3^hG8>C3NZljRVkdB5f7HFWMoOsa|UKj#0oTqla>^GhuLvSj<2Nl**-4AAkFDEbo`K%&J6Lk+TM!5T0iuV~zLk z^szF?n3rq{B&v50FzmFUJTx+?>XiH9>bck(}{T`HG7F8ywksx2cY`<@;dhpnNx;;0UW+-Or`YZmtTPL)|Cu-2K7D}&Vjr*vCIQ^HnTa1 zrlJydK`@J8?;$-@(@RQ#Xrc=Nnu?#9hKrG!U-CX2sRhJX8-_FIW%*d@YB9A3hFl&1 zLr|WRd@Mt7CO3}f;yN{^d)F}uL;wBTJ#^b%a%9)nTZjPq9WS0&k$VBJ%zIp&zjxNH{tVP&@=Va-6c{#3YF?`LkZz;lZ^9rzux3lVhY9aC{!IHW052 zb%^4vO=grhVv)ju_tkUXO_(QITC?#ROwRX2C~#~0+gQE+0X81|9q`K!;g{~C4z-czaS6Ij zQf3|K>~k`=qevlAB_KI7hQB7qBgcHTSL5YTg-MyPzT~mo z1p=QM9GnH@Sz6@FwDk!Be9_2xvo(eU+=Y>Fth)cKsKF6rAYlyhTuH393WrQ7HIDnu zC^s4_hq9(CO4U|9#;R0^@pyd=`5b*eQ!bjfl#ymN6|jJ(=KmM=zB0&hE$Q-H=}I!Y z?BZs6^f50pGcz+Y@9$;i{h0Y1W}bOW&D>qg;BuK!($z{CSCMhU(fg)jdfWWW9r_FZ{iOhY1^n2I`t< z4kWIu74XvCDsC)!g;SN{Z{DujC%-29gKSo3_H6RG`BE4vw)|6)n9=-^KA(H zaa!fn$`od$F@287qUI|BV_wWJ{*jam~$9(dNmt=zZDF}j`tlGXa4A){*4!Z>>vETZ+hu3 z{+6fye zfB?-Ob}$~aV{0NBccJ_N((*o&V@>UT&Hth8)LT#{XtFL^#2$|sHyC7IgI^}C#8^;q zbuXa4NqS4cpv{sqMAabgYcNh_c{q1BCVmqUXX&~9Mu@FikpA)+_>F}_8t@CXd3qVA_Zt|qC9_2_PU~oJ+ZWj+;eE$9@Y;fK6S;zCobo4(4Il1SjOyB2F08M%eF`^ zsnZ?IIcoU(yMwU=5b|jRozit(NGWlAeEhaB>uY_&<>h57HVHsJK39bSj5c|p2TG|> zg&}%FzkX2f^zW|h;`Z_m;%)lE^PWoz3$a^`>Qn`_;d#8e{mpoD>l|wRatdfh^(bOz zNw*^fh++$Z5yD^y6$}vieF8S(nVJ2Y?17kda=l_t%B+}1Fq6j2Pcr#tVnPMCJB-li zDF_Wl$Gr$ky8(_`T5&;tHdiJgj76L?#kG9HM=50m{DAUlxUe8m$qU+F%nCr5P4D~} zxLrxl9pDz33D&s@EVkZf@VXGegniUvcvyOyue%9KCW07E?|cjsU^yfP zz3D_4Yz*_Y0DvEh)CBjQ+BOkx4RE7p!67slz^HHl%f^FUiBDX~#$H$+hwU;>&Q@Z} zVY-w>F5}X5+COUH&dN3(ZtSDk=@&8**(4j2_MW8?j&0jf;v{rBowtQqU#k*xgk07^#+C5H5S#l)xU;&8&AmEZ|EJEKz}YirzSJ5- z_oZzmoU#jR?;KZpY7=UN8|2c2tNZ`z@ zjdE5n-NTgTrXQ0ZQs@b3M|AvR)#A1%?HxHJe@(4UXb%+jn;|{FvhNe)pMQXnF;b4q zJSXSK)MTE@Yz$AwyaDXhFpM)u7{f%ka*7E+n9RY6$!SSoFfk{Jn~8kzE(T+enW3av zxi!wm@yG}xAO6myGDb_{2n0bu5l+0u#>U3m#;mXA zo5%f-76ALnv^(&7XitpRVHhR`TI(+&HWeR1Bw5e3F;mLo^lT9)W=r%YTl)>%THe9R zb`AZ(2%eirqBxi?xmcXeL%55$eUt#&GgvuZKp17{M=kX@e%Ky_jJItU!X_uvY|K^M zMPM@j34~4ku@vMK&)77wb3z|){1lnL1)lpYll=Uh?Ih3CoM~M+P8y36Q4T$FSCjM!|_KoL<`O- zGRT-*5>4AMuBn-ON>9ohLSp}$$4>}KhLM?&=Mb5EZi8nBqtBEb z<5=hnZM^!x!v|l<;Oa^dx!epcoS4E~HHUoGLDqB78;-HIQ^Wn$T^!U~$YnfSI=hH( zdFl*K%~vS}(r&jg==Viz7>$N>GYKJ7nzD(B=t(gydRJF1V<53&v!6f*xT@8RM4K6?ET{TC}0vhi^) z&de9#X6NzX_-TA;?HSxTT!e5d$QP^dvL#5b0LRNi*jZQvY7Qb;2B}tuKN{HBLj&i; z*w}+J$g+_Vh>YYut&P4%vzR~!8qMW}3~+kd0#PUE^N`V;#lxmTy`zZynsHf@#`kGx zNh-KV{g*jc(7DPvLE)$Zdz-=xzYHBV_83hCRuhOgGjC3cH`|<8W1qo-vEOX0*Ip0v z_-tdMr{UoluNK@04rcZn!isdAEP^p8cA+Nahrqxk1Ox0NJW@l21t8^E`e%I9w&T#z z#V@_+;_g-n*-Sb1z{;o;J>;_sD-!!l+nRh*j5W3G}z zA?woTI&O9GU}F!f+cmVi15B3-`1a>6;ya$Zgi{N%)G-ihf;aQ%EaWp@6dU@30eNT# z2L}l$J(0+Y-j#Y}@kJ1^Ju-p+*7OQkuzK|2p3P@jJM>9Km-_ zB41vFmzyFFO<0ok?7?h$Blp4$#q3RRSY+hN^kOEQnUcXhjl@+jTcKPBB$Ai{(N-aS@q3 zxyf@q$}1&qnGkjiS~foVx{Hs!p2Kl(8fO=0aAC1b706OP0{}RvxA9 z7{D&zTVpS5akfJLv{Uf1=za{zqDWyp8sXsRSj2`_t0`htnS|4sF#4m|@OCrnD|`bH zoAvlf{Ko>W=q%09P0Z|t zgh8la4@vXKc(j>d86H4r@aEyKoS$P37-1ZMxw1uhuzFj;kr8=kmrmH!o9Rl>dGfA+ zZSz3h!6>2}+U{`(Kjbze&lSmg@ehAeq16O525nZR;4%Jekw`Vs1YsV} z;j2+GG#BIC29;t`>)*WfxH;UMQV#QQ4k^v2Ci7#0t|`LE#+^-x54`H)Q*UO`8&|P7 zQ^Kja0_DFlo}}-5@2G|QF@WvXni!3JbUH0+@oUtNFkdZGM8S>Z9P0)_K=*v|8wf*{ z97on}cfy!iAl{7wdc{{jp?CtG*n|Ll#Dbg@&=8IVfsZf@AcO_aa{++9I29=k5CjIW zEgJwRoIE*O!inh|X38GMzEAmvn-8|JbI>5~BA<0pF6OXM%_DD(aQo^F{L=ehz!zRw z$5F>aCWLm%kfFM+cRE$!S!&S<;gkq8ElSL@z z=vV|HttpgToD!HW3Mc|=AnyU8VhQlxC?U%#Eg!=LgsDO*xonhGCt9NPXXBg|v(zU& zB4PA9PEaoRe3PT<4C$VTiDP2YQ=Aw{XNW=?ofDHF6-JLx%HU<9r_-#Y8eu85DUFql z%gZ)?{&|TP?&P7wG%lT<#>v?Ns>Lit556B_``|bZArEla=)xZdi6=z>wz;{5;b;iQ zkwl0!hOkg?ZmM|V!1FwKnGCYoET&3%6&oTI(p7)A0ojxAzM?M!tfI#RHwD1fmhl5v zgK-FH+oT^Bdye!a3L$8pumobD(?6_G^RPlXZ6WK$jk`1Wo@Y+r+`<$A&-&gmZZ0L% zjXFl-5ZR1Ng@Ku=JaS@)8?Sr;FTb&8u|OZ7PfkxSGD&d(uDobw=7rYF!E0%`JI z=QPrVwdPIjEf!{E32)|hWnF<26@jTdD51Z85K^eJedq@b|)AruUw%^CAb-sjPQ`nOoTJvEHWqkLRe#N8Wf`Pvjh@Fu~9uY9pML&Vf7espF;3NZy(Xi2zFZ zu}d+KeRm9K&z!Epl@<<;ySTHmOT~dsZ%8*^G3O>BDTSuR;yl(n33cOH+}b;Zo}VKL z7isJN=&U!!Q?K=YP?*KE3IU-(0Y<0ov-I!7?~) zte+Mt;MBB@vq=ukHirs(4sdG5f=B@tlU3R<1#Pert=Xr@Tr$NvVn)6XfI(vc0QShh zp*KtkAl6C)0Zpi202mMAnB<}{ftQWvoKBA813=!7*2kx9a4Qk*^IV$%XS*)&*=rs? z@>&j?M^(&E&n5sy{{XYDL&qnewX}JN<*h^FgGDO9pwqzN{tgZg4=K-;%Vyw62|*sO zMb|(&4xL*mg)mGkj4dFGB9&GuNu6c)poS~AAL6LhEzed6&#&BxNkvnXbrE)Zb~6(p~UbJJ&lx@o~&2` zVuHnQ&{4UE6TAiX#w^-zAgEHx^si`{@Bn$3FoPt_7BjP$z$4nCG=Wdv{@Q_s558)} zRmd#18)a0d$~Zk=K&6yHx!{4Mua8^geQg~y(bs~V{q`}A4|dS+G~ii^c#t&g7ohub zFc=~&j0D;n)9yTh7ZJie519;|14qYA++E(pz2z;mx_vm3h}>iTF5X$8rT97`voLG$ zkL~rP7?5rEM-M-LdF8Ku@#@;&h?~aWkhX|Im9*LPv2obJach9IaeI`w-9ezijDL7k z6i7^una^Z0WC>7Jb2es64yKD)>IxW+$5`DuBaOCUrm&_fn{G-ZX9Zl4kcJATsi`$`Rrx{yWe{N??Sbp9J% zMIKrhApt3(ZcLX1Hje`I$4XxpU@C9LU~cQFOD3rDa2Eh9TnQNSK~3rbnFb?6^2SiF zU~n+bWeOrPt%7oj6O}^^Xh^4io2nGh)Qrj3(!xYo0mYwzJ75{aiMOR-Og+ zsl12jQjUsFp$h4GJCbNWlq2&pt_H6RTvs=WAJ%dG?lSJKY@yli6Qw9V|9I=L{gWH} zja#t+fWq5&vA*5__5?h-5P$-I5ktK%3!t-8Yk&N6mskGMi#Im@L8CLc?n#?m@txxy zHV)e841JK-75GTiW@%d{=ZL(t?ZXDbP!aHzaxUhkJS@&kp&OmS<=q6(E@G!U4G0^aqd|$;Pe3{;iDhlL zN+@_-8Vf`6nq_l%U)BT8%vm@)OG9qcVIoAySl$b;w5PDL8&H)p**{kj$hknInCuxU z#6U(P<`4wjUX{+GUqglOAH6Cove?&|zByBEo}nZfOP5k8E69wej;WIQZn7E`q3vvx^m6I9WzH zp8+*-2T298K^(A{N$RiUB!G7e z{bHhO@r@5^6Z8vT|4o5T`nv$~Q3O8@Gr#cZHR+O4du8DGi#!L8Hmq!-zbx-Y{tn z=ZQ=}@>-&+(DQnbu)*7656x(l=WxudP;#_qsJ=2l^IY@EM)Q=(Q62FIzub2Kw9|4=Uu#bI|JL9#-&qL5QU8mmOCA_p$L=j}AN}x;fAZS*{>Ptr@z32{-n(-7{>em@4HEYj2}KZVuo|8^f%`z|Y}sy@LCP$2eQ5 zAptj?6Gudz zwPFMOko3t&eU_d_3P6gVUdZ92-Fxb+13%{l!;rZ~fofs|Q!~JA3-lh7*p=I|#@gDJ^ZRpM0X9-~X|4 zc042pT)C7Qzx|vu9`jSSjya==8_v^hcN}=aKbX z0=8yn08rTACfi##mN!0fW99Jq{&3s?;0YnJy0bum3RuF45Mk?}bvF)c@5T9$i_e^$ z`7Lp8=dX-!Pz znSG}8gAf3a(ilRn#0l^qVhXvyUP>6z&|W%fFczpaLBQ7Rrnw@0w>u!OW3~hYp&+U2 zjAPOJ={`?`k7dOMqw2>Zivp8vL=e26Jv*~v$;uNZQgWDT^2G#bjgdVIOO4^4_{|XG zLqvlI5SB~FgGCDIT3E(7Id1*prgB!iP3495n*w(?1vU>IsK~?V`4XiWGOj~aN)>^; zp?b4NK$aG4f^p)3b*Rh4(tV*}NS+jIOB%wPLYVq{)S<%4!us=B$Q6pn=8LdwiCVpZ zd^UsO*l(>Kc787YXZyb&Zr2~2KQ$wByNzOe-v%1MQZYqI+wU}w?6HCE>+h*qV6d|p z#ON{fzMS#-bq*~ERqx?e{b$$q8lSmza{711fb%DdIqzhx)u+~vI3ysjsJ8~IS03zq z=+0X0h4?;b0mumb`zxjF$DcVp{hQ7#lz(lr(<`;Q z1EO`zPZtT;+^hrFwUcla&921$popEdF3xlVq&cNuaRCUR5a_%aH)m5$3pOHCl+cO{ zJ$HjuuKOT8871t08VMIg39x}e$lV6DF`+vIf#j)Ki$bbE4;VJ*d7A378bEpY%A`l8 zLtO@^Xu|JiIcyc1ZFD?5*1Yr)mmbap3q zWzaVDs1AIImAyntI>gGh2hYi3zM4TUD=B&JQvOvDc*VWCBq>ces6zBRE%?I$f?#Z@ z{-*rFKm~AI&i~OU>!j zzyLr1_TVf~7l0bv+o=8gr(Rq7v++&vKYc$uNVq!9?&yBJ@8AB!C$IgTIF$To3}Ryd z1<>z`7jqs+r1U;&6R<2{3jz1I-QSJf`yc<*>ns2A-bVeG1|z@T>Gg4cZJ(4k4vyOZ zfUK7caLr(0I*V$#g2rG5wQdE+y%KKkRL~DgkPZ#vg-PsW4+eU=QrZH=Y;_*As{o`^ zf+~5$>%>a~=BEVFH0H||TrIkoTGjx1Xt-iOqm*m0p@ZA7|b_30$Jq)@{l1P`*PUldjgQj(B zk(Clz$@D_cb3dto?KmiwD_A&n4yDQr9O=MwEQCRL_{zvy27LV+$fK9MHQP%(C<Ke@iw{M>vs|8yK4-W&O0Pv_h6kIErx;1cm-?$Tfx?~g1h znZa&#hxN<%c78Fg6n*YnFV6qAZ@n=02iv_NI-5fja&62^6{tBqpK<6ve4rD%L8!1% zuVC5tFkd*v>Cz!)@_p9(((OAz$P9eTX7NM8`F5o3Oko1_0AZ8 zQvfWO#4CqeBvPqrW1fqspR zFK>xVKr{9$y`Sb~KnSll7&X>*8?XG9?>_ejv!wi)Oz|F}yF142Q42Gr91_O0=Q*jW zEH!nH?HmpVS?si`sATFmSE*sKlscLUB87*DLCoTu4=g~3q2P%@W}a8K4RM&t`tm7o ziB$SWC;N2*S~tL(;cKc$YfAFa^P0lUPjD^|VD4Cm$-c`pqz;9P^4VVlSM(4L>rg=t zAgLOmktsu7oBqrbLXHADPvrxy3j&yC&%)g;iQDTIe3cB#&0wZ1DRk2$QjB~bjrIV| zb~g#bj)kz9ho(1D<33-JRwoJ2(rq9j8c>}7imgO6AQgsi z9XrY8?#5NeAO6zSwI7Ys7h5`gQq=c#Pv85FzV{_K0to=_vSND=$leOn)Fad~#1o`q znCIdorUEB2`^M*Bugrq!!HqemM%$s@cInth_oNBa8zbQ2|F8^bmVTV9ocIChqLqsZ zgHe!#v(%chU2Eg8*+aFI$J}(0DyfdN;kgRgP{H@}@o^bk*_}qE(Zq$yAx=#7Auxhs zbTD`e1aL6DC}C6rSq57YXt9T7NH<4HbH~6#K0DBCS>j|l8m%5$ojw%3*23a^LUx_ObfrY(RQj6J*`^wSX)+QlI=_}?r;suX znM22UM+L`qk;xUw1CvsFU>49G2HP*+T>s%OTwVLQTBEy`dSCz|4Pq8}9r6A9=nCb# zHAnXNpvHjWYYPqU?a6p+5t~t3R%HBmtelk=xlY{z%bPWH`$Pdj)^$mrYP#%UVY&og zoW#}rXYu^!X?KfZTJbHSbvg z1JI++QWC4BJ;ljs;rtk!7ze=od?wBkzC>d{`9Mf(2o=DB(w`5;`y-?<)ugfATdGv`E}+k zLLL}kW3wi3W6i-<%|$+&r}2O;@#Z9XTA>O_HMrL3pxYY)l>C=CwK$8D^V29~GijR= z6KW$?QlxGWv-#b~f${tX3vMP$z~y)uKu`seNUn{}aP^J5o8KR|+Py!f|7-wob;K~# z_aB)2P3s}2Sje7uALV;MHo2%rfSN`2m5^j73lThah)qJLU|?2Z9hk><^^MZe05&o; z(CB@v#|pXm7fc#cky4~!K;?ER0Z^|dvA4&eLR=(3cNn1F>{6q8G3OB%EzxK9q=Y1r zCXjIi#z8VPrHYMa3#UqlI8$lDv&S@S1ki+5Lkfrs228RA9}u)%{j?r#0SXWv-*>6qVmq>D`jaGp1!HAf$kjJsN_ububx z9+1((F}%TVk=pDpQ?JYfHuEu8Ehk%>z(7it?(-R_G|;hEmepW3*3W14>oSiq{w`9H zVy3p>a=T8>Q(v9!*d$HuNgGpsNMP3PkJ0VL)<44jQ5&BfL|fHUO=vd&oZ(8ypjm~mSSSPjEep5+E>daXXrY*yrOH4KwAU{9*Dl1-{$ z7z!8kTFc@&kme#-A}H-LfDK`jlN_%-z;+=d^~oX8kzN#6$MObY_Ml0z-(uqZyGwr20xbvS3Nym(`$s@wjSeiQZiR78EBof5tZ15 z1w)eCb0p<#iUd+VS_zm9#%OhGG=Ozsb}9z7BK6jVic}a-%*pr|7b}e-w%R=`M6`H9OzIyKg**7Yv@t5fu z-Wq?Aj}v+-eqJ}5vjJxHQ-BkwL!=%YgItFJH}%@+Gdlm@&qx!UeURrRC4>|tT}(GV z0s?>({BmJVFJkaK`0$8V8oh!pv3+n5&j(27%I5!n|i=9C+C57u`#RUZhRZ|&AUl*5l2uHz!qK1ASMJ(+oT)lY(d+YnidkeT&O+rXXo{uFcfsUhQ zkAyM(AfWGIH0q<#XwrBzCZ%!_0-y$NzC)lDh5<-H)kUO?e9qy4a$n`j40&Rarm}ch z58DULt1(gff4_Qr5^tl0^8#cHY77{b31W|> zXU3XloUc=03t_f6WjMb_p8>SZodhMY=jTmc>r@vD1PbYp6vuIhs2TJ!hnka( z`23vT(_y4-*>J23M!vx9jXrMOxsRj0UF2kd(=$2ZU^zDBwMbO3-s;f|$h3$s9u0AL zSfhU=p;n-9Byq>+ABU8ZJT5^wM()GZvAAw)qW7nNP62&?PTB`aK$gl5Nyo}|S1Q~mQoQL4&UA^w>b6K>_mCT`D zM|!^vUW^K@A1cx{o1MyIx}2k%KcywuuB-d(ETkG_k(M!zEJaCX&&!Y}2cd8(8Co%2 zM7=%4-f@={JL3EqC9UK98HJqXVir=504wJe`a_B4xQJIaXEB|v;nH*+bEP3%CxD`E z0^)|H-WaWUB%0A^3NR??l$lw209DwtK7+x%Tsm(|9TfqNh&HfUnqli~QB!b`Ed% zCH@=OQv(F6lh7E z)(^3D*h z4=kmO@B|^l6^@J?k(u8jI;wFbH*dr2GB92TT8NJ(Y}EP=HXn9y_vRfm_STV=Aui14 zK^~a2D6bX&?Zn56JsL<&tr!pcI6khUR&PQ|o6K>j0ts&UqFD}fomCi8_{pD()mfD# zU_};=;&W_l@4?BIQ7t+2&qkAfqZp*V^tm^e{@2ar{VyhMZ!rnl&bZP|IEAs=N+%)O zo?EO~#at$ewZa?~pCF(0qHlj{F*tXk5+&ffymf@{e)i;K=>zXAGEtg*2QI-M`Ay#z z0O)62N5(ghbM?Wt7lT?Ff`S3+EkaHPvyis=c}X@&Ebi)aI2yp(FuMWz8qEACipGv@ z5pyBYJL~i#3bMvK+Q~{E0*aFJk6KhpvC!Ls zhkUTmB8QZm>|wSoC`oP+wi^WmIs|5JErN}$n!vRc7hClKT=!!rx)Dy#&j|B!Qvry1EDx zqJG@O&Owc+F}5usT_Vu}fQtKezwrFE)&IxdH2~SMb=`g1x39-DNk(y=ZNJ~P?ZR){ zwr!iAo~_uY2T(PW4Tv2f?hnvG!WO^U{&&XEEzqE4YsH zW%umTFvF4_s{ZNoiy^+@8n<6F(i!fnz{#n3eR8%YzpwD~AGkL7$n(djb(nXp=;7P8 z!o{UEcy(l9dM%YN&9=N>n*aPlV%gHZGZqqm=%J4;9_tK2>|FM z%gK722`I%-3{psNa}EI<-lOH_b2IZKvy5+KRCeYai`JhUD*(^cF_W|4m6-~hz-P8} zFTh}N4L`3(D>ZSY6>%O(QtA;9F-{tSEYl!MslY13TaB5EyxJ6(o+A|sgcvw`Nx<%t z8afh5`S1etRZJ-4@VG=ymAdz&zFJ#tsA(eM0C>%HTH+1@k3OF&Es5Gfo(o<;CFgp* zNyC+*T~O}y9%W^5Ml4iw-=u$o`GrO7M=lUiS!g=lH+3PWlflGn?W2#peEN?t1A87p zu!(=qCMuv*#y51YBL^@T>8}{C9GkXKDL8P3x})7kr_JZ~pM$Ub)SEiDTr~{;^vHfV zbb1!9-7=VEV6P#>&wbmc!G|%1QLhI1I@XhW&)8EJYc{6)<`wvAbU!`SgK`FLr$-6n+$ z{e)U?HH%?=fbQNw6?vWJ*NVaw)i z;59CSp(XyI@|u)$l+7tL(=_EhYMUg%Ju$Dt?h_%*)-0%&iqfTuGB4MTd0>rJ8~b0B zbtc)K?{{c-@jR_ni47R8e`x55h!k0s%`yFf$O$d;~J>wyTCc$1+39 z(lvbZif}07>zbe@zT91t)R5N>U|AS)0`g%D{BuWc&T4=9T|3)1Zr>=dr)EC0|EzOj za?WOZm^{*BZY@=M(oZ$p4DcBUdZ{TV-(<*RX4pVkpMRBV7??SJ+K%Dg&u|^1NB)p3 zt+xxd_v5kv$sc}It~@4~UgE;zHaoNNmeod6Ky z_;vu$zO=@5$+$I}Isz^eN?uxdL9RD7)N6|~u;sdqS!y1AAT5##w@rh-9;%4Y1afJ4 zjs8x^Yr$(n9kZ`yV+}$z{gpwqiCA%hK%Wy;3FH7s%d1#I zF2W*S!wBO2SeH0^?NjF$|NG-Fo&1aAlMBz`=WGCg#oo9)Y=VhW!SQ#F_6Ivgd&7T! z^04-K_g(E{CLHut3$T5p_f2G8S%`oA#jj4?%Hqh`OXd@MPCJp-iy2JJ>Y5iaDrmP&~~;i@HB8QXnKR48a@6mL@8bLXw}XSz7Q z6cc$7z-;QFMNRB!{X3SBe{y1K{s3lRg7r_^e7E@eZ5y;(c5U(wp1J_rhI@S^GHd-^ zg~)ZRw}1ndh4}6-zYi`SS(LGUdu;b98~YVG+<$W}v*6ATffpy!ras1EU?!C8Kv^T{L-64Txyrk|DShPK#fV0sK zFoSD?2v^B4MFLti?~_D0fT2oFow#W_0ogX#zI_|`^^2g1q_m_=$IvyRQLHos?mz+@ zo6-?LY;p)H7c9yu9gFyN#Ql<#l6oViIS2r9A8M!uz7UX*QrW&H-|3*Qt?nn8EQ

diff --git a/src/doc/policies.md b/src/doc/policies.md new file mode 100644 index 00000000000..c832f8936b3 --- /dev/null +++ b/src/doc/policies.md @@ -0,0 +1,116 @@ +% Crates.io package policies + +# Packages Policy for Crates.io + +In [a previous post to the Rust blog] +(http://blog.rust-lang.org/2014/11/20/Cargo.html), +we announced the preview launch of +[crates.io](http://crates.io/), giving the Rust community a +way to easily publish packages. After a few weeks of kicking the tires, and +hearing the most common questions people have about the registry, we wanted to +clarify the rationale behind some of the design decisions. We also wanted to +take the opportunity to be more explicit about the policies around package +ownership on crates.io. + +In general, these policies are guidelines. Problems are often contextual, and +exceptional circumstances sometimes require exceptional measures. We plan to +continue to clarify and expand these rules over time as new circumstances arise. + +# Package Ownership + +We have had, and will continue to have, a first-come, first-served policy on +crate names. Upon publishing a package, the publisher will be made owner of the +package on Crates.io. This follows the precedent of nearly all package +management ecosystems. + +# Removal + +Many questions are specialized instances of a more general form: “Under what +circumstances can a package be removed from Crates.io?” + +The short version is that packages are first-come, first-served, and we won’t +attempt to get into policing what exactly makes a legitimate package. We will do +what the law requires us to do, and address flagrant violations of the Rust Code +of Conduct. + +# Squatting + +Nobody likes a “squatter”, but finding good rules that define squatting that can +be applied mechanically is notoriously difficult. If we require that the package +has at least some content in it, squatters will insert random content. If we +require regular updates, squatters will make sure to update regularly, and that +rule might apply over-zealously to packages that are relatively stable. + + +A more case-by-case policy would be very hard to get right, and would almost +certainly result in bad mistakes and and regular controversies. + +Instead, we are going to stick to a first-come, first-served system. If someone +wants to take over a package, and the previous owner agrees, the existing +maintainer can add them as an owner, and the new maintainer can remove them. If +necessary, the team may reach out to inactive maintainers and help mediate the +process of ownership transfer. We know that this means, in practice, that +certain desirable names will be taken early on, and that those early users may +not be using them in the most optimal way (whether they are claimed by squatters +or just low-quality packages). Other ecosystems have addressed this problem +through the use of more colorful names, and we think that this is actually a +feature, not a bug, of this system. We talk about this more below. + +# The Law + +For issues such as DMCA violations, trademark and copyright infringement, +Crates.io will respect Mozilla Legal’s decisions with regards to content that is +hosted. + +# Code of Conduct + +The Rust project has a [Code of Conduct] +(https://github.com/rust-lang/rust/wiki/Note-development-policy#conduct) +which governs appropriate conduct for the Rust community. In general, any +content on Crates.io that violates the Code of Conduct may be removed. There are +two important, related aspects: + +- We will not be pro-actively monitoring the site for these kinds of violations, + but relying on the community to draw them to our attention. +- “Does this violate the Code of Conduct” is a contextual question that + cannot be directly answered in the hypothetical sense. All of the details + must be taken into consideration in these kinds of situations. + +We plan on adding ‘report’ functionality to alert the administrators that a +package may be in violation of some of these rules. + +# Namespacing + +In the first month with crates.io, a number of people have asked us aboutthe +possibility of introducing [namespaced packages] +(https://github.com/rust-lang/crates.io/issues/58). + +While namespaced packages allow multiple authors to use a single, generic name, +they add complexity to how packaged are referenced in Rust code and in human +communication about packages. At first glance, they allow multiple authors to +claim names like http, but that simply means that people will need to refer to +those packages as `wycats’ http or reem’s http`, offering little benefit over +package names like wycats-http or reem-http. + +When we looked at package ecosystems without namespacing, we found that people +tended to go with more creative names (like nokogiri instead of “tenderlove’s +libxml2”). These creative names tend to be short and memorable, in part because +of the lack of any hierarchy. They make it easier to communicate concisely and +unambiguously about packages. They create exciting brands. And we’ve seen the +success of several 10,000+ package ecosystems like NPM and RubyGems whose +communities are prospering within a single namespace. + +In short, we don’t think the Cargo ecosystem would be better off if Piston chose +a name like `bvssvni/game-engine` (allowing other users to choose +`wycats/game-engine`) instead of simply piston. + +Because namespaces are strictly more complicated in a number of ways,and because +they can be added compatibly in the future should they become necessary, we’re +going to stick with a single shared namespace. + +# Organizations & related packages + +One situation in which a namespace could be useful is when an organization +releases a number of related packages. We plan on expanding the ’tags’ feature +to indicate when multiple crates come from one organization. Details about this +plan will come at a later time. From 66571b97b496529aa61e4fa90d4a0c464172d451 Mon Sep 17 00:00:00 2001 From: Jake Goldsborough Date: Mon, 29 Aug 2016 12:56:41 -0700 Subject: [PATCH 0695/3888] adding policies to Makefile.in --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index d8093de5e8e..9aa14d5d205 100644 --- a/Makefile.in +++ b/Makefile.in @@ -136,7 +136,7 @@ clean: # === Documentation DOCS := index faq config guide manifest build-script pkgid-spec crates-io \ - environment-variables specifying-dependencies source-replacement + environment-variables specifying-dependencies source-replacement policies DOC_DIR := target/doc DOC_OPTS := --markdown-no-toc \ --markdown-css stylesheets/normalize.css \ From 5f3fb83ccb0edafe89d809ed7b8f6634fbea3506 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 29 Aug 2016 17:26:46 -0400 Subject: [PATCH 0696/3888] tweak policies --- src/doc/policies.md | 110 +++++++++----------------------------------- 1 file changed, 23 insertions(+), 87 deletions(-) diff --git a/src/doc/policies.md b/src/doc/policies.md index c832f8936b3..f32db45f49b 100644 --- a/src/doc/policies.md +++ b/src/doc/policies.md @@ -1,27 +1,19 @@ % Crates.io package policies -# Packages Policy for Crates.io - -In [a previous post to the Rust blog] -(http://blog.rust-lang.org/2014/11/20/Cargo.html), -we announced the preview launch of -[crates.io](http://crates.io/), giving the Rust community a -way to easily publish packages. After a few weeks of kicking the tires, and -hearing the most common questions people have about the registry, we wanted to -clarify the rationale behind some of the design decisions. We also wanted to -take the opportunity to be more explicit about the policies around package -ownership on crates.io. - In general, these policies are guidelines. Problems are often contextual, and exceptional circumstances sometimes require exceptional measures. We plan to -continue to clarify and expand these rules over time as new circumstances arise. +continue to clarify and expand these rules over time as new circumstances +arise. # Package Ownership -We have had, and will continue to have, a first-come, first-served policy on -crate names. Upon publishing a package, the publisher will be made owner of the -package on Crates.io. This follows the precedent of nearly all package -management ecosystems. +We have a first-come, first-served policy on crate names. Upon publishing a +package, the publisher will be made owner of the package on Crates.io. + +If someone wants to take over a package, and the previous owner agrees, the +existing maintainer can add them as an owner, and the new maintainer can remove +them. If necessary, the team may reach out to inactive maintainers and help +mediate the process of ownership transfer. # Removal @@ -29,46 +21,27 @@ Many questions are specialized instances of a more general form: “Under what circumstances can a package be removed from Crates.io?” The short version is that packages are first-come, first-served, and we won’t -attempt to get into policing what exactly makes a legitimate package. We will do -what the law requires us to do, and address flagrant violations of the Rust Code -of Conduct. - -# Squatting +attempt to get into policing what exactly makes a legitimate package. We will +do what the law requires us to do, and address flagrant violations of the Rust +Code of Conduct. -Nobody likes a “squatter”, but finding good rules that define squatting that can -be applied mechanically is notoriously difficult. If we require that the package -has at least some content in it, squatters will insert random content. If we -require regular updates, squatters will make sure to update regularly, and that -rule might apply over-zealously to packages that are relatively stable. +## Squatting +We do not have any policies to define 'squatting', and so will not hand over +ownership of a package for that reason. -A more case-by-case policy would be very hard to get right, and would almost -certainly result in bad mistakes and and regular controversies. -Instead, we are going to stick to a first-come, first-served system. If someone -wants to take over a package, and the previous owner agrees, the existing -maintainer can add them as an owner, and the new maintainer can remove them. If -necessary, the team may reach out to inactive maintainers and help mediate the -process of ownership transfer. We know that this means, in practice, that -certain desirable names will be taken early on, and that those early users may -not be using them in the most optimal way (whether they are claimed by squatters -or just low-quality packages). Other ecosystems have addressed this problem -through the use of more colorful names, and we think that this is actually a -feature, not a bug, of this system. We talk about this more below. - -# The Law +## The Law For issues such as DMCA violations, trademark and copyright infringement, -Crates.io will respect Mozilla Legal’s decisions with regards to content that is -hosted. +Crates.io will respect Mozilla Legal’s decisions with regards to content that +is hosted. -# Code of Conduct +## Code of Conduct -The Rust project has a [Code of Conduct] -(https://github.com/rust-lang/rust/wiki/Note-development-policy#conduct) -which governs appropriate conduct for the Rust community. In general, any -content on Crates.io that violates the Code of Conduct may be removed. There are -two important, related aspects: +The Rust project has a [Code of Conduct] which governs appropriate conduct for +the Rust community. In general, any content on Crates.io that violates the Code +of Conduct may be removed. There are two important, related aspects: - We will not be pro-actively monitoring the site for these kinds of violations, but relying on the community to draw them to our attention. @@ -76,41 +49,4 @@ two important, related aspects: cannot be directly answered in the hypothetical sense. All of the details must be taken into consideration in these kinds of situations. -We plan on adding ‘report’ functionality to alert the administrators that a -package may be in violation of some of these rules. - -# Namespacing - -In the first month with crates.io, a number of people have asked us aboutthe -possibility of introducing [namespaced packages] -(https://github.com/rust-lang/crates.io/issues/58). - -While namespaced packages allow multiple authors to use a single, generic name, -they add complexity to how packaged are referenced in Rust code and in human -communication about packages. At first glance, they allow multiple authors to -claim names like http, but that simply means that people will need to refer to -those packages as `wycats’ http or reem’s http`, offering little benefit over -package names like wycats-http or reem-http. - -When we looked at package ecosystems without namespacing, we found that people -tended to go with more creative names (like nokogiri instead of “tenderlove’s -libxml2”). These creative names tend to be short and memorable, in part because -of the lack of any hierarchy. They make it easier to communicate concisely and -unambiguously about packages. They create exciting brands. And we’ve seen the -success of several 10,000+ package ecosystems like NPM and RubyGems whose -communities are prospering within a single namespace. - -In short, we don’t think the Cargo ecosystem would be better off if Piston chose -a name like `bvssvni/game-engine` (allowing other users to choose -`wycats/game-engine`) instead of simply piston. - -Because namespaces are strictly more complicated in a number of ways,and because -they can be added compatibly in the future should they become necessary, we’re -going to stick with a single shared namespace. - -# Organizations & related packages - -One situation in which a namespace could be useful is when an organization -releases a number of related packages. We plan on expanding the ’tags’ feature -to indicate when multiple crates come from one organization. Details about this -plan will come at a later time. +[Code of Conduct]: https://www.rust-lang.org/conduct.html From 14a011b40bfade7d96df93a376607b336eac722c Mon Sep 17 00:00:00 2001 From: Daniel Albert Date: Wed, 31 Aug 2016 19:03:26 +0200 Subject: [PATCH 0697/3888] Add --all-features flag to cargo --- src/bin/bench.rs | 3 ++ src/bin/build.rs | 3 ++ src/bin/doc.rs | 3 ++ src/bin/install.rs | 5 ++- src/bin/metadata.rs | 3 ++ src/bin/run.rs | 3 ++ src/bin/rustc.rs | 3 ++ src/bin/rustdoc.rs | 3 ++ src/bin/test.rs | 3 ++ src/cargo/core/package.rs | 2 +- src/cargo/ops/cargo_compile.rs | 20 ++++++++---- src/cargo/ops/cargo_output_metadata.rs | 2 ++ src/cargo/ops/cargo_package.rs | 1 + src/etc/_cargo | 9 ++++++ src/etc/cargo.bashcomp.sh | 2 +- src/etc/man/cargo-bench.1 | 5 +++ src/etc/man/cargo-build.1 | 5 +++ src/etc/man/cargo-doc.1 | 5 +++ src/etc/man/cargo-install.1 | 5 +++ src/etc/man/cargo-metadata.1 | 5 +++ src/etc/man/cargo-run.1 | 5 +++ src/etc/man/cargo-rustc.1 | 5 +++ src/etc/man/cargo-rustdoc.1 | 5 +++ src/etc/man/cargo-test.1 | 5 +++ tests/features.rs | 44 ++++++++++++++++++++++++++ 25 files changed, 145 insertions(+), 9 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index c7cf6b69332..f2d028d34e4 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -9,6 +9,7 @@ pub struct Options { flag_package: Vec, flag_jobs: Option, flag_features: Vec, + flag_all_features: bool, flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, @@ -42,6 +43,7 @@ Options: -p SPEC, --package SPEC ... Package to run benchmarks for -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --features FEATURES Space-separated list of features to also build + --all-features Build all available features --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to build benchmarks for @@ -83,6 +85,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|s| &s[..]), features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, exec_engine: None, diff --git a/src/bin/build.rs b/src/bin/build.rs index 601344adf7c..2f23ce1be3b 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -11,6 +11,7 @@ pub struct Options { flag_package: Vec, flag_jobs: Option, flag_features: Vec, + flag_all_features: bool, flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, @@ -44,6 +45,7 @@ Options: --bench NAME Build only the specified benchmark target --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build + --all-features Build all available features --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to compile @@ -79,6 +81,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, exec_engine: None, diff --git a/src/bin/doc.rs b/src/bin/doc.rs index 7f4fc2878e5..c4139987cf7 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -7,6 +7,7 @@ use cargo::util::important_paths::{find_root_manifest_for_wd}; pub struct Options { flag_target: Option, flag_features: Vec, + flag_all_features: bool, flag_jobs: Option, flag_manifest_path: Option, flag_no_default_features: bool, @@ -39,6 +40,7 @@ Options: --bin NAME Document only the specified binary --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build + --all-features Build all available features --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to document @@ -74,6 +76,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, exec_engine: None, diff --git a/src/bin/install.rs b/src/bin/install.rs index 2a58688021d..544b115e9a2 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -6,6 +6,7 @@ use cargo::util::{CliResult, Config, ToUrl}; pub struct Options { flag_jobs: Option, flag_features: Vec, + flag_all_features: bool, flag_no_default_features: bool, flag_debug: bool, flag_bin: Vec, @@ -48,8 +49,9 @@ Specifying what crate to install: Build and install options: -h, --help Print this message -j N, --jobs N Number of parallel jobs, defaults to # of CPUs - --features FEATURES Space-separated list of features to activate -f, --force Force overwriting existing crates or binaries + --features FEATURES Space-separated list of features to activate + --all-features Build all available features --no-default-features Do not build the `default` feature --debug Build in debug mode instead of release mode --bin NAME Only install the binary NAME @@ -104,6 +106,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: None, features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &[], exec_engine: None, diff --git a/src/bin/metadata.rs b/src/bin/metadata.rs index d5c2d09056e..4553711045b 100644 --- a/src/bin/metadata.rs +++ b/src/bin/metadata.rs @@ -7,6 +7,7 @@ use cargo::util::{CliResult, Config}; pub struct Options { flag_color: Option, flag_features: Vec, + flag_all_features: bool, flag_format_version: u32, flag_manifest_path: Option, flag_no_default_features: bool, @@ -27,6 +28,7 @@ Usage: Options: -h, --help Print this message --features FEATURES Space-separated list of features + --all-features Build all available features --no-default-features Do not include the `default` feature --no-deps Output information only about the root package and don't fetch dependencies. @@ -50,6 +52,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult, flag_jobs: Option, flag_features: Vec, + flag_all_features: bool, flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, @@ -34,6 +35,7 @@ Options: -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build + --all-features Build all available features --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to execute @@ -75,6 +77,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &[], exec_engine: None, diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 10fd9fc9130..e81c8d18f7a 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -12,6 +12,7 @@ pub struct Options { flag_package: Option, flag_jobs: Option, flag_features: Vec, + flag_all_features: bool, flag_no_default_features: bool, flag_target: Option, flag_manifest_path: Option, @@ -47,6 +48,7 @@ Options: --release Build artifacts in release mode, with optimizations --profile PROFILE Profile to build the selected target for --features FEATURES Features to compile for the package + --all-features Build all available features --no-default-features Do not compile default features for the package --target TRIPLE Target triple which compiles will be for --manifest-path PATH Path to the manifest to fetch dependencies for @@ -97,6 +99,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]), exec_engine: None, diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index 010b003c58d..15e4a91ca66 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -8,6 +8,7 @@ pub struct Options { arg_opts: Vec, flag_target: Option, flag_features: Vec, + flag_all_features: bool, flag_jobs: Option, flag_manifest_path: Option, flag_no_default_features: bool, @@ -44,6 +45,7 @@ Options: --bench NAME Build only the specified benchmark target --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build + --all-features Build all available features --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to document @@ -83,6 +85,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|t| &t[..]), features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]), exec_engine: None, diff --git a/src/bin/test.rs b/src/bin/test.rs index cd823a59172..c5e687a6483 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -7,6 +7,7 @@ use cargo::util::important_paths::{find_root_manifest_for_wd}; pub struct Options { arg_args: Vec, flag_features: Vec, + flag_all_features: bool, flag_jobs: Option, flag_manifest_path: Option, flag_no_default_features: bool, @@ -47,6 +48,7 @@ Options: -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build + --all-features Build all available features --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to build tests for @@ -115,6 +117,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { jobs: options.flag_jobs, target: options.flag_target.as_ref().map(|s| &s[..]), features: &options.flag_features, + all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, exec_engine: None, diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index ffd5c93640a..c0554fbfc55 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -78,7 +78,7 @@ impl Package { pub fn package_id(&self) -> &PackageId { self.manifest.package_id() } pub fn root(&self) -> &Path { self.manifest_path.parent().unwrap() } pub fn summary(&self) -> &Summary { self.manifest.summary() } - pub fn targets(&self) -> &[Target] { self.manifest().targets() } + pub fn targets(&self) -> &[Target] { self.manifest.targets() } pub fn version(&self) -> &Version { self.package_id().version() } pub fn authors(&self) -> &Vec { &self.manifest.metadata().authors } pub fn publish(&self) -> bool { self.manifest.publish() } diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 09643591b2a..25b96891787 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -44,6 +44,8 @@ pub struct CompileOptions<'a> { pub target: Option<&'a str>, /// Extra features to build for the root package pub features: &'a [String], + /// Flag whether all available features should be built for the root package + pub all_features: bool, /// Flag if the default feature should be built for the root package pub no_default_features: bool, /// Root package to build (if None it's the current one) @@ -94,6 +96,7 @@ pub fn compile<'a>(ws: &Workspace<'a>, options: &CompileOptions<'a>) pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, source: Option>, features: Vec, + all_features: bool, no_default_features: bool) -> CargoResult<(PackageSet<'a>, Resolve)> { @@ -115,10 +118,14 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, try!(add_overrides(&mut registry, ws)); - let method = Method::Required{ - dev_deps: true, // TODO: remove this option? - features: &features, - uses_default_features: !no_default_features, + let method = if all_features { + Method::Everything + } else { + Method::Required { + dev_deps: true, // TODO: remove this option? + features: &features, + uses_default_features: !no_default_features, + } }; let resolved_with_overrides = @@ -137,7 +144,8 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, -> CargoResult> { let root_package = try!(ws.current()); let CompileOptions { config, jobs, target, spec, features, - no_default_features, release, mode, + all_features, no_default_features, + release, mode, ref filter, ref exec_engine, ref target_rustdoc_args, ref target_rustc_args } = *options; @@ -157,7 +165,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, } let (packages, resolve_with_overrides) = { - try!(resolve_dependencies(ws, source, features, no_default_features)) + try!(resolve_dependencies(ws, source, features, all_features, no_default_features)) }; let mut pkgids = Vec::new(); diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 5178dbc8eec..035c7350fe9 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -10,6 +10,7 @@ const VERSION: u32 = 1; pub struct OutputMetadataOptions { pub features: Vec, pub no_default_features: bool, + pub all_features: bool, pub no_deps: bool, pub version: u32, } @@ -45,6 +46,7 @@ fn metadata_full(ws: &Workspace, let deps = try!(ops::resolve_dependencies(ws, None, opt.features.clone(), + opt.all_features, opt.no_default_features)); let (packages, resolve) = deps; diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index e6a89e331b0..3a6f51d5f13 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -275,6 +275,7 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> target: None, features: &[], no_default_features: false, + all_features: false, spec: &[], filter: ops::CompileFilter::Everything, exec_engine: None, diff --git a/src/etc/_cargo b/src/etc/_cargo index 9a883dd2509..17585920252 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -20,6 +20,7 @@ case $state in bench) _arguments \ '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ "${command_scope_spec[@]}" \ @@ -36,6 +37,7 @@ case $state in build) _arguments \ '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ "${command_scope_spec[@]}" \ @@ -64,6 +66,7 @@ case $state in doc) _arguments \ '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ '--manifest-path=[path to manifest]: :_files -/' \ @@ -131,6 +134,7 @@ case $state in '--debug[build in debug mode instead of release mode]' \ '--example[install the specified example instead of binaries]' \ '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ '--git=[URL from which to install the crate]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ @@ -168,6 +172,7 @@ case $state in '--no-default-features[do not include the default feature]' \ '--manifest-path=[path to manifest]: :_files -/' \ '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ '--format-version=[format version(default: 1)]' \ '--color=:colorization option:(auto always never)' \ ;; @@ -241,6 +246,7 @@ case $state in _arguments \ '--example=[name of the bin target]' \ '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ '--manifest-path=[path to manifest]: :_files -/' \ @@ -258,6 +264,7 @@ case $state in _arguments \ '--color=:colorization option:(auto always never)' \ '--features=[features to compile for the package]' \ + '--all-features[enable all available features]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ '--manifest-path=[path to the manifest to fetch dependencies for]' \ @@ -275,6 +282,7 @@ case $state in _arguments \ '--color=:colorization option:(auto always never)' \ '--features=[space-separated list of features to also build]' \ + '--all-features[enable all available features]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ '--manifest-path=[path to the manifest to document]' \ @@ -301,6 +309,7 @@ case $state in test) _arguments \ '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ '(-h, --help)'{-h,--help}'[show help message]' \ '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ '--manifest-path=[path to manifest]: :_files -/' \ diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh index b1652b6cc2a..5c6675e9069 100644 --- a/src/etc/cargo.bashcomp.sh +++ b/src/etc/cargo.bashcomp.sh @@ -17,7 +17,7 @@ _cargo() local opt_color='--color' local opt_common="$opt_help $opt_verbose $opt_quiet $opt_color" local opt_pkg='-p --package' - local opt_feat='--features --no-default-features' + local opt_feat='--features --all-features --no-default-features' local opt_mani='--manifest-path' local opt_jobs='-j --jobs' diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1 index 7f32d196dcc..dfb9ee4ec61 100644 --- a/src/etc/man/cargo-bench.1 +++ b/src/etc/man/cargo-bench.1 @@ -83,6 +83,11 @@ Space\-separated list of features to also build. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-no\-default\-features Do not build the \f[C]default\f[] feature. .RS diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1 index e4c00dc2110..18c16c63da1 100644 --- a/src/etc/man/cargo-build.1 +++ b/src/etc/man/cargo-build.1 @@ -67,6 +67,11 @@ Build artifacts in release mode, with optimizations. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-features \f[I]FEATURES\f[] Space\-separated list of features to also build. .RS diff --git a/src/etc/man/cargo-doc.1 b/src/etc/man/cargo-doc.1 index 54807f65486..f910957c693 100644 --- a/src/etc/man/cargo-doc.1 +++ b/src/etc/man/cargo-doc.1 @@ -57,6 +57,11 @@ Space\-separated list of features to also build. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-no\-default\-features Do not build the \f[C]default\f[] feature. .RS diff --git a/src/etc/man/cargo-install.1 b/src/etc/man/cargo-install.1 index 9944d9104d0..8822e730f72 100644 --- a/src/etc/man/cargo-install.1 +++ b/src/etc/man/cargo-install.1 @@ -98,6 +98,11 @@ Space\-separated list of features to activate. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-f, \-\-force Force overwriting existing crates or binaries .RS diff --git a/src/etc/man/cargo-metadata.1 b/src/etc/man/cargo-metadata.1 index 939d0265648..69d72535cb6 100644 --- a/src/etc/man/cargo-metadata.1 +++ b/src/etc/man/cargo-metadata.1 @@ -22,6 +22,11 @@ Space-separated list of features. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-no\-default\-features Do not include the \f[C]default\f[] feature. .RS diff --git a/src/etc/man/cargo-run.1 b/src/etc/man/cargo-run.1 index 91d0bfba6c6..80473d2be46 100644 --- a/src/etc/man/cargo-run.1 +++ b/src/etc/man/cargo-run.1 @@ -51,6 +51,11 @@ Space\-separated list of features to also build. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-no\-default\-features Do not build the \f[C]default\f[] feature. .RS diff --git a/src/etc/man/cargo-rustc.1 b/src/etc/man/cargo-rustc.1 index b503fed1009..f5d9a3521a4 100644 --- a/src/etc/man/cargo-rustc.1 +++ b/src/etc/man/cargo-rustc.1 @@ -83,6 +83,11 @@ The version to yank or un\-yank. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-no\-default\-features Do not compile default features for the package. .RS diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1 index 278e6088654..3a898a31a6b 100644 --- a/src/etc/man/cargo-rustdoc.1 +++ b/src/etc/man/cargo-rustdoc.1 @@ -81,6 +81,11 @@ Space-separated list of features to also build. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-no\-default\-features Do not build the \f[C]default\f[] feature. .RS diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1 index 63f1b2b801d..2d9907f0bd0 100644 --- a/src/etc/man/cargo-test.1 +++ b/src/etc/man/cargo-test.1 @@ -107,6 +107,11 @@ Space\-separated list of features to also build. .RS .RE .TP +.B \-\-all\-features +Build all available features. +.RS +.RE +.TP .B \-\-no\-default\-features Do not build the \f[C]default\f[] feature. .RS diff --git a/tests/features.rs b/tests/features.rs index 1551c703c22..a6921de3814 100644 --- a/tests/features.rs +++ b/tests/features.rs @@ -960,4 +960,48 @@ fn dep_feature_in_cmd_line() { execs().with_status(101).with_stderr("\ [ERROR] feature names may not contain slashes: `bar/some-feat` ")); + +#[test] +fn all_features_flag_enables_all_features() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + + [features] + foo = [] + bar = [] + + [dependencies.baz] + path = "baz" + optional = true + "#) + .file("src/main.rs", r#" + #[cfg(feature = "foo")] + pub fn foo() {} + + #[cfg(feature = "bar")] + pub fn bar() { + extern crate baz; + baz::baz(); + } + + fn main() { + foo(); + bar(); + } + "#) + .file("baz/Cargo.toml", r#" + [package] + name = "baz" + version = "0.0.1" + authors = [] + "#) + .file("baz/src/lib.rs", "pub fn baz() {}"); + + assert_that(p.cargo_process("build").arg("--all-features"), + execs().with_status(0)); +} } From f17a87d6b54dcab033f547380a3e0e1a23fb7544 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 31 Aug 2016 16:11:33 -0700 Subject: [PATCH 0698/3888] Check for path dependencies. Port registry::verify_dependencies to the `cargo package` command to perform the local portion of that check. It looks like the package operation doesn't generally make reference to the registry, so skip variant-origin checks until publish time. --- src/cargo/ops/cargo_package.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 3a6f51d5f13..2ed76ab7595 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -35,6 +35,8 @@ pub fn package(ws: &Workspace, try!(check_metadata(pkg, config)); } + try!(verify_dependencies(&pkg)); + if opts.list { let root = pkg.root(); let mut list: Vec<_> = try!(src.list_files(&pkg)).iter().map(|file| { @@ -119,6 +121,20 @@ fn check_metadata(pkg: &Package, config: &Config) -> CargoResult<()> { Ok(()) } +// check that the package dependencies are safe to deploy. +fn verify_dependencies(pkg: &Package) -> CargoResult<()> { + for dep in pkg.dependencies() { + if dep.source_id().is_path() { + if !dep.specified_req() { + bail!("all path dependencies must have a version specified \ + when packaging.\ndependency `{}` does not specify \ + a version.", dep.name()) + } + } + } + Ok(()) +} + fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> { if let Ok(repo) = git2::Repository::discover(p.root()) { if let Some(workdir) = repo.workdir() { From 84b78257cbe156f2afffd13ded4513c541944456 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 31 Aug 2016 16:13:26 -0700 Subject: [PATCH 0699/3888] Verify `cargo package` rejects path dependencies. Port of the equivalent test from the `cargo publish` command. --- tests/package.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/package.rs b/tests/package.rs index b953c3916c6..c9bbfd0f72c 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -206,6 +206,37 @@ fn package_verification() { dir = p.url()))); } +#[test] +fn path_dependency_no_version() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + license = "MIT" + description = "foo" + + [dependencies.bar] + path = "bar" + "#) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + "#) + .file("bar/src/lib.rs", ""); + + assert_that(p.cargo_process("package"), + execs().with_status(101).with_stderr("\ +[WARNING] manifest has no documentation, homepage or repository. See http://doc.crates.io/manifest.html#package-metadata for more info. +[ERROR] all path dependencies must have a version specified when packaging. +dependency `bar` does not specify a version. +")); +} + #[test] fn exclude() { let p = project("foo") From d0c0682fb99bed88bac8223d2afe273aa92419d4 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Wed, 31 Aug 2016 23:25:07 -0400 Subject: [PATCH 0700/3888] Clarify wording: this restriction is not just libraries --- src/doc/faq.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/faq.md b/src/doc/faq.md index c7ac8a9b1e7..96272fefde0 100644 --- a/src/doc/faq.md +++ b/src/doc/faq.md @@ -130,10 +130,10 @@ picture to decide what versions of dependencies should be used. # Can libraries use `*` as a version for their dependencies? -**Starting January 22nd, 2016, [crates.io] will begin rejecting packages with -wildcard dependency constraints.** +**As of January 22nd, 2016, [crates.io] rejects all packages (not just libraries) +with wildcard dependency constraints.** -While they _can_, strictly speaking, they should not. A version requirement +While libraries _can_, strictly speaking, they should not. A version requirement of `*` says “This will work with every version ever,” which is never going to be true. Libraries should always specify the range that they do work with, even if it’s something as general as “every 1.x.y version.” From 0962507cb23c879fb66ea32aa73f09996cbfbab2 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 31 Aug 2016 21:01:36 -0700 Subject: [PATCH 0701/3888] Macros 1.1 --- src/cargo/core/manifest.rs | 6 +++++- src/cargo/util/toml.rs | 18 +++++++++++++++++- src/doc/manifest.md | 11 ++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index a0e7450574f..827008b8be4 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -61,6 +61,7 @@ pub enum LibKind { Lib, Rlib, Dylib, + RustcMacro, Other(String), } @@ -70,6 +71,7 @@ impl LibKind { "lib" => LibKind::Lib, "rlib" => LibKind::Rlib, "dylib" => LibKind::Dylib, + "rustc-macro" => LibKind::RustcMacro, s => LibKind::Other(s.to_string()), } } @@ -80,6 +82,7 @@ impl LibKind { LibKind::Lib => "lib", LibKind::Rlib => "rlib", LibKind::Dylib => "dylib", + LibKind::RustcMacro => "rustc-macro", LibKind::Other(ref s) => s, } } @@ -88,7 +91,8 @@ impl LibKind { match *self { LibKind::Lib | LibKind::Rlib | - LibKind::Dylib => true, + LibKind::Dylib | + LibKind::RustcMacro => true, LibKind::Other(..) => false, } } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 0c138e648bf..811e58b49c4 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -444,6 +444,7 @@ impl TomlManifest { let lib = match self.lib { Some(ref lib) => { try!(lib.validate_library_name()); + try!(lib.validate_crate_type()); Some( TomlTarget { name: lib.name.clone().or(Some(project.name.clone())), @@ -900,6 +901,7 @@ struct TomlTarget { bench: Option, doc: Option, plugin: Option, + rustc_macro: Option, harness: Option, } @@ -928,6 +930,7 @@ impl TomlTarget { bench: None, doc: None, plugin: None, + rustc_macro: None, harness: None, } } @@ -1006,6 +1009,14 @@ impl TomlTarget { None => Err(human("bench target bench.name is required".to_string())) } } + + fn validate_crate_type(&self) -> CargoResult<()> { + if self.plugin == Some(true) && self.rustc_macro == Some(true) { + Err(human("lib.plugin and lib.rustc-macro cannot both be true".to_string())) + } else { + Ok(()) + } + } } impl PathValue { @@ -1040,7 +1051,11 @@ fn normalize(lib: &Option, .set_doctest(toml.doctest.unwrap_or(t2.doctested())) .set_benched(toml.bench.unwrap_or(t2.benched())) .set_harness(toml.harness.unwrap_or(t2.harness())) - .set_for_host(toml.plugin.unwrap_or(t2.for_host())); + .set_for_host(match (toml.plugin, toml.rustc_macro) { + (None, None) => t2.for_host(), + (Some(true), _) | (_, Some(true)) => true, + _ => false, + }); } fn lib_target(dst: &mut Vec, @@ -1053,6 +1068,7 @@ fn normalize(lib: &Option, Some(kinds) => kinds.iter().map(|s| LibKind::from_str(s)).collect(), None => { vec![ if l.plugin == Some(true) {LibKind::Dylib} + else if l.rustc_macro == Some(true) {LibKind::RustcMacro} else {LibKind::Lib} ] } }; diff --git a/src/doc/manifest.md b/src/doc/manifest.md index 675841784d7..086d214d894 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -508,6 +508,10 @@ doc = true # for Cargo to correctly compile it and make it available for all dependencies. plugin = false +# If the target is meant to be a "macros 1.1" procedural macro, this field must +# be set to true. +rustc-macro = false + # If set to false, `cargo test` will omit the `--test` flag to rustc, which # stops it from generating a test harness. This is useful when the binary being # built manages the test runner itself. @@ -527,9 +531,10 @@ name = "..." crate-type = ["dylib"] # could be `staticlib` as well ``` -The available options are `dylib`, `rlib`, `staticlib`, and `cdylib`. You -should only use this option in a project. Cargo will always compile packages -(dependencies) based on the requirements of the project that includes them. +The available options are `dylib`, `rlib`, `staticlib`, `cdylib`, and +`rustc-macro`. You should only use this option in a project. Cargo will always +compile packages (dependencies) based on the requirements of the project that +includes them. You can read more about the different crate types in the [Rust Reference Manual](https://doc.rust-lang.org/reference.html#linkage) From 3ad114dbfaef0fc115c7d198f9dc7da47144298c Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Wed, 31 Aug 2016 17:04:29 -0700 Subject: [PATCH 0702/3888] Linewrap the error message from check_metadata. This lets test result expected output pass the long-line style check. --- src/cargo/ops/cargo_package.rs | 2 +- tests/package.rs | 20 +++++++++++++++----- tests/publish.rs | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 2ed76ab7595..78fde8ed7dd 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -114,7 +114,7 @@ fn check_metadata(pkg: &Package, config: &Config) -> CargoResult<()> { things.push_str(&missing.last().unwrap()); try!(config.shell().warn( - &format!("manifest has no {things}. \ + &format!("manifest has no {things}.\n\ See http://doc.crates.io/manifest.html#package-metadata for more info.", things = things))) } diff --git a/tests/package.rs b/tests/package.rs index c9bbfd0f72c..d23cc539aab 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -37,6 +37,7 @@ fn simple() { assert_that(p.cargo_process("package"), execs().with_status(0).with_stderr(&format!("\ [WARNING] manifest has no documentation[..] +See [..] [PACKAGING] foo v0.0.1 ({dir}) [VERIFYING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir}[..]) @@ -82,8 +83,8 @@ fn metadata_warning() { assert_that(p.cargo_process("package"), execs().with_status(0).with_stderr(&format!("\ warning: manifest has no description, license, license-file, documentation, \ -homepage or repository. See \ -http://doc.crates.io/manifest.html#package-metadata for more info. +homepage or repository. +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ({dir}) [VERIFYING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir}[..]) @@ -104,8 +105,8 @@ http://doc.crates.io/manifest.html#package-metadata for more info. "#); assert_that(p.cargo_process("package"), execs().with_status(0).with_stderr(&format!("\ -warning: manifest has no description, documentation, homepage or repository. See \ -http://doc.crates.io/manifest.html#package-metadata for more info. +warning: manifest has no description, documentation, homepage or repository. +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ({dir}) [VERIFYING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir}[..]) @@ -165,6 +166,7 @@ fn package_verbose() { assert_that(cargo.clone().arg("package").arg("-v").arg("--no-verify"), execs().with_status(0).with_stderr("\ [WARNING] manifest has no description[..] +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ([..]) [ARCHIVING] [..] [ARCHIVING] [..] @@ -175,6 +177,7 @@ fn package_verbose() { .cwd(p.root().join("a")), execs().with_status(0).with_stderr("\ [WARNING] manifest has no description[..] +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] a v0.0.1 ([..]) [ARCHIVING] [..] [ARCHIVING] [..] @@ -198,6 +201,7 @@ fn package_verification() { assert_that(p.cargo("package"), execs().with_status(0).with_stderr(&format!("\ [WARNING] manifest has no description[..] +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ({dir}) [VERIFYING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir}[..]) @@ -231,7 +235,8 @@ fn path_dependency_no_version() { assert_that(p.cargo_process("package"), execs().with_status(101).with_stderr("\ -[WARNING] manifest has no documentation, homepage or repository. See http://doc.crates.io/manifest.html#package-metadata for more info. +[WARNING] manifest has no documentation, homepage or repository. +See http://doc.crates.io/manifest.html#package-metadata for more info. [ERROR] all path dependencies must have a version specified when packaging. dependency `bar` does not specify a version. ")); @@ -256,6 +261,7 @@ fn exclude() { assert_that(p.cargo_process("package").arg("--no-verify").arg("-v"), execs().with_status(0).with_stderr("\ [WARNING] manifest has no description[..] +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ([..]) [ARCHIVING] [..] [ARCHIVING] [..] @@ -282,6 +288,7 @@ fn include() { assert_that(p.cargo_process("package").arg("--no-verify").arg("-v"), execs().with_status(0).with_stderr("\ [WARNING] manifest has no description[..] +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ([..]) [ARCHIVING] [..] [ARCHIVING] [..] @@ -391,6 +398,7 @@ fn ignore_nested() { assert_that(p.cargo_process("package"), execs().with_status(0).with_stderr(&format!("\ [WARNING] manifest has no documentation[..] +See http://doc.crates.io/manifest.html#package-metadata for more info. [PACKAGING] nested v0.0.1 ({dir}) [VERIFYING] nested v0.0.1 ({dir}) [COMPILING] nested v0.0.1 ({dir}[..]) @@ -439,6 +447,7 @@ fn package_weird_characters() { assert_that(p.cargo_process("package"), execs().with_status(101).with_stderr("\ warning: [..] +See [..] [PACKAGING] foo [..] [ERROR] failed to prepare local package for uploading @@ -479,6 +488,7 @@ fn repackage_on_source_change() { // Check that cargo rebuilds the tarball assert_that(pro, execs().with_status(0).with_stderr(&format!("\ [WARNING] [..] +See [..] [PACKAGING] foo v0.0.1 ({dir}) [VERIFYING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 ({dir}[..]) diff --git a/tests/publish.rs b/tests/publish.rs index 38ccad219ff..eb3221b6315 100644 --- a/tests/publish.rs +++ b/tests/publish.rs @@ -60,6 +60,7 @@ fn simple() { execs().with_status(0).with_stderr(&format!("\ [UPDATING] registry `{reg}` [WARNING] manifest has no documentation, [..] +See [..] [PACKAGING] foo v0.0.1 ({dir}) [UPLOADING] foo v0.0.1 ({dir}) ", @@ -357,6 +358,7 @@ fn dry_run() { execs().with_status(0).with_stderr(&format!("\ [UPDATING] registry `[..]` [WARNING] manifest has no documentation, [..] +See [..] [PACKAGING] foo v0.0.1 ({dir}) [VERIFYING] foo v0.0.1 ({dir}) [COMPILING] foo v0.0.1 [..] From ed65d53062bb77a968fa8010f7d83275f63e2c37 Mon Sep 17 00:00:00 2001 From: Mikael Brockman Date: Thu, 1 Sep 2016 18:53:45 +0300 Subject: [PATCH 0703/3888] doc: mention feature toggling in "Specifying deps" --- src/doc/specifying-dependencies.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/doc/specifying-dependencies.md b/src/doc/specifying-dependencies.md index 15873c310c8..c7b95fdac6a 100644 --- a/src/doc/specifying-dependencies.md +++ b/src/doc/specifying-dependencies.md @@ -391,3 +391,19 @@ unless listed under the `dependencies` section as well. A package itself and its build script are built separately, so their dependencies need not coincide. Cargo is kept simpler and cleaner by using independent dependencies for independent purposes. + +# Choosing features + +If a package you depend on offers conditional features, you can +specify which to use: + +```toml +[dependencies.awesome] +version = "1.3.5" +default-features = false # do not include the default features, and optionally + # cherry-pick individual features +features = ["secure-password", "civet"] +``` + +More information about features can be found in the +[manifest documentation](manifest.html#the-features-section). From 03786c16cec71330842fc94adc22eef942d7f01c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 1 Sep 2016 10:29:24 -0700 Subject: [PATCH 0704/3888] Test for rustc-macro --- tests/rustc-macro.rs | 146 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 tests/rustc-macro.rs diff --git a/tests/rustc-macro.rs b/tests/rustc-macro.rs new file mode 100644 index 00000000000..fe49b359d2d --- /dev/null +++ b/tests/rustc-macro.rs @@ -0,0 +1,146 @@ +extern crate cargotest; +extern crate hamcrest; + +use cargotest::is_nightly; +use cargotest::support::{project, execs}; +use hamcrest::assert_that; + +#[test] +fn noop() { + if !is_nightly() { + return; + } + + let client = project("client") + .file("Cargo.toml", r#" + [package] + name = "client" + version = "0.0.1" + authors = [] + + [dependencies.noop] + path = "../noop" + "#) + .file("src/main.rs", r#" + #![feature(rustc_macro)] + + #[macro_use] + extern crate noop; + + #[derive(Noop)] + struct X; + + fn main() {} + "#); + let noop = project("noop") + .file("Cargo.toml", r#" + [package] + name = "noop" + version = "0.0.1" + authors = [] + + [lib] + rustc-macro = true + "#) + .file("src/lib.rs", r#" + #![feature(rustc_macro, rustc_macro_lib)] + + extern crate rustc_macro; + use rustc_macro::TokenStream; + + #[rustc_macro_derive(Noop)] + pub fn noop(input: TokenStream) -> TokenStream { + input + } + "#); + noop.build(); + + assert_that(client.cargo_process("build"), + execs().with_status(0)); + assert_that(client.cargo("build"), + execs().with_status(0)); +} + +#[test] +fn impl_and_derive() { + if !is_nightly() { + return; + } + + let client = project("client") + .file("Cargo.toml", r#" + [package] + name = "client" + version = "0.0.1" + authors = [] + + [dependencies.transmogrify] + path = "../transmogrify" + "#) + .file("src/main.rs", r#" + #![feature(rustc_macro)] + + #[macro_use] + extern crate transmogrify; + + trait ImplByTransmogrify { + fn impl_by_transmogrify(&self) -> bool; + } + + #[derive(Transmogrify)] + struct X; + + fn main() { + let x = X::new(); + assert!(x.impl_by_transmogrify()); + println!("{:?}", x); + } + "#); + let transmogrify = project("transmogrify") + .file("Cargo.toml", r#" + [package] + name = "transmogrify" + version = "0.0.1" + authors = [] + + [lib] + rustc-macro = true + "#) + .file("src/lib.rs", r#" + #![feature(rustc_macro, rustc_macro_lib)] + + extern crate rustc_macro; + use rustc_macro::TokenStream; + + #[rustc_macro_derive(Transmogrify)] + #[doc(hidden)] + pub fn transmogrify(input: TokenStream) -> TokenStream { + assert_eq!(input.to_string(), "struct X;\n"); + + " + impl X { + fn new() -> Self { + X { success: true } + } + } + + impl ImplByTransmogrify for X { + fn impl_by_transmogrify(&self) -> bool { + true + } + } + + #[derive(Debug)] + struct X { + success: bool, + } + ".parse().unwrap() + } + "#); + transmogrify.build(); + + assert_that(client.cargo_process("build"), + execs().with_status(0)); + assert_that(client.cargo("run"), + execs().with_status(0).with_stdout("X { success: true }")); +} From cf8ac6dbecccf5057f3f38227084ab55e073f970 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 1 Sep 2016 10:42:23 -0700 Subject: [PATCH 0705/3888] Test a crate that is both a plugin and a proc macro --- src/cargo/util/toml.rs | 9 +++++++++ tests/rustc-macro.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 811e58b49c4..15e5246315d 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -1011,6 +1011,15 @@ impl TomlTarget { } fn validate_crate_type(&self) -> CargoResult<()> { + // Per the Macros 1.1 RFC: + // + // > Initially if a crate is compiled with the rustc-macro crate type + // > (and possibly others) it will forbid exporting any items in the + // > crate other than those functions tagged #[rustc_macro_derive] and + // > those functions must also be placed at the crate root. + // + // A plugin requires exporting plugin_registrar so a crate cannot be + // both at once. if self.plugin == Some(true) && self.rustc_macro == Some(true) { Err(human("lib.plugin and lib.rustc-macro cannot both be true".to_string())) } else { diff --git a/tests/rustc-macro.rs b/tests/rustc-macro.rs index fe49b359d2d..f3d618b1228 100644 --- a/tests/rustc-macro.rs +++ b/tests/rustc-macro.rs @@ -144,3 +144,44 @@ fn impl_and_derive() { assert_that(client.cargo("run"), execs().with_status(0).with_stdout("X { success: true }")); } + +#[test] +fn plugin_and_rustc_macro() { + if !is_nightly() { + return; + } + + let questionable = project("questionable") + .file("Cargo.toml", r#" + [package] + name = "questionable" + version = "0.0.1" + authors = [] + + [lib] + plugin = true + rustc-macro = true + "#) + .file("src/lib.rs", r#" + #![feature(plugin_registrar, rustc_private)] + #![feature(rustc_macro, rustc_macro_lib)] + + extern crate rustc_plugin; + use rustc_plugin::Registry; + + extern crate rustc_macro; + use rustc_macro::TokenStream; + + #[plugin_registrar] + pub fn plugin_registrar(reg: &mut Registry) {} + + #[rustc_macro_derive(Questionable)] + pub fn questionable(input: TokenStream) -> TokenStream { + input + } + "#); + + let msg = " lib.plugin and lib.rustc-macro cannot both be true"; + assert_that(questionable.cargo_process("build"), + execs().with_status(101).with_stderr_contains(msg)); +} From 9dce5621735ce53c81e938a3e3bd5420982fbdc9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 1 Sep 2016 14:17:42 -0700 Subject: [PATCH 0706/3888] Explicitly bind Some(false) --- src/cargo/util/toml.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 15e5246315d..ac94d3a2837 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -1063,7 +1063,7 @@ fn normalize(lib: &Option, .set_for_host(match (toml.plugin, toml.rustc_macro) { (None, None) => t2.for_host(), (Some(true), _) | (_, Some(true)) => true, - _ => false, + (Some(false), _) | (_, Some(false)) => false, }); } From b94ab1ad438fd76078f8accce9a5f161cb7ce9e2 Mon Sep 17 00:00:00 2001 From: Binary Birch Tree Date: Fri, 2 Sep 2016 21:05:26 -0400 Subject: [PATCH 0707/3888] Generalize error message used by both `cargo package` and `cargo publish`. --- src/cargo/ops/cargo_package.rs | 3 +-- tests/package.rs | 36 +++++++++++++++++++++++++++++++++- tests/publish.rs | 2 +- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 78fde8ed7dd..dc12e46ffe8 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -173,8 +173,7 @@ fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> { Ok(()) } else { bail!("{} dirty files found in the working directory:\n\n{}\n\n\ - to publish despite this, pass `--allow-dirty` to \ - `cargo publish`", + to proceed despite this, pass the `--allow-dirty` flag", dirty.len(), dirty.join("\n")) } } diff --git a/tests/package.rs b/tests/package.rs index d23cc539aab..7f3712f3724 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -6,7 +6,7 @@ extern crate hamcrest; extern crate tar; extern crate cargo; -use std::fs::File; +use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::path::{Path, PathBuf}; @@ -544,3 +544,37 @@ Caused by: [..] ")); } + +#[test] +fn do_not_package_if_repository_is_dirty() { + // Create a Git repository containing a minimal Rust project. + git::repo(&paths::root().join("foo")) + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.0.1" + license = "MIT" + description = "foo" + documentation = "foo" + homepage = "foo" + repository = "foo" + "#) + .file("src/main.rs", "fn main() {}") + .build(); + + // Modify Cargo.toml without committing the change. + let p = project("foo"); + let manifest_path = p.root().join("Cargo.toml"); + let mut manifest = t!(OpenOptions::new().append(true).open(manifest_path)); + t!(writeln!(manifest, "")); + + assert_that(p.cargo("package"), + execs().with_status(101) + .with_stderr("\ +error: 1 dirty files found in the working directory: + +Cargo.toml + +to proceed despite this, pass the `--allow-dirty` flag +")); +} diff --git a/tests/publish.rs b/tests/publish.rs index eb3221b6315..b11cb7a47d6 100644 --- a/tests/publish.rs +++ b/tests/publish.rs @@ -207,7 +207,7 @@ error: 1 dirty files found in the working directory: bar -to publish despite this, pass `--allow-dirty` to `cargo publish` +to proceed despite this, pass the `--allow-dirty` flag ")); } From 02819fcef82156230d6bdf46a32d9128be09f47a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 3 Sep 2016 19:45:18 -0500 Subject: [PATCH 0708/3888] prepare for cargo for mips and powerpc with these changes I can cross compile Cargo for these targets: - mips-unknown-linux-gnu - mipsel-unknown-linux-gnu - powerpc-unknown-linux-gnu - powerpc64-unknown-linux-gnu - powerpc64el-unknown-linux-gnu using these commands: ``` $ ./.travis.install.deps.sh $ ./configure --local-rust-root=$(pwd)/rustc --enable-nightly --target=$TARGET $ make ``` in Ubuntu 16.04 using the standard cross toolchains --- Makefile.in | 51 ++++++++++++++++++++++++++--------------- src/etc/install-deps.py | 13 +++++++---- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/Makefile.in b/Makefile.in index d8093de5e8e..c64240391cd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -166,37 +166,52 @@ $(DOC_DIR)/%: src/doc/% @mkdir -p $(@D) cp $< $@ -OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64 -OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64 -OPENSSL_OS_i686-unknown-linux-gnu := linux-elf +OPENSSL_OS_aarch64-unknown-linux-gnu := linux-aarch64 OPENSSL_OS_arm-unknown-linux-gnueabi := linux-armv4 OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4 -OPENSSL_OS_aarch64-unknown-linux-gnu := linux-aarch64 OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf +OPENSSL_OS_i686-unknown-linux-gnu := linux-elf +OPENSSL_OS_mips-unknown-linux-gnu := linux-mips32 +OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32 +OPENSSL_OS_powerpc-unknown-linux-gnu := linux-ppc +OPENSSL_OS_powerpc64-unknown-linux-gnu := linux-ppc64 +OPENSSL_OS_powerpc64le-unknown-linux-gnu := linux-ppc64le OPENSSL_OS_x86_64-unknown-freebsd := BSD-x86_64 +OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64 +OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64 OPENSSL_OS_x86_64-unknown-netbsd := BSD-x86_64 -OPENSSL_CC_x86_64-unknown-linux-gnu := gcc -OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc -OPENSSL_CC_i686-unknown-linux-gnu := gcc -OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc -OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc -OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc -OPENSSL_CC_aarch64-unknown-linux-gnu := aarch64-linux-gnu-gcc -OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc -OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc -OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc -OPENSSL_AR_x86_64-unknown-linux-gnu := ar -OPENSSL_AR_x86_64-unknown-linux-musl := ar -OPENSSL_AR_i686-unknown-linux-gnu := ar +OPENSSL_AR_aarch64-unknown-linux-gnu := aarch64-linux-gnu-ar OPENSSL_AR_arm-unknown-linux-gnueabi := arm-linux-gnueabi-ar OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar -OPENSSL_AR_aarch64-unknown-linux-gnu := aarch64-linux-gnu-ar OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar +OPENSSL_AR_i686-unknown-linux-gnu := ar +OPENSSL_AR_mips-unknown-linux-gnu := mips-linux-gnu-ar +OPENSSL_AR_mipsel-unknown-linux-gnu := mipsel-linux-gnu-ar +OPENSSL_AR_powerpc-unknown-linux-gnu := powerpc-linux-gnu-ar +OPENSSL_AR_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-ar +OPENSSL_AR_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-ar OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar +OPENSSL_AR_x86_64-unknown-linux-gnu := ar +OPENSSL_AR_x86_64-unknown-linux-musl := ar OPENSSL_AR_x86_64-unknown-netbsd := x86_64-unknown-netbsd-ar +OPENSSL_CC_aarch64-unknown-linux-gnu := aarch64-linux-gnu-gcc +OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc +OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc +OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc +OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc +OPENSSL_CC_i686-unknown-linux-gnu := gcc +OPENSSL_CC_mips-unknown-linux-gnu := mips-linux-gnu-gcc +OPENSSL_CC_mipsel-unknown-linux-gnu := mipsel-linux-gnu-gcc +OPENSSL_CC_powerpc-unknown-linux-gnu := powerpc-linux-gnu-gcc +OPENSSL_CC_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-gcc +OPENSSL_CC_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-gcc +OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc +OPENSSL_CC_x86_64-unknown-linux-gnu := gcc +OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc +OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc SETARCH_i686-unknown-linux-gnu := setarch i386 OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32 diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py index 638461c22a7..a833c26c961 100644 --- a/src/etc/install-deps.py +++ b/src/etc/install-deps.py @@ -17,15 +17,20 @@ if sys.platform == 'linux' or sys.platform == 'linux2': host = host_bits + '-unknown-linux-gnu' targets = [ - 'i686-unknown-linux-gnu', - 'x86_64-unknown-linux-gnu', - 'x86_64-unknown-linux-musl', + 'aarch64-unknown-linux-gnu', 'arm-unknown-linux-gnueabi', 'arm-unknown-linux-gnueabihf', 'armv7-unknown-linux-gnueabihf', - 'aarch64-unknown-linux-gnu', 'i686-unknown-freebsd', + 'i686-unknown-linux-gnu', + 'mips-unknown-linux-gnu', + 'mipsel-unknown-linux-gnu', + 'powerpc-unknown-linux-gnu', + 'powerpc64-unknown-linux-gnu', + 'powerpc64le-unknown-linux-gnu', 'x86_64-unknown-freebsd', + 'x86_64-unknown-linux-gnu', + 'x86_64-unknown-linux-musl', 'x86_64-unknown-netbsd', ] elif sys.platform == 'darwin': From ac7e7b6c7255534cb5d6061beed5f3df5d702d2d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 4 Sep 2016 08:25:30 -0700 Subject: [PATCH 0709/3888] Empty commit to trigger Travis build of rustc-macro From af85785343b7a071efdf6821805aaf8482a5c426 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Sun, 4 Sep 2016 21:56:05 +0200 Subject: [PATCH 0710/3888] Remove reference of Rust 1.11.0 release date in the FAQ This commit also reflows the text after removing the reference. --- src/doc/faq.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/doc/faq.md b/src/doc/faq.md index 96272fefde0..cf92bbe2cc4 100644 --- a/src/doc/faq.md +++ b/src/doc/faq.md @@ -178,14 +178,14 @@ and a populated cache of the crates reflected in the lock file. If either of these components are missing, then they're required for the build to succeed and must be fetched remotely. -As of Rust 1.11.0 (to be released 2016-09-29) Cargo understands a new flag, -`--frozen`, which is an assertion that it shouldn't touch the network. When -passed, Cargo will immediately return an error if it would otherwise attempt a -network request. The error should include contextual information about why the -network request is being made in the first place to help debug as well. Note -that this flag *does not change the behavior of Cargo*, it simply asserts that -Cargo shouldn't touch the network as a previous command has been run to ensure -that network activity shouldn't be necessary. +As of Rust 1.11.0 Cargo understands a new flag, `--frozen`, which is an +assertion that it shouldn't touch the network. When passed, Cargo will +immediately return an error if it would otherwise attempt a network request. +The error should include contextual information about why the network request is +being made in the first place to help debug as well. Note that this flag *does +not change the behavior of Cargo*, it simply asserts that Cargo shouldn't touch +the network as a previous command has been run to ensure that network activity +shouldn't be necessary. For more information about vendoring, see documentation on [source replacement][replace]. From 34170e83b71b5d7021ed7ac457b581ba00a77af1 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 5 Sep 2016 14:22:30 +0200 Subject: [PATCH 0711/3888] docfix: `extern crate` uses `lib.name`; default is post '-' => '_' substitution --- src/doc/manifest.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doc/manifest.md b/src/doc/manifest.md index 675841784d7..b0354841f57 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -484,7 +484,9 @@ specified. [lib] # The name of a target is the name of the library that will be generated. This -# is defaulted to the name of the package or project. +# is defaulted to the name of the package or project, with any dashes replaced +# with underscores. (Rust `extern crate` declarations reference this name; +# therefore the value must be a valid Rust identifier to be usable.) name = "foo" # This field points at where the crate is located, relative to the `Cargo.toml`. From fee7b00bd2c18535fe0ab3a7da7a3d779a040710 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 6 Sep 2016 10:34:35 -0700 Subject: [PATCH 0712/3888] Bump rustcversion to pick up rustc-macro support --- src/rustversion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rustversion.txt b/src/rustversion.txt index 8b6746a8608..f96de36a9fd 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-07-12 +2016-09-05 From c1dab534b88570b948cd79a7d3d0c5261f49dafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Thu, 8 Sep 2016 15:13:31 -0400 Subject: [PATCH 0713/3888] Add a test that reproduces the error of parsing home config twice. --- tests/cargotest/support/mod.rs | 5 +++++ tests/rustflags.rs | 28 +++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index c99e8e294a0..fb6c7daf629 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -198,6 +198,11 @@ pub fn project(name: &str) -> ProjectBuilder { ProjectBuilder::new(name, paths::root().join(name)) } +// Generates a project layout inside our fake home dir +pub fn project_in_home(name: &str) -> ProjectBuilder { + ProjectBuilder::new(name, paths::home().join(name)) +} + // === Helpers === pub fn main_file(println: &str, deps: &[&str]) -> String { diff --git a/tests/rustflags.rs b/tests/rustflags.rs index 264c47219ef..ccdc6a91dc9 100644 --- a/tests/rustflags.rs +++ b/tests/rustflags.rs @@ -5,7 +5,7 @@ use std::io::Write; use std::fs::{self, File}; use cargotest::rustc_host; -use cargotest::support::{project, execs, paths}; +use cargotest::support::{project, project_in_home, execs, paths}; use hamcrest::assert_that; #[test] @@ -852,3 +852,29 @@ fn build_rustflags_no_recompile() { assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"), execs().with_stdout("").with_status(0)); } + +#[test] +fn build_rustflags_with_home_config() { + // We need a config file inside the home directory + let home = paths::home(); + let home_config = home.join(".cargo"); + fs::create_dir(&home_config).unwrap(); + File::create(&home_config.join("config")).unwrap().write_all(br#" + [build] + rustflags = ["-Cllvm-args=-x86-asm-syntax=intel"] + "#).unwrap(); + + // And we need the project to be inside the home directory + // so the walking process finds the home project twice. + let p = project_in_home("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + "#) + .file("src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("build").arg("-v"), + execs().with_status(0)); +} From b07bc5c3d66f6e7591ee32f3e230c952d91bfc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Thu, 8 Sep 2016 15:58:53 -0400 Subject: [PATCH 0714/3888] Don't parse the config in home if it was parsed already. This is the first version of the fix. It needs clean up. --- src/cargo/util/config.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 21d68c1cef4..0d0a89791dc 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -1,6 +1,7 @@ use std::cell::{RefCell, RefMut, Cell}; use std::collections::hash_map::Entry::{Occupied, Vacant}; -use std::collections::hash_map::{HashMap}; +use std::collections::hash_map::HashMap; +use std::collections::HashSet; use std::env; use std::fmt; use std::fs::{self, File}; @@ -675,13 +676,20 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> where F: FnMut(File, &Path) -> CargoResult<()> { let mut current = pwd; + let mut stash: HashSet = HashSet::new(); loop { let possible = current.join(".cargo").join("config"); if fs::metadata(&possible).is_ok() { - let file = try!(File::open(&possible)); + let canonical = fs::canonicalize(possible).unwrap(); + let string = canonical.to_str().unwrap().to_owned(); + if stash.get(&string).is_none() { + let file = try!(File::open(&canonical)); - try!(walk(file, &possible)); + try!(walk(file, &canonical)); + + stash.insert(string); + } } match current.parent() { Some(p) => current = p, @@ -696,8 +704,9 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> human("Cargo couldn't find your home directory. \ This probably means that $HOME was not set.") })); - if !pwd.starts_with(&home) { - let config = home.join("config"); + let config = home.join("config"); + let key = config.to_str().unwrap().to_owned(); + if stash.get(&key).is_none() { if fs::metadata(&config).is_ok() { let file = try!(File::open(&config)); try!(walk(file, &config)); From fcd480b24e53ec6df03be3145ecf13e0e278f003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Thu, 8 Sep 2016 16:20:36 -0400 Subject: [PATCH 0715/3888] Add ConfigFile struct to handle config file paths. --- src/cargo/util/config.rs | 54 +++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 0d0a89791dc..70dadbd988d 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -22,6 +22,30 @@ use util::toml as cargo_toml; use self::ConfigValue as CV; +#[derive(PartialEq, Eq, Hash)] +struct ConfigFile { + path: Option, +} + +impl ConfigFile { + pub fn new(path: PathBuf) -> ConfigFile { + let canonical = match fs::canonicalize(path) { + Ok(p) => Some(p), + Err(_) => None, + }; + + ConfigFile { path: canonical } + } + + pub fn exist(&self) -> bool { + self.path.is_some() + } + + pub fn as_path_buf(&self) -> Option { + self.path.clone() + } +} + pub struct Config { home_path: Filesystem, shell: RefCell, @@ -676,21 +700,19 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> where F: FnMut(File, &Path) -> CargoResult<()> { let mut current = pwd; - let mut stash: HashSet = HashSet::new(); + let mut stash: HashSet = HashSet::new(); loop { - let possible = current.join(".cargo").join("config"); - if fs::metadata(&possible).is_ok() { - let canonical = fs::canonicalize(possible).unwrap(); - let string = canonical.to_str().unwrap().to_owned(); - if stash.get(&string).is_none() { - let file = try!(File::open(&canonical)); + let possible = ConfigFile::new(current.join(".cargo").join("config")); + if possible.exist() && stash.get(&possible).is_none() { + let name = possible.as_path_buf().unwrap(); + let file = try!(File::open(&name)); - try!(walk(file, &canonical)); + try!(walk(file, &name)); - stash.insert(string); - } + stash.insert(possible); } + match current.parent() { Some(p) => current = p, None => break, @@ -704,13 +726,11 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> human("Cargo couldn't find your home directory. \ This probably means that $HOME was not set.") })); - let config = home.join("config"); - let key = config.to_str().unwrap().to_owned(); - if stash.get(&key).is_none() { - if fs::metadata(&config).is_ok() { - let file = try!(File::open(&config)); - try!(walk(file, &config)); - } + let config = ConfigFile::new(home.join("config")); + if config.exist() && stash.get(&config).is_none() { + let name = config.as_path_buf().unwrap(); + let file = try!(File::open(&name)); + try!(walk(file, &name)); } Ok(()) From 0ddbd0214a5008d4d4a9572aa58ef78cddbbb123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Thu, 8 Sep 2016 20:35:13 -0400 Subject: [PATCH 0716/3888] Remove fs::canonicalize in walk_tree fix. * Remove ConfiFile struct, it is not needed without the fs::canonicalize call. * Don't check if the file is in the stash when walking the tree, without "canonicalization" it is not necessary. --- src/cargo/util/config.rs | 44 ++++++++-------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 70dadbd988d..2f207d86eab 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -22,30 +22,6 @@ use util::toml as cargo_toml; use self::ConfigValue as CV; -#[derive(PartialEq, Eq, Hash)] -struct ConfigFile { - path: Option, -} - -impl ConfigFile { - pub fn new(path: PathBuf) -> ConfigFile { - let canonical = match fs::canonicalize(path) { - Ok(p) => Some(p), - Err(_) => None, - }; - - ConfigFile { path: canonical } - } - - pub fn exist(&self) -> bool { - self.path.is_some() - } - - pub fn as_path_buf(&self) -> Option { - self.path.clone() - } -} - pub struct Config { home_path: Filesystem, shell: RefCell, @@ -700,15 +676,14 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> where F: FnMut(File, &Path) -> CargoResult<()> { let mut current = pwd; - let mut stash: HashSet = HashSet::new(); + let mut stash: HashSet = HashSet::new(); loop { - let possible = ConfigFile::new(current.join(".cargo").join("config")); - if possible.exist() && stash.get(&possible).is_none() { - let name = possible.as_path_buf().unwrap(); - let file = try!(File::open(&name)); + let possible = current.join(".cargo").join("config"); + if fs::metadata(&possible).is_ok() { + let file = try!(File::open(&possible)); - try!(walk(file, &name)); + try!(walk(file, &possible)); stash.insert(possible); } @@ -726,11 +701,10 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> human("Cargo couldn't find your home directory. \ This probably means that $HOME was not set.") })); - let config = ConfigFile::new(home.join("config")); - if config.exist() && stash.get(&config).is_none() { - let name = config.as_path_buf().unwrap(); - let file = try!(File::open(&name)); - try!(walk(file, &name)); + let config = home.join("config"); + if !stash.contains(&config) && fs::metadata(&config).is_ok() { + let file = try!(File::open(&config)); + try!(walk(file, &config)); } Ok(()) From f8081d583f7d897022c4d9d62c96dbce85a79b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Sat, 10 Sep 2016 17:25:23 -0400 Subject: [PATCH 0717/3888] Properly close dep_feature_in_cmd_line test. It was including the test all_features_flag_enables_all_features inside its function body. --- tests/features.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/features.rs b/tests/features.rs index a6921de3814..449e1f9c8c7 100644 --- a/tests/features.rs +++ b/tests/features.rs @@ -960,6 +960,7 @@ fn dep_feature_in_cmd_line() { execs().with_status(101).with_stderr("\ [ERROR] feature names may not contain slashes: `bar/some-feat` ")); +} #[test] fn all_features_flag_enables_all_features() { @@ -1004,4 +1005,3 @@ fn all_features_flag_enables_all_features() { assert_that(p.cargo_process("build").arg("--all-features"), execs().with_status(0)); } -} From c3affaf964e28c870d3e6b63be164294e36db671 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 12 Sep 2016 21:45:29 -0400 Subject: [PATCH 0718/3888] Document recommended way for running tests Fixes #3084. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 49d73629aae..71c74508d79 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,12 @@ bit versions of cargo on unix you would use: $ ./configure --target=i686-unknown-linux-gnu,x86_64-unknown-linux-gnu ``` +## Running the tests + +To run cargo's tests, use `cargo test`. If you do not have the cross-compilers +installed locally, ignore the cross-compile test failures, or disable them by +using `CFG_DISABLE_CROSS_TESTS=1 cargo test`. + ## Adding new subcommands to Cargo Cargo is designed to be extensible with new subcommands without having to modify From 83d43dc3955ecf2fcbe3f49ace30e06bd717edb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Wed, 14 Sep 2016 15:02:47 -0400 Subject: [PATCH 0719/3888] FIX: Don't try to generate Gargo.lock on empty workspaces. There was a panic! when the command `cargo update` was executed in a workspace like this: mkdir ws cd ws echo '[workspace]' > Cargo.toml cargo new p1 cargo new p2 cargo update The problem is that cargo tries to generate the Cargo.lock file even if there aren't any members on the workspace. This fix checks the existence of members in the workspace before trying to do anything so at least we report an error instead of throwing a panic! --- src/cargo/core/workspace.rs | 8 +++++++- src/cargo/ops/cargo_generate_lockfile.rs | 4 ++++ tests/workspaces.rs | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index bdf00a44e83..afa6e3bf2b1 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -101,7 +101,7 @@ impl<'cfg> Workspace<'cfg> { Ok(ws) } - /// Creates a "tempoarary workspace" from one package which only contains + /// Creates a "temporary workspace" from one package which only contains /// that package. /// /// This constructor will not touch the filesystem and only creates an @@ -464,6 +464,12 @@ impl<'cfg> Packages<'cfg> { } } +impl<'a, 'cfg> Members<'a, 'cfg> { + pub fn is_empty(self) -> bool { + self.count() == 0 + } +} + impl<'a, 'cfg> Iterator for Members<'a, 'cfg> { type Item = &'a Package; diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 45ee2b10111..6a6d198b35b 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -31,6 +31,10 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) bail!("cannot specify both aggressive and precise simultaneously") } + if ws.members().is_empty() { + bail!("you can't generate a lockfile for an empty workspace.") + } + let previous_resolve = match try!(ops::load_pkg_lockfile(ws)) { Some(resolve) => resolve, None => return generate_lockfile(ws), diff --git a/tests/workspaces.rs b/tests/workspaces.rs index ab3b117fab8..08be87bf4cf 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -940,3 +940,25 @@ fn lockfile_can_specify_nonexistant_members() { assert_that(p.cargo("build").cwd(p.root().join("a")), execs().with_status(0)); } + +#[test] +fn you_cannot_generate_lockfile_for_empty_workspaces() { + let p = project("foo") + .file("Cargo.toml", r#" + [workspace] + "#) + .file("bar/Cargo.toml", r#" + [project] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo("update"), + execs().with_status(101) + .with_stderr("\ +error: you can't generate a lockfile for an empty workspace. +")); +} From a354b2a8983a1e90cb6688a28b117836d5e12375 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 14 Sep 2016 21:10:30 +0300 Subject: [PATCH 0720/3888] Move stream_output to ProcessBuilder --- src/cargo/ops/cargo_rustc/custom_build.rs | 63 ++------------------- src/cargo/ops/cargo_rustc/job_queue.rs | 4 +- src/cargo/util/process_builder.rs | 69 +++++++++++++++++++++-- tests/build-script.rs | 2 +- tests/build.rs | 2 +- tests/run.rs | 4 +- 6 files changed, 74 insertions(+), 70 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index ffc1aeaab8f..8835824898c 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -3,16 +3,12 @@ use std::fs; use std::path::{PathBuf, Path}; use std::str; use std::sync::{Mutex, Arc}; -use std::process::{Stdio, Output}; use core::PackageId; -use util::{CargoResult, Human}; +use util::{CargoResult, Human, Freshness}; use util::{internal, ChainError, profile, paths}; -use util::{Freshness, ProcessBuilder, read2}; -use util::errors::{process_error, ProcessError}; use super::job::Work; -use super::job_queue::JobState; use super::{fingerprint, Kind, Context, Unit}; use super::CommandType; @@ -209,7 +205,10 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // And now finally, run the build command itself! state.running(&p); let cmd = p.into_process_builder(); - let output = try!(stream_output(state, &cmd).map_err(|mut e| { + let output = try!(cmd.exec_with_streaming( + &mut |out_line| state.stdout(out_line), + &mut |err_line| state.stderr(err_line), + ).map_err(|mut e| { e.desc = format!("failed to run custom build command for `{}`\n{}", pkg_name, e.desc); Human(e) @@ -443,55 +442,3 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, } } } - -fn stream_output(state: &JobState, cmd: &ProcessBuilder) - -> Result { - let mut stdout = Vec::new(); - let mut stderr = Vec::new(); - - let status = try!((|| { - let mut cmd = cmd.build_command(); - cmd.stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .stdin(Stdio::null()); - let mut child = try!(cmd.spawn()); - let out = child.stdout.take().unwrap(); - let err = child.stderr.take().unwrap(); - - try!(read2(out, err, &mut |is_out, data, eof| { - let idx = if eof { - data.len() - } else { - match data.iter().rposition(|b| *b == b'\n') { - Some(i) => i + 1, - None => return, - } - }; - let data = data.drain(..idx); - let dst = if is_out {&mut stdout} else {&mut stderr}; - let start = dst.len(); - dst.extend(data); - let s = String::from_utf8_lossy(&dst[start..]); - if is_out { - state.stdout(&s); - } else { - state.stderr(&s); - } - })); - child.wait() - })().map_err(|e| { - let msg = format!("could not exeute process {}", cmd); - process_error(&msg, Some(e), None, None) - })); - let output = Output { - stdout: stdout, - stderr: stderr, - status: status, - }; - if !output.status.success() { - let msg = format!("process didn't exit successfully: {}", cmd); - Err(process_error(&msg, None, Some(&status), Some(&output))) - } else { - Ok(output) - } -} diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index a0cb1dddee9..53bad6b786c 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -170,12 +170,12 @@ impl<'a> JobQueue<'a> { } Message::Stdout(out) => { if cx.config.extra_verbose() { - try!(write!(cx.config.shell().out(), "{}", out)); + try!(writeln!(cx.config.shell().out(), "{}", out)); } } Message::Stderr(err) => { if cx.config.extra_verbose() { - try!(write!(cx.config.shell().err(), "{}", err)); + try!(writeln!(cx.config.shell().err(), "{}", err)); } } Message::Finish(result) => { diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index d86df727fa3..856e337e200 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -3,9 +3,9 @@ use std::env; use std::ffi::{OsString, OsStr}; use std::fmt; use std::path::Path; -use std::process::{Command, Output}; +use std::process::{Command, Stdio, Output}; -use util::{ProcessError, process_error}; +use util::{ProcessError, process_error, read2}; use util::shell_escape::escape; #[derive(Clone, PartialEq, Debug)] @@ -75,7 +75,7 @@ impl ProcessBuilder { pub fn exec(&self) -> Result<(), ProcessError> { let mut command = self.build_command(); let exit = try!(command.status().map_err(|e| { - process_error(&format!("Could not execute process `{}`", + process_error(&format!("could not execute process `{}`", self.debug_string()), Some(e), None, None) })); @@ -83,7 +83,7 @@ impl ProcessBuilder { if exit.success() { Ok(()) } else { - Err(process_error(&format!("Process didn't exit successfully: `{}`", + Err(process_error(&format!("process didn't exit successfully: `{}`", self.debug_string()), None, Some(&exit), None)) } @@ -93,7 +93,7 @@ impl ProcessBuilder { let mut command = self.build_command(); let output = try!(command.output().map_err(|e| { - process_error(&format!("Could not execute process `{}`", + process_error(&format!("could not execute process `{}`", self.debug_string()), Some(e), None, None) })); @@ -101,12 +101,69 @@ impl ProcessBuilder { if output.status.success() { Ok(output) } else { - Err(process_error(&format!("Process didn't exit successfully: `{}`", + Err(process_error(&format!("process didn't exit successfully: `{}`", self.debug_string()), None, Some(&output.status), Some(&output))) } } + pub fn exec_with_streaming(&self, + on_stdout_line: &mut FnMut(&str), + on_stderr_line: &mut FnMut(&str)) + -> Result { + let mut stdout = Vec::new(); + let mut stderr = Vec::new(); + + let mut cmd = self.build_command(); + cmd.stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .stdin(Stdio::null()); + + let status = try!((|| { + let mut child = try!(cmd.spawn()); + let out = child.stdout.take().unwrap(); + let err = child.stderr.take().unwrap(); + try!(read2(out, err, &mut |is_out, data, eof| { + let idx = if eof { + data.len() + } else { + match data.iter().rposition(|b| *b == b'\n') { + Some(i) => i + 1, + None => return, + } + }; + let data = data.drain(..idx); + let dst = if is_out {&mut stdout} else {&mut stderr}; + let start = dst.len(); + dst.extend(data); + for line in String::from_utf8_lossy(&dst[start..]).lines() { + if is_out { + on_stdout_line(line) + } else { + on_stderr_line(line) + } + } + })); + child.wait() + })().map_err(|e| { + process_error(&format!("could not execute process `{}`", + self.debug_string()), + Some(e), None, None) + })); + let output = Output { + stdout: stdout, + stderr: stderr, + status: status, + }; + if !output.status.success() { + Err(process_error(&format!("process didn't exit successfully: `{}`", + self.debug_string()), + None, Some(&output.status), Some(&output))) + } else { + Ok(output) + } + } + pub fn build_command(&self) -> Command { let mut command = Command::new(&self.program); if let Some(cwd) = self.get_cwd() { diff --git a/tests/build-script.rs b/tests/build-script.rs index f471f5475b9..e0669311039 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -715,7 +715,7 @@ fn build_deps_not_for_normal() { [ERROR] Could not compile `foo`. Caused by: - Process didn't exit successfully: [..] + process didn't exit successfully: [..] ")); } diff --git a/tests/build.rs b/tests/build.rs index 4844eae5362..5657396382c 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -1967,7 +1967,7 @@ fn rustc_env_var() { .env("RUSTC", "rustc-that-does-not-exist").arg("-v"), execs().with_status(101) .with_stderr("\ -[ERROR] Could not execute process `rustc-that-does-not-exist -vV` ([..]) +[ERROR] could not execute process `rustc-that-does-not-exist -vV` ([..]) Caused by: [..] diff --git a/tests/run.rs b/tests/run.rs index 1f76df20dcd..7c769c24515 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -132,7 +132,7 @@ fn exit_code() { [COMPILING] foo v0.0.1 (file[..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[..]` -[ERROR] Process didn't exit successfully: `target[..]foo[..]` (exit code: 2) +[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2) ")); } @@ -156,7 +156,7 @@ fn exit_code_verbose() { [RUNNING] `rustc [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[..]` -[ERROR] Process didn't exit successfully: `target[..]foo[..]` (exit code: 2) +[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2) ")); } From 5f1f6ac295c1b2a9530de33f3a509b95f461b28f Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Tue, 20 Sep 2016 01:57:10 -0400 Subject: [PATCH 0721/3888] Remove duplicate option in cargo-publish man page The `--host` option was listed twice; this commit removes one of the duplicates. --- src/etc/man/cargo-publish.1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/etc/man/cargo-publish.1 b/src/etc/man/cargo-publish.1 index acfab197b8d..2f5063139b5 100644 --- a/src/etc/man/cargo-publish.1 +++ b/src/etc/man/cargo-publish.1 @@ -21,11 +21,6 @@ Host to upload the package to. .RS .RE .TP -.B \-\-host \f[I]HOST\f[] -Host to upload the package to. -.RS -.RE -.TP .B \-\-token \f[I]TOKEN\f[] Token to use when uploading. .RS From 63de23dd22485d5f9ffba70671051d97d6009e42 Mon Sep 17 00:00:00 2001 From: Phaiax Date: Sun, 25 Sep 2016 14:10:01 +0200 Subject: [PATCH 0722/3888] Fix #3107. rustdoc without --target if compiled for host --- src/cargo/ops/cargo_rustc/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index b36ed3cebd1..d6ba1548084 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -402,8 +402,10 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { .cwd(cx.config.cwd()) .arg("--crate-name").arg(&unit.target.crate_name()); - if let Some(target) = cx.requested_target() { - rustdoc.arg("--target").arg(target); + if unit.kind != Kind::Host { + if let Some(target) = cx.requested_target() { + rustdoc.arg("--target").arg(target); + } } let doc_dir = cx.out_dir(unit); From 2103bac4b843420295cddb083b25bd671275111e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 25 Sep 2016 12:29:51 -0700 Subject: [PATCH 0723/3888] Update OpenSSL used by Cargo --- Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index c64240391cd..ec904b48b09 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,8 +1,8 @@ CFG_RELEASE_NUM=0.13.0 CFG_RELEASE_LABEL= -OPENSSL_VERS=1.0.2h -OPENSSL_SHA256=1d4007e53aad94a5b2002fe045ee7bb0b3d98f1a47f8b2bc851dcd1c74332919 +OPENSSL_VERS=1.0.2i +OPENSSL_SHA256=9287487d11c9545b6efb287cdb70535d4e9b284dd10d51441d9b9963d000de6f include config.mk From fc799d41c4b0568d7fe530b9ca78ec405cd0632f Mon Sep 17 00:00:00 2001 From: "Cliff L. Biffle" Date: Sun, 25 Sep 2016 13:53:07 -0700 Subject: [PATCH 0724/3888] Fall back to fs::copy when hard_link fails. Some filesystems don't allow hard links. Since Cargo's use of hard links is an optimization, and not necessary for correctness, it can fall back to a file copy when hard linking is not available. This is one possible solution to #3098. Caveat: this will try to copy if the hard link fails *for any reason*. It's not clear that there's a more surgical way of handling this; Unix tends to indicate the condition as "permission denied," not with a granular "links not supported by filesystem" error. --- src/cargo/ops/cargo_rustc/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index b36ed3cebd1..59d1ec57f63 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -317,9 +317,11 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { human(format!("failed to remove: {}", dst.display())) })); } - try!(fs::hard_link(&src, &dst).chain_error(|| { - human(format!("failed to link `{}` to `{}`", - src.display(), dst.display())) + try!(fs::hard_link(&src, &dst) + .or_else(|_| fs::copy(&src, &dst).map(|_| ())) + .chain_error(|| { + human(format!("failed to link or copy `{}` to `{}`", + src.display(), dst.display())) })); } } From 2919234b0a14f0c499946e6cdb271c9b8f21019d Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Sun, 25 Sep 2016 14:57:51 -0700 Subject: [PATCH 0725/3888] cargo: add license and license_file to cargo metadata output --- src/cargo/core/package.rs | 7 +++++++ tests/metadata.rs | 18 ++++++++++++++++++ tests/read-manifest.rs | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index c0554fbfc55..da14b04fc33 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -29,6 +29,8 @@ struct SerializedPackage<'a> { name: &'a str, version: &'a str, id: &'a PackageId, + license: Option<&'a str>, + license_file: Option<&'a str>, source: &'a SourceId, dependencies: &'a [Dependency], targets: &'a [Target], @@ -40,11 +42,16 @@ impl Encodable for Package { fn encode(&self, s: &mut S) -> Result<(), S::Error> { let summary = self.manifest.summary(); let package_id = summary.package_id(); + let manmeta = self.manifest.metadata(); + let license = manmeta.license.as_ref().map(String::as_ref); + let license_file = manmeta.license_file.as_ref().map(String::as_ref); SerializedPackage { name: &package_id.name(), version: &package_id.version().to_string(), id: package_id, + license: license, + license_file: license_file, source: summary.source_id(), dependencies: summary.dependencies(), targets: &self.manifest.targets(), diff --git a/tests/metadata.rs b/tests/metadata.rs index 2f2c21056e5..a180aae49a9 100644 --- a/tests/metadata.rs +++ b/tests/metadata.rs @@ -19,6 +19,8 @@ fn cargo_metadata_simple() { "id": "foo[..]", "source": null, "dependencies": [], + "license": null, + "license_file": null, "targets": [ { "kind": [ @@ -80,6 +82,8 @@ fn cargo_metadata_with_deps_and_version() { "manifest_path": "[..]Cargo.toml", "name": "baz", "source": "registry+[..]", + "license": null, + "license_file": null, "targets": [ { "kind": [ @@ -109,6 +113,8 @@ fn cargo_metadata_with_deps_and_version() { "manifest_path": "[..]Cargo.toml", "name": "bar", "source": "registry+[..]", + "license": null, + "license_file": null, "targets": [ { "kind": [ @@ -138,6 +144,8 @@ fn cargo_metadata_with_deps_and_version() { "manifest_path": "[..]Cargo.toml", "name": "foo", "source": null, + "license": "MIT", + "license_file": null, "targets": [ { "kind": [ @@ -198,6 +206,8 @@ fn workspace_metadata() { "id": "bar[..]", "source": null, "dependencies": [], + "license": null, + "license_file": null, "targets": [ { "kind": [ "lib" ], @@ -214,6 +224,8 @@ fn workspace_metadata() { "id": "baz[..]", "source": null, "dependencies": [], + "license": null, + "license_file": null, "targets": [ { "kind": [ "lib" ], @@ -265,6 +277,8 @@ fn workspace_metadata_no_deps() { "id": "bar[..]", "source": null, "dependencies": [], + "license": null, + "license_file": null, "targets": [ { "kind": [ "lib" ], @@ -281,6 +295,8 @@ fn workspace_metadata_no_deps() { "id": "baz[..]", "source": null, "dependencies": [], + "license": null, + "license_file": null, "targets": [ { "kind": [ "lib" ], @@ -320,6 +336,8 @@ const MANIFEST_OUTPUT: &'static str= "id":"foo[..]0.5.0[..](path+file://[..]/foo)", "source":null, "dependencies":[], + "license": null, + "license_file": null, "targets":[{ "kind":["bin"], "name":"foo", diff --git a/tests/read-manifest.rs b/tests/read-manifest.rs index cc24f3f6c87..44f7fa6f9ea 100644 --- a/tests/read-manifest.rs +++ b/tests/read-manifest.rs @@ -14,6 +14,8 @@ fn read_manifest_output() -> String { "name":"foo", "version":"0.5.0", "id":"foo[..]0.5.0[..](path+file://[..]/foo)", + "license": null, + "license_file": null, "source":null, "dependencies":[], "targets":[{ From cac8ec419ad1f0b63dbcb7856b6480dd1abdb12d Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 12 Sep 2016 22:26:16 -0400 Subject: [PATCH 0726/3888] Should not have to specify crates-io registry URL to replace-with Since cargo knows crates-io's registry URL and, anyway, you're trying to say that you don't want to use crates-io. --- src/cargo/sources/config.rs | 3 +++ tests/local-registry.rs | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index e40b6a7d546..01205ff51b7 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -146,6 +146,9 @@ a lock file compatible with `{orig}` cannot be generated in this situation path.push(s); srcs.push(try!(SourceId::for_directory(&path))); } + if name == "crates-io" && srcs.is_empty() { + srcs.push(try!(SourceId::crates_io(self.config))); + } let mut srcs = srcs.into_iter(); let src = try!(srcs.next().chain_error(|| { diff --git a/tests/local-registry.rs b/tests/local-registry.rs index b974f01c4c8..7643a92aa57 100644 --- a/tests/local-registry.rs +++ b/tests/local-registry.rs @@ -348,3 +348,51 @@ unable to verify that `foo v0.0.1` is the same as when the lockfile was generate ")); } + +#[test] +fn crates_io_registry_url_is_optional() { + let root = paths::root(); + t!(fs::create_dir(&root.join(".cargo"))); + t!(t!(File::create(root.join(".cargo/config"))).write_all(br#" + [source.crates-io] + replace-with = 'my-awesome-local-registry' + + [source.my-awesome-local-registry] + local-registry = 'registry' + "#)); + + Package::new("foo", "0.0.1") + .local(true) + .file("src/lib.rs", "pub fn foo() {}") + .publish(); + + let p = project("bar") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "0.0.1" + "#) + .file("src/lib.rs", r#" + extern crate foo; + pub fn bar() { + foo::foo(); + } + "#); + + assert_that(p.cargo_process("build"), + execs().with_status(0).with_stderr(&format!("\ +[UNPACKING] foo v0.0.1 ([..]) +[COMPILING] foo v0.0.1 +[COMPILING] bar v0.0.1 ({dir}) +[FINISHED] [..] +", + dir = p.url()))); + assert_that(p.cargo("build"), execs().with_status(0).with_stderr("\ +[FINISHED] [..] +")); + assert_that(p.cargo("test"), execs().with_status(0)); +} From c1774572893820eb599fbb873950a6334d3cc144 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 26 Sep 2016 09:15:08 -0700 Subject: [PATCH 0727/3888] Update OpenSSL again to 1.0.2j --- Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index ec904b48b09..541fe627ba9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,8 +1,8 @@ CFG_RELEASE_NUM=0.13.0 CFG_RELEASE_LABEL= -OPENSSL_VERS=1.0.2i -OPENSSL_SHA256=9287487d11c9545b6efb287cdb70535d4e9b284dd10d51441d9b9963d000de6f +OPENSSL_VERS=1.0.2j +OPENSSL_SHA256=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431 include config.mk From 370f05656a497c43a7cee0423920e4993e60d488 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Mon, 26 Sep 2016 15:11:36 -0400 Subject: [PATCH 0728/3888] Add missing quotation mark --- src/doc/specifying-dependencies.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/specifying-dependencies.md b/src/doc/specifying-dependencies.md index c7b95fdac6a..fb61a8db7ce 100644 --- a/src/doc/specifying-dependencies.md +++ b/src/doc/specifying-dependencies.md @@ -307,7 +307,7 @@ winhttp = "0.4.0" [target.'cfg(unix)'.dependencies] openssl = "1.0.1" -[target.'cfg(target_arch = "x86)'.dependencies] +[target.'cfg(target_arch = "x86")'.dependencies] native = { path = "native/i686" } [target.'cfg(target_arch = "x86_64")'.dependencies] From 6ad82d596bb9cb46ecf8c2d086e06a93d3147916 Mon Sep 17 00:00:00 2001 From: Wim Hueskes Date: Tue, 27 Sep 2016 00:46:10 +0200 Subject: [PATCH 0729/3888] add test cfg/ignore_version_from_other_platform if different platforms have a dependency to a different version of a crate, only the correct dependency should be downloaded and used --- tests/cfg.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/cfg.rs b/tests/cfg.rs index e8de0101beb..6712af6d869 100644 --- a/tests/cfg.rs +++ b/tests/cfg.rs @@ -228,6 +228,38 @@ fn works_through_the_registry() { ")); } +#[test] +fn ignore_version_from_other_platform() { + let this_family = if cfg!(unix) {"unix"} else {"windows"}; + let other_family = if cfg!(unix) {"windows"} else {"unix"}; + Package::new("foo", "0.1.0").publish(); + Package::new("foo", "0.2.0").publish(); + + let p = project("a") + .file("Cargo.toml", &format!(r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [target.'cfg({})'.dependencies] + foo = "0.1.0" + + [target.'cfg({})'.dependencies] + foo = "0.2.0" + "#, this_family, other_family)) + .file("src/lib.rs", "extern crate foo;"); + + assert_that(p.cargo_process("build"), + execs().with_status(0).with_stderr("\ +[UPDATING] registry [..] +[DOWNLOADING] [..] +[COMPILING] foo v0.1.0 +[COMPILING] a v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); +} + #[test] fn bad_target_spec() { let p = project("a") From e675d55a4e91b1d16a8664d1643677c868a3f188 Mon Sep 17 00:00:00 2001 From: Wim Hueskes Date: Tue, 27 Sep 2016 00:55:58 +0200 Subject: [PATCH 0730/3888] Do not download dependencies from other platforms --- src/cargo/ops/cargo_rustc/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 922da9ccdf8..fe0a9424141 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -454,7 +454,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let deps = self.resolve.deps(id); let mut ret = try!(deps.filter(|dep| { unit.pkg.dependencies().iter().filter(|d| { - d.name() == dep.name() + d.name() == dep.name() && d.version_req().matches(dep.version()) }).any(|d| { // If this target is a build command, then we only want build // dependencies, otherwise we want everything *other than* build From 51d565fea2cf8978dc11c86ce6c72886ce01d22c Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 26 Sep 2016 14:13:49 -0700 Subject: [PATCH 0731/3888] Build transitive dev-dependencies when needed When running `cargo test -p foo` where `foo` is a crate in the current workspace, build and link `foo`'s dev-dependencies. Fixes #860. --- src/cargo/ops/cargo_compile.rs | 16 +++++--- src/cargo/ops/cargo_generate_lockfile.rs | 5 ++- src/cargo/ops/cargo_output_metadata.rs | 3 +- src/cargo/ops/resolve.rs | 10 +++-- tests/workspaces.rs | 48 ++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 25b96891787..512117ed8ba 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -28,7 +28,7 @@ use std::sync::Arc; use core::registry::PackageRegistry; use core::{Source, SourceId, PackageSet, Package, Target}; -use core::{Profile, TargetKind, Profiles, Workspace}; +use core::{Profile, TargetKind, Profiles, Workspace, PackageIdSpec}; use core::resolver::{Method, Resolve}; use ops::{self, BuildOutput, ExecEngine}; use sources::PathSource; @@ -97,7 +97,8 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, source: Option>, features: Vec, all_features: bool, - no_default_features: bool) + no_default_features: bool, + spec: &'a [String]) -> CargoResult<(PackageSet<'a>, Resolve)> { let mut registry = try!(PackageRegistry::new(ws.config())); @@ -128,9 +129,13 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, } }; + let specs = try!(spec.iter().map(|p| PackageIdSpec::parse(p)) + .collect::>>()); + let resolved_with_overrides = try!(ops::resolve_with_previous(&mut registry, ws, - method, Some(&resolve), None)); + method, Some(&resolve), None, + &specs)); let packages = ops::get_resolved_packages(&resolved_with_overrides, registry); @@ -164,9 +169,8 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, try!(generate_targets(root_package, profiles, mode, filter, release)); } - let (packages, resolve_with_overrides) = { - try!(resolve_dependencies(ws, source, features, all_features, no_default_features)) - }; + let (packages, resolve_with_overrides) = + try!(resolve_dependencies(ws, source, features, all_features, no_default_features, spec)); let mut pkgids = Vec::new(); if spec.len() > 0 { diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 6a6d198b35b..25e2204ba9e 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -19,7 +19,7 @@ pub fn generate_lockfile(ws: &Workspace) -> CargoResult<()> { let mut registry = try!(PackageRegistry::new(ws.config())); let resolve = try!(ops::resolve_with_previous(&mut registry, ws, Method::Everything, - None, None)); + None, None, &[])); try!(ops::write_pkg_lockfile(ws, &resolve)); Ok(()) } @@ -78,7 +78,8 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) ws, Method::Everything, Some(&previous_resolve), - Some(&to_avoid))); + Some(&to_avoid), + &[])); // Summarize what is changing for the user. let print_change = |status: &str, msg: String| { diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 035c7350fe9..131b93825db 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -47,7 +47,8 @@ fn metadata_full(ws: &Workspace, None, opt.features.clone(), opt.all_features, - opt.no_default_features)); + opt.no_default_features, + &[])); let (packages, resolve) = deps; let packages = try!(packages.package_ids() diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 7ab3d1b4c12..5c8b0d89a4a 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -1,6 +1,6 @@ use std::collections::{HashMap, HashSet}; -use core::{PackageId, SourceId, Workspace}; +use core::{PackageId, PackageIdSpec, SourceId, Workspace}; use core::registry::PackageRegistry; use core::resolver::{self, Resolve, Method}; use ops; @@ -16,7 +16,7 @@ pub fn resolve_ws(registry: &mut PackageRegistry, ws: &Workspace) let prev = try!(ops::load_pkg_lockfile(ws)); let resolve = try!(resolve_with_previous(registry, ws, Method::Everything, - prev.as_ref(), None)); + prev.as_ref(), None, &[])); // Avoid writing a lockfile if we are `cargo install`ing a non local package. if ws.current_opt().map(|pkg| pkg.package_id().source_id().is_path()).unwrap_or(true) { @@ -38,7 +38,8 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, ws: &Workspace, method: Method, previous: Option<&'a Resolve>, - to_avoid: Option<&HashSet<&'a PackageId>>) + to_avoid: Option<&HashSet<&'a PackageId>>, + specs: &[PackageIdSpec]) -> CargoResult { // Here we place an artificial limitation that all non-registry sources // cannot be locked at more than one revision. This means that if a git @@ -67,7 +68,8 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, if let Method::Required { .. } = method { assert!(previous.is_some()); if let Some(current) = ws.current_opt() { - if member.package_id() != current.package_id() { + if member.package_id() != current.package_id() && + !specs.iter().any(|spec| spec.matches(member.package_id())) { continue; } } diff --git a/tests/workspaces.rs b/tests/workspaces.rs index 08be87bf4cf..42ac608da46 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -962,3 +962,51 @@ fn you_cannot_generate_lockfile_for_empty_workspaces() { error: you can't generate a lockfile for an empty workspace. ")); } + +#[test] +fn workspace_with_transitive_dev_deps() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.5.0" + authors = ["mbrubeck@example.com"] + + [dependencies.bar] + path = "bar" + + [workspace] + "#) + .file("src/main.rs", r#"fn main() {}"#) + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = ["mbrubeck@example.com"] + + [dev-dependencies.baz] + path = "../baz" + "#) + .file("bar/src/lib.rs", r#" + pub fn init() {} + + #[cfg(test)] + + #[test] + fn test() { + extern crate baz; + baz::do_stuff(); + } + "#) + .file("baz/Cargo.toml", r#" + [project] + name = "baz" + version = "0.5.0" + authors = ["mbrubeck@example.com"] + "#) + .file("baz/src/lib.rs", r#"pub fn do_stuff() {}"#); + p.build(); + + assert_that(p.cargo("test").args(&["-p", "bar"]), + execs().with_status(0)); +} From d25e7796ac2f2bf896f0363cc5e544a690e8c4a7 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 28 Sep 2016 03:54:09 -0700 Subject: [PATCH 0732/3888] Add newlines to SYNOPSIS sections --- src/etc/man/cargo-install.1 | 5 +++-- src/etc/man/cargo-uninstall.1 | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/etc/man/cargo-install.1 b/src/etc/man/cargo-install.1 index 8822e730f72..b85e68a492c 100644 --- a/src/etc/man/cargo-install.1 +++ b/src/etc/man/cargo-install.1 @@ -5,8 +5,9 @@ cargo\-install \- Install a Rust binary .SH SYNOPSIS .PP -\f[I]cargo install\f[] [OPTIONS] \f[I]cargo install\f[] -[OPTIONS] \-\-list +\f[I]cargo install\f[] [OPTIONS] +.PP +\f[I]cargo install\f[] [OPTIONS] \-\-list .SH DESCRIPTION .PP Install a Rust binary diff --git a/src/etc/man/cargo-uninstall.1 b/src/etc/man/cargo-uninstall.1 index 6a3e603b488..64e9aa7f069 100644 --- a/src/etc/man/cargo-uninstall.1 +++ b/src/etc/man/cargo-uninstall.1 @@ -6,6 +6,7 @@ cargo\-uninstall \- Remove a Rust binary .SH SYNOPSIS .PP \f[I]cargo uninstall\f[] [OPTIONS] +.PP \f[I]cargo uninstall\f[] (\-h | \-\-help) .SH DESCRIPTION .PP From bfd0e1a4f309fe4efe5ad3b508f78003b78c9d2c Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 29 Sep 2016 11:22:40 +0000 Subject: [PATCH 0733/3888] doc: build-script: use cfg(unix), not a hardcoded x86_64 triple This used to not be possible, but it is now, so let's promote best practices. --- src/doc/build-script.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/build-script.md b/src/doc/build-script.md index cc50b4c7480..f5fe8e283fb 100644 --- a/src/doc/build-script.md +++ b/src/doc/build-script.md @@ -440,7 +440,7 @@ build = "build.rs" [dependencies] libssh2-sys = { git = "https://github.com/alexcrichton/ssh2-rs" } -[target.x86_64-unknown-linux-gnu.dependencies] +[target.'cfg(unix)'.dependencies] openssl-sys = { git = "https://github.com/alexcrichton/openssl-sys" } # ... @@ -452,7 +452,7 @@ crate (`libgit2-sys`) links to the `git2` native library. Here we also see the unconditional dependency on `libssh2` via the `libssh2-sys` crate, as well as a platform-specific dependency on `openssl-sys` -for unix (other variants elided for now). It may seem a little counterintuitive +for \*nix (other variants elided for now). It may seem a little counterintuitive to express *C dependencies* in the *Cargo manifest*, but this is actually using one of Cargo’s conventions in this space. From 8a7000b53ddab344537e4068f72b55eb38c1e9b2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Sep 2016 11:31:17 -0700 Subject: [PATCH 0734/3888] Bump to 0.14.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa528fadde8..7dc67435fff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "cargo" -version = "0.13.0" +version = "0.14.0" dependencies = [ "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -72,7 +72,7 @@ name = "cargotest" version = "0.1.0" dependencies = [ "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cargo 0.13.0", + "cargo 0.14.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 666cb2d4b2e..6ced3b09d3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo" -version = "0.13.0" +version = "0.14.0" authors = ["Yehuda Katz ", "Carl Lerche ", "Alex Crichton "] From f00adbc385925355bb6cac284948a498e0b97d18 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Sep 2016 16:35:22 -0700 Subject: [PATCH 0735/3888] Warn about path overrides that won't work Cargo has a long-standing [bug] in path overrides where they will cause spurious rebuilds of crates in the crate graph. This can be very difficult to diagnose and be incredibly frustrating as well. Unfortunately, though, it's behavior that fundamentally can't be fixed in Cargo. The crux of the problem happens when a `path` replacement changes something about the list of dependencies of the crate that it's replacing. This alteration to the list of dependencies *cannot be tracked by Cargo* as the lock file was previously emitted. In the best case this ends up causing random recompiles. In the worst case it cause infinite registry updates that always result in recompiles. A solution to this intention, changing the dependency graph of an overridden dependency, was [implemented] with the `[replace]` feature in Cargo awhile back. With that in mind, this commit implements a *warning* whenever a bad dependency replacement is detected. The message here is pretty wordy, but it's intended to convey that you should switch to using `[replace]` for a more robust impelmentation, and it can also give security to anyone using `path` overrides that if they get past this warning everything should work as intended. [bug]: https://github.com/rust-lang/cargo/issues/2041 [implemented]: http://doc.crates.io/specifying-dependencies.html#overriding-dependencies Closes #2041 --- src/cargo/core/registry.rs | 107 ++++++++++++++++++++++++++++-------- src/cargo/sources/config.rs | 4 ++ tests/overrides.rs | 67 ++++++++++++++++++++++ 3 files changed, 156 insertions(+), 22 deletions(-) diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 90a1b76d244..ecaac98157b 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -1,4 +1,4 @@ -use std::collections::{HashSet, HashMap}; +use std::collections::HashMap; use core::{Source, SourceId, SourceMap, Summary, Dependency, PackageId, Package}; use core::PackageSet; @@ -188,17 +188,16 @@ impl<'cfg> PackageRegistry<'cfg> { } fn query_overrides(&mut self, dep: &Dependency) - -> CargoResult> { - let mut seen = HashSet::new(); - let mut ret = Vec::new(); + -> CargoResult> { for s in self.overrides.iter() { let src = self.sources.get_mut(s).unwrap(); let dep = Dependency::new_override(dep.name(), s); - ret.extend(try!(src.query(&dep)).into_iter().filter(|s| { - seen.insert(s.name().to_string()) - })); + let mut results = try!(src.query(&dep)); + if results.len() > 0 { + return Ok(Some(results.remove(0))) + } } - Ok(ret) + Ok(None) } // This function is used to transform a summary to another locked summary if @@ -277,25 +276,89 @@ impl<'cfg> PackageRegistry<'cfg> { } }) } + + fn warn_bad_override(&self, + override_summary: &Summary, + real_summary: &Summary) -> CargoResult<()> { + let real = real_summary.package_id(); + let map = try!(self.locked.get(real.source_id()).chain_error(|| { + human(format!("failed to find lock source of {}", real)) + })); + let list = try!(map.get(real.name()).chain_error(|| { + human(format!("failed to find lock name of {}", real)) + })); + let &(_, ref real_deps) = try!(list.iter().find(|&&(ref id, _)| { + real == id + }).chain_error(|| { + human(format!("failed to find lock version of {}", real)) + })); + let mut real_deps = real_deps.clone(); + + let boilerplate = "\ +This is currently allowed but is known to produce buggy behavior with spurious +recompiles and changes to the crate graph. Path overrides unfortunately were +never intended to support this feature, so for now this message is just a +warning. In the future, however, this message will become a hard error. + +To change the dependency graph via an override it's recommended to use the +`[replace]` feature of Cargo instead of the path override feature. This is +documented online at the url below for more information. + +http://doc.crates.io/specifying-dependencies.html#overriding-dependencies +"; + + for dep in override_summary.dependencies() { + if let Some(i) = real_deps.iter().position(|id| dep.matches_id(id)) { + real_deps.remove(i); + continue + } + let msg = format!("\ + path override for crate `{}` has altered the original list of\n\ + dependencies; the dependency on `{}` was either added or\n\ + modified to not match the previously resolved version\n\n\ + {}", override_summary.package_id().name(), dep.name(), boilerplate); + try!(self.source_config.config().shell().warn(&msg)); + return Ok(()) + } + + for id in real_deps { + let msg = format!("\ + path override for crate `{}` has altered the original list of + dependencies; the dependency on `{}` was removed\n\n + {}", override_summary.package_id().name(), id.name(), boilerplate); + try!(self.source_config.config().shell().warn(&msg)); + return Ok(()) + } + + Ok(()) + } } impl<'cfg> Registry for PackageRegistry<'cfg> { fn query(&mut self, dep: &Dependency) -> CargoResult> { - let overrides = try!(self.query_overrides(&dep)); - - let ret = if overrides.is_empty() { - // Ensure the requested source_id is loaded - try!(self.ensure_loaded(dep.source_id(), Kind::Normal).chain_error(|| { - human(format!("failed to load source for a dependency \ - on `{}`", dep.name())) - })); - - match self.sources.get_mut(dep.source_id()) { - Some(src) => try!(src.query(&dep)), - None => Vec::new(), + // Ensure the requested source_id is loaded + try!(self.ensure_loaded(dep.source_id(), Kind::Normal).chain_error(|| { + human(format!("failed to load source for a dependency \ + on `{}`", dep.name())) + })); + + let override_summary = try!(self.query_overrides(&dep)); + let real_summaries = match self.sources.get_mut(dep.source_id()) { + Some(src) => Some(try!(src.query(&dep))), + None => None, + }; + + let ret = match (override_summary, real_summaries) { + (Some(candidate), Some(summaries)) => { + if summaries.len() != 1 { + bail!("found an override with a non-locked list"); + } + try!(self.warn_bad_override(&candidate, &summaries[0])); + vec![candidate] } - } else { - overrides + (Some(_), None) => bail!("override found but no real ones"), + (None, Some(summaries)) => summaries, + (None, None) => Vec::new(), }; // post-process all returned summaries to ensure that we lock all diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index 01205ff51b7..ac254f147ec 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -62,6 +62,10 @@ impl<'cfg> SourceConfigMap<'cfg> { Ok(base) } + pub fn config(&self) -> &'cfg Config { + self.config + } + pub fn load(&self, id: &SourceId) -> CargoResult> { debug!("loading: {}", id); let mut name = match self.id2name.get(id) { diff --git a/tests/overrides.rs b/tests/overrides.rs index 5eebed0bfa1..7ae8538efc8 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -682,3 +682,70 @@ fn no_override_self() { assert_that(p.cargo_process("build").arg("--verbose"), execs().with_status(0)); } + +#[test] +fn broken_path_override_warns() { + Package::new("foo", "0.1.0").publish(); + Package::new("foo", "0.2.0").publish(); + + let p = project("local") + .file("Cargo.toml", r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a1" } + "#) + .file("src/lib.rs", "") + .file("a1/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "0.1" + "#) + .file("a1/src/lib.rs", "") + .file("a2/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "0.2" + "#) + .file("a2/src/lib.rs", "") + .file(".cargo/config", r#" + paths = ["a2"] + "#); + + assert_that(p.cargo_process("build"), + execs().with_status(0) + .with_stderr("\ +[UPDATING] [..] +warning: path override for crate `a` has altered the original list of +dependencies; the dependency on `foo` was either added or +modified to not match the previously resolved version + +This is currently allowed but is known to produce buggy behavior with spurious +recompiles and changes to the crate graph. Path overrides unfortunately were +never intended to support this feature, so for now this message is just a +warning. In the future, however, this message will become a hard error. + +To change the dependency graph via an override it's recommended to use the +`[replace]` feature of Cargo instead of the path override feature. This is +documented online at the url below for more information. + +http://doc.crates.io/specifying-dependencies.html#overriding-dependencies + +[DOWNLOADING] [..] +[COMPILING] [..] +[COMPILING] [..] +[COMPILING] [..] +[FINISHED] [..] +")); +} From 632cbf82172430a98bf576dc50bdf378362c5b2a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 29 Sep 2016 17:30:18 -0700 Subject: [PATCH 0736/3888] Update curl to track more error info --- Cargo.lock | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7dc67435fff..408c0e0ab12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ dependencies = [ "cargotest 0.1.0", "crates-io 0.4.0", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -105,7 +105,7 @@ dependencies = [ name = "crates-io" version = "0.4.0" dependencies = [ - "curl 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -117,17 +117,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "curl" -version = "0.3.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl-sys" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -135,6 +136,7 @@ dependencies = [ "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -214,7 +216,7 @@ name = "git2-curl" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -641,8 +643,8 @@ dependencies = [ "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" "checksum cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "dfcf5bcece56ef953b8ea042509e9dcbdfe97820b7e20d86beb53df30ed94978" "checksum crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fb974f835e90390c5f9dfac00f05b06dc117299f5ea4e85fbc7bb443af4911cc" -"checksum curl 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "124f5a753ff53957e01d15258cddb497f0cce3b04abac0d34432afcca8b69f15" -"checksum curl-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3da1d4b92dc22964e4b098c9e5863abfb9126d2c619bbeefb7eaa4ae63adbc5" +"checksum curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f0ae0143e62b183e072d8344a1c30b6281c2b2f2b4d8407d2d8adb95652112c3" +"checksum curl-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae8698d4d2bc4b8182a11f4a5298fa03d2127c29e95dbae538d0cf003141818" "checksum docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20016093b4e545dccf6ad4a01099de0b695f9bc99b08210e68f6425db2d37d" "checksum env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "82dcb9ceed3868a03b335657b85a159736c961900f7e7747d3b0b97b9ccb5ccb" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" From e34774c9c4d3f2b86047f3479cb84d9eea1c298a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Fri, 30 Sep 2016 13:27:10 +0200 Subject: [PATCH 0737/3888] Show an error messager for invalid semver spec for packages in the [replace] section. The [replace] section in the Cargo.toml file doesn't allow invalid semver specs for packages, so something like this: [dependencies] foo = "*" [replace] "foo:*" = { git = 'https://example.com' } It's not valid. In this case we will display an error message like this: error: failed to parse manifest at `Cargo.toml` Caused by: replacements must specify a valid semver version to replace, but `foo:*` does not --- src/cargo/core/package_id_spec.rs | 1 + src/cargo/util/toml.rs | 7 ++++++- tests/overrides.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index 03124939366..3299ada5738 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -257,6 +257,7 @@ mod tests { #[test] fn bad_parsing() { assert!(PackageIdSpec::parse("baz:").is_err()); + assert!(PackageIdSpec::parse("baz:*").is_err()); assert!(PackageIdSpec::parse("baz:1.0").is_err()); assert!(PackageIdSpec::parse("http://baz:1.0").is_err()); assert!(PackageIdSpec::parse("http://#baz:1.0").is_err()); diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index ac94d3a2837..578d4474327 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -737,7 +737,12 @@ impl TomlManifest { -> CargoResult> { let mut replace = Vec::new(); for (spec, replacement) in self.replace.iter().flat_map(|x| x) { - let spec = try!(PackageIdSpec::parse(spec)); + let spec = match PackageIdSpec::parse(spec) { + Ok(spec) => spec, + Err(_) => bail!("replacements must specify a \ + valid semver version \ + to replace, but `{}` does not", spec), + }; let version_specified = match *replacement { TomlDependency::Detailed(ref d) => d.version.is_some(), diff --git a/tests/overrides.rs b/tests/overrides.rs index 5eebed0bfa1..eff9bbf9d85 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -77,6 +77,32 @@ Caused by: ")); } +#[test] +fn invalid_semver_version() { + let p = project("local") + .file("Cargo.toml", r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "*" + + [replace] + "foo:*" = { git = 'https://example.com' } + "#) + .file("src/lib.rs", ""); + + assert_that(p.cargo_process("build"), + execs().with_status(101).with_stderr("\ +error: failed to parse manifest at `[..]` + +Caused by: + replacements must specify a valid semver version to replace, but `foo:*` does not +")); +} + #[test] fn different_version() { Package::new("foo", "0.2.0").publish(); From 41f34ba014e0cadd3ca3027b4af6173c8035694b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 30 Sep 2016 09:17:36 -0700 Subject: [PATCH 0738/3888] Allow deprecated use of SipHasher This type is being deprecated in rust-lang/rust#36815, so allow use of the deprecated type for now. We can fix this later once new APIs have landed. --- src/cargo/sources/git/source.rs | 9 +++------ src/cargo/util/hex.rs | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 3ab8b79c638..eeffcb05b72 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -1,12 +1,12 @@ use std::fmt::{self, Debug, Formatter}; -use std::hash::{Hash, Hasher, SipHasher}; use url::Url; use core::source::{Source, SourceId}; use core::GitReference; use core::{Package, PackageId, Summary, Registry, Dependency}; -use util::{CargoResult, Config, to_hex}; +use util::{CargoResult, Config}; +use util::hex::short_hash; use sources::PathSource; use sources::git::utils::{GitRemote, GitRevision}; @@ -57,8 +57,6 @@ impl<'cfg> GitSource<'cfg> { } fn ident(url: &Url) -> String { - let mut hasher = SipHasher::new_with_keys(0,0); - let url = canonicalize_url(url); let ident = url.path_segments().and_then(|mut s| s.next_back()).unwrap_or(""); @@ -68,8 +66,7 @@ fn ident(url: &Url) -> String { ident }; - url.hash(&mut hasher); - format!("{}-{}", ident, to_hex(hasher.finish())) + format!("{}-{}", ident, short_hash(&url)) } // Some hacks and heuristics for making equivalent URLs hash the same diff --git a/src/cargo/util/hex.rs b/src/cargo/util/hex.rs index 43687b75dfb..28fed76fc0f 100644 --- a/src/cargo/util/hex.rs +++ b/src/cargo/util/hex.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use std::hash::{Hasher, Hash, SipHasher}; use rustc_serialize::hex::ToHex; From bfbe0777a2a5576434b3e126883f7ac9ee71649d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 21 Jul 2016 09:50:33 -0700 Subject: [PATCH 0739/3888] Avoid updating registry when adding existing deps Cargo previously erroneously updated the registry whenever a new dependency was added on a crate which already exists in the DAG. This commit fixes this behavior by ensuring that if the new dependency matches a previously locked version it uses that instead. This commit involved a bit of refactoring around this logic to be a bit more clear how the locking and "falling back to the registry" is happening. Closes #2895 Closes #2931 --- src/cargo/core/registry.rs | 112 ++++++++++++++++++------------------- src/cargo/ops/resolve.rs | 86 +++++++++++----------------- tests/registry.rs | 95 +++++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+), 113 deletions(-) diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 90a1b76d244..99d9db83f95 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -201,22 +201,24 @@ impl<'cfg> PackageRegistry<'cfg> { Ok(ret) } - // This function is used to transform a summary to another locked summary if - // possible. This is where the concept of a lockfile comes into play. - // - // If a summary points at a package id which was previously locked, then we - // override the summary's id itself, as well as all dependencies, to be - // rewritten to the locked versions. This will transform the summary's - // source to a precise source (listed in the locked version) as well as - // transforming all of the dependencies from range requirements on imprecise - // sources to exact requirements on precise sources. - // - // If a summary does not point at a package id which was previously locked, - // we still want to avoid updating as many dependencies as possible to keep - // the graph stable. In this case we map all of the summary's dependencies - // to be rewritten to a locked version wherever possible. If we're unable to - // map a dependency though, we just pass it on through. - fn lock(&self, summary: Summary) -> Summary { + /// This function is used to transform a summary to another locked summary + /// if possible. This is where the concept of a lockfile comes into play. + /// + /// If a summary points at a package id which was previously locked, then we + /// override the summary's id itself, as well as all dependencies, to be + /// rewritten to the locked versions. This will transform the summary's + /// source to a precise source (listed in the locked version) as well as + /// transforming all of the dependencies from range requirements on + /// imprecise sources to exact requirements on precise sources. + /// + /// If a summary does not point at a package id which was previously locked, + /// or if any dependencies were added and don't have a previously listed + /// version, we still want to avoid updating as many dependencies as + /// possible to keep the graph stable. In this case we map all of the + /// summary's dependencies to be rewritten to a locked version wherever + /// possible. If we're unable to map a dependency though, we just pass it on + /// through. + pub fn lock(&self, summary: Summary) -> Summary { let pair = self.locked.get(summary.source_id()).and_then(|map| { map.get(summary.name()) }).and_then(|vec| { @@ -229,51 +231,43 @@ impl<'cfg> PackageRegistry<'cfg> { None => summary, }; summary.map_dependencies(|dep| { - match pair { - // If we've got a known set of overrides for this summary, then - // one of a few cases can arise: - // - // 1. We have a lock entry for this dependency from the same - // source as it's listed as coming from. In this case we make - // sure to lock to precisely the given package id. - // - // 2. We have a lock entry for this dependency, but it's from a - // different source than what's listed, or the version - // requirement has changed. In this case we must discard the - // locked version because the dependency needs to be - // re-resolved. - // - // 3. We don't have a lock entry for this dependency, in which - // case it was likely an optional dependency which wasn't - // included previously so we just pass it through anyway. - Some(&(_, ref deps)) => { - match deps.iter().find(|d| d.name() == dep.name()) { - Some(lock) => { - if dep.matches_id(lock) { - dep.lock_to(lock) - } else { - dep - } - } - None => dep, - } + // If we've got a known set of overrides for this summary, then + // one of a few cases can arise: + // + // 1. We have a lock entry for this dependency from the same + // source as it's listed as coming from. In this case we make + // sure to lock to precisely the given package id. + // + // 2. We have a lock entry for this dependency, but it's from a + // different source than what's listed, or the version + // requirement has changed. In this case we must discard the + // locked version because the dependency needs to be + // re-resolved. + // + // 3. We don't have a lock entry for this dependency, in which + // case it was likely an optional dependency which wasn't + // included previously so we just pass it through anyway. + // + // Cases 1/2 are handled by `matches_id` and case 3 is handled by + // falling through to the logic below. + if let Some(&(_, ref locked_deps)) = pair { + let locked = locked_deps.iter().find(|id| dep.matches_id(id)); + if let Some(locked) = locked { + return dep.lock_to(locked) } + } - // If this summary did not have a locked version, then we query - // all known locked packages to see if they match this - // dependency. If anything does then we lock it to that and move - // on. - None => { - let v = self.locked.get(dep.source_id()).and_then(|map| { - map.get(dep.name()) - }).and_then(|vec| { - vec.iter().find(|&&(ref id, _)| dep.matches_id(id)) - }); - match v { - Some(&(ref id, _)) => dep.lock_to(id), - None => dep - } - } + // If this dependency did not have a locked version, then we query + // all known locked packages to see if they match this dependency. + // If anything does then we lock it to that and move on. + let v = self.locked.get(dep.source_id()).and_then(|map| { + map.get(dep.name()) + }).and_then(|vec| { + vec.iter().find(|&&(ref id, _)| dep.matches_id(id)) + }); + match v { + Some(&(ref id, _)) => dep.lock_to(id), + None => dep } }) } diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 5c8b0d89a4a..af912b0dfba 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -1,4 +1,4 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; use core::{PackageId, PackageIdSpec, SourceId, Workspace}; use core::registry::PackageRegistry; @@ -55,6 +55,36 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, .filter(|s| !s.is_registry())); } + // In the case where a previous instance of resolve is available, we + // want to lock as many packages as possible to the previous version + // without disturbing the graph structure. To this end we perform + // two actions here: + // + // 1. We inform the package registry of all locked packages. This + // involves informing it of both the locked package's id as well + // as the versions of all locked dependencies. The registry will + // then takes this information into account when it is queried. + // + // 2. The specified package's summary will have its dependencies + // modified to their precise variants. This will instruct the + // first step of the resolution process to not query for ranges + // but rather for precise dependency versions. + // + // This process must handle altered dependencies, however, as + // it's possible for a manifest to change over time to have + // dependencies added, removed, or modified to different version + // ranges. To deal with this, we only actually lock a dependency + // to the previously resolved version if the dependency listed + // still matches the locked version. + if let Some(r) = previous { + for node in r.iter().filter(|p| keep(p, to_avoid, &to_avoid_sources)) { + let deps = r.deps_not_replaced(node) + .filter(|p| keep(p, to_avoid, &to_avoid_sources)) + .cloned().collect(); + registry.register_lock(node.clone(), deps); + } + } + let mut summaries = Vec::new(); for member in ws.members() { try!(registry.add_sources(&[member.package_id().source_id() @@ -75,59 +105,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, } } - // If we don't have a previous instance of resolve then we just need to - // resolve our entire summary (method should be Everything) and we just - // move along to the next member. - let r = match previous { - Some(r) => r, - None => { - summaries.push((member.summary().clone(), method)); - continue - } - }; - - // In the case where a previous instance of resolve is available, we - // want to lock as many packages as possible to the previous version - // without disturbing the graph structure. To this end we perform - // two actions here: - // - // 1. We inform the package registry of all locked packages. This - // involves informing it of both the locked package's id as well - // as the versions of all locked dependencies. The registry will - // then takes this information into account when it is queried. - // - // 2. The specified package's summary will have its dependencies - // modified to their precise variants. This will instruct the - // first step of the resolution process to not query for ranges - // but rather for precise dependency versions. - // - // This process must handle altered dependencies, however, as - // it's possible for a manifest to change over time to have - // dependencies added, removed, or modified to different version - // ranges. To deal with this, we only actually lock a dependency - // to the previously resolved version if the dependency listed - // still matches the locked version. - for node in r.iter().filter(|p| keep(p, to_avoid, &to_avoid_sources)) { - let deps = r.deps_not_replaced(node) - .filter(|p| keep(p, to_avoid, &to_avoid_sources)) - .cloned().collect(); - registry.register_lock(node.clone(), deps); - } - - let summary = { - let map = r.deps_not_replaced(member.package_id()).filter(|p| { - keep(p, to_avoid, &to_avoid_sources) - }).map(|d| { - (d.name(), d) - }).collect::>(); - - member.summary().clone().map_dependencies(|dep| { - match map.get(dep.name()) { - Some(&lock) if dep.matches_id(lock) => dep.lock_to(lock), - _ => dep, - } - }) - }; + let summary = registry.lock(member.summary().clone()); summaries.push((summary, method)); } diff --git a/tests/registry.rs b/tests/registry.rs index 1a069f5628c..34150a856b5 100644 --- a/tests/registry.rs +++ b/tests/registry.rs @@ -1147,3 +1147,98 @@ Caused by: attempting to make an HTTP request, but --frozen was specified ")); } + +#[test] +fn add_dep_dont_update_registry() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + baz = { path = "baz" } + "#) + .file("src/main.rs", "fn main() {}") + .file("baz/Cargo.toml", r#" + [project] + name = "baz" + version = "0.5.0" + authors = [] + + [dependencies] + remote = "0.3" + "#) + .file("baz/src/lib.rs", ""); + p.build(); + + Package::new("remote", "0.3.4").publish(); + + assert_that(p.cargo("build"), execs().with_status(0)); + + t!(t!(File::create(p.root().join("Cargo.toml"))).write_all(br#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + baz = { path = "baz" } + remote = "0.3" + "#)); + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +[COMPILING] bar v0.5.0 ([..]) +[FINISHED] [..] +")); +} + +#[test] +fn bump_version_dont_update_registry() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + baz = { path = "baz" } + "#) + .file("src/main.rs", "fn main() {}") + .file("baz/Cargo.toml", r#" + [project] + name = "baz" + version = "0.5.0" + authors = [] + + [dependencies] + remote = "0.3" + "#) + .file("baz/src/lib.rs", ""); + p.build(); + + Package::new("remote", "0.3.4").publish(); + + assert_that(p.cargo("build"), execs().with_status(0)); + + t!(t!(File::create(p.root().join("Cargo.toml"))).write_all(br#" + [project] + name = "bar" + version = "0.6.0" + authors = [] + + [dependencies] + baz = { path = "baz" } + "#)); + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +[COMPILING] bar v0.6.0 ([..]) +[FINISHED] [..] +")); +} From 1e4bc169c2c787a0839a0af9e48e7bd068df0156 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 30 Sep 2016 13:07:37 -0700 Subject: [PATCH 0740/3888] Test requested --target from source of truth We skip doc tests for any cross compiles (as they don't work) but to detect a cross compile we checked `--target` but forgot to check other locations like `CARGO_BUILD_TARGET` or `[build.target]`. This alters the check to ensure that it verifies from the source of truth whether a cross compilation happened or not. Closes #3143 --- src/cargo/ops/cargo_rustc/compilation.rs | 3 +++ src/cargo/ops/cargo_rustc/mod.rs | 1 + src/cargo/ops/cargo_test.rs | 6 ++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 71263450d36..23f0a044fcf 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -44,6 +44,8 @@ pub struct Compilation<'cfg> { /// Features enabled during this compilation. pub cfgs: HashSet, + pub target: String, + config: &'cfg Config, } @@ -60,6 +62,7 @@ impl<'cfg> Compilation<'cfg> { to_doc_test: Vec::new(), cfgs: HashSet::new(), config: config, + target: String::new(), } } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 59d1ec57f63..7f02b3138d6 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -159,6 +159,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, cx.compilation.native_dirs.insert(dir.clone()); } } + cx.compilation.target = cx.target_triple().to_string(); Ok(cx.compilation) } diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 44a51be3017..e8f155a345b 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -116,10 +116,8 @@ fn run_doc_tests(options: &TestOptions, let config = options.compile_opts.config; // We don't build/rust doctests if target != host - if let Some(target) = options.compile_opts.target { - if try!(config.rustc()).host != target { - return Ok(errors); - } + if try!(config.rustc()).host != compilation.target { + return Ok(errors); } let libs = compilation.to_doc_test.iter().map(|package| { From 9521a4961828f3ba49f4d99ecb4bc0bd747a1dd4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 30 Sep 2016 13:16:38 -0700 Subject: [PATCH 0741/3888] Use workspaces during `cargo install` Prevent lock files from oscillating. Closes #3133 --- src/cargo/ops/cargo_install.rs | 5 ++++- tests/install.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index d25bf11ba18..616c7b35186 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -90,7 +90,10 @@ pub fn install(root: Option<&str>, Some(Filesystem::new(config.cwd().join("target-install"))) }; - let ws = try!(Workspace::one(pkg, config, overidden_target_dir)); + let ws = match overidden_target_dir { + Some(dir) => try!(Workspace::one(pkg, config, Some(dir))), + None => try!(Workspace::new(pkg.manifest_path(), config)), + }; let pkg = try!(ws.current()); // Preflight checks to check up front whether we'll overwrite something. diff --git a/tests/install.rs b/tests/install.rs index 5a9182a3242..6d064703fe2 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -793,3 +793,36 @@ fn readonly_dir() { execs().with_status(0)); assert_that(cargo_home(), has_installed_exe("foo")); } + +#[test] +fn use_path_workspace() { + Package::new("foo", "1.0.0").publish(); + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + + [workspace] + members = ["baz"] + "#) + .file("src/main.rs", "fn main() {}") + .file("baz/Cargo.toml", r#" + [package] + name = "baz" + version = "0.1.0" + authors = [] + + [dependencies] + foo = "1" + "#) + .file("baz/src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("build"), execs().with_status(0)); + let lock = p.read_lockfile(); + assert_that(p.cargo("install"), execs().with_status(0)); + let lock2 = p.read_lockfile(); + assert!(lock == lock2, "different lockfiles"); +} From b4565b874fa587311c6a6a3ca6b0c5a6b03e1263 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 30 Sep 2016 19:51:08 -0400 Subject: [PATCH 0742/3888] Add information about Cargo releases going with Rust releases --- README.md | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 71c74508d79..dd3008268bd 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,33 @@ make doc open target/doc/index.html ``` -## Release notes - -High level release notes are available as part of [Rust's release notes](https://github.com/rust-lang/rust/blob/master/RELEASES.md). +## Releases + +High level release notes are available as part of [Rust's release notes][rel]. +Cargo releases coincide with Rust releases. + +[rel]: https://github.com/rust-lang/rust/blob/master/RELEASES.md + +
+ Table of Rust versions with their Cargo versions + +Rust version | Cargo version +-------------|--------------| + 1.12.0 | 0.13.0 | + 1.11.0 | 0.12.0 | + 1.10.0 | 0.11.0 | + 1.9.0 | 0.10.0 | + 1.8.0 | 0.9.0 | + 1.7.0 | 0.8.0 | + 1.6.0 | 0.7.0 | + 1.5.0 | 0.6.0 | + 1.4.0 | 0.5.0 | + 1.3.0 | 0.4.0 | + 1.2.0 | 0.3.0 | + 1.1.0 | 0.2.0 | + 1.0.0 | 0.1.0 | + +
## Reporting Issues From f2957b37d31b8bf7cd65e6e1d8c47274c1f361db Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Oct 2016 17:20:45 +0300 Subject: [PATCH 0743/3888] Document that read_manifest command is deprecated --- src/bin/read_manifest.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/read_manifest.rs b/src/bin/read_manifest.rs index 1cbb0cff8c4..bd44b0ad581 100644 --- a/src/bin/read_manifest.rs +++ b/src/bin/read_manifest.rs @@ -11,7 +11,8 @@ pub struct Options { } pub const USAGE: &'static str = " -Print a JSON representation of a Cargo.toml manifest +Deprecated, use `cargo metadata --no-deps` instead. +Print a JSON representation of a Cargo.toml manifest. Usage: cargo read-manifest [options] From a2c572ab6f42a6a9fbcf29cafee69ee74d645d3a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 12 Aug 2016 00:47:49 +0300 Subject: [PATCH 0744/3888] Add --message-format flag. --- src/bin/bench.rs | 7 ++- src/bin/build.rs | 6 +++ src/bin/doc.rs | 6 +++ src/bin/install.rs | 1 + src/bin/run.rs | 6 +++ src/bin/rustc.rs | 6 +++ src/bin/rustdoc.rs | 6 +++ src/bin/test.rs | 7 +++ src/cargo/ops/cargo_compile.rs | 22 +++++++++- src/cargo/ops/cargo_package.rs | 1 + src/cargo/ops/cargo_rustc/mod.rs | 43 ++++++++++++++++-- src/cargo/ops/mod.rs | 2 +- tests/build.rs | 75 ++++++++++++++++++++++++++++++++ tests/cargotest/support/mod.rs | 31 ++++++++----- 14 files changed, 201 insertions(+), 18 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index f2d028d34e4..521c87c2f70 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -16,6 +16,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, + flag_message_format: Option, flag_lib: bool, flag_bin: Vec, flag_example: Vec, @@ -50,6 +51,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json-v1 --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -75,7 +77,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - + let message_format = try!(ops::MessageFormat::from_option( + &options.flag_message_format + )); let ops = ops::TestOptions { no_run: options.flag_no_run, no_fail_fast: false, @@ -96,6 +100,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + message_format: message_format, target_rustdoc_args: None, target_rustc_args: None, }, diff --git a/src/bin/build.rs b/src/bin/build.rs index 2f23ce1be3b..c4619f541e9 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -18,6 +18,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, + flag_message_format: Option, flag_release: bool, flag_lib: bool, flag_bin: Vec, @@ -52,6 +53,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json-v1 --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -73,6 +75,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); + let message_format = try!(ops::MessageFormat::from_option( + &options.flag_message_format + )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -92,6 +97,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + message_format: message_format, target_rustdoc_args: None, target_rustc_args: None, }; diff --git a/src/bin/doc.rs b/src/bin/doc.rs index c4139987cf7..83431ef66ff 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -17,6 +17,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, + flag_message_format: Option, flag_package: Vec, flag_lib: bool, flag_bin: Vec, @@ -47,6 +48,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json-v1 --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -65,6 +67,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); + let message_format = try!(ops::MessageFormat::from_option( + &options.flag_message_format + )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -85,6 +90,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &empty, &empty, &empty), + message_format: message_format, release: options.flag_release, mode: ops::CompileMode::Doc { deps: !options.flag_no_deps, diff --git a/src/bin/install.rs b/src/bin/install.rs index 544b115e9a2..b5d67fd411f 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -114,6 +114,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { release: !options.flag_debug, filter: ops::CompileFilter::new(false, &options.flag_bin, &[], &options.flag_example, &[]), + message_format: ops::MessageFormat::Human, target_rustc_args: None, target_rustdoc_args: None, }; diff --git a/src/bin/run.rs b/src/bin/run.rs index 5f9843c83ba..4b03b53bc53 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -16,6 +16,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, + flag_message_format: Option, flag_release: bool, flag_frozen: bool, flag_locked: bool, @@ -42,6 +43,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json-v1 --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -61,6 +63,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); + let message_format = try!(ops::MessageFormat::from_option( + &options.flag_message_format + )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -91,6 +96,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { bins: &bins, examples: &examples, } }, + message_format: message_format, target_rustdoc_args: None, target_rustc_args: None, }; diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index e81c8d18f7a..2743c3669f0 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -19,6 +19,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, + flag_message_format: Option, flag_release: bool, flag_lib: bool, flag_bin: Vec, @@ -55,6 +56,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json-v1 --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -80,6 +82,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); + let message_format = try!(ops::MessageFormat::from_option( + &options.flag_message_format + )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -110,6 +115,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + message_format: message_format, target_rustdoc_args: None, target_rustc_args: options.arg_opts.as_ref().map(|a| &a[..]), }; diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index 15e4a91ca66..79e368090b6 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -17,6 +17,7 @@ pub struct Options { flag_release: bool, flag_quiet: Option, flag_color: Option, + flag_message_format: Option, flag_package: Option, flag_lib: bool, flag_bin: Vec, @@ -52,6 +53,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json-v1 --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -74,6 +76,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); + let message_format = try!(ops::MessageFormat::from_option( + &options.flag_message_format + )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -95,6 +100,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + message_format: message_format, mode: ops::CompileMode::Doc { deps: false }, target_rustdoc_args: Some(&options.arg_opts), target_rustc_args: None, diff --git a/src/bin/test.rs b/src/bin/test.rs index c5e687a6483..a2f1f5f129b 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -23,6 +23,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, + flag_message_format: Option, flag_release: bool, flag_no_fail_fast: bool, flag_frozen: bool, @@ -55,6 +56,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json-v1 --no-fail-fast Run all tests regardless of failure --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -92,6 +94,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); + let message_format = try!(ops::MessageFormat::from_option( + &options.flag_message_format + )); + let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); let empty = Vec::new(); @@ -124,6 +130,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { release: options.flag_release, mode: mode, filter: filter, + message_format: message_format, target_rustdoc_args: None, target_rustc_args: None, }, diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 512117ed8ba..3b88365d5f9 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -59,6 +59,8 @@ pub struct CompileOptions<'a> { pub release: bool, /// Mode for this compile. pub mode: CompileMode, + /// `--error_format` flag for the compiler. + pub message_format: MessageFormat, /// Extra arguments to be passed to rustdoc (for main crate and dependencies) pub target_rustdoc_args: Option<&'a [String]>, /// The specified target will be compiled with all the available arguments, @@ -74,6 +76,23 @@ pub enum CompileMode { Doc { deps: bool }, } +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum MessageFormat { + Human, + Json +} + +impl MessageFormat { + pub fn from_option(opt: &Option) -> CargoResult { + match opt.as_ref().map(|s| s.as_ref()) { + None | Some("human") => Ok(MessageFormat::Human), + Some("json-v1") => Ok(MessageFormat::Json), + Some(other) => bail!("argument for --message-format must be human or json-v1, \ + but found `{}`", other) + } + } +} + pub enum CompileFilter<'a> { Everything, Only { @@ -150,7 +169,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let root_package = try!(ws.current()); let CompileOptions { config, jobs, target, spec, features, all_features, no_default_features, - release, mode, + release, mode, message_format, ref filter, ref exec_engine, ref target_rustdoc_args, ref target_rustc_args } = *options; @@ -242,6 +261,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, build_config.exec_engine = exec_engine.clone(); build_config.release = release; build_config.test = mode == CompileMode::Test; + build_config.json_errors = message_format == MessageFormat::Json; if let CompileMode::Doc { deps } = mode { build_config.doc_all = deps; } diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index dc12e46ffe8..2001c6c8711 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -295,6 +295,7 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> filter: ops::CompileFilter::Everything, exec_engine: None, release: false, + message_format: ops::MessageFormat::Human, mode: ops::CompileMode::Build, target_rustdoc_args: None, target_rustc_args: None, diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 59d1ec57f63..dac09a7ea38 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -5,6 +5,8 @@ use std::fs; use std::path::{self, PathBuf}; use std::sync::Arc; +use rustc_serialize::json; + use core::{Package, PackageId, PackageSet, Target, Resolve}; use core::{Profile, Profiles, Workspace}; use core::shell::ColorConfig; @@ -44,6 +46,7 @@ pub struct BuildConfig { pub release: bool, pub test: bool, pub doc_all: bool, + pub json_errors: bool, } #[derive(Clone, Default)] @@ -212,7 +215,6 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { } } let has_custom_args = unit.profile.rustc_args.is_some(); - let exec_engine = cx.exec_engine.clone(); let filenames = try!(cx.target_filenames(unit)); let root = cx.out_dir(unit); @@ -240,7 +242,9 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { let cwd = cx.config.cwd().to_path_buf(); rustc.args(&try!(cx.rustflags_args(unit))); - + let json_errors = cx.build_config.json_errors; + let package_id = unit.pkg.package_id().clone(); + let target = unit.target.clone(); return Ok(Work::new(move |state| { // Only at runtime have we discovered what the extra -L and -l // arguments are for native libraries, so we process those here. We @@ -266,7 +270,36 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { } state.running(&rustc); - try!(exec_engine.exec(rustc).chain_error(|| { + let process_builder = rustc.into_process_builder(); + try!(if json_errors { + #[derive(RustcEncodable)] + struct Message<'a> { + reason: &'a str, + package_id: &'a PackageId, + target: &'a Target, + message: json::Json, + } + process_builder.exec_with_streaming( + &mut |line| assert!(line.is_empty()), + &mut |line| { + let rustc_message = json::Json::from_str(line).unwrap_or_else(|_| { + panic!("Compiler produced invalid json: `{}`", line) + }); + + let message = Message { + reason: "rustc-message", + package_id: &package_id, + target: &target, + message: rustc_message, + }; + let encoded = json::encode(&message).unwrap(); + println!("{}", encoded); + + }, + ).map(|_| ()) + } else { + process_builder.exec() + }.chain_error(|| { human(format!("Could not compile `{}`.", name)) })); @@ -495,6 +528,10 @@ fn build_base_args(cx: &Context, cmd.arg("--color").arg(&color_config.to_string()); } + if cx.build_config.json_errors { + cmd.arg("--error-format").arg("json"); + } + cmd.arg("--crate-name").arg(&unit.target.crate_name()); if !test { diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 48edabd9462..442d8c5a8ae 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -1,6 +1,6 @@ pub use self::cargo_clean::{clean, CleanOptions}; pub use self::cargo_compile::{compile, compile_ws, resolve_dependencies, CompileOptions}; -pub use self::cargo_compile::{CompileFilter, CompileMode}; +pub use self::cargo_compile::{CompileFilter, CompileMode, MessageFormat}; pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages}; pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind, Unit}; pub use self::cargo_rustc::{Context, LayoutProxy}; diff --git a/tests/build.rs b/tests/build.rs index 5657396382c..14817b167cd 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -2276,6 +2276,81 @@ fn explicit_color_config_is_propagated_to_rustc() { ")); } +#[test] +fn compiler_json_error_format() { + if !is_nightly() { return } + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + + name = "foo" + version = "0.5.0" + authors = ["wycats@example.com"] + + [dependencies.bar] + path = "bar" + "#) + .file("src/main.rs", "fn main() { let unused = 92; }") + .file("bar/Cargo.toml", r#" + [project] + + name = "bar" + version = "0.5.0" + authors = ["wycats@example.com"] + "#) + .file("bar/src/lib.rs", r#"fn dead() {}"#); + + assert_that(p.cargo_process("build").arg("-v") + .arg("--message-format").arg("json-v1"), + execs().with_json(r#" + { + "reason":"rustc-message", + "package_id":"bar 0.5.0 ([..])", + "target":{"kind":["lib"],"name":"bar","src_path":"[..]lib.rs"}, + "message":{ + "children":[],"code":null,"level":"warning","rendered":null, + "message":"function is never used: `dead`, #[warn(dead_code)] on by default", + "spans":[{ + "byte_end":12,"byte_start":0,"column_end":13,"column_start":1,"expansion":null, + "file_name":"[..]","is_primary":true,"label":null,"line_end":1,"line_start":1, + "suggested_replacement":null, + "text":[{"highlight_end":13,"highlight_start":1,"text":"fn dead() {}"}] + }] + } + } + + { + "reason":"rustc-message", + "package_id":"foo 0.5.0 ([..])", + "target":{"kind":["bin"],"name":"foo","src_path":"[..]main.rs"}, + "message":{ + "children":[],"code":null,"level":"warning","rendered":null, + "message":"unused variable: `unused`, #[warn(unused_variables)] on by default", + "spans":[{ + "byte_end":22,"byte_start":16,"column_end":23,"column_start":17,"expansion":null, + "file_name":"[..]","is_primary":true,"label":null,"line_end":1,"line_start":1, + "suggested_replacement":null, + "text":[{"highlight_end":23,"highlight_start":17,"text":"[..]"}] + }] + } + } +"#)); +} + +#[test] +fn wrong_message_format_option() { + let p = project("foo") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo_process("build").arg("--message-format").arg("XML"), + execs().with_status(101) + .with_stderr_contains("\ +[ERROR] argument for --message-format must be human or json-v1, but found `XML`")); +} + #[test] fn no_warn_about_package_metadata() { let p = project("foo") diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index fb6c7daf629..6de6df19764 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -258,7 +258,7 @@ pub struct Execs { expect_exit_code: Option, expect_stdout_contains: Vec, expect_stderr_contains: Vec, - expect_json: Option, + expect_json: Option>, } impl Execs { @@ -288,7 +288,9 @@ impl Execs { } pub fn with_json(mut self, expected: &str) -> Execs { - self.expect_json = Some(Json::from_str(expected).unwrap()); + self.expect_json = Some(expected.split("\n\n").map(|obj| { + Json::from_str(obj).unwrap() + }).collect()); self } @@ -324,8 +326,18 @@ impl Execs { &actual.stdout, true)); } - if let Some(ref expect_json) = self.expect_json { - try!(self.match_json(expect_json, &actual.stdout)); + if let Some(ref objects) = self.expect_json { + let lines = match str::from_utf8(&actual.stdout) { + Err(..) => return Err("stdout was not utf8 encoded".to_owned()), + Ok(stdout) => stdout.lines().collect::>(), + }; + if lines.len() != objects.len() { + return Err(format!("expected {} json lines, got {}", + objects.len(), lines.len())); + } + for (obj, line) in objects.iter().zip(lines) { + try!(self.match_json(obj, line)); + } } Ok(()) } @@ -375,14 +387,9 @@ impl Execs { } - fn match_json(&self, expected: &Json, stdout: &[u8]) -> ham::MatchResult { - let stdout = match str::from_utf8(stdout) { - Err(..) => return Err("stdout was not utf8 encoded".to_owned()), - Ok(stdout) => stdout, - }; - - let actual = match Json::from_str(stdout) { - Err(..) => return Err(format!("Invalid json {}", stdout)), + fn match_json(&self, expected: &Json, line: &str) -> ham::MatchResult { + let actual = match Json::from_str(line) { + Err(e) => return Err(format!("invalid json, {}:\n`{}`", e, line)), Ok(actual) => actual, }; From adcf59991ece8a50fc765761917cdc88f911dc21 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 27 Sep 2016 14:39:08 +0300 Subject: [PATCH 0745/3888] Don't panic while streaming compiler output --- src/cargo/ops/cargo_rustc/custom_build.rs | 4 ++-- src/cargo/ops/cargo_rustc/mod.rs | 14 ++++++++----- src/cargo/util/errors.rs | 9 ++++---- src/cargo/util/process_builder.rs | 25 +++++++++++++++-------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 8835824898c..5a15e85a853 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -206,8 +206,8 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) state.running(&p); let cmd = p.into_process_builder(); let output = try!(cmd.exec_with_streaming( - &mut |out_line| state.stdout(out_line), - &mut |err_line| state.stderr(err_line), + &mut |out_line| { state.stdout(out_line); Ok(()) }, + &mut |err_line| { state.stderr(err_line); Ok(()) }, ).map_err(|mut e| { e.desc = format!("failed to run custom build command for `{}`\n{}", pkg_name, e.desc); diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index dac09a7ea38..7d423dd8dcb 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -280,11 +280,15 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { message: json::Json, } process_builder.exec_with_streaming( - &mut |line| assert!(line.is_empty()), + &mut |line| if !line.is_empty() { + Err(internal(&format!("compiler stdout is not empty: `{}`", line))) + } else { + Ok(()) + }, &mut |line| { - let rustc_message = json::Json::from_str(line).unwrap_or_else(|_| { - panic!("Compiler produced invalid json: `{}`", line) - }); + let rustc_message = try!(json::Json::from_str(line).map_err(|_| { + internal(&format!("compiler produced invalid json: `{}`", line)) + })); let message = Message { reason: "rustc-message", @@ -294,7 +298,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { }; let encoded = json::encode(&message).unwrap(); println!("{}", encoded); - + Ok(()) }, ).map(|_| ()) } else { diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 8b41dd3e6ce..39e22cbe5da 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -110,13 +110,13 @@ pub struct ProcessError { pub desc: String, pub exit: Option, pub output: Option, - cause: Option, + cause: Option>, } impl Error for ProcessError { fn description(&self) -> &str { &self.desc } fn cause(&self) -> Option<&Error> { - self.cause.as_ref().map(|s| s as &Error) + self.cause.as_ref().map(|e| &**e as &Error) } } @@ -375,9 +375,10 @@ impl CargoError for str::ParseBoolError {} // Construction helpers pub fn process_error(msg: &str, - cause: Option, + cause: Option>, status: Option<&ExitStatus>, - output: Option<&Output>) -> ProcessError { + output: Option<&Output>) -> ProcessError +{ let exit = match status { Some(s) => status_to_string(s), None => "never executed".to_string(), diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index 856e337e200..c0d88d2ae86 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -5,7 +5,7 @@ use std::fmt; use std::path::Path; use std::process::{Command, Stdio, Output}; -use util::{ProcessError, process_error, read2}; +use util::{CargoResult, ProcessError, process_error, read2}; use util::shell_escape::escape; #[derive(Clone, PartialEq, Debug)] @@ -77,7 +77,7 @@ impl ProcessBuilder { let exit = try!(command.status().map_err(|e| { process_error(&format!("could not execute process `{}`", self.debug_string()), - Some(e), None, None) + Some(Box::new(e)), None, None) })); if exit.success() { @@ -94,8 +94,8 @@ impl ProcessBuilder { let output = try!(command.output().map_err(|e| { process_error(&format!("could not execute process `{}`", - self.debug_string()), - Some(e), None, None) + self.debug_string()), + Some(Box::new(e)), None, None) })); if output.status.success() { @@ -108,8 +108,8 @@ impl ProcessBuilder { } pub fn exec_with_streaming(&self, - on_stdout_line: &mut FnMut(&str), - on_stderr_line: &mut FnMut(&str)) + on_stdout_line: &mut FnMut(&str) -> CargoResult<()>, + on_stderr_line: &mut FnMut(&str) -> CargoResult<()>) -> Result { let mut stdout = Vec::new(); let mut stderr = Vec::new(); @@ -119,6 +119,7 @@ impl ProcessBuilder { .stderr(Stdio::piped()) .stdin(Stdio::null()); + let mut callback_error = None; let status = try!((|| { let mut child = try!(cmd.spawn()); let out = child.stdout.take().unwrap(); @@ -137,10 +138,14 @@ impl ProcessBuilder { let start = dst.len(); dst.extend(data); for line in String::from_utf8_lossy(&dst[start..]).lines() { - if is_out { + if callback_error.is_some() { break } + let callback_result = if is_out { on_stdout_line(line) } else { on_stderr_line(line) + }; + if let Err(e) = callback_result { + callback_error = Some(e); } } })); @@ -148,7 +153,7 @@ impl ProcessBuilder { })().map_err(|e| { process_error(&format!("could not execute process `{}`", self.debug_string()), - Some(e), None, None) + Some(Box::new(e)), None, None) })); let output = Output { stdout: stdout, @@ -159,6 +164,10 @@ impl ProcessBuilder { Err(process_error(&format!("process didn't exit successfully: `{}`", self.debug_string()), None, Some(&output.status), Some(&output))) + } else if let Some(e) = callback_error { + Err(process_error(&format!("failed to parse process output: `{}`", + self.debug_string()), + Some(Box::new(e)), Some(&output.status), Some(&output))) } else { Ok(output) } From 842fce8683ae9e6b2e6b50db7fcd1c6b7d7efbfe Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 28 Sep 2016 19:54:35 +0300 Subject: [PATCH 0746/3888] Create a centralized machine_message module --- src/cargo/ops/cargo_rustc/mod.rs | 25 ++++++++----------------- src/cargo/util/machine_message.rs | 30 ++++++++++++++++++++++++++++++ src/cargo/util/mod.rs | 7 ++++--- tests/build.rs | 4 ++-- 4 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 src/cargo/util/machine_message.rs diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 7d423dd8dcb..0b321c0c9c4 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -10,7 +10,7 @@ use rustc_serialize::json; use core::{Package, PackageId, PackageSet, Target, Resolve}; use core::{Profile, Profiles, Workspace}; use core::shell::ColorConfig; -use util::{self, CargoResult, human}; +use util::{self, CargoResult, human, machine_message}; use util::{Config, internal, ChainError, profile, join_paths, short_hash}; use self::job::{Job, Work}; @@ -272,13 +272,6 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { state.running(&rustc); let process_builder = rustc.into_process_builder(); try!(if json_errors { - #[derive(RustcEncodable)] - struct Message<'a> { - reason: &'a str, - package_id: &'a PackageId, - target: &'a Target, - message: json::Json, - } process_builder.exec_with_streaming( &mut |line| if !line.is_empty() { Err(internal(&format!("compiler stdout is not empty: `{}`", line))) @@ -286,18 +279,16 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { Ok(()) }, &mut |line| { - let rustc_message = try!(json::Json::from_str(line).map_err(|_| { + let compiler_message = try!(json::Json::from_str(line).map_err(|_| { internal(&format!("compiler produced invalid json: `{}`", line)) })); - let message = Message { - reason: "rustc-message", - package_id: &package_id, - target: &target, - message: rustc_message, - }; - let encoded = json::encode(&message).unwrap(); - println!("{}", encoded); + machine_message::FromCompiler::new( + &package_id, + &target, + compiler_message + ).emit(); + Ok(()) }, ).map(|_| ()) diff --git a/src/cargo/util/machine_message.rs b/src/cargo/util/machine_message.rs new file mode 100644 index 00000000000..7de1ead0e67 --- /dev/null +++ b/src/cargo/util/machine_message.rs @@ -0,0 +1,30 @@ +use rustc_serialize::json; +use core::{PackageId, Target}; + +#[derive(RustcEncodable)] +pub struct FromCompiler<'a> { + reason: &'static str, + package_id: &'a PackageId, + target: &'a Target, + message: json::Json, +} + +impl<'a> FromCompiler<'a> { + pub fn new(package_id: &'a PackageId, + target: &'a Target, + message: json::Json) + -> FromCompiler<'a> { + FromCompiler { + reason: "compiler-message", + package_id: package_id, + target: target, + message: message, + } + } + + pub fn emit(self) { + let json = json::encode(&self).unwrap(); + println!("{}", json); + } +} + diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 3b18fb1e573..56bbeed0d99 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -25,15 +25,16 @@ pub mod errors; pub mod graph; pub mod hex; pub mod important_paths; +pub mod job; +pub mod lev_distance; +pub mod machine_message; +pub mod network; pub mod paths; pub mod process_builder; pub mod profile; pub mod to_semver; pub mod to_url; pub mod toml; -pub mod lev_distance; -pub mod job; -pub mod network; mod cfg; mod dependency_queue; mod rustc; diff --git a/tests/build.rs b/tests/build.rs index 14817b167cd..f30dc54f676 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -2305,7 +2305,7 @@ fn compiler_json_error_format() { .arg("--message-format").arg("json-v1"), execs().with_json(r#" { - "reason":"rustc-message", + "reason":"compiler-message", "package_id":"bar 0.5.0 ([..])", "target":{"kind":["lib"],"name":"bar","src_path":"[..]lib.rs"}, "message":{ @@ -2321,7 +2321,7 @@ fn compiler_json_error_format() { } { - "reason":"rustc-message", + "reason":"compiler-message", "package_id":"foo 0.5.0 ([..])", "target":{"kind":["bin"],"name":"foo","src_path":"[..]main.rs"}, "message":{ From 8eefdf73053e71f5a8968ca14956e208f04898c6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 1 Oct 2016 13:31:12 +0300 Subject: [PATCH 0747/3888] Rename message-format flag to json --- src/bin/bench.rs | 11 ++++------- src/bin/build.rs | 12 ++++-------- src/bin/doc.rs | 11 ++++------- src/bin/run.rs | 11 ++++------- src/bin/rustc.rs | 12 ++++-------- src/bin/rustdoc.rs | 11 ++++------- src/bin/test.rs | 11 ++++------- src/cargo/lib.rs | 3 +-- src/cargo/ops/cargo_compile.rs | 13 +------------ tests/build.rs | 8 ++++---- 10 files changed, 34 insertions(+), 69 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 521c87c2f70..d9abefe40b8 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops; +use cargo::ops::{self, MessageFormat}; use cargo::util::{CliResult, CliError, Human, Config, human}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -16,7 +16,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, - flag_message_format: Option, + flag_message_format: MessageFormat, flag_lib: bool, flag_bin: Vec, flag_example: Vec, @@ -51,7 +51,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - --message-format FMT Error format: human, json-v1 + --message-format FMT Error format: human, json [default: human] --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -77,9 +77,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - let message_format = try!(ops::MessageFormat::from_option( - &options.flag_message_format - )); let ops = ops::TestOptions { no_run: options.flag_no_run, no_fail_fast: false, @@ -100,7 +97,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), - message_format: message_format, + message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, }, diff --git a/src/bin/build.rs b/src/bin/build.rs index c4619f541e9..0357fe08096 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -1,8 +1,7 @@ use std::env; use cargo::core::Workspace; -use cargo::ops::CompileOptions; -use cargo::ops; +use cargo::ops::{self, CompileOptions, MessageFormat}; use cargo::util::important_paths::{find_root_manifest_for_wd}; use cargo::util::{CliResult, Config}; @@ -18,7 +17,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, - flag_message_format: Option, + flag_message_format: MessageFormat, flag_release: bool, flag_lib: bool, flag_bin: Vec, @@ -53,7 +52,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - --message-format FMT Error format: human, json-v1 + --message-format FMT Error format: human, json [default: human] --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -75,9 +74,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - let message_format = try!(ops::MessageFormat::from_option( - &options.flag_message_format - )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -97,7 +93,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), - message_format: message_format, + message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, }; diff --git a/src/bin/doc.rs b/src/bin/doc.rs index 83431ef66ff..c1841c20a54 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops; +use cargo::ops::{self, MessageFormat}; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -17,7 +17,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, - flag_message_format: Option, + flag_message_format: MessageFormat, flag_package: Vec, flag_lib: bool, flag_bin: Vec, @@ -48,7 +48,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - --message-format FMT Error format: human, json-v1 + --message-format FMT Error format: human, json [default: human] --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -67,9 +67,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - let message_format = try!(ops::MessageFormat::from_option( - &options.flag_message_format - )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -90,7 +87,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &empty, &empty, &empty), - message_format: message_format, + message_format: options.flag_message_format, release: options.flag_release, mode: ops::CompileMode::Doc { deps: !options.flag_no_deps, diff --git a/src/bin/run.rs b/src/bin/run.rs index 4b03b53bc53..f5055b5eba0 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops; +use cargo::ops::{self, MessageFormat}; use cargo::util::{CliResult, CliError, Config, Human}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -16,7 +16,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, - flag_message_format: Option, + flag_message_format: MessageFormat, flag_release: bool, flag_frozen: bool, flag_locked: bool, @@ -43,7 +43,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - --message-format FMT Error format: human, json-v1 + --message-format FMT Error format: human, json [default: human] --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -63,9 +63,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - let message_format = try!(ops::MessageFormat::from_option( - &options.flag_message_format - )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -96,7 +93,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { bins: &bins, examples: &examples, } }, - message_format: message_format, + message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, }; diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 2743c3669f0..fa9334f5b29 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -1,8 +1,7 @@ use std::env; use cargo::core::Workspace; -use cargo::ops::{CompileOptions, CompileMode}; -use cargo::ops; +use cargo::ops::{self, CompileOptions, CompileMode, MessageFormat}; use cargo::util::important_paths::{find_root_manifest_for_wd}; use cargo::util::{CliResult, CliError, Config, human}; @@ -19,7 +18,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, - flag_message_format: Option, + flag_message_format: MessageFormat, flag_release: bool, flag_lib: bool, flag_bin: Vec, @@ -56,7 +55,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - --message-format FMT Error format: human, json-v1 + --message-format FMT Error format: human, json [default: human] --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -82,9 +81,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - let message_format = try!(ops::MessageFormat::from_option( - &options.flag_message_format - )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -115,7 +111,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), - message_format: message_format, + message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: options.arg_opts.as_ref().map(|a| &a[..]), }; diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index 79e368090b6..587046200df 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops; +use cargo::ops::{self, MessageFormat}; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -17,7 +17,7 @@ pub struct Options { flag_release: bool, flag_quiet: Option, flag_color: Option, - flag_message_format: Option, + flag_message_format: MessageFormat, flag_package: Option, flag_lib: bool, flag_bin: Vec, @@ -53,7 +53,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - --message-format FMT Error format: human, json-v1 + --message-format FMT Error format: human, json [default: human] --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -76,9 +76,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - let message_format = try!(ops::MessageFormat::from_option( - &options.flag_message_format - )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -100,7 +97,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), - message_format: message_format, + message_format: options.flag_message_format, mode: ops::CompileMode::Doc { deps: false }, target_rustdoc_args: Some(&options.arg_opts), target_rustc_args: None, diff --git a/src/bin/test.rs b/src/bin/test.rs index a2f1f5f129b..410c0a2c4d5 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops; +use cargo::ops::{self, MessageFormat}; use cargo::util::{CliResult, CliError, Human, human, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -23,7 +23,7 @@ pub struct Options { flag_verbose: u32, flag_quiet: Option, flag_color: Option, - flag_message_format: Option, + flag_message_format: MessageFormat, flag_release: bool, flag_no_fail_fast: bool, flag_frozen: bool, @@ -56,7 +56,7 @@ Options: -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - --message-format FMT Error format: human, json-v1 + --message-format FMT Error format: human, json [default: human] --no-fail-fast Run all tests regardless of failure --frozen Require Cargo.lock and cache are up to date --locked Require Cargo.lock is up to date @@ -94,9 +94,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_color, options.flag_frozen, options.flag_locked)); - let message_format = try!(ops::MessageFormat::from_option( - &options.flag_message_format - )); let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); @@ -130,7 +127,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { release: options.flag_release, mode: mode, filter: filter, - message_format: message_format, + message_format: options.flag_message_format, target_rustdoc_args: None, target_rustc_args: None, }, diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index b96da7d6606..d1a8f908866 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -211,8 +211,7 @@ pub fn version() -> String { }) } -fn flags_from_args(usage: &str, args: &[String], - options_first: bool) -> CliResult +fn flags_from_args(usage: &str, args: &[String], options_first: bool) -> CliResult where T: Decodable { let docopt = Docopt::new(usage).unwrap() diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 3b88365d5f9..0767e9e467a 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -76,23 +76,12 @@ pub enum CompileMode { Doc { deps: bool }, } -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, RustcDecodable)] pub enum MessageFormat { Human, Json } -impl MessageFormat { - pub fn from_option(opt: &Option) -> CargoResult { - match opt.as_ref().map(|s| s.as_ref()) { - None | Some("human") => Ok(MessageFormat::Human), - Some("json-v1") => Ok(MessageFormat::Json), - Some(other) => bail!("argument for --message-format must be human or json-v1, \ - but found `{}`", other) - } - } -} - pub enum CompileFilter<'a> { Everything, Only { diff --git a/tests/build.rs b/tests/build.rs index f30dc54f676..739a5b9c467 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -2302,7 +2302,7 @@ fn compiler_json_error_format() { .file("bar/src/lib.rs", r#"fn dead() {}"#); assert_that(p.cargo_process("build").arg("-v") - .arg("--message-format").arg("json-v1"), + .arg("--message-format").arg("json"), execs().with_json(r#" { "reason":"compiler-message", @@ -2346,9 +2346,9 @@ fn wrong_message_format_option() { p.build(); assert_that(p.cargo_process("build").arg("--message-format").arg("XML"), - execs().with_status(101) - .with_stderr_contains("\ -[ERROR] argument for --message-format must be human or json-v1, but found `XML`")); + execs().with_status(1) + .with_stderr_contains( +r#"[ERROR] Could not match 'xml' with any of the allowed variants: ["Human", "Json"]"#)); } #[test] From 3ff59b8c3a08279b9198ff813ad67badcbca6b64 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 1 Oct 2016 13:53:42 +0300 Subject: [PATCH 0748/3888] Store CargoError inside the ProcessError --- src/cargo/util/errors.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 39e22cbe5da..0f1bfe9efb4 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -23,6 +23,7 @@ pub type CargoResult = Result>; pub trait CargoError: Error + Send + 'static { fn is_human(&self) -> bool { false } fn cargo_cause(&self) -> Option<&CargoError>{ None } + fn as_error(&self) -> &Error where Self: Sized { self as &Error } } impl Error for Box { @@ -110,13 +111,13 @@ pub struct ProcessError { pub desc: String, pub exit: Option, pub output: Option, - cause: Option>, + cause: Option>, } impl Error for ProcessError { fn description(&self) -> &str { &self.desc } fn cause(&self) -> Option<&Error> { - self.cause.as_ref().map(|e| &**e as &Error) + self.cause.as_ref().map(|e| e.as_error()) } } @@ -375,7 +376,7 @@ impl CargoError for str::ParseBoolError {} // Construction helpers pub fn process_error(msg: &str, - cause: Option>, + cause: Option>, status: Option<&ExitStatus>, output: Option<&Output>) -> ProcessError { From b9aa5d5e2be26c173571978c0c2fc6a58cd001c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Mon, 3 Oct 2016 10:55:05 +0200 Subject: [PATCH 0749/3888] Use chain_error in TomlManifest.replace when checking valid semver. Don't throw away previous error messages, they might be useful for the user. --- src/cargo/util/toml.rs | 11 +++++------ tests/overrides.rs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 578d4474327..a051a2836b3 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -737,12 +737,11 @@ impl TomlManifest { -> CargoResult> { let mut replace = Vec::new(); for (spec, replacement) in self.replace.iter().flat_map(|x| x) { - let spec = match PackageIdSpec::parse(spec) { - Ok(spec) => spec, - Err(_) => bail!("replacements must specify a \ - valid semver version \ - to replace, but `{}` does not", spec), - }; + let spec = try!(PackageIdSpec::parse(spec).chain_error(|| { + human(format!("replacements must specify a valid semver \ + version to replace, but `{}` does not", + spec)) + })); let version_specified = match *replacement { TomlDependency::Detailed(ref d) => d.version.is_some(), diff --git a/tests/overrides.rs b/tests/overrides.rs index eff9bbf9d85..816efd53c1d 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -95,7 +95,7 @@ fn invalid_semver_version() { .file("src/lib.rs", ""); assert_that(p.cargo_process("build"), - execs().with_status(101).with_stderr("\ + execs().with_status(101).with_stderr_contains("\ error: failed to parse manifest at `[..]` Caused by: From d1aea0ba09fc0ecf83f183fc95165942b3080fdd Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 3 Oct 2016 20:37:25 -0500 Subject: [PATCH 0750/3888] add support for per-target rustflags in .cargo/config you can now specify rustflags on a per-target basis in .cargo/config: ``` toml [target.x86_64-unknown-linux-gnu] rustflags = ["x86", "specific", "flags"] [target.arm-unknown-linux-gnueabi] rustflags = ["arm", "specific", "flags"] ``` If both build.rustflags and target.*.rustflags are specified, the target.* ones will be used. As before RUSTFLAGS overrides either set. closes #3153 --- src/cargo/ops/cargo_rustc/context.rs | 10 +++- tests/rustflags.rs | 71 ++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index fe0a9424141..7cbd2149fe4 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -775,8 +775,16 @@ fn env_args(config: &Config, return Ok(args.collect()); } - // Then the build.rustflags value let name = name.chars().flat_map(|c| c.to_lowercase()).collect::(); + // Then the target.*.rustflags value + let target = build_config.requested_target.as_ref().unwrap_or(&build_config.host_triple); + let key = format!("target.{}.{}", target, name); + if let Some(args) = try!(config.get_list(&key)) { + let args = args.val.into_iter().map(|a| a.0); + return Ok(args.collect()); + } + + // Then the build.rustflags value let key = format!("build.{}", name); if let Some(args) = try!(config.get_list(&key)) { let args = args.val.into_iter().map(|a| a.0); diff --git a/tests/rustflags.rs b/tests/rustflags.rs index ccdc6a91dc9..cc9266ac281 100644 --- a/tests/rustflags.rs +++ b/tests/rustflags.rs @@ -878,3 +878,74 @@ fn build_rustflags_with_home_config() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); } + +#[test] +fn target_rustflags_normal_source() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + "#) + .file("src/lib.rs", "") + .file("src/bin/a.rs", "fn main() {}") + .file("examples/b.rs", "fn main() {}") + .file("tests/c.rs", "#[test] fn f() { }") + .file("benches/d.rs", r#" + #![feature(test)] + extern crate test; + #[bench] fn run1(_ben: &mut test::Bencher) { }"#) + .file(".cargo/config", &format!(" + [target.{}] + rustflags = [\"-Z\", \"bogus\"] + ", rustc_host())); + p.build(); + + assert_that(p.cargo("build") + .arg("--lib"), + execs().with_status(101)); + assert_that(p.cargo("build") + .arg("--bin=a"), + execs().with_status(101)); + assert_that(p.cargo("build") + .arg("--example=b"), + execs().with_status(101)); + assert_that(p.cargo("test"), + execs().with_status(101)); + assert_that(p.cargo("bench"), + execs().with_status(101)); +} + +// target.{}.rustflags takes precedence over build.rustflags +#[test] +fn target_rustflags_precedence() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + "#) + .file("src/lib.rs", "") + .file(".cargo/config", &format!(" + [build] + rustflags = [\"--cfg\", \"foo\"] + + [target.{}] + rustflags = [\"-Z\", \"bogus\"] + ", rustc_host())); + p.build(); + + assert_that(p.cargo("build") + .arg("--lib"), + execs().with_status(101)); + assert_that(p.cargo("build") + .arg("--bin=a"), + execs().with_status(101)); + assert_that(p.cargo("build") + .arg("--example=b"), + execs().with_status(101)); + assert_that(p.cargo("test"), + execs().with_status(101)); + assert_that(p.cargo("bench"), + execs().with_status(101)); +} From 1db1af006a034739a608f559b9f0027eff4d53b6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 4 Oct 2016 15:59:37 -0700 Subject: [PATCH 0751/3888] Leak mspdbsrv.exe processes on Windows Instead of having our job object tear them down, instead leak them intentionally if everything succeeded. Closes #3161 --- Cargo.lock | 17 +++- Cargo.toml | 3 +- src/bin/cargo.rs | 2 +- src/cargo/util/job.rs | 197 +++++++++++++++++++++++++++++++++++++++--- 4 files changed, 200 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7dc67435fff..13449eb396a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,6 +24,7 @@ dependencies = [ "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -270,7 +271,7 @@ dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -286,7 +287,7 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.1.38" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -483,6 +484,15 @@ dependencies = [ "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "psapi-sys" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand" version = "0.3.14" @@ -660,7 +670,7 @@ dependencies = [ "checksum libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "23e3757828fa702a20072c37ff47938e9dd331b92fac6e223d26d4b7a55f7ee2" "checksum libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3293dc95169a6351c5a03eca4bf5549f3a9a06336a000315876ff1165a5fba10" "checksum libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc058951ab6a3ef35ca16462d7642c4867e6403520811f28537a4e2f2db3e71" -"checksum libssh2-sys 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "49c845f8fad4f5761d1018dd0dba8ca49934cc7c97a8473ff20a2f181cda830c" +"checksum libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "1debd7e56d19655eb786f827675dc55f6d530de6d7b81e76d13d1afc635d6c07" "checksum libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "40f2df7730b5d29426c3e44ce4d088d8c5def6471c2c93ba98585b89fb201ce6" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" "checksum matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "15305656809ce5a4805b1ff2946892810992197ce1270ff79baded852187942e" @@ -682,6 +692,7 @@ dependencies = [ "checksum openssl-sys-extras 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "11c5e1dba7d3d03d80f045bf0d60111dc69213b67651e7c889527a3badabb9fa" "checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa" "checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b" +"checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" "checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5" "checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2" "checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199" diff --git a/Cargo.toml b/Cargo.toml index 6ced3b09d3a..083a8654efb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,14 +27,15 @@ filetime = "0.1" flate2 = "0.2" fs2 = "0.2" git2 = "0.4" -libgit2-sys = "0.4" git2-curl = "0.5" glob = "0.2" kernel32-sys = "0.2" libc = "0.2" +libgit2-sys = "0.4" log = "0.3" miow = "0.1" num_cpus = "1.0" +psapi-sys = "0.1" regex = "0.1" rustc-serialize = "0.3" semver = "0.2.3" diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 2e4ceb0eb96..fdcea48c89f 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -123,7 +123,7 @@ fn execute(flags: Flags, config: &Config) -> CliResult> { flags.flag_locked)); init_git_transports(config); - cargo::util::job::setup(); + let _token = cargo::util::job::setup(); if flags.flag_version { println!("{}", cargo::version()); diff --git a/src/cargo/util/job.rs b/src/cargo/util/job.rs index dee6d0bd7cb..06f51356d25 100644 --- a/src/cargo/util/job.rs +++ b/src/cargo/util/job.rs @@ -15,7 +15,9 @@ //! child will be associated with the job object as well. This means if we add //! ourselves to the job object we create then everything will get torn down! -pub fn setup() { +pub use self::imp::Setup; + +pub fn setup() -> Option { unsafe { imp::setup() } } @@ -24,7 +26,9 @@ mod imp { use std::env; use libc; - pub unsafe fn setup() { + pub type Setup = (); + + pub unsafe fn setup() -> Option<()> { // There's a test case for the behavior of // when-cargo-is-killed-subprocesses-are-also-killed, but that requires // one cargo spawned to become its own session leader, so we do that @@ -32,6 +36,7 @@ mod imp { if env::var("__CARGO_TEST_SETSID_PLEASE_DONT_USE_ELSEWHERE").is_ok() { libc::setsid(); } + Some(()) } } @@ -39,10 +44,26 @@ mod imp { mod imp { extern crate kernel32; extern crate winapi; + extern crate psapi; + use std::ffi::OsString; + use std::io; use std::mem; + use std::os::windows::prelude::*; + + pub struct Setup { + job: Handle, + } - pub unsafe fn setup() { + pub struct Handle { + inner: winapi::HANDLE, + } + + fn last_err() -> io::Error { + io::Error::last_os_error() + } + + pub unsafe fn setup() -> Option { // Creates a new job object for us to use and then adds ourselves to it. // Note that all errors are basically ignored in this function, // intentionally. Job objects are "relatively new" in Windows, @@ -54,8 +75,9 @@ mod imp { let job = kernel32::CreateJobObjectW(0 as *mut _, 0 as *const _); if job.is_null() { - return + return None } + let job = Handle { inner: job }; // Indicate that when all handles to the job object are gone that all // process in the object should be killed. Note that this includes our @@ -65,27 +87,174 @@ mod imp { info = mem::zeroed(); info.BasicLimitInformation.LimitFlags = winapi::JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; - let r = kernel32::SetInformationJobObject(job, + let r = kernel32::SetInformationJobObject(job.inner, winapi::JobObjectExtendedLimitInformation, &mut info as *mut _ as winapi::LPVOID, mem::size_of_val(&info) as winapi::DWORD); if r == 0 { - kernel32::CloseHandle(job); - return + return None } // Assign our process to this job object, meaning that our children will // now live or die based on our existence. let me = kernel32::GetCurrentProcess(); - let r = kernel32::AssignProcessToJobObject(job, me); + let r = kernel32::AssignProcessToJobObject(job.inner, me); if r == 0 { - kernel32::CloseHandle(job); - return + return None + } + + Some(Setup { job: job }) + } + + impl Drop for Setup { + fn drop(&mut self) { + // This is a litte subtle. By default if we are terminated then all + // processes in our job object are terminated as well, but we + // intentionally want to whitelist some processes to outlive our job + // object (see below). + // + // To allow for this, we manually kill processes instead of letting + // the job object kill them for us. We do this in a loop to handle + // processes spawning other processes. + // + // Finally once this is all done we know that the only remaining + // ones are ourselves and the whitelisted processes. The destructor + // here then configures our job object to *not* kill everything on + // close, then closes the job object. + unsafe { + while self.kill_remaining() { + info!("killed some, going for more"); + } + + let mut info: winapi::JOBOBJECT_EXTENDED_LIMIT_INFORMATION; + info = mem::zeroed(); + let r = kernel32::SetInformationJobObject( + self.job.inner, + winapi::JobObjectExtendedLimitInformation, + &mut info as *mut _ as winapi::LPVOID, + mem::size_of_val(&info) as winapi::DWORD); + if r == 0 { + info!("failed to configure job object to defaults: {}", + last_err()); + } + } } + } + + impl Setup { + unsafe fn kill_remaining(&mut self) -> bool { + #[repr(C)] + struct Jobs { + header: winapi::JOBOBJECT_BASIC_PROCESS_ID_LIST, + list: [winapi::ULONG_PTR; 1024], + } + + let mut jobs: Jobs = mem::zeroed(); + let r = kernel32::QueryInformationJobObject( + self.job.inner, + winapi::JobObjectBasicProcessIdList, + &mut jobs as *mut _ as winapi::LPVOID, + mem::size_of_val(&jobs) as winapi::DWORD, + 0 as *mut _); + if r == 0 { + info!("failed to query job object: {}", last_err()); + return false + } + + let mut killed = false; + let list = &jobs.list[..jobs.header.NumberOfProcessIdsInList as usize]; + assert!(list.len() > 0); + info!("found {} remaining processes", list.len() - 1); + + let list = list.iter().filter(|&&id| { + // let's not kill ourselves + id as winapi::DWORD != kernel32::GetCurrentProcessId() + }).filter_map(|&id| { + // Open the process with the necessary rights, and if this + // fails then we probably raced with the process exiting so we + // ignore the problem. + let flags = winapi::PROCESS_QUERY_INFORMATION | + winapi::PROCESS_TERMINATE | + winapi::SYNCHRONIZE; + let p = kernel32::OpenProcess(flags, + winapi::FALSE, + id as winapi::DWORD); + if p.is_null() { + None + } else { + Some(Handle { inner: p }) + } + }).filter(|p| { + // Test if this process was actually in the job object or not. + // If it's not then we likely raced with something else + // recycling this PID, so we just skip this step. + let mut res = 0; + let r = kernel32::IsProcessInJob(p.inner, self.job.inner, &mut res); + if r == 0 { + info!("failed to test is process in job: {}", last_err()); + return false + } + res == winapi::TRUE + }); + + + for p in list { + // Load the file which this process was spawned from. We then + // later use this for identification purposes. + let mut buf = [0; 1024]; + let r = psapi::GetProcessImageFileNameW(p.inner, + buf.as_mut_ptr(), + buf.len() as winapi::DWORD); + if r == 0 { + info!("failed to get image name: {}", last_err()); + continue + } + let s = OsString::from_wide(&buf[..r as usize]); + info!("found remaining: {:?}", s); - // Intentionally leak the `job` handle here. We've got the only - // reference to this job, so once it's gone we and all our children will - // be killed. This typically won't happen unless Cargo itself is - // ctrl-c'd. + // And here's where we find the whole purpose for this + // function! Currently, our only whitelisted process is + // `mspdbsrv.exe`, and more details about that can be found + // here: + // + // https://github.com/rust-lang/rust/issues/33145 + // + // The gist of it is that all builds on one machine use the + // same `mspdbsrv.exe` instance. If we were to kill this + // instance then we could erroneously cause other builds to + // fail. + if let Some(s) = s.to_str() { + if s.contains("mspdbsrv") { + info!("\toops, this is mspdbsrv"); + continue + } + } + + // Ok, this isn't mspdbsrv, let's kill the process. After we + // kill it we wait on it to ensure that the next time around in + // this function we're not going to see it again. + let r = kernel32::TerminateProcess(p.inner, 1); + if r == 0 { + info!("\tfailed to kill subprocess: {}", last_err()); + info!("\tassuming subprocess is dead..."); + } else { + info!("\tterminated subprocess"); + } + let r = kernel32::WaitForSingleObject(p.inner, winapi::INFINITE); + if r != 0 { + info!("failed to wait for process to die: {}", last_err()); + return false + } + killed = true; + } + + return killed + } + } + + impl Drop for Handle { + fn drop(&mut self) { + unsafe { kernel32::CloseHandle(self.inner); } + } } } From e4e27235e6e0f4a4979fc7a022607686a81a1530 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 5 Oct 2016 00:21:10 +0000 Subject: [PATCH 0752/3888] Update rust-installer --- src/rust-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rust-installer b/src/rust-installer index 755bc3db4ff..4f994850808 160000 --- a/src/rust-installer +++ b/src/rust-installer @@ -1 +1 @@ -Subproject commit 755bc3db4ff795865ea31b5b4f38ac920d8acacb +Subproject commit 4f994850808a572e2cc8d43f968893c8e942e9bf From ae59a423da225ae892e4fabf296382328688d750 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 4 Oct 2016 23:59:03 -0500 Subject: [PATCH 0753/3888] add documentation about target.$triple.rustflags --- src/doc/config.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/config.md b/src/doc/config.md index 6a41019923a..c542af429eb 100644 --- a/src/doc/config.md +++ b/src/doc/config.md @@ -69,6 +69,9 @@ linker = ".." # Similar to the above linker configuration, but this only applies to # when the `$triple` is being compiled for. linker = ".." +# custom flags to pass to all compiler invocations that target $triple +# this value overrides build.rustflags when both are present +rustflags = ["..", ".."] # Configuration keys related to the registry [registry] From 27e21c7ac1f922fb78bfeeb009bb4e3ce358c543 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 5 Oct 2016 21:26:15 +0300 Subject: [PATCH 0754/3888] Add some docs about JSON messages --- src/doc/header.html | 1 + src/doc/machine-readable-output.md | 78 ++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 src/doc/machine-readable-output.md diff --git a/src/doc/header.html b/src/doc/header.html index 2ab3c4b4273..83e76173c95 100644 --- a/src/doc/header.html +++ b/src/doc/header.html @@ -39,6 +39,7 @@

CARGO

  • Package ID specs
  • Environment Variables
  • Source Replacement
  • +
  • Machine readable output
  • Policies
  • diff --git a/src/doc/machine-readable-output.md b/src/doc/machine-readable-output.md new file mode 100644 index 00000000000..e486fd6c685 --- /dev/null +++ b/src/doc/machine-readable-output.md @@ -0,0 +1,78 @@ +% Machine readable output. + +Cargo can output information about project and build in JSON format. + +# Information about project structure + +You can use `cargo metadata` command to get information about project structure +and dependencies. The output of the command looks like this: + +``` +{ + // Integer version number of the format. + "version": integer, + + // List of packages for this workspace, including dependencies. + "packages": [ + { + // Opaque package identifier. + "id": PackageId, + + "name": string, + + "version": string, + + "source": SourceId, + + // A list of declared dependencies, see `resolve` field for actual dependencies. + "dependencies": [ Dependency ], + + "targets: [ Target ], + + // Path to Cargo.toml + "manifest_path": string, + } + ], + + "workspace_members": [ PackageId ], + + // Dependencies graph. + "resolve": { + "nodes": [ + { + "id": PackageId, + "dependencies": [ PackageId ] + } + ] + } +} +``` + + +# Compiler errors + +If you supply `--message-format json` to commands like `cargo build`, Cargo +reports compilation errors and warnings in JSON format. Messages go to the +standard output. Each message occupies exactly one line and does not contain +internal `\n` symbols, so it is possible to process messages one by one +without waiting for the whole build to finish. + +The message format looks like this: + +``` +{ + // Type of the message. + "reason": "compiler-message", + + // Unique opaque identifier of compiled package. + "package_id": PackageId, + + // Unique specification of a particular target within the package. + "target": Target, + + // The error message from the compiler in JSON format. + "message": {...} +} +``` + +Package and target specification are the same that `cargo metadata` uses. From 394feb916bb3c69be7c8146b4ca03ce0b8c21f2b Mon Sep 17 00:00:00 2001 From: Jake Goldsborough Date: Wed, 5 Oct 2016 16:40:10 -0700 Subject: [PATCH 0755/3888] tweaking the way the dropdown opens to fix links not working --- src/doc/javascripts/all.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/doc/javascripts/all.js b/src/doc/javascripts/all.js index 2694e8fc60b..d2124a9528f 100644 --- a/src/doc/javascripts/all.js +++ b/src/doc/javascripts/all.js @@ -19,18 +19,23 @@ $(function() { pres[i].className += ' language-rust'; } + // Toggles docs menu $('button.dropdown, a.dropdown').click(function(el, e) { - $(this).toggleClass('active'); - $(this).siblings('ul').toggleClass('open'); + $(this).toggleClass('active').siblings('ul').toggleClass('open'); - if ($(this).hasClass('active')) { - $(document).on('mousedown.useroptions', function() { - setTimeout(function() { - $('button.dropdown, a.dropdown').removeClass('active'); - $('button.dropdown + ul').removeClass('open'); - }, 150); - $(document).off('mousedown.useroptions'); - }); + return false; + }); + + // A click in the page anywhere but in the menu will turn the menu off + $(document).on('click', function(e) { + // Checks to make sure the click did not come from inside dropdown menu + // if it doesn't we close the menu + // else, we do nothing and just follow the link + if (!$(e.target).closest('ul.dropdown').length) { + var toggles = $('button.dropdown.active, a.dropdown.active'); + toggles.toggleClass('active').siblings('ul').toggleClass('open'); + + return false; } }); }); From eb4743386258c601f3579c5c1a62d7fa42f3bf06 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 6 Oct 2016 09:46:32 -0700 Subject: [PATCH 0756/3888] Ignore rustc-macro tests for now We need to ignore them to land rust-lang/rust#36945 and after that we'll shortly re-enable them. --- tests/rustc-macro.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/rustc-macro.rs b/tests/rustc-macro.rs index f3d618b1228..f9ea79d2a17 100644 --- a/tests/rustc-macro.rs +++ b/tests/rustc-macro.rs @@ -6,6 +6,7 @@ use cargotest::support::{project, execs}; use hamcrest::assert_that; #[test] +#[ignore] fn noop() { if !is_nightly() { return; @@ -62,6 +63,7 @@ fn noop() { } #[test] +#[ignore] fn impl_and_derive() { if !is_nightly() { return; @@ -146,6 +148,7 @@ fn impl_and_derive() { } #[test] +#[ignore] fn plugin_and_rustc_macro() { if !is_nightly() { return; From 2c4988973bf302bdc1a4ad2f26113d2d5966ad9b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 4 Oct 2016 09:58:28 -0700 Subject: [PATCH 0757/3888] Blanket rename rustc-macro to proc-macro --- src/cargo/core/manifest.rs | 8 +++--- src/cargo/util/toml.rs | 16 +++++------ src/doc/manifest.md | 6 ++-- tests/{rustc-macro.rs => proc-macro.rs} | 38 ++++++++++++------------- 4 files changed, 34 insertions(+), 34 deletions(-) rename tests/{rustc-macro.rs => proc-macro.rs} (83%) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 827008b8be4..e72674b9602 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -61,7 +61,7 @@ pub enum LibKind { Lib, Rlib, Dylib, - RustcMacro, + ProcMacro, Other(String), } @@ -71,7 +71,7 @@ impl LibKind { "lib" => LibKind::Lib, "rlib" => LibKind::Rlib, "dylib" => LibKind::Dylib, - "rustc-macro" => LibKind::RustcMacro, + "procc-macro" => LibKind::ProcMacro, s => LibKind::Other(s.to_string()), } } @@ -82,7 +82,7 @@ impl LibKind { LibKind::Lib => "lib", LibKind::Rlib => "rlib", LibKind::Dylib => "dylib", - LibKind::RustcMacro => "rustc-macro", + LibKind::ProcMacro => "proc-macro", LibKind::Other(ref s) => s, } } @@ -92,7 +92,7 @@ impl LibKind { LibKind::Lib | LibKind::Rlib | LibKind::Dylib | - LibKind::RustcMacro => true, + LibKind::ProcMacro => true, LibKind::Other(..) => false, } } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index a051a2836b3..0a9ecd6136c 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -905,7 +905,7 @@ struct TomlTarget { bench: Option, doc: Option, plugin: Option, - rustc_macro: Option, + proc_macro: Option, harness: Option, } @@ -934,7 +934,7 @@ impl TomlTarget { bench: None, doc: None, plugin: None, - rustc_macro: None, + proc_macro: None, harness: None, } } @@ -1017,15 +1017,15 @@ impl TomlTarget { fn validate_crate_type(&self) -> CargoResult<()> { // Per the Macros 1.1 RFC: // - // > Initially if a crate is compiled with the rustc-macro crate type + // > Initially if a crate is compiled with the proc-macro crate type // > (and possibly others) it will forbid exporting any items in the - // > crate other than those functions tagged #[rustc_macro_derive] and + // > crate other than those functions tagged #[proc_macro_derive] and // > those functions must also be placed at the crate root. // // A plugin requires exporting plugin_registrar so a crate cannot be // both at once. - if self.plugin == Some(true) && self.rustc_macro == Some(true) { - Err(human("lib.plugin and lib.rustc-macro cannot both be true".to_string())) + if self.plugin == Some(true) && self.proc_macro == Some(true) { + Err(human("lib.plugin and lib.proc-macro cannot both be true".to_string())) } else { Ok(()) } @@ -1064,7 +1064,7 @@ fn normalize(lib: &Option, .set_doctest(toml.doctest.unwrap_or(t2.doctested())) .set_benched(toml.bench.unwrap_or(t2.benched())) .set_harness(toml.harness.unwrap_or(t2.harness())) - .set_for_host(match (toml.plugin, toml.rustc_macro) { + .set_for_host(match (toml.plugin, toml.proc_macro) { (None, None) => t2.for_host(), (Some(true), _) | (_, Some(true)) => true, (Some(false), _) | (_, Some(false)) => false, @@ -1081,7 +1081,7 @@ fn normalize(lib: &Option, Some(kinds) => kinds.iter().map(|s| LibKind::from_str(s)).collect(), None => { vec![ if l.plugin == Some(true) {LibKind::Dylib} - else if l.rustc_macro == Some(true) {LibKind::RustcMacro} + else if l.proc_macro == Some(true) {LibKind::ProcMacro} else {LibKind::Lib} ] } }; diff --git a/src/doc/manifest.md b/src/doc/manifest.md index eb5331d54e2..9aaab670738 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -512,7 +512,7 @@ plugin = false # If the target is meant to be a "macros 1.1" procedural macro, this field must # be set to true. -rustc-macro = false +proc-macro = false # If set to false, `cargo test` will omit the `--test` flag to rustc, which # stops it from generating a test harness. This is useful when the binary being @@ -534,11 +534,11 @@ crate-type = ["dylib"] # could be `staticlib` as well ``` The available options are `dylib`, `rlib`, `staticlib`, `cdylib`, and -`rustc-macro`. You should only use this option in a project. Cargo will always +`proc-macro`. You should only use this option in a project. Cargo will always compile packages (dependencies) based on the requirements of the project that includes them. -You can read more about the different crate types in the +You can read more about the different crate types in the [Rust Reference Manual](https://doc.rust-lang.org/reference.html#linkage) # The `[replace]` Section diff --git a/tests/rustc-macro.rs b/tests/proc-macro.rs similarity index 83% rename from tests/rustc-macro.rs rename to tests/proc-macro.rs index f9ea79d2a17..daae388e0ce 100644 --- a/tests/rustc-macro.rs +++ b/tests/proc-macro.rs @@ -23,7 +23,7 @@ fn noop() { path = "../noop" "#) .file("src/main.rs", r#" - #![feature(rustc_macro)] + #![feature(proc_macro)] #[macro_use] extern crate noop; @@ -41,15 +41,15 @@ fn noop() { authors = [] [lib] - rustc-macro = true + proc-macro = true "#) .file("src/lib.rs", r#" - #![feature(rustc_macro, rustc_macro_lib)] + #![feature(proc_macro, proc_macro_lib)] - extern crate rustc_macro; - use rustc_macro::TokenStream; + extern crate proc_macro; + use proc_macro::TokenStream; - #[rustc_macro_derive(Noop)] + #[proc_macro_derive(Noop)] pub fn noop(input: TokenStream) -> TokenStream { input } @@ -80,7 +80,7 @@ fn impl_and_derive() { path = "../transmogrify" "#) .file("src/main.rs", r#" - #![feature(rustc_macro)] + #![feature(proc_macro)] #[macro_use] extern crate transmogrify; @@ -106,15 +106,15 @@ fn impl_and_derive() { authors = [] [lib] - rustc-macro = true + proc-macro = true "#) .file("src/lib.rs", r#" - #![feature(rustc_macro, rustc_macro_lib)] + #![feature(proc_macro, proc_macro_lib)] - extern crate rustc_macro; - use rustc_macro::TokenStream; + extern crate proc_macro; + use proc_macro::TokenStream; - #[rustc_macro_derive(Transmogrify)] + #[proc_macro_derive(Transmogrify)] #[doc(hidden)] pub fn transmogrify(input: TokenStream) -> TokenStream { assert_eq!(input.to_string(), "struct X;\n"); @@ -149,7 +149,7 @@ fn impl_and_derive() { #[test] #[ignore] -fn plugin_and_rustc_macro() { +fn plugin_and_proc_macro() { if !is_nightly() { return; } @@ -163,28 +163,28 @@ fn plugin_and_rustc_macro() { [lib] plugin = true - rustc-macro = true + proc-macro = true "#) .file("src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] - #![feature(rustc_macro, rustc_macro_lib)] + #![feature(proc_macro, proc_macro_lib)] extern crate rustc_plugin; use rustc_plugin::Registry; - extern crate rustc_macro; - use rustc_macro::TokenStream; + extern crate proc_macro; + use proc_macro::TokenStream; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) {} - #[rustc_macro_derive(Questionable)] + #[proc_macro_derive(Questionable)] pub fn questionable(input: TokenStream) -> TokenStream { input } "#); - let msg = " lib.plugin and lib.rustc-macro cannot both be true"; + let msg = " lib.plugin and lib.proc-macro cannot both be true"; assert_that(questionable.cargo_process("build"), execs().with_status(101).with_stderr_contains(msg)); } From 37ac87b7edacd893155c6b73ba700f16722388d9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 7 Oct 2016 15:01:38 +0300 Subject: [PATCH 0758/3888] Remove ExecEngine abstraction --- src/bin/bench.rs | 1 - src/bin/build.rs | 1 - src/bin/doc.rs | 1 - src/bin/install.rs | 1 - src/bin/run.rs | 1 - src/bin/rustc.rs | 1 - src/bin/rustdoc.rs | 1 - src/bin/test.rs | 1 - src/cargo/ops/cargo_compile.rs | 8 ++----- src/cargo/ops/cargo_package.rs | 1 - .../ops/cargo_rustc/{engine.rs => command.rs} | 24 +------------------ src/cargo/ops/cargo_rustc/context.rs | 6 ----- src/cargo/ops/cargo_rustc/job_queue.rs | 2 +- src/cargo/ops/cargo_rustc/mod.rs | 10 ++++---- src/cargo/ops/cargo_test.rs | 6 ++--- src/cargo/ops/mod.rs | 2 +- 16 files changed, 12 insertions(+), 55 deletions(-) rename src/cargo/ops/cargo_rustc/{engine.rs => command.rs} (75%) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index d9abefe40b8..d5bc21dd46e 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -89,7 +89,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, - exec_engine: None, release: true, mode: ops::CompileMode::Bench, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/build.rs b/src/bin/build.rs index 0357fe08096..eb6673c2f9a 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -85,7 +85,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, - exec_engine: None, mode: ops::CompileMode::Build, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/doc.rs b/src/bin/doc.rs index c1841c20a54..c250dde227c 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -81,7 +81,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, - exec_engine: None, filter: ops::CompileFilter::new(options.flag_lib, &options.flag_bin, &empty, diff --git a/src/bin/install.rs b/src/bin/install.rs index b5d67fd411f..319b9bdf6f4 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -109,7 +109,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &[], - exec_engine: None, mode: ops::CompileMode::Build, release: !options.flag_debug, filter: ops::CompileFilter::new(false, &options.flag_bin, &[], diff --git a/src/bin/run.rs b/src/bin/run.rs index f5055b5eba0..f9ce057319c 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -82,7 +82,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &[], - exec_engine: None, release: options.flag_release, mode: ops::CompileMode::Build, filter: if examples.is_empty() && bins.is_empty() { diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index fa9334f5b29..83103198496 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -103,7 +103,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]), - exec_engine: None, mode: mode, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index 587046200df..df3e4886ba1 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -90,7 +90,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]), - exec_engine: None, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, &options.flag_bin, diff --git a/src/bin/test.rs b/src/bin/test.rs index 410c0a2c4d5..ed487aa4226 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -123,7 +123,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, spec: &options.flag_package, - exec_engine: None, release: options.flag_release, mode: mode, filter: filter, diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 0767e9e467a..7b6cb1b71a9 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -24,13 +24,12 @@ use std::collections::HashMap; use std::path::PathBuf; -use std::sync::Arc; use core::registry::PackageRegistry; use core::{Source, SourceId, PackageSet, Package, Target}; use core::{Profile, TargetKind, Profiles, Workspace, PackageIdSpec}; use core::resolver::{Method, Resolve}; -use ops::{self, BuildOutput, ExecEngine}; +use ops::{self, BuildOutput}; use sources::PathSource; use util::config::Config; use util::{CargoResult, profile, human, ChainError}; @@ -53,8 +52,6 @@ pub struct CompileOptions<'a> { /// Filter to apply to the root package to select which targets will be /// built. pub filter: CompileFilter<'a>, - /// Engine which drives compilation - pub exec_engine: Option>>, /// Whether this is a release build or not pub release: bool, /// Mode for this compile. @@ -159,7 +156,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let CompileOptions { config, jobs, target, spec, features, all_features, no_default_features, release, mode, message_format, - ref filter, ref exec_engine, + ref filter, ref target_rustdoc_args, ref target_rustc_args } = *options; @@ -247,7 +244,6 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let mut ret = { let _p = profile::start("compiling"); let mut build_config = try!(scrape_build_config(config, jobs, target)); - build_config.exec_engine = exec_engine.clone(); build_config.release = release; build_config.test = mode == CompileMode::Test; build_config.json_errors = message_format == MessageFormat::Json; diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 2001c6c8711..55f8dd64fc9 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -293,7 +293,6 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> all_features: false, spec: &[], filter: ops::CompileFilter::Everything, - exec_engine: None, release: false, message_format: ops::MessageFormat::Human, mode: ops::CompileMode::Build, diff --git a/src/cargo/ops/cargo_rustc/engine.rs b/src/cargo/ops/cargo_rustc/command.rs similarity index 75% rename from src/cargo/ops/cargo_rustc/engine.rs rename to src/cargo/ops/cargo_rustc/command.rs index ec892392c9e..d49951c8a12 100644 --- a/src/cargo/ops/cargo_rustc/engine.rs +++ b/src/cargo/ops/cargo_rustc/command.rs @@ -2,32 +2,10 @@ use std::collections::HashMap; use std::ffi::{OsStr, OsString}; use std::fmt; use std::path::Path; -use std::process::Output; -use util::{CargoResult, ProcessError, ProcessBuilder, process}; +use util::{CargoResult, ProcessBuilder, process}; use util::Config; -/// Trait for objects that can execute commands. -pub trait ExecEngine: Send + Sync { - fn exec(&self, CommandPrototype) -> Result<(), ProcessError>; - fn exec_with_output(&self, CommandPrototype) -> Result; -} - -/// Default implementation of `ExecEngine`. -#[derive(Clone, Copy)] -pub struct ProcessEngine; - -impl ExecEngine for ProcessEngine { - fn exec(&self, command: CommandPrototype) -> Result<(), ProcessError> { - command.into_process_builder().exec() - } - - fn exec_with_output(&self, command: CommandPrototype) - -> Result { - command.into_process_builder().exec_with_output() - } -} - /// Prototype for a command that must be executed. #[derive(Clone)] pub struct CommandPrototype { diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 7cbd2149fe4..e7f57fe57d2 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -16,7 +16,6 @@ use super::fingerprint::Fingerprint; use super::layout::{Layout, LayoutProxy}; use super::links::Links; use super::{Kind, Compilation, BuildConfig}; -use super::{ProcessEngine, ExecEngine}; #[derive(Clone, Copy, Eq, PartialEq, Hash)] pub struct Unit<'a> { @@ -34,7 +33,6 @@ pub struct Context<'a, 'cfg: 'a> { pub packages: &'a PackageSet<'cfg>, pub build_state: Arc, pub build_explicit_deps: HashMap, (PathBuf, Vec)>, - pub exec_engine: Arc>, pub fingerprints: HashMap, Arc>, pub compiled: HashSet>, pub build_config: BuildConfig, @@ -72,9 +70,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { None => None, }; - let engine = build_config.exec_engine.as_ref().cloned().unwrap_or({ - Arc::new(Box::new(ProcessEngine)) - }); let current_package = try!(ws.current()).package_id().clone(); Ok(Context { host: host_layout, @@ -88,7 +83,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { compilation: Compilation::new(config), build_state: Arc::new(BuildState::new(&build_config)), build_config: build_config, - exec_engine: engine, fingerprints: HashMap::new(), profiles: profiles, compiled: HashSet::new(), diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 53bad6b786c..d02d841b828 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -13,7 +13,7 @@ use util::{CargoResult, profile, internal}; use super::{Context, Kind, Unit}; use super::job::Job; -use super::engine::CommandPrototype; +use super::command::CommandPrototype; /// A management structure of the entire dependency graph to compile. /// diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 280b6c05df5..1efcc2b0c1d 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -18,14 +18,14 @@ use self::job_queue::JobQueue; pub use self::compilation::Compilation; pub use self::context::{Context, Unit}; -pub use self::engine::{CommandPrototype, CommandType, ExecEngine, ProcessEngine}; +pub use self::command::{CommandPrototype, CommandType}; pub use self::layout::{Layout, LayoutProxy}; pub use self::custom_build::{BuildOutput, BuildMap, BuildScripts}; -mod context; +mod command; mod compilation; +mod context; mod custom_build; -mod engine; mod fingerprint; mod job; mod job_queue; @@ -42,7 +42,6 @@ pub struct BuildConfig { pub requested_target: Option, pub target: TargetConfig, pub jobs: u32, - pub exec_engine: Option>>, pub release: bool, pub test: bool, pub doc_all: bool, @@ -467,7 +466,6 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { let name = unit.pkg.name().to_string(); let build_state = cx.build_state.clone(); let key = (unit.pkg.package_id().clone(), unit.kind); - let exec_engine = cx.exec_engine.clone(); Ok(Work::new(move |state| { if let Some(output) = build_state.outputs.lock().unwrap().get(&key) { @@ -476,7 +474,7 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { } } state.running(&rustdoc); - exec_engine.exec(rustdoc).chain_error(|| { + rustdoc.into_process_builder().exec().chain_error(|| { human(format!("Could not document `{}`.", name)) }) })) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index e8f155a345b..d73ec8103fa 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -1,6 +1,6 @@ use std::ffi::{OsString, OsStr}; -use ops::{self, ExecEngine, ProcessEngine, Compilation}; +use ops::{self, Compilation}; use util::{self, CargoResult, CargoTestError, ProcessError}; use core::Workspace; @@ -98,7 +98,7 @@ fn run_unit_tests(options: &TestOptions, shell.status("Running", cmd.to_string()) })); - if let Err(e) = ExecEngine::exec(&ProcessEngine, cmd) { + if let Err(e) = cmd.into_process_builder().exec() { errors.push(e); if !options.no_fail_fast { break @@ -175,7 +175,7 @@ fn run_doc_tests(options: &TestOptions, try!(config.shell().verbose(|shell| { shell.status("Running", p.to_string()) })); - if let Err(e) = ExecEngine::exec(&ProcessEngine, p) { + if let Err(e) = p.into_process_builder().exec() { errors.push(e); if !options.no_fail_fast { return Ok(errors); diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 442d8c5a8ae..4d646ea3058 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -5,7 +5,7 @@ pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages}; pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind, Unit}; pub use self::cargo_rustc::{Context, LayoutProxy}; pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig}; -pub use self::cargo_rustc::{CommandType, CommandPrototype, ExecEngine, ProcessEngine}; +pub use self::cargo_rustc::{CommandType, CommandPrototype}; pub use self::cargo_run::run; pub use self::cargo_install::{install, install_list, uninstall}; pub use self::cargo_new::{new, init, NewOptions, VersionControl}; From 806f9f882461e22bdf21099cc27b24ee81ce8b80 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 6 Oct 2016 09:48:12 -0700 Subject: [PATCH 0759/3888] Fix Travis OSX They recently changed images, gotta tweak how we work with OpenSSL --- .travis.yml | 10 +++++++--- tests/cargotest/lib.rs | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2aef32ba66c..731d1a5f272 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,9 +27,13 @@ env: - CARGOFLAGS=-j1 - secure: scGpeetUfba5RWyuS4yt10bPoFAI9wpHEReIFqEx7eH5vr2Anajk6+70jW6GdrWVdUvdINiArlQ3An2DeB9vEUWcBjw8WvuPtOH0tDMoSsuVloPlFD8yn1Ac0Bx9getAO5ofxqtoNg+OV4MDVuGabEesqAOWqURNrBC7XK+ntC8= -os: - - linux - - osx +matrix: + include: + - os: osx + rust: stable + before_install: + - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include + - export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib branches: only: diff --git a/tests/cargotest/lib.rs b/tests/cargotest/lib.rs index ffd094f9759..cc5b17cf01c 100644 --- a/tests/cargotest/lib.rs +++ b/tests/cargotest/lib.rs @@ -22,6 +22,7 @@ use cargo::util::Rustc; use std::ffi::OsStr; use std::time::Duration; use std::path::PathBuf; +use std::env; pub mod support; pub mod install; @@ -40,7 +41,11 @@ pub fn is_nightly() -> bool { } pub fn process>(t: T) -> cargo::util::ProcessBuilder { - let mut p = cargo::util::process(t.as_ref()); + _process(t.as_ref()) +} + +fn _process(t: &OsStr) -> cargo::util::ProcessBuilder { + let mut p = cargo::util::process(t); p.cwd(&support::paths::root()) .env_remove("CARGO_HOME") .env("HOME", support::paths::home()) @@ -51,6 +56,35 @@ pub fn process>(t: T) -> cargo::util::ProcessBuilder { .env("GIT_CONFIG_NOSYSTEM", "1") // keep trying to sandbox ourselves .env_remove("CARGO_TARGET_DIR") // we assume 'target' .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows + + // We'll need dynamic libraries at some point in this test suite, so ensure + // that the rustc libdir is somewhere in LD_LIBRARY_PATH as appropriate. + // Note that this isn't needed on Windows as we assume the bindir (with + // dlls) is in PATH. + if cfg!(unix) { + let var = if cfg!(target_os = "macos") { + "DYLD_LIBRARY_PATH" + } else { + "LD_LIBRARY_PATH" + }; + let rustc = RUSTC.with(|r| r.path.clone()); + let path = env::var_os("PATH").unwrap_or(Default::default()); + let rustc = env::split_paths(&path) + .map(|p| p.join(&rustc)) + .find(|p| p.exists()) + .unwrap(); + let mut libdir = rustc.clone(); + libdir.pop(); + libdir.pop(); + libdir.push("lib"); + let prev = env::var_os(&var).unwrap_or(Default::default()); + let mut paths = env::split_paths(&prev).collect::>(); + println!("libdir: {:?}", libdir); + if !paths.contains(&libdir) { + paths.push(libdir); + p.env(var, env::join_paths(&paths).unwrap()); + } + } return p } From 788ba7b1fc3635967987d23962efa9912b91b3b5 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 3 Oct 2016 14:41:02 -0400 Subject: [PATCH 0760/3888] upgrade semver --- Cargo.lock | 24 ++++++++++++++---------- Cargo.toml | 2 +- src/cargo/core/dependency.rs | 19 ++++++++++++++++++- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c348bfa691..7a43b2b6208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.4.1 (git+https://github.com/steveklabnik/semver?branch=deprecation)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -359,11 +359,6 @@ dependencies = [ "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nom" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "num" version = "0.1.34" @@ -527,10 +522,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "semver" -version = "0.2.3" +version = "0.4.1" +source = "git+https://github.com/steveklabnik/semver?branch=deprecation#a3b67d654d7e00ea0a05a37851f49352d79834a3" +dependencies = [ + "semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -680,7 +684,6 @@ dependencies = [ "checksum miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d1f4d337a01c32e1f2122510fed46393d53ca35a7f429cb0450abaedfa3ed54" "checksum miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5bfc6782530ac8ace97af10a540054a37126b63b0702ddaaa243b73b5745b9a" "checksum net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "5edf9cb6be97212423aed9413dd4729d62b370b5e1c571750e882cebbbc1e3e2" -"checksum nom 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce" "checksum num 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "d2ee34a0338c16ae67afb55824aaf8852700eb0f77ccd977807ccb7606b295f6" "checksum num-bigint 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc450723a2fe91d332a29edd8660e099b937d29e1a3ebe914e0da3f77ac1ad3" "checksum num-complex 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "8aabbc079e1855ce8415141fee0ebebf171f56505373b3a966e2716ad7c0e555" @@ -699,7 +702,8 @@ dependencies = [ "checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2" "checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199" "checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" -"checksum semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2d5b7638a1f03815d94e88cb3b3c08e87f0db4d683ef499d1836aaf70a45623f" +"checksum semver 0.4.1 (git+https://github.com/steveklabnik/semver?branch=deprecation)" = "" +"checksum semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e88e43a5a74dd2a11707f9c21dfd4a423c66bd871df813227bb0a3e78f3a1ae9" "checksum strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4d73a2c36a4d095ed1a6df5cbeac159863173447f7a82b3f4757426844ab825" "checksum tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "12e1b959f637c2e4c69dbdbf4d7dc609edbaada9b8c35d0c2fc9802d02383b65" "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" diff --git a/Cargo.toml b/Cargo.toml index 083a8654efb..563c865278d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ num_cpus = "1.0" psapi-sys = "0.1" regex = "0.1" rustc-serialize = "0.3" -semver = "0.2.3" +semver = { git = "https://github.com/steveklabnik/semver", branch = "deprecation" } tar = { version = "0.4", default-features = false } tempdir = "0.3" term = "0.4.4" diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index 48f4bd456d9..be8ff5d903f 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -3,6 +3,7 @@ use std::rc::Rc; use std::str::FromStr; use semver::VersionReq; +use semver::ReqParseError; use rustc_serialize::{Encoder, Encodable}; use core::{SourceId, Summary, PackageId}; @@ -91,7 +92,7 @@ impl DependencyInner { version: Option<&str>, source_id: &SourceId) -> CargoResult { let (specified_req, version_req) = match version { - Some(v) => (true, try!(VersionReq::parse(v))), + Some(v) => (true, try!(DependencyInner::parse_with_deprecated(v))), None => (false, VersionReq::any()) }; @@ -103,6 +104,22 @@ impl DependencyInner { }) } + fn parse_with_deprecated(req: &str) -> Result { + match VersionReq::parse(req) { + Err(e) => { + match e { + ReqParseError::DeprecatedVersionRequirement(requirement) => { + // warn here + + Ok(requirement) + } + e => Err(e), + } + }, + Ok(v) => Ok(v), + } + } + pub fn new_override(name: &str, source_id: &SourceId) -> DependencyInner { DependencyInner { name: name.to_string(), From 38c919dd32d3ac557286eaa0e6b497689a8129d6 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 3 Oct 2016 16:40:57 -0400 Subject: [PATCH 0761/3888] thread a config throughout --- src/cargo/core/dependency.rs | 10 +++--- src/cargo/core/package.rs | 4 +-- src/cargo/core/registry.rs | 16 +++++----- src/cargo/core/resolver/mod.rs | 39 +++++++++++++---------- src/cargo/core/source.rs | 6 ++-- src/cargo/ops/cargo_clean.rs | 4 +-- src/cargo/ops/cargo_compile.rs | 6 ++-- src/cargo/ops/cargo_fetch.rs | 4 +-- src/cargo/ops/cargo_generate_lockfile.rs | 5 +-- src/cargo/ops/cargo_install.rs | 13 ++++---- src/cargo/ops/cargo_output_metadata.rs | 2 +- src/cargo/ops/cargo_rustc/context.rs | 29 +++++++++-------- src/cargo/ops/cargo_rustc/custom_build.rs | 2 +- src/cargo/ops/cargo_rustc/fingerprint.rs | 2 +- src/cargo/ops/cargo_rustc/job_queue.rs | 4 +-- src/cargo/ops/cargo_rustc/mod.rs | 6 ++-- src/cargo/ops/resolve.rs | 11 ++++--- src/cargo/sources/directory.rs | 4 +-- src/cargo/sources/git/source.rs | 8 ++--- src/cargo/sources/path.rs | 6 ++-- src/cargo/sources/registry/index.rs | 26 +++++++-------- src/cargo/sources/registry/mod.rs | 12 +++---- src/cargo/sources/replaced.rs | 10 +++--- src/cargo/util/toml.rs | 2 +- tests/resolve.rs | 15 ++++++--- 25 files changed, 133 insertions(+), 113 deletions(-) diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index be8ff5d903f..61167a8b4f5 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -7,7 +7,7 @@ use semver::ReqParseError; use rustc_serialize::{Encoder, Encodable}; use core::{SourceId, Summary, PackageId}; -use util::{CargoError, CargoResult, Cfg, CfgExpr, ChainError, human}; +use util::{CargoError, CargoResult, Cfg, CfgExpr, ChainError, human, Config}; /// Information about a dependency requested by a Cargo manifest. /// Cheap to copy. @@ -90,7 +90,8 @@ impl DependencyInner { /// Attempt to create a `Dependency` from an entry in the manifest. pub fn parse(name: &str, version: Option<&str>, - source_id: &SourceId) -> CargoResult { + source_id: &SourceId, + _config: &Config) -> CargoResult { let (specified_req, version_req) = match version { Some(v) => (true, try!(DependencyInner::parse_with_deprecated(v))), None => (false, VersionReq::any()) @@ -233,8 +234,9 @@ impl Dependency { /// Attempt to create a `Dependency` from an entry in the manifest. pub fn parse(name: &str, version: Option<&str>, - source_id: &SourceId) -> CargoResult { - DependencyInner::parse(name, version, source_id).map(|di| { + source_id: &SourceId, + config: &Config) -> CargoResult { + DependencyInner::parse(name, version, source_id, config).map(|di| { di.into_dependency() }) } diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index da14b04fc33..0235b619285 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -156,7 +156,7 @@ impl<'cfg> PackageSet<'cfg> { Box::new(self.packages.iter().map(|&(ref p, _)| p)) } - pub fn get(&self, id: &PackageId) -> CargoResult<&Package> { + pub fn get(&self, id: &PackageId, config: &Config) -> CargoResult<&Package> { let slot = try!(self.packages.iter().find(|p| p.0 == *id).chain_error(|| { internal(format!("couldn't find `{}` in package set", id)) })); @@ -168,7 +168,7 @@ impl<'cfg> PackageSet<'cfg> { let source = try!(sources.get_mut(id.source_id()).chain_error(|| { internal(format!("couldn't find source for `{}`", id)) })); - let pkg = try!(source.download(id).chain_error(|| { + let pkg = try!(source.download(id, config).chain_error(|| { human("unable to get packages from source") })); assert!(slot.fill(pkg).is_ok()); diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 79089ee4d7e..5aa11abfda7 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -10,7 +10,7 @@ use sources::config::SourceConfigMap; /// See also `core::Source`. pub trait Registry { /// Attempt to find the packages that match a dependency request. - fn query(&mut self, name: &Dependency) -> CargoResult>; + fn query(&mut self, name: &Dependency, config: &Config) -> CargoResult>; /// Returns whether or not this registry will return summaries with /// checksums listed. @@ -22,22 +22,22 @@ pub trait Registry { } impl Registry for Vec { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, _config: &Config) -> CargoResult> { Ok(self.iter().filter(|summary| dep.matches(*summary)) .cloned().collect()) } } impl Registry for Vec { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, _config: &Config) -> CargoResult> { Ok(self.iter().filter(|pkg| dep.matches(pkg.summary())) .map(|pkg| pkg.summary().clone()).collect()) } } impl<'a, T: ?Sized + Registry + 'a> Registry for Box { - fn query(&mut self, name: &Dependency) -> CargoResult> { - (**self).query(name) + fn query(&mut self, name: &Dependency, config: &Config) -> CargoResult> { + (**self).query(name, config) } } @@ -364,7 +364,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> { #[cfg(test)] pub mod test { use core::{Summary, Registry, Dependency}; - use util::{CargoResult}; + use util::{CargoResult, Config}; pub struct RegistryBuilder { summaries: Vec, @@ -405,13 +405,13 @@ pub mod test { } impl Registry for RegistryBuilder { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { debug!("querying; dep={:?}", dep); let overrides = self.query_overrides(dep); if overrides.is_empty() { - self.summaries.query(dep) + self.summaries.query(dep, config) } else { Ok(overrides) } diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 7a9e953365a..ed57a1a9b0b 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -55,7 +55,7 @@ use semver; use core::{PackageId, Registry, SourceId, Summary, Dependency}; use core::PackageIdSpec; -use util::{CargoResult, Graph, human, CargoError}; +use util::{CargoResult, Graph, human, CargoError, Config}; use util::profile; use util::ChainError; use util::graph::{Nodes, Edges}; @@ -265,7 +265,8 @@ struct Context<'a> { /// Builds the list of all packages required to build the first argument. pub fn resolve(summaries: &[(Summary, Method)], replacements: &[(PackageIdSpec, Dependency)], - registry: &mut Registry) -> CargoResult { + registry: &mut Registry, + config: &Config) -> CargoResult { let cx = Context { resolve_graph: Graph::new(), resolve_features: HashMap::new(), @@ -274,7 +275,7 @@ pub fn resolve(summaries: &[(Summary, Method)], replacements: replacements, }; let _p = profile::start(format!("resolving")); - let cx = try!(activate_deps_loop(cx, registry, summaries)); + let cx = try!(activate_deps_loop(cx, registry, summaries, config)); let mut resolve = Resolve { graph: cx.resolve_graph, @@ -305,7 +306,8 @@ fn activate(cx: &mut Context, registry: &mut Registry, parent: Option<&Rc>, candidate: Candidate, - method: &Method) + method: &Method, + config: &Config) -> CargoResult> { if let Some(parent) = parent { cx.resolve_graph.link(parent.package_id().clone(), @@ -333,7 +335,7 @@ fn activate(cx: &mut Context, } }; - let deps = try!(cx.build_deps(registry, &candidate, method)); + let deps = try!(cx.build_deps(registry, &candidate, method, config)); Ok(Some(DepsFrame { parent: candidate, @@ -435,7 +437,8 @@ struct BacktrackFrame<'a> { /// dependency graph, cx.resolve is returned. fn activate_deps_loop<'a>(mut cx: Context<'a>, registry: &mut Registry, - summaries: &[(Summary, Method)]) + summaries: &[(Summary, Method)], + config: &Config) -> CargoResult> { // Note that a `BinaryHeap` is used for the remaining dependencies that need // activation. This heap is sorted such that the "largest value" is the most @@ -451,7 +454,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, let summary = Rc::new(summary.clone()); let candidate = Candidate { summary: summary, replace: None }; remaining_deps.extend(try!(activate(&mut cx, registry, None, candidate, - method))); + method, config))); } // Main resolution loop, this is the workhorse of the resolution algorithm. @@ -545,7 +548,8 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, None => return Err(activation_error(&cx, registry, &parent, &dep, &cx.prev_active(&dep), - &candidates)), + &candidates, + config)), Some(candidate) => candidate, } } @@ -559,7 +563,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, trace!("{}[{}]>{} trying {}", parent.name(), cur, dep.name(), candidate.summary.version()); remaining_deps.extend(try!(activate(&mut cx, registry, Some(&parent), - candidate, &method))); + candidate, &method, config))); } Ok(cx) @@ -595,7 +599,8 @@ fn activation_error(cx: &Context, parent: &Summary, dep: &Dependency, prev_active: &[Rc], - candidates: &[Candidate]) -> Box { + candidates: &[Candidate], + config: &Config) -> Box { if candidates.len() > 0 { let mut msg = format!("failed to select a version for `{}` \ (required by `{}`):\n\ @@ -648,7 +653,7 @@ fn activation_error(cx: &Context, let mut msg = msg; let all_req = semver::VersionReq::parse("*").unwrap(); let new_dep = dep.clone_inner().set_version_req(all_req).into_dependency(); - let mut candidates = match registry.query(&new_dep) { + let mut candidates = match registry.query(&new_dep, config) { Ok(candidates) => candidates, Err(e) => return e, }; @@ -816,7 +821,8 @@ impl<'a> Context<'a> { fn build_deps(&mut self, registry: &mut Registry, candidate: &Summary, - method: &Method) -> CargoResult> { + method: &Method, + config: &Config) -> CargoResult> { // First, figure out our set of dependencies based on the requsted set // of features. This also calculates what features we're going to enable // for our own dependencies. @@ -825,7 +831,7 @@ impl<'a> Context<'a> { // Next, transform all dependencies into a list of possible candidates // which can satisfy that dependency. let mut deps = try!(deps.into_iter().map(|(dep, features)| { - let mut candidates = try!(self.query(registry, &dep)); + let mut candidates = try!(self.query(registry, &dep, config)); // When we attempt versions for a package, we'll want to start at // the maximum version and work our way down. candidates.sort_by(|a, b| { @@ -851,8 +857,9 @@ impl<'a> Context<'a> { /// return. fn query(&self, registry: &mut Registry, - dep: &Dependency) -> CargoResult> { - let summaries = try!(registry.query(dep)); + dep: &Dependency, + config: &Config) -> CargoResult> { + let summaries = try!(registry.query(dep, config)); summaries.into_iter().map(Rc::new).map(|summary| { // get around lack of non-lexical lifetimes let summary2 = summary.clone(); @@ -865,7 +872,7 @@ impl<'a> Context<'a> { Some(replacement) => replacement, }; - let mut summaries = try!(registry.query(dep)).into_iter(); + let mut summaries = try!(registry.query(dep, config)).into_iter(); let s = try!(summaries.next().chain_error(|| { human(format!("no matching package for override `{}` found\n\ location searched: {}\n\ diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 4a46c19294d..b09d57ef93e 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -27,7 +27,7 @@ pub trait Source: Registry { /// The download method fetches the full package for each name and /// version specified. - fn download(&mut self, package: &PackageId) -> CargoResult; + fn download(&mut self, package: &PackageId, config: &Config) -> CargoResult; /// Generates a unique string which represents the fingerprint of the /// current state of the source. @@ -57,8 +57,8 @@ impl<'a, T: Source + ?Sized + 'a> Source for Box { (**self).update() } - fn download(&mut self, id: &PackageId) -> CargoResult { - (**self).download(id) + fn download(&mut self, id: &PackageId, config: &Config) -> CargoResult { + (**self).download(id, config) } fn fingerprint(&self, pkg: &Package) -> CargoResult { diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index e19b37f116f..6c50a90dc6b 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -29,7 +29,7 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { } let mut registry = try!(PackageRegistry::new(opts.config)); - let resolve = try!(ops::resolve_ws(&mut registry, ws)); + let resolve = try!(ops::resolve_ws(&mut registry, ws, opts.config)); let packages = ops::get_resolved_packages(&resolve, registry); let profiles = try!(ws.current()).manifest().profiles(); @@ -47,7 +47,7 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { for spec in opts.spec { // Translate the spec to a Package let pkgid = try!(resolve.query(spec)); - let pkg = try!(packages.get(&pkgid)); + let pkg = try!(packages.get(&pkgid, ws.config())); // Generate all relevant `Unit` targets for this package for target in pkg.targets() { diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 0767e9e467a..c8b50cd93b9 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -118,7 +118,7 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, // First, resolve the root_package's *listed* dependencies, as well as // downloading and updating all remotes and such. - let resolve = try!(ops::resolve_ws(&mut registry, ws)); + let resolve = try!(ops::resolve_ws(&mut registry, ws, ws.config())); // Second, resolve with precisely what we're doing. Filter out // transitive dependencies if necessary, specify features, handle @@ -143,7 +143,7 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, let resolved_with_overrides = try!(ops::resolve_with_previous(&mut registry, ws, method, Some(&resolve), None, - &specs)); + &specs, ws.config())); let packages = ops::get_resolved_packages(&resolved_with_overrides, registry); @@ -190,7 +190,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, }; let to_builds = try!(pkgids.iter().map(|id| { - packages.get(id) + packages.get(id, config) }).collect::>>()); let mut general_targets = Vec::new(); diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index a0144c8f472..77634b9c83f 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -6,10 +6,10 @@ use util::CargoResult; /// Executes `cargo fetch`. pub fn fetch<'a>(ws: &Workspace<'a>) -> CargoResult<(Resolve, PackageSet<'a>)> { let mut registry = try!(PackageRegistry::new(ws.config())); - let resolve = try!(ops::resolve_ws(&mut registry, ws)); + let resolve = try!(ops::resolve_ws(&mut registry, ws, ws.config())); let packages = get_resolved_packages(&resolve, registry); for id in resolve.iter() { - try!(packages.get(id)); + try!(packages.get(id, ws.config())); } Ok((resolve, packages)) } diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 25e2204ba9e..7758cc63c4d 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -19,7 +19,7 @@ pub fn generate_lockfile(ws: &Workspace) -> CargoResult<()> { let mut registry = try!(PackageRegistry::new(ws.config())); let resolve = try!(ops::resolve_with_previous(&mut registry, ws, Method::Everything, - None, None, &[])); + None, None, &[], ws.config())); try!(ops::write_pkg_lockfile(ws, &resolve)); Ok(()) } @@ -79,7 +79,8 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) Method::Everything, Some(&previous_resolve), Some(&to_avoid), - &[])); + &[], + ws.config())); // Summarize what is changing for the user. let print_change = |status: &str, msg: String| { diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 616c7b35186..91d44a4d4ff 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -57,7 +57,7 @@ pub fn install(root: Option<&str>, let map = try!(SourceConfigMap::new(config)); let (pkg, source) = if source_id.is_git() { try!(select_pkg(GitSource::new(source_id, config), source_id, - krate, vers, &mut |git| git.read_packages())) + krate, vers, config, &mut |git| git.read_packages())) } else if source_id.is_path() { let path = source_id.url().to_file_path().ok() .expect("path sources must have a valid path"); @@ -68,11 +68,11 @@ pub fn install(root: Option<&str>, specify an alternate source", path.display())) })); try!(select_pkg(PathSource::new(&path, source_id, config), - source_id, krate, vers, + source_id, krate, vers, config, &mut |path| path.read_packages())) } else { try!(select_pkg(try!(map.load(source_id)), - source_id, krate, vers, + source_id, krate, vers, config, &mut |_| Err(human("must specify a crate to install from \ crates.io, or use --path or --git to \ specify alternate source")))) @@ -251,6 +251,7 @@ fn select_pkg<'a, T>(mut source: T, source_id: &SourceId, name: Option<&str>, vers: Option<&str>, + config: &Config, list_all: &mut FnMut(&mut T) -> CargoResult>) -> CargoResult<(Package, Box)> where T: Source + 'a @@ -258,11 +259,11 @@ fn select_pkg<'a, T>(mut source: T, try!(source.update()); match name { Some(name) => { - let dep = try!(Dependency::parse(name, vers, source_id)); - let deps = try!(source.query(&dep)); + let dep = try!(Dependency::parse(name, vers, source_id, config)); + let deps = try!(source.query(&dep, config)); match deps.iter().map(|p| p.package_id()).max() { Some(pkgid) => { - let pkg = try!(source.download(pkgid)); + let pkg = try!(source.download(pkgid, config)); Ok((pkg, Box::new(source))) } None => { diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 131b93825db..488fa9853a1 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -52,7 +52,7 @@ fn metadata_full(ws: &Workspace, let (packages, resolve) = deps; let packages = try!(packages.package_ids() - .map(|i| packages.get(i).map(|p| p.clone())) + .map(|i| packages.get(i, ws.config()).map(|p| p.clone())) .collect()); Ok(ExportInfo { diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 7cbd2149fe4..5ff2a6c8fee 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -156,7 +156,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } })); } - for dep in try!(self.dep_targets(&unit)) { + for dep in try!(self.dep_targets(&unit, self.config)) { try!(self.visit_crate_type(&dep, crate_types)); } Ok(()) @@ -251,7 +251,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { for unit in units { try!(self.walk_used_in_plugin_map(unit, unit.target.for_host(), - &mut visited)); + &mut visited, + self.config)); } Ok(()) } @@ -259,7 +260,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { fn walk_used_in_plugin_map(&mut self, unit: &Unit<'a>, is_plugin: bool, - visited: &mut HashSet<(Unit<'a>, bool)>) + visited: &mut HashSet<(Unit<'a>, bool)>, + config: &Config) -> CargoResult<()> { if !visited.insert((*unit, is_plugin)) { return Ok(()) @@ -267,10 +269,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { if is_plugin { self.used_in_plugin.insert(*unit); } - for unit in try!(self.dep_targets(unit)) { + for unit in try!(self.dep_targets(unit, config)) { try!(self.walk_used_in_plugin_map(&unit, is_plugin || unit.target.for_host(), - visited)); + visited, + config)); } Ok(()) } @@ -443,11 +446,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// For a package, return all targets which are registered as dependencies /// for that package. - pub fn dep_targets(&self, unit: &Unit<'a>) -> CargoResult>> { + pub fn dep_targets(&self, unit: &Unit<'a>, config: &Config) -> CargoResult>> { if unit.profile.run_custom_build { return self.dep_run_custom_build(unit) } else if unit.profile.doc { - return self.doc_deps(unit); + return self.doc_deps(unit, config); } let id = unit.pkg.package_id(); @@ -490,7 +493,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { true }) }).filter_map(|id| { - match self.get_package(id) { + match self.get_package(id, config) { Ok(pkg) => { pkg.targets().iter().find(|t| t.is_lib()).map(|t| { Ok(Unit { @@ -564,7 +567,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { profile: &self.profiles.dev, ..*unit }; - let deps = try!(self.dep_targets(&tmp)); + let deps = try!(self.dep_targets(&tmp, self.config)); Ok(deps.iter().filter_map(|unit| { if !unit.target.linkable() || unit.pkg.manifest().links().is_none() { return None @@ -578,7 +581,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Returns the dependencies necessary to document a package - fn doc_deps(&self, unit: &Unit<'a>) -> CargoResult>> { + fn doc_deps(&self, unit: &Unit<'a>, config: &Config) -> CargoResult>> { let deps = self.resolve.deps(unit.pkg.package_id()).filter(|dep| { unit.pkg.dependencies().iter().filter(|d| { d.name() == dep.name() @@ -590,7 +593,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } }) }).map(|dep| { - self.get_package(dep) + self.get_package(dep, config) }); // To document a library, we depend on dependencies actually being @@ -673,8 +676,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Gets a package for the given package id. - pub fn get_package(&self, id: &PackageId) -> CargoResult<&'a Package> { - self.packages.get(id) + pub fn get_package(&self, id: &PackageId, config: &Config) -> CargoResult<&'a Package> { + self.packages.get(id, config) } /// Get the user-specified linker for a particular host or target diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 5a15e85a853..c78d067d618 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -413,7 +413,7 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, if !unit.target.is_custom_build() && unit.pkg.has_custom_build() { add_to_link(&mut ret, unit.pkg.package_id(), unit.kind); } - for unit in try!(cx.dep_targets(unit)).iter() { + for unit in try!(cx.dep_targets(unit, cx.config)).iter() { let dep_scripts = try!(build(out, cx, unit)); if unit.target.for_host() { diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 702deb5f863..a24d7ad2b6d 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -345,7 +345,7 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // elsewhere. Also skip fingerprints of binaries because they don't actually // induce a recompile, they're just dependencies in the sense that they need // to be built. - let deps = try!(cx.dep_targets(unit)); + let deps = try!(cx.dep_targets(unit, cx.config)); let deps = try!(deps.iter().filter(|u| { !u.target.is_custom_build() && !u.target.is_bin() }).map(|unit| { diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 53bad6b786c..db359a7345a 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -323,12 +323,12 @@ impl<'a> Key<'a> { fn dependencies<'cfg>(&self, cx: &Context<'a, 'cfg>) -> CargoResult>> { let unit = Unit { - pkg: try!(cx.get_package(self.pkg)), + pkg: try!(cx.get_package(self.pkg, cx.config)), target: self.target, profile: self.profile, kind: self.kind, }; - let targets = try!(cx.dep_targets(&unit)); + let targets = try!(cx.dep_targets(&unit, cx.config)); Ok(targets.iter().filter_map(|unit| { // Binaries aren't actually needed to *compile* tests, just to run // them, so we don't include this dependency edge in the job graph. diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 280b6c05df5..660f517ca8f 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -130,7 +130,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, if !unit.target.is_lib() { continue } // Include immediate lib deps as well - for unit in try!(cx.dep_targets(unit)).iter() { + for unit in try!(cx.dep_targets(unit, cx.config)).iter() { let pkgid = unit.pkg.package_id(); if !unit.target.is_lib() { continue } if unit.profile.doc { continue } @@ -197,7 +197,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, drop(p); // Be sure to compile all dependencies of this target as well. - for unit in try!(cx.dep_targets(unit)).iter() { + for unit in try!(cx.dep_targets(unit, cx.config)).iter() { try!(compile(cx, jobs, unit)); } Ok(()) @@ -652,7 +652,7 @@ fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) cmd.env("OUT_DIR", &layout.build_out(unit.pkg)); } - for unit in try!(cx.dep_targets(unit)).iter() { + for unit in try!(cx.dep_targets(unit, cx.config)).iter() { if unit.target.linkable() && !unit.profile.doc { try!(link_to(cmd, cx, unit)); } diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index af912b0dfba..5f4c1617acc 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -4,19 +4,19 @@ use core::{PackageId, PackageIdSpec, SourceId, Workspace}; use core::registry::PackageRegistry; use core::resolver::{self, Resolve, Method}; use ops; -use util::CargoResult; +use util::{CargoResult, Config}; /// Resolve all dependencies for the specified `package` using the previous /// lockfile as a guide if present. /// /// This function will also write the result of resolution as a new /// lockfile. -pub fn resolve_ws(registry: &mut PackageRegistry, ws: &Workspace) +pub fn resolve_ws(registry: &mut PackageRegistry, ws: &Workspace, config: &Config) -> CargoResult { let prev = try!(ops::load_pkg_lockfile(ws)); let resolve = try!(resolve_with_previous(registry, ws, Method::Everything, - prev.as_ref(), None, &[])); + prev.as_ref(), None, &[], config)); // Avoid writing a lockfile if we are `cargo install`ing a non local package. if ws.current_opt().map(|pkg| pkg.package_id().source_id().is_path()).unwrap_or(true) { @@ -39,7 +39,8 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, method: Method, previous: Option<&'a Resolve>, to_avoid: Option<&HashSet<&'a PackageId>>, - specs: &[PackageIdSpec]) + specs: &[PackageIdSpec], + config: &Config) -> CargoResult { // Here we place an artificial limitation that all non-registry sources // cannot be locked at more than one revision. This means that if a git @@ -127,7 +128,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, None => root_replace.to_vec(), }; - let mut resolved = try!(resolver::resolve(&summaries, &replace, registry)); + let mut resolved = try!(resolver::resolve(&summaries, &replace, registry, config)); if let Some(previous) = previous { try!(resolved.merge_from(previous)); } diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index 84a9501a03b..650a5092413 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -44,7 +44,7 @@ impl<'cfg> Debug for DirectorySource<'cfg> { } impl<'cfg> Registry for DirectorySource<'cfg> { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, _config: &Config) -> CargoResult> { let packages = self.packages.values().map(|p| &p.0); let matches = packages.filter(|pkg| dep.matches(pkg.summary())); let summaries = matches.map(|pkg| pkg.summary().clone()); @@ -98,7 +98,7 @@ impl<'cfg> Source for DirectorySource<'cfg> { Ok(()) } - fn download(&mut self, id: &PackageId) -> CargoResult { + fn download(&mut self, id: &PackageId, _config: &Config) -> CargoResult { self.packages.get(id).map(|p| &p.0).cloned().chain_error(|| { human(format!("failed to find package with id: {}", id)) }) diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index eeffcb05b72..87e424810a9 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -114,10 +114,10 @@ impl<'cfg> Debug for GitSource<'cfg> { } impl<'cfg> Registry for GitSource<'cfg> { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { let src = self.path_source.as_mut() .expect("BUG: update() must be called before query()"); - src.query(dep) + src.query(dep, config) } } @@ -175,12 +175,12 @@ impl<'cfg> Source for GitSource<'cfg> { self.path_source.as_mut().unwrap().update() } - fn download(&mut self, id: &PackageId) -> CargoResult { + fn download(&mut self, id: &PackageId, config: &Config) -> CargoResult { trace!("getting packages for package id `{}` from `{:?}`", id, self.remote); self.path_source.as_mut() .expect("BUG: update() must be called before get()") - .download(id) + .download(id, config) } fn fingerprint(&self, _pkg: &Package) -> CargoResult { diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 052d01c7dab..cee7f6cf3f1 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -310,8 +310,8 @@ impl<'cfg> Debug for PathSource<'cfg> { } impl<'cfg> Registry for PathSource<'cfg> { - fn query(&mut self, dep: &Dependency) -> CargoResult> { - self.packages.query(dep) + fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { + self.packages.query(dep, config) } } @@ -326,7 +326,7 @@ impl<'cfg> Source for PathSource<'cfg> { Ok(()) } - fn download(&mut self, id: &PackageId) -> CargoResult { + fn download(&mut self, id: &PackageId, _config: &Config) -> CargoResult { trace!("getting packages; id={}", id); let pkg = self.packages.iter().find(|pkg| pkg.package_id() == id); diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index 5f27b4b2a4f..9d50b4f75bb 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -35,13 +35,13 @@ impl<'cfg> RegistryIndex<'cfg> { } /// Return the hash listed for a specified PackageId. - pub fn hash(&mut self, pkg: &PackageId) -> CargoResult { + pub fn hash(&mut self, pkg: &PackageId, config: &Config) -> CargoResult { let key = (pkg.name().to_string(), pkg.version().to_string()); if let Some(s) = self.hashes.get(&key) { return Ok(s.clone()) } // Ok, we're missing the key, so parse the index file to load it. - try!(self.summaries(pkg.name())); + try!(self.summaries(pkg.name(), config)); self.hashes.get(&key).chain_error(|| { internal(format!("no hash listed for {}", pkg)) }).map(|s| s.clone()) @@ -51,11 +51,11 @@ impl<'cfg> RegistryIndex<'cfg> { /// /// Returns a list of pairs of (summary, yanked) for the package name /// specified. - pub fn summaries(&mut self, name: &str) -> CargoResult<&Vec<(Summary, bool)>> { + pub fn summaries(&mut self, name: &str, config: &Config) -> CargoResult<&Vec<(Summary, bool)>> { if self.cache.contains_key(name) { return Ok(self.cache.get(name).unwrap()); } - let summaries = try!(self.load_summaries(name)); + let summaries = try!(self.load_summaries(name, config)); let summaries = summaries.into_iter().filter(|summary| { summary.0.package_id().name() == name }).collect(); @@ -63,7 +63,7 @@ impl<'cfg> RegistryIndex<'cfg> { Ok(self.cache.get(name).unwrap()) } - fn load_summaries(&mut self, name: &str) -> CargoResult> { + fn load_summaries(&mut self, name: &str, config: &Config) -> CargoResult> { let (path, _lock) = if self.locked { let lock = self.path.open_ro(Path::new(INDEX_LOCK), self.config, @@ -97,7 +97,7 @@ impl<'cfg> RegistryIndex<'cfg> { try!(f.read_to_string(&mut contents)); let ret: CargoResult>; ret = contents.lines().filter(|l| l.trim().len() > 0) - .map(|l| self.parse_registry_package(l)) + .map(|l| self.parse_registry_package(l, config)) .collect(); ret.chain_error(|| { internal(format!("failed to parse registry's information \ @@ -112,14 +112,14 @@ impl<'cfg> RegistryIndex<'cfg> { /// package. /// /// The returned boolean is whether or not the summary has been yanked. - fn parse_registry_package(&mut self, line: &str) + fn parse_registry_package(&mut self, line: &str, config: &Config) -> CargoResult<(Summary, bool)> { let RegistryPackage { name, vers, cksum, deps, features, yanked } = try!(json::decode::(line)); let pkgid = try!(PackageId::new(&name, &vers, &self.source_id)); let deps: CargoResult> = deps.into_iter().map(|dep| { - self.parse_registry_dependency(dep) + self.parse_registry_dependency(dep, config) }).collect(); let deps = try!(deps); let summary = try!(Summary::new(pkgid, deps, features)); @@ -129,14 +129,14 @@ impl<'cfg> RegistryIndex<'cfg> { } /// Converts an encoded dependency in the registry to a cargo dependency - fn parse_registry_dependency(&self, dep: RegistryDependency) + fn parse_registry_dependency(&self, dep: RegistryDependency, config: &Config) -> CargoResult { let RegistryDependency { name, req, features, optional, default_features, target, kind } = dep; let dep = try!(DependencyInner::parse(&name, Some(&req), - &self.source_id)); + &self.source_id, config)); let kind = match kind.as_ref().map(|s| &s[..]).unwrap_or("") { "dev" => Kind::Development, "build" => Kind::Build, @@ -165,9 +165,9 @@ impl<'cfg> RegistryIndex<'cfg> { } impl<'cfg> Registry for RegistryIndex<'cfg> { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { let mut summaries = { - let summaries = try!(self.summaries(dep.name())); + let summaries = try!(self.summaries(dep.name(), config)); summaries.iter().filter(|&&(_, yanked)| { dep.source_id().precise().is_some() || !yanked }).map(|s| s.0.clone()).collect::>() @@ -187,7 +187,7 @@ impl<'cfg> Registry for RegistryIndex<'cfg> { _ => true, } }); - summaries.query(dep) + summaries.query(dep, config) } fn supports_checksums(&self) -> bool { diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 3a1babafb04..2b959b163f2 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -317,18 +317,18 @@ impl<'cfg> RegistrySource<'cfg> { } impl<'cfg> Registry for RegistrySource<'cfg> { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { // If this is a precise dependency, then it came from a lockfile and in // theory the registry is known to contain this version. If, however, we // come back with no summaries, then our registry may need to be // updated, so we fall back to performing a lazy update. if dep.source_id().precise().is_some() && !self.updated { - if try!(self.index.query(dep)).is_empty() { + if try!(self.index.query(dep, config)).is_empty() { try!(self.do_update()); } } - self.index.query(dep) + self.index.query(dep, config) } fn supports_checksums(&self) -> bool { @@ -351,15 +351,15 @@ impl<'cfg> Source for RegistrySource<'cfg> { Ok(()) } - fn download(&mut self, package: &PackageId) -> CargoResult { - let hash = try!(self.index.hash(package)); + fn download(&mut self, package: &PackageId, config: &Config) -> CargoResult { + let hash = try!(self.index.hash(package, config)); let path = try!(self.ops.download(package, &hash)); let path = try!(self.unpack_package(package, &path).chain_error(|| { internal(format!("failed to unpack package `{}`", package)) })); let mut src = PathSource::new(&path, &self.source_id, self.config); try!(src.update()); - src.download(package) + src.download(package, config) } fn fingerprint(&self, pkg: &Package) -> CargoResult { diff --git a/src/cargo/sources/replaced.rs b/src/cargo/sources/replaced.rs index 7fb95bdf6c8..ad94d101cb8 100644 --- a/src/cargo/sources/replaced.rs +++ b/src/cargo/sources/replaced.rs @@ -1,5 +1,5 @@ use core::{Source, Registry, PackageId, Package, Dependency, Summary, SourceId}; -use util::{CargoResult, ChainError, human}; +use util::{CargoResult, ChainError, human, Config}; pub struct ReplacedSource<'cfg> { to_replace: SourceId, @@ -20,9 +20,9 @@ impl<'cfg> ReplacedSource<'cfg> { } impl<'cfg> Registry for ReplacedSource<'cfg> { - fn query(&mut self, dep: &Dependency) -> CargoResult> { + fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { let dep = dep.clone().map_source(&self.to_replace, &self.replace_with); - let ret = try!(self.inner.query(&dep).chain_error(|| { + let ret = try!(self.inner.query(&dep, config).chain_error(|| { human(format!("failed to query replaced source `{}`", self.to_replace)) })); @@ -40,9 +40,9 @@ impl<'cfg> Source for ReplacedSource<'cfg> { }) } - fn download(&mut self, id: &PackageId) -> CargoResult { + fn download(&mut self, id: &PackageId, config: &Config) -> CargoResult { let id = id.with_source_id(&self.replace_with); - let pkg = try!(self.inner.download(&id).chain_error(|| { + let pkg = try!(self.inner.download(&id, config).chain_error(|| { human(format!("failed to download replaced source `{}`", self.to_replace)) })); diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index a051a2836b3..06a169bed58 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -883,7 +883,7 @@ impl TomlDependency { }; let version = details.version.as_ref().map(|v| &v[..]); - let mut dep = try!(DependencyInner::parse(name, version, &new_source_id)); + let mut dep = try!(DependencyInner::parse(name, version, &new_source_id, cx.config)); dep = dep.set_features(details.features.unwrap_or(Vec::new())) .set_default_features(details.default_features.unwrap_or(true)) .set_optional(details.optional.unwrap_or(false)) diff --git a/tests/resolve.rs b/tests/resolve.rs index 9e30c002860..8ed295e91a8 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -10,17 +10,19 @@ use hamcrest::{assert_that, equal_to, contains}; use cargo::core::source::{SourceId, GitReference}; use cargo::core::dependency::Kind::{self, Development}; use cargo::core::{Dependency, PackageId, Summary, Registry}; -use cargo::util::{CargoResult, ToUrl}; +use cargo::util::{CargoResult, ToUrl, Config}; use cargo::core::resolver::{self, Method}; fn resolve(pkg: PackageId, deps: Vec, registry: &mut R) -> CargoResult> { + let config = Config::default().unwrap(); let summary = Summary::new(pkg.clone(), deps, HashMap::new()).unwrap(); let method = Method::Everything; Ok(try!(resolver::resolve(&[(summary, method)], &[], - registry)).iter().map(|p| { + registry, + &config)).iter().map(|p| { p.clone() }).collect()) } @@ -33,7 +35,8 @@ impl ToDep for &'static str { fn to_dep(self) -> Dependency { let url = "http://example.com".to_url().unwrap(); let source_id = SourceId::for_registry(&url); - Dependency::parse(self, Some("1.0.0"), &source_id).unwrap() + let config = Config::default().unwrap(); + Dependency::parse(self, Some("1.0.0"), &source_id, &config).unwrap() } } @@ -101,14 +104,16 @@ fn dep(name: &str) -> Dependency { dep_req(name, "1.0.0") } fn dep_req(name: &str, req: &str) -> Dependency { let url = "http://example.com".to_url().unwrap(); let source_id = SourceId::for_registry(&url); - Dependency::parse(name, Some(req), &source_id).unwrap() + let config = Config::default().unwrap(); + Dependency::parse(name, Some(req), &source_id, &config).unwrap() } fn dep_loc(name: &str, location: &str) -> Dependency { let url = location.to_url().unwrap(); let master = GitReference::Branch("master".to_string()); let source_id = SourceId::for_git(&url, master); - Dependency::parse(name, Some("1.0.0"), &source_id).unwrap() + let config = Config::default().unwrap(); + Dependency::parse(name, Some("1.0.0"), &source_id, &config).unwrap() } fn dep_kind(name: &str, kind: Kind) -> Dependency { dep(name).clone_inner().set_kind(kind).into_dependency() From e0b7e2d66a477076deb26b98a54a2ce86654fb84 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 3 Oct 2016 16:55:24 -0400 Subject: [PATCH 0762/3888] Print the warning --- src/cargo/core/dependency.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index 61167a8b4f5..bd909b309d9 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -91,9 +91,9 @@ impl DependencyInner { pub fn parse(name: &str, version: Option<&str>, source_id: &SourceId, - _config: &Config) -> CargoResult { + config: &Config) -> CargoResult { let (specified_req, version_req) = match version { - Some(v) => (true, try!(DependencyInner::parse_with_deprecated(v))), + Some(v) => (true, try!(DependencyInner::parse_with_deprecated(v, config))), None => (false, VersionReq::any()) }; @@ -105,16 +105,19 @@ impl DependencyInner { }) } - fn parse_with_deprecated(req: &str) -> Result { + fn parse_with_deprecated(req: &str, config: &Config) -> CargoResult { match VersionReq::parse(req) { Err(e) => { match e { ReqParseError::DeprecatedVersionRequirement(requirement) => { - // warn here + let msg = format!("One of your version requirements ({}) is invalid. \ +Previous versions of Cargo accepted this malformed requirement, but it is being deprecated. Please \ +use {} instead.", req, requirement); + try!(config.shell().warn(&msg)); Ok(requirement) } - e => Err(e), + e => Err(From::from(e)), } }, Ok(v) => Ok(v), From ae1f269ea2f0a093616f6cad7b0fe2cfebaf8cc9 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 3 Oct 2016 17:21:46 -0400 Subject: [PATCH 0763/3888] simplify slightly --- src/cargo/ops/cargo_clean.rs | 2 +- src/cargo/ops/cargo_compile.rs | 4 ++-- src/cargo/ops/cargo_fetch.rs | 2 +- src/cargo/ops/cargo_generate_lockfile.rs | 5 ++--- src/cargo/ops/resolve.rs | 11 +++++------ 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 6c50a90dc6b..c5a32e1d634 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -29,7 +29,7 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { } let mut registry = try!(PackageRegistry::new(opts.config)); - let resolve = try!(ops::resolve_ws(&mut registry, ws, opts.config)); + let resolve = try!(ops::resolve_ws(&mut registry, ws)); let packages = ops::get_resolved_packages(&resolve, registry); let profiles = try!(ws.current()).manifest().profiles(); diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index c8b50cd93b9..44ea51afdd5 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -118,7 +118,7 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, // First, resolve the root_package's *listed* dependencies, as well as // downloading and updating all remotes and such. - let resolve = try!(ops::resolve_ws(&mut registry, ws, ws.config())); + let resolve = try!(ops::resolve_ws(&mut registry, ws)); // Second, resolve with precisely what we're doing. Filter out // transitive dependencies if necessary, specify features, handle @@ -143,7 +143,7 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, let resolved_with_overrides = try!(ops::resolve_with_previous(&mut registry, ws, method, Some(&resolve), None, - &specs, ws.config())); + &specs)); let packages = ops::get_resolved_packages(&resolved_with_overrides, registry); diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index 77634b9c83f..43cd5c109a9 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -6,7 +6,7 @@ use util::CargoResult; /// Executes `cargo fetch`. pub fn fetch<'a>(ws: &Workspace<'a>) -> CargoResult<(Resolve, PackageSet<'a>)> { let mut registry = try!(PackageRegistry::new(ws.config())); - let resolve = try!(ops::resolve_ws(&mut registry, ws, ws.config())); + let resolve = try!(ops::resolve_ws(&mut registry, ws)); let packages = get_resolved_packages(&resolve, registry); for id in resolve.iter() { try!(packages.get(id, ws.config())); diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 7758cc63c4d..25e2204ba9e 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -19,7 +19,7 @@ pub fn generate_lockfile(ws: &Workspace) -> CargoResult<()> { let mut registry = try!(PackageRegistry::new(ws.config())); let resolve = try!(ops::resolve_with_previous(&mut registry, ws, Method::Everything, - None, None, &[], ws.config())); + None, None, &[])); try!(ops::write_pkg_lockfile(ws, &resolve)); Ok(()) } @@ -79,8 +79,7 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) Method::Everything, Some(&previous_resolve), Some(&to_avoid), - &[], - ws.config())); + &[])); // Summarize what is changing for the user. let print_change = |status: &str, msg: String| { diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 5f4c1617acc..6b114dd61cc 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -4,19 +4,19 @@ use core::{PackageId, PackageIdSpec, SourceId, Workspace}; use core::registry::PackageRegistry; use core::resolver::{self, Resolve, Method}; use ops; -use util::{CargoResult, Config}; +use util::CargoResult; /// Resolve all dependencies for the specified `package` using the previous /// lockfile as a guide if present. /// /// This function will also write the result of resolution as a new /// lockfile. -pub fn resolve_ws(registry: &mut PackageRegistry, ws: &Workspace, config: &Config) +pub fn resolve_ws(registry: &mut PackageRegistry, ws: &Workspace) -> CargoResult { let prev = try!(ops::load_pkg_lockfile(ws)); let resolve = try!(resolve_with_previous(registry, ws, Method::Everything, - prev.as_ref(), None, &[], config)); + prev.as_ref(), None, &[])); // Avoid writing a lockfile if we are `cargo install`ing a non local package. if ws.current_opt().map(|pkg| pkg.package_id().source_id().is_path()).unwrap_or(true) { @@ -39,8 +39,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, method: Method, previous: Option<&'a Resolve>, to_avoid: Option<&HashSet<&'a PackageId>>, - specs: &[PackageIdSpec], - config: &Config) + specs: &[PackageIdSpec]) -> CargoResult { // Here we place an artificial limitation that all non-registry sources // cannot be locked at more than one revision. This means that if a git @@ -128,7 +127,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, None => root_replace.to_vec(), }; - let mut resolved = try!(resolver::resolve(&summaries, &replace, registry, config)); + let mut resolved = try!(resolver::resolve(&summaries, &replace, registry, ws.config())); if let Some(previous) = previous { try!(resolved.merge_from(previous)); } From f6b0fcb580ff814793ea4421e5793b2a0d3ec6a5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Oct 2016 11:07:37 -0700 Subject: [PATCH 0764/3888] Revert addition of a number of Config params --- src/cargo/core/package.rs | 4 +-- src/cargo/core/registry.rs | 10 +++--- src/cargo/core/resolver/mod.rs | 39 ++++++++++------------- src/cargo/core/source.rs | 6 ++-- src/cargo/ops/cargo_clean.rs | 2 +- src/cargo/ops/cargo_compile.rs | 2 +- src/cargo/ops/cargo_fetch.rs | 2 +- src/cargo/ops/cargo_install.rs | 4 +-- src/cargo/ops/cargo_output_metadata.rs | 2 +- src/cargo/ops/cargo_rustc/context.rs | 29 ++++++++--------- src/cargo/ops/cargo_rustc/custom_build.rs | 2 +- src/cargo/ops/cargo_rustc/fingerprint.rs | 2 +- src/cargo/ops/cargo_rustc/job_queue.rs | 4 +-- src/cargo/ops/cargo_rustc/mod.rs | 6 ++-- src/cargo/ops/resolve.rs | 2 +- src/cargo/sources/directory.rs | 4 +-- src/cargo/sources/git/source.rs | 8 ++--- src/cargo/sources/path.rs | 6 ++-- src/cargo/sources/registry/index.rs | 27 ++++++++-------- src/cargo/sources/registry/mod.rs | 12 +++---- src/cargo/sources/replaced.rs | 10 +++--- tests/resolve.rs | 4 +-- 22 files changed, 88 insertions(+), 99 deletions(-) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 0235b619285..da14b04fc33 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -156,7 +156,7 @@ impl<'cfg> PackageSet<'cfg> { Box::new(self.packages.iter().map(|&(ref p, _)| p)) } - pub fn get(&self, id: &PackageId, config: &Config) -> CargoResult<&Package> { + pub fn get(&self, id: &PackageId) -> CargoResult<&Package> { let slot = try!(self.packages.iter().find(|p| p.0 == *id).chain_error(|| { internal(format!("couldn't find `{}` in package set", id)) })); @@ -168,7 +168,7 @@ impl<'cfg> PackageSet<'cfg> { let source = try!(sources.get_mut(id.source_id()).chain_error(|| { internal(format!("couldn't find source for `{}`", id)) })); - let pkg = try!(source.download(id, config).chain_error(|| { + let pkg = try!(source.download(id).chain_error(|| { human("unable to get packages from source") })); assert!(slot.fill(pkg).is_ok()); diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 5aa11abfda7..bea9e6a1041 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -10,7 +10,7 @@ use sources::config::SourceConfigMap; /// See also `core::Source`. pub trait Registry { /// Attempt to find the packages that match a dependency request. - fn query(&mut self, name: &Dependency, config: &Config) -> CargoResult>; + fn query(&mut self, name: &Dependency) -> CargoResult>; /// Returns whether or not this registry will return summaries with /// checksums listed. @@ -22,22 +22,22 @@ pub trait Registry { } impl Registry for Vec { - fn query(&mut self, dep: &Dependency, _config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { Ok(self.iter().filter(|summary| dep.matches(*summary)) .cloned().collect()) } } impl Registry for Vec { - fn query(&mut self, dep: &Dependency, _config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { Ok(self.iter().filter(|pkg| dep.matches(pkg.summary())) .map(|pkg| pkg.summary().clone()).collect()) } } impl<'a, T: ?Sized + Registry + 'a> Registry for Box { - fn query(&mut self, name: &Dependency, config: &Config) -> CargoResult> { - (**self).query(name, config) + fn query(&mut self, name: &Dependency) -> CargoResult> { + (**self).query(name) } } diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index ed57a1a9b0b..7a9e953365a 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -55,7 +55,7 @@ use semver; use core::{PackageId, Registry, SourceId, Summary, Dependency}; use core::PackageIdSpec; -use util::{CargoResult, Graph, human, CargoError, Config}; +use util::{CargoResult, Graph, human, CargoError}; use util::profile; use util::ChainError; use util::graph::{Nodes, Edges}; @@ -265,8 +265,7 @@ struct Context<'a> { /// Builds the list of all packages required to build the first argument. pub fn resolve(summaries: &[(Summary, Method)], replacements: &[(PackageIdSpec, Dependency)], - registry: &mut Registry, - config: &Config) -> CargoResult { + registry: &mut Registry) -> CargoResult { let cx = Context { resolve_graph: Graph::new(), resolve_features: HashMap::new(), @@ -275,7 +274,7 @@ pub fn resolve(summaries: &[(Summary, Method)], replacements: replacements, }; let _p = profile::start(format!("resolving")); - let cx = try!(activate_deps_loop(cx, registry, summaries, config)); + let cx = try!(activate_deps_loop(cx, registry, summaries)); let mut resolve = Resolve { graph: cx.resolve_graph, @@ -306,8 +305,7 @@ fn activate(cx: &mut Context, registry: &mut Registry, parent: Option<&Rc>, candidate: Candidate, - method: &Method, - config: &Config) + method: &Method) -> CargoResult> { if let Some(parent) = parent { cx.resolve_graph.link(parent.package_id().clone(), @@ -335,7 +333,7 @@ fn activate(cx: &mut Context, } }; - let deps = try!(cx.build_deps(registry, &candidate, method, config)); + let deps = try!(cx.build_deps(registry, &candidate, method)); Ok(Some(DepsFrame { parent: candidate, @@ -437,8 +435,7 @@ struct BacktrackFrame<'a> { /// dependency graph, cx.resolve is returned. fn activate_deps_loop<'a>(mut cx: Context<'a>, registry: &mut Registry, - summaries: &[(Summary, Method)], - config: &Config) + summaries: &[(Summary, Method)]) -> CargoResult> { // Note that a `BinaryHeap` is used for the remaining dependencies that need // activation. This heap is sorted such that the "largest value" is the most @@ -454,7 +451,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, let summary = Rc::new(summary.clone()); let candidate = Candidate { summary: summary, replace: None }; remaining_deps.extend(try!(activate(&mut cx, registry, None, candidate, - method, config))); + method))); } // Main resolution loop, this is the workhorse of the resolution algorithm. @@ -548,8 +545,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, None => return Err(activation_error(&cx, registry, &parent, &dep, &cx.prev_active(&dep), - &candidates, - config)), + &candidates)), Some(candidate) => candidate, } } @@ -563,7 +559,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, trace!("{}[{}]>{} trying {}", parent.name(), cur, dep.name(), candidate.summary.version()); remaining_deps.extend(try!(activate(&mut cx, registry, Some(&parent), - candidate, &method, config))); + candidate, &method))); } Ok(cx) @@ -599,8 +595,7 @@ fn activation_error(cx: &Context, parent: &Summary, dep: &Dependency, prev_active: &[Rc], - candidates: &[Candidate], - config: &Config) -> Box { + candidates: &[Candidate]) -> Box { if candidates.len() > 0 { let mut msg = format!("failed to select a version for `{}` \ (required by `{}`):\n\ @@ -653,7 +648,7 @@ fn activation_error(cx: &Context, let mut msg = msg; let all_req = semver::VersionReq::parse("*").unwrap(); let new_dep = dep.clone_inner().set_version_req(all_req).into_dependency(); - let mut candidates = match registry.query(&new_dep, config) { + let mut candidates = match registry.query(&new_dep) { Ok(candidates) => candidates, Err(e) => return e, }; @@ -821,8 +816,7 @@ impl<'a> Context<'a> { fn build_deps(&mut self, registry: &mut Registry, candidate: &Summary, - method: &Method, - config: &Config) -> CargoResult> { + method: &Method) -> CargoResult> { // First, figure out our set of dependencies based on the requsted set // of features. This also calculates what features we're going to enable // for our own dependencies. @@ -831,7 +825,7 @@ impl<'a> Context<'a> { // Next, transform all dependencies into a list of possible candidates // which can satisfy that dependency. let mut deps = try!(deps.into_iter().map(|(dep, features)| { - let mut candidates = try!(self.query(registry, &dep, config)); + let mut candidates = try!(self.query(registry, &dep)); // When we attempt versions for a package, we'll want to start at // the maximum version and work our way down. candidates.sort_by(|a, b| { @@ -857,9 +851,8 @@ impl<'a> Context<'a> { /// return. fn query(&self, registry: &mut Registry, - dep: &Dependency, - config: &Config) -> CargoResult> { - let summaries = try!(registry.query(dep, config)); + dep: &Dependency) -> CargoResult> { + let summaries = try!(registry.query(dep)); summaries.into_iter().map(Rc::new).map(|summary| { // get around lack of non-lexical lifetimes let summary2 = summary.clone(); @@ -872,7 +865,7 @@ impl<'a> Context<'a> { Some(replacement) => replacement, }; - let mut summaries = try!(registry.query(dep, config)).into_iter(); + let mut summaries = try!(registry.query(dep)).into_iter(); let s = try!(summaries.next().chain_error(|| { human(format!("no matching package for override `{}` found\n\ location searched: {}\n\ diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index b09d57ef93e..4a46c19294d 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -27,7 +27,7 @@ pub trait Source: Registry { /// The download method fetches the full package for each name and /// version specified. - fn download(&mut self, package: &PackageId, config: &Config) -> CargoResult; + fn download(&mut self, package: &PackageId) -> CargoResult; /// Generates a unique string which represents the fingerprint of the /// current state of the source. @@ -57,8 +57,8 @@ impl<'a, T: Source + ?Sized + 'a> Source for Box { (**self).update() } - fn download(&mut self, id: &PackageId, config: &Config) -> CargoResult { - (**self).download(id, config) + fn download(&mut self, id: &PackageId) -> CargoResult { + (**self).download(id) } fn fingerprint(&self, pkg: &Package) -> CargoResult { diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index c5a32e1d634..e19b37f116f 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -47,7 +47,7 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { for spec in opts.spec { // Translate the spec to a Package let pkgid = try!(resolve.query(spec)); - let pkg = try!(packages.get(&pkgid, ws.config())); + let pkg = try!(packages.get(&pkgid)); // Generate all relevant `Unit` targets for this package for target in pkg.targets() { diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 44ea51afdd5..0767e9e467a 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -190,7 +190,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, }; let to_builds = try!(pkgids.iter().map(|id| { - packages.get(id, config) + packages.get(id) }).collect::>>()); let mut general_targets = Vec::new(); diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index 43cd5c109a9..a0144c8f472 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -9,7 +9,7 @@ pub fn fetch<'a>(ws: &Workspace<'a>) -> CargoResult<(Resolve, PackageSet<'a>)> { let resolve = try!(ops::resolve_ws(&mut registry, ws)); let packages = get_resolved_packages(&resolve, registry); for id in resolve.iter() { - try!(packages.get(id, ws.config())); + try!(packages.get(id)); } Ok((resolve, packages)) } diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 91d44a4d4ff..59d16e27286 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -260,10 +260,10 @@ fn select_pkg<'a, T>(mut source: T, match name { Some(name) => { let dep = try!(Dependency::parse(name, vers, source_id, config)); - let deps = try!(source.query(&dep, config)); + let deps = try!(source.query(&dep)); match deps.iter().map(|p| p.package_id()).max() { Some(pkgid) => { - let pkg = try!(source.download(pkgid, config)); + let pkg = try!(source.download(pkgid)); Ok((pkg, Box::new(source))) } None => { diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 488fa9853a1..131b93825db 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -52,7 +52,7 @@ fn metadata_full(ws: &Workspace, let (packages, resolve) = deps; let packages = try!(packages.package_ids() - .map(|i| packages.get(i, ws.config()).map(|p| p.clone())) + .map(|i| packages.get(i).map(|p| p.clone())) .collect()); Ok(ExportInfo { diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 5ff2a6c8fee..7cbd2149fe4 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -156,7 +156,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } })); } - for dep in try!(self.dep_targets(&unit, self.config)) { + for dep in try!(self.dep_targets(&unit)) { try!(self.visit_crate_type(&dep, crate_types)); } Ok(()) @@ -251,8 +251,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { for unit in units { try!(self.walk_used_in_plugin_map(unit, unit.target.for_host(), - &mut visited, - self.config)); + &mut visited)); } Ok(()) } @@ -260,8 +259,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { fn walk_used_in_plugin_map(&mut self, unit: &Unit<'a>, is_plugin: bool, - visited: &mut HashSet<(Unit<'a>, bool)>, - config: &Config) + visited: &mut HashSet<(Unit<'a>, bool)>) -> CargoResult<()> { if !visited.insert((*unit, is_plugin)) { return Ok(()) @@ -269,11 +267,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> { if is_plugin { self.used_in_plugin.insert(*unit); } - for unit in try!(self.dep_targets(unit, config)) { + for unit in try!(self.dep_targets(unit)) { try!(self.walk_used_in_plugin_map(&unit, is_plugin || unit.target.for_host(), - visited, - config)); + visited)); } Ok(()) } @@ -446,11 +443,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// For a package, return all targets which are registered as dependencies /// for that package. - pub fn dep_targets(&self, unit: &Unit<'a>, config: &Config) -> CargoResult>> { + pub fn dep_targets(&self, unit: &Unit<'a>) -> CargoResult>> { if unit.profile.run_custom_build { return self.dep_run_custom_build(unit) } else if unit.profile.doc { - return self.doc_deps(unit, config); + return self.doc_deps(unit); } let id = unit.pkg.package_id(); @@ -493,7 +490,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { true }) }).filter_map(|id| { - match self.get_package(id, config) { + match self.get_package(id) { Ok(pkg) => { pkg.targets().iter().find(|t| t.is_lib()).map(|t| { Ok(Unit { @@ -567,7 +564,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { profile: &self.profiles.dev, ..*unit }; - let deps = try!(self.dep_targets(&tmp, self.config)); + let deps = try!(self.dep_targets(&tmp)); Ok(deps.iter().filter_map(|unit| { if !unit.target.linkable() || unit.pkg.manifest().links().is_none() { return None @@ -581,7 +578,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Returns the dependencies necessary to document a package - fn doc_deps(&self, unit: &Unit<'a>, config: &Config) -> CargoResult>> { + fn doc_deps(&self, unit: &Unit<'a>) -> CargoResult>> { let deps = self.resolve.deps(unit.pkg.package_id()).filter(|dep| { unit.pkg.dependencies().iter().filter(|d| { d.name() == dep.name() @@ -593,7 +590,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } }) }).map(|dep| { - self.get_package(dep, config) + self.get_package(dep) }); // To document a library, we depend on dependencies actually being @@ -676,8 +673,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Gets a package for the given package id. - pub fn get_package(&self, id: &PackageId, config: &Config) -> CargoResult<&'a Package> { - self.packages.get(id, config) + pub fn get_package(&self, id: &PackageId) -> CargoResult<&'a Package> { + self.packages.get(id) } /// Get the user-specified linker for a particular host or target diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index c78d067d618..5a15e85a853 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -413,7 +413,7 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, if !unit.target.is_custom_build() && unit.pkg.has_custom_build() { add_to_link(&mut ret, unit.pkg.package_id(), unit.kind); } - for unit in try!(cx.dep_targets(unit, cx.config)).iter() { + for unit in try!(cx.dep_targets(unit)).iter() { let dep_scripts = try!(build(out, cx, unit)); if unit.target.for_host() { diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index a24d7ad2b6d..702deb5f863 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -345,7 +345,7 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // elsewhere. Also skip fingerprints of binaries because they don't actually // induce a recompile, they're just dependencies in the sense that they need // to be built. - let deps = try!(cx.dep_targets(unit, cx.config)); + let deps = try!(cx.dep_targets(unit)); let deps = try!(deps.iter().filter(|u| { !u.target.is_custom_build() && !u.target.is_bin() }).map(|unit| { diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index db359a7345a..53bad6b786c 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -323,12 +323,12 @@ impl<'a> Key<'a> { fn dependencies<'cfg>(&self, cx: &Context<'a, 'cfg>) -> CargoResult>> { let unit = Unit { - pkg: try!(cx.get_package(self.pkg, cx.config)), + pkg: try!(cx.get_package(self.pkg)), target: self.target, profile: self.profile, kind: self.kind, }; - let targets = try!(cx.dep_targets(&unit, cx.config)); + let targets = try!(cx.dep_targets(&unit)); Ok(targets.iter().filter_map(|unit| { // Binaries aren't actually needed to *compile* tests, just to run // them, so we don't include this dependency edge in the job graph. diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 660f517ca8f..280b6c05df5 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -130,7 +130,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, if !unit.target.is_lib() { continue } // Include immediate lib deps as well - for unit in try!(cx.dep_targets(unit, cx.config)).iter() { + for unit in try!(cx.dep_targets(unit)).iter() { let pkgid = unit.pkg.package_id(); if !unit.target.is_lib() { continue } if unit.profile.doc { continue } @@ -197,7 +197,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, drop(p); // Be sure to compile all dependencies of this target as well. - for unit in try!(cx.dep_targets(unit, cx.config)).iter() { + for unit in try!(cx.dep_targets(unit)).iter() { try!(compile(cx, jobs, unit)); } Ok(()) @@ -652,7 +652,7 @@ fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) cmd.env("OUT_DIR", &layout.build_out(unit.pkg)); } - for unit in try!(cx.dep_targets(unit, cx.config)).iter() { + for unit in try!(cx.dep_targets(unit)).iter() { if unit.target.linkable() && !unit.profile.doc { try!(link_to(cmd, cx, unit)); } diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 6b114dd61cc..af912b0dfba 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -127,7 +127,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, None => root_replace.to_vec(), }; - let mut resolved = try!(resolver::resolve(&summaries, &replace, registry, ws.config())); + let mut resolved = try!(resolver::resolve(&summaries, &replace, registry)); if let Some(previous) = previous { try!(resolved.merge_from(previous)); } diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index 650a5092413..84a9501a03b 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -44,7 +44,7 @@ impl<'cfg> Debug for DirectorySource<'cfg> { } impl<'cfg> Registry for DirectorySource<'cfg> { - fn query(&mut self, dep: &Dependency, _config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { let packages = self.packages.values().map(|p| &p.0); let matches = packages.filter(|pkg| dep.matches(pkg.summary())); let summaries = matches.map(|pkg| pkg.summary().clone()); @@ -98,7 +98,7 @@ impl<'cfg> Source for DirectorySource<'cfg> { Ok(()) } - fn download(&mut self, id: &PackageId, _config: &Config) -> CargoResult { + fn download(&mut self, id: &PackageId) -> CargoResult { self.packages.get(id).map(|p| &p.0).cloned().chain_error(|| { human(format!("failed to find package with id: {}", id)) }) diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 87e424810a9..eeffcb05b72 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -114,10 +114,10 @@ impl<'cfg> Debug for GitSource<'cfg> { } impl<'cfg> Registry for GitSource<'cfg> { - fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { let src = self.path_source.as_mut() .expect("BUG: update() must be called before query()"); - src.query(dep, config) + src.query(dep) } } @@ -175,12 +175,12 @@ impl<'cfg> Source for GitSource<'cfg> { self.path_source.as_mut().unwrap().update() } - fn download(&mut self, id: &PackageId, config: &Config) -> CargoResult { + fn download(&mut self, id: &PackageId) -> CargoResult { trace!("getting packages for package id `{}` from `{:?}`", id, self.remote); self.path_source.as_mut() .expect("BUG: update() must be called before get()") - .download(id, config) + .download(id) } fn fingerprint(&self, _pkg: &Package) -> CargoResult { diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index cee7f6cf3f1..052d01c7dab 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -310,8 +310,8 @@ impl<'cfg> Debug for PathSource<'cfg> { } impl<'cfg> Registry for PathSource<'cfg> { - fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { - self.packages.query(dep, config) + fn query(&mut self, dep: &Dependency) -> CargoResult> { + self.packages.query(dep) } } @@ -326,7 +326,7 @@ impl<'cfg> Source for PathSource<'cfg> { Ok(()) } - fn download(&mut self, id: &PackageId, _config: &Config) -> CargoResult { + fn download(&mut self, id: &PackageId) -> CargoResult { trace!("getting packages; id={}", id); let pkg = self.packages.iter().find(|pkg| pkg.package_id() == id); diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index 9d50b4f75bb..e7bd2b87223 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -35,13 +35,13 @@ impl<'cfg> RegistryIndex<'cfg> { } /// Return the hash listed for a specified PackageId. - pub fn hash(&mut self, pkg: &PackageId, config: &Config) -> CargoResult { + pub fn hash(&mut self, pkg: &PackageId) -> CargoResult { let key = (pkg.name().to_string(), pkg.version().to_string()); if let Some(s) = self.hashes.get(&key) { return Ok(s.clone()) } // Ok, we're missing the key, so parse the index file to load it. - try!(self.summaries(pkg.name(), config)); + try!(self.summaries(pkg.name())); self.hashes.get(&key).chain_error(|| { internal(format!("no hash listed for {}", pkg)) }).map(|s| s.clone()) @@ -51,11 +51,11 @@ impl<'cfg> RegistryIndex<'cfg> { /// /// Returns a list of pairs of (summary, yanked) for the package name /// specified. - pub fn summaries(&mut self, name: &str, config: &Config) -> CargoResult<&Vec<(Summary, bool)>> { + pub fn summaries(&mut self, name: &str) -> CargoResult<&Vec<(Summary, bool)>> { if self.cache.contains_key(name) { return Ok(self.cache.get(name).unwrap()); } - let summaries = try!(self.load_summaries(name, config)); + let summaries = try!(self.load_summaries(name)); let summaries = summaries.into_iter().filter(|summary| { summary.0.package_id().name() == name }).collect(); @@ -63,7 +63,7 @@ impl<'cfg> RegistryIndex<'cfg> { Ok(self.cache.get(name).unwrap()) } - fn load_summaries(&mut self, name: &str, config: &Config) -> CargoResult> { + fn load_summaries(&mut self, name: &str) -> CargoResult> { let (path, _lock) = if self.locked { let lock = self.path.open_ro(Path::new(INDEX_LOCK), self.config, @@ -97,7 +97,7 @@ impl<'cfg> RegistryIndex<'cfg> { try!(f.read_to_string(&mut contents)); let ret: CargoResult>; ret = contents.lines().filter(|l| l.trim().len() > 0) - .map(|l| self.parse_registry_package(l, config)) + .map(|l| self.parse_registry_package(l)) .collect(); ret.chain_error(|| { internal(format!("failed to parse registry's information \ @@ -112,14 +112,14 @@ impl<'cfg> RegistryIndex<'cfg> { /// package. /// /// The returned boolean is whether or not the summary has been yanked. - fn parse_registry_package(&mut self, line: &str, config: &Config) + fn parse_registry_package(&mut self, line: &str) -> CargoResult<(Summary, bool)> { let RegistryPackage { name, vers, cksum, deps, features, yanked } = try!(json::decode::(line)); let pkgid = try!(PackageId::new(&name, &vers, &self.source_id)); let deps: CargoResult> = deps.into_iter().map(|dep| { - self.parse_registry_dependency(dep, config) + self.parse_registry_dependency(dep) }).collect(); let deps = try!(deps); let summary = try!(Summary::new(pkgid, deps, features)); @@ -129,14 +129,15 @@ impl<'cfg> RegistryIndex<'cfg> { } /// Converts an encoded dependency in the registry to a cargo dependency - fn parse_registry_dependency(&self, dep: RegistryDependency, config: &Config) + fn parse_registry_dependency(&self, dep: RegistryDependency) -> CargoResult { let RegistryDependency { name, req, features, optional, default_features, target, kind } = dep; let dep = try!(DependencyInner::parse(&name, Some(&req), - &self.source_id, config)); + &self.source_id, + self.config)); let kind = match kind.as_ref().map(|s| &s[..]).unwrap_or("") { "dev" => Kind::Development, "build" => Kind::Build, @@ -165,9 +166,9 @@ impl<'cfg> RegistryIndex<'cfg> { } impl<'cfg> Registry for RegistryIndex<'cfg> { - fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { let mut summaries = { - let summaries = try!(self.summaries(dep.name(), config)); + let summaries = try!(self.summaries(dep.name())); summaries.iter().filter(|&&(_, yanked)| { dep.source_id().precise().is_some() || !yanked }).map(|s| s.0.clone()).collect::>() @@ -187,7 +188,7 @@ impl<'cfg> Registry for RegistryIndex<'cfg> { _ => true, } }); - summaries.query(dep, config) + summaries.query(dep) } fn supports_checksums(&self) -> bool { diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 2b959b163f2..3a1babafb04 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -317,18 +317,18 @@ impl<'cfg> RegistrySource<'cfg> { } impl<'cfg> Registry for RegistrySource<'cfg> { - fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { // If this is a precise dependency, then it came from a lockfile and in // theory the registry is known to contain this version. If, however, we // come back with no summaries, then our registry may need to be // updated, so we fall back to performing a lazy update. if dep.source_id().precise().is_some() && !self.updated { - if try!(self.index.query(dep, config)).is_empty() { + if try!(self.index.query(dep)).is_empty() { try!(self.do_update()); } } - self.index.query(dep, config) + self.index.query(dep) } fn supports_checksums(&self) -> bool { @@ -351,15 +351,15 @@ impl<'cfg> Source for RegistrySource<'cfg> { Ok(()) } - fn download(&mut self, package: &PackageId, config: &Config) -> CargoResult { - let hash = try!(self.index.hash(package, config)); + fn download(&mut self, package: &PackageId) -> CargoResult { + let hash = try!(self.index.hash(package)); let path = try!(self.ops.download(package, &hash)); let path = try!(self.unpack_package(package, &path).chain_error(|| { internal(format!("failed to unpack package `{}`", package)) })); let mut src = PathSource::new(&path, &self.source_id, self.config); try!(src.update()); - src.download(package, config) + src.download(package) } fn fingerprint(&self, pkg: &Package) -> CargoResult { diff --git a/src/cargo/sources/replaced.rs b/src/cargo/sources/replaced.rs index ad94d101cb8..7fb95bdf6c8 100644 --- a/src/cargo/sources/replaced.rs +++ b/src/cargo/sources/replaced.rs @@ -1,5 +1,5 @@ use core::{Source, Registry, PackageId, Package, Dependency, Summary, SourceId}; -use util::{CargoResult, ChainError, human, Config}; +use util::{CargoResult, ChainError, human}; pub struct ReplacedSource<'cfg> { to_replace: SourceId, @@ -20,9 +20,9 @@ impl<'cfg> ReplacedSource<'cfg> { } impl<'cfg> Registry for ReplacedSource<'cfg> { - fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { let dep = dep.clone().map_source(&self.to_replace, &self.replace_with); - let ret = try!(self.inner.query(&dep, config).chain_error(|| { + let ret = try!(self.inner.query(&dep).chain_error(|| { human(format!("failed to query replaced source `{}`", self.to_replace)) })); @@ -40,9 +40,9 @@ impl<'cfg> Source for ReplacedSource<'cfg> { }) } - fn download(&mut self, id: &PackageId, config: &Config) -> CargoResult { + fn download(&mut self, id: &PackageId) -> CargoResult { let id = id.with_source_id(&self.replace_with); - let pkg = try!(self.inner.download(&id, config).chain_error(|| { + let pkg = try!(self.inner.download(&id).chain_error(|| { human(format!("failed to download replaced source `{}`", self.to_replace)) })); diff --git a/tests/resolve.rs b/tests/resolve.rs index 8ed295e91a8..56ae25c6262 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -16,13 +16,11 @@ use cargo::core::resolver::{self, Method}; fn resolve(pkg: PackageId, deps: Vec, registry: &mut R) -> CargoResult> { - let config = Config::default().unwrap(); let summary = Summary::new(pkg.clone(), deps, HashMap::new()).unwrap(); let method = Method::Everything; Ok(try!(resolver::resolve(&[(summary, method)], &[], - registry, - &config)).iter().map(|p| { + registry)).iter().map(|p| { p.clone() }).collect()) } From fc0851a64a6dbd673f51b956dd52fe98f577d865 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Oct 2016 12:34:00 -0700 Subject: [PATCH 0765/3888] Tweak message in Dependency::parse Provide some contextual information about why a dependency failed to parse. --- src/cargo/core/dependency.rs | 51 ++++++++++++++++++++++++----- src/cargo/core/registry.rs | 6 ++-- src/cargo/ops/cargo_install.rs | 9 +++-- src/cargo/sources/registry/index.rs | 4 +-- src/cargo/util/toml.rs | 11 ++++++- tests/resolve.rs | 11 +++---- 6 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index bd909b309d9..b96fed73f1d 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -88,12 +88,21 @@ impl Encodable for Kind { impl DependencyInner { /// Attempt to create a `Dependency` from an entry in the manifest. + /// + /// The `deprecated_extra` information is set to `Some` when this method + /// should *also* parse historically deprecated semver requirements. This + /// information allows providing diagnostic information about what's going + /// on. + /// + /// If set to `None`, then historically deprecated semver requirements will + /// all be rejected. pub fn parse(name: &str, version: Option<&str>, source_id: &SourceId, - config: &Config) -> CargoResult { + deprecated_extra: Option<(&PackageId, &Config)>) + -> CargoResult { let (specified_req, version_req) = match version { - Some(v) => (true, try!(DependencyInner::parse_with_deprecated(v, config))), + Some(v) => (true, try!(DependencyInner::parse_with_deprecated(v, deprecated_extra))), None => (false, VersionReq::any()) }; @@ -105,16 +114,31 @@ impl DependencyInner { }) } - fn parse_with_deprecated(req: &str, config: &Config) -> CargoResult { + fn parse_with_deprecated(req: &str, + extra: Option<(&PackageId, &Config)>) + -> CargoResult { match VersionReq::parse(req) { Err(e) => { + let (inside, config) = match extra { + Some(pair) => pair, + None => return Err(e.into()), + }; match e { ReqParseError::DeprecatedVersionRequirement(requirement) => { - let msg = format!("One of your version requirements ({}) is invalid. \ -Previous versions of Cargo accepted this malformed requirement, but it is being deprecated. Please \ -use {} instead.", req, requirement); + let msg = format!("\ +parsed version requirement `{}` is no longer valid + +Previous versions of Cargo accepted this malformed requirement, +but it is being deprecated. This was found when parsing the manifest +of {} {}, and the correct version requirement is `{}`. + +This will soon become a hard error, so it's either recommended to +update to a fixed version or contact the upstream maintainer about +this warning. +", + req, inside.name(), inside.version(), requirement); try!(config.shell().warn(&msg)); - + Ok(requirement) } e => Err(From::from(e)), @@ -238,8 +262,19 @@ impl Dependency { pub fn parse(name: &str, version: Option<&str>, source_id: &SourceId, + inside: &PackageId, config: &Config) -> CargoResult { - DependencyInner::parse(name, version, source_id, config).map(|di| { + let arg = Some((inside, config)); + DependencyInner::parse(name, version, source_id, arg).map(|di| { + di.into_dependency() + }) + } + + /// Attempt to create a `Dependency` from an entry in the manifest. + pub fn parse_no_deprecated(name: &str, + version: Option<&str>, + source_id: &SourceId) -> CargoResult { + DependencyInner::parse(name, version, source_id, None).map(|di| { di.into_dependency() }) } diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index bea9e6a1041..854340077c6 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -364,7 +364,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> { #[cfg(test)] pub mod test { use core::{Summary, Registry, Dependency}; - use util::{CargoResult, Config}; + use util::CargoResult; pub struct RegistryBuilder { summaries: Vec, @@ -405,13 +405,13 @@ pub mod test { } impl Registry for RegistryBuilder { - fn query(&mut self, dep: &Dependency, config: &Config) -> CargoResult> { + fn query(&mut self, dep: &Dependency) -> CargoResult> { debug!("querying; dep={:?}", dep); let overrides = self.query_overrides(dep); if overrides.is_empty() { - self.summaries.query(dep, config) + self.summaries.query(dep) } else { Ok(overrides) } diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 59d16e27286..93ceb40409a 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -57,7 +57,7 @@ pub fn install(root: Option<&str>, let map = try!(SourceConfigMap::new(config)); let (pkg, source) = if source_id.is_git() { try!(select_pkg(GitSource::new(source_id, config), source_id, - krate, vers, config, &mut |git| git.read_packages())) + krate, vers, &mut |git| git.read_packages())) } else if source_id.is_path() { let path = source_id.url().to_file_path().ok() .expect("path sources must have a valid path"); @@ -68,11 +68,11 @@ pub fn install(root: Option<&str>, specify an alternate source", path.display())) })); try!(select_pkg(PathSource::new(&path, source_id, config), - source_id, krate, vers, config, + source_id, krate, vers, &mut |path| path.read_packages())) } else { try!(select_pkg(try!(map.load(source_id)), - source_id, krate, vers, config, + source_id, krate, vers, &mut |_| Err(human("must specify a crate to install from \ crates.io, or use --path or --git to \ specify alternate source")))) @@ -251,7 +251,6 @@ fn select_pkg<'a, T>(mut source: T, source_id: &SourceId, name: Option<&str>, vers: Option<&str>, - config: &Config, list_all: &mut FnMut(&mut T) -> CargoResult>) -> CargoResult<(Package, Box)> where T: Source + 'a @@ -259,7 +258,7 @@ fn select_pkg<'a, T>(mut source: T, try!(source.update()); match name { Some(name) => { - let dep = try!(Dependency::parse(name, vers, source_id, config)); + let dep = try!(Dependency::parse_no_deprecated(name, vers, source_id)); let deps = try!(source.query(&dep)); match deps.iter().map(|p| p.package_id()).max() { Some(pkgid) => { diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index e7bd2b87223..cda824676d4 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -135,9 +135,7 @@ impl<'cfg> RegistryIndex<'cfg> { name, req, features, optional, default_features, target, kind } = dep; - let dep = try!(DependencyInner::parse(&name, Some(&req), - &self.source_id, - self.config)); + let dep = try!(DependencyInner::parse(&name, Some(&req), &self.source_id, None)); let kind = match kind.as_ref().map(|s| &s[..]).unwrap_or("") { "dev" => Kind::Development, "build" => Kind::Build, diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 06a169bed58..b3de140969d 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -336,6 +336,7 @@ impl TomlProject { } struct Context<'a, 'b> { + pkgid: Option<&'a PackageId>, deps: &'a mut Vec, source_id: &'a SourceId, nested_paths: &'a mut Vec, @@ -566,6 +567,7 @@ impl TomlManifest { { let mut cx = Context { + pkgid: Some(&pkgid), deps: &mut deps, source_id: source_id, nested_paths: &mut nested_paths, @@ -714,6 +716,7 @@ impl TomlManifest { let mut warnings = Vec::new(); let mut deps = Vec::new(); let replace = try!(self.replace(&mut Context { + pkgid: None, deps: &mut deps, source_id: source_id, nested_paths: &mut nested_paths, @@ -883,7 +886,13 @@ impl TomlDependency { }; let version = details.version.as_ref().map(|v| &v[..]); - let mut dep = try!(DependencyInner::parse(name, version, &new_source_id, cx.config)); + let mut dep = match cx.pkgid { + Some(id) => { + try!(DependencyInner::parse(name, version, &new_source_id, + Some((id, cx.config)))) + } + None => try!(DependencyInner::parse(name, version, &new_source_id, None)), + }; dep = dep.set_features(details.features.unwrap_or(Vec::new())) .set_default_features(details.default_features.unwrap_or(true)) .set_optional(details.optional.unwrap_or(false)) diff --git a/tests/resolve.rs b/tests/resolve.rs index 56ae25c6262..9129a1e6e92 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -10,7 +10,7 @@ use hamcrest::{assert_that, equal_to, contains}; use cargo::core::source::{SourceId, GitReference}; use cargo::core::dependency::Kind::{self, Development}; use cargo::core::{Dependency, PackageId, Summary, Registry}; -use cargo::util::{CargoResult, ToUrl, Config}; +use cargo::util::{CargoResult, ToUrl}; use cargo::core::resolver::{self, Method}; fn resolve(pkg: PackageId, deps: Vec, @@ -33,8 +33,7 @@ impl ToDep for &'static str { fn to_dep(self) -> Dependency { let url = "http://example.com".to_url().unwrap(); let source_id = SourceId::for_registry(&url); - let config = Config::default().unwrap(); - Dependency::parse(self, Some("1.0.0"), &source_id, &config).unwrap() + Dependency::parse_no_deprecated(self, Some("1.0.0"), &source_id).unwrap() } } @@ -102,16 +101,14 @@ fn dep(name: &str) -> Dependency { dep_req(name, "1.0.0") } fn dep_req(name: &str, req: &str) -> Dependency { let url = "http://example.com".to_url().unwrap(); let source_id = SourceId::for_registry(&url); - let config = Config::default().unwrap(); - Dependency::parse(name, Some(req), &source_id, &config).unwrap() + Dependency::parse_no_deprecated(name, Some(req), &source_id).unwrap() } fn dep_loc(name: &str, location: &str) -> Dependency { let url = location.to_url().unwrap(); let master = GitReference::Branch("master".to_string()); let source_id = SourceId::for_git(&url, master); - let config = Config::default().unwrap(); - Dependency::parse(name, Some("1.0.0"), &source_id, &config).unwrap() + Dependency::parse_no_deprecated(name, Some("1.0.0"), &source_id).unwrap() } fn dep_kind(name: &str, kind: Kind) -> Dependency { dep(name).clone_inner().set_kind(kind).into_dependency() From c6d5f2aa0d90968603fdf909d45e53c9bb479f12 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Oct 2016 12:43:48 -0700 Subject: [PATCH 0766/3888] Add a test for deprecation warnings --- tests/registry.rs | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/tests/registry.rs b/tests/registry.rs index 34150a856b5..e95dc1e49ea 100644 --- a/tests/registry.rs +++ b/tests/registry.rs @@ -1242,3 +1242,101 @@ fn bump_version_dont_update_registry() { [FINISHED] [..] ")); } + +#[test] +fn old_version_req() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + remote = "0.2*" + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + Package::new("remote", "0.2.0").publish(); + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +warning: parsed version requirement `0.2*` is no longer valid + +Previous versions of Cargo accepted this malformed requirement, +but it is being deprecated. This was found when parsing the manifest +of bar 0.5.0, and the correct version requirement is `0.2.*`. + +This will soon become a hard error, so it's either recommended to +update to a fixed version or contact the upstream maintainer about +this warning. + +warning: parsed version requirement `0.2*` is no longer valid + +Previous versions of Cargo accepted this malformed requirement, +but it is being deprecated. This was found when parsing the manifest +of bar 0.5.0, and the correct version requirement is `0.2.*`. + +This will soon become a hard error, so it's either recommended to +update to a fixed version or contact the upstream maintainer about +this warning. + +[UPDATING] [..] +[DOWNLOADING] [..] +[COMPILING] [..] +[COMPILING] [..] +[FINISHED] [..] +")); +} + +#[test] +fn old_version_req_upstream() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + remote = "0.3" + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + Package::new("remote", "0.3.0") + .file("Cargo.toml", r#" + [project] + name = "remote" + version = "0.3.0" + authors = [] + + [dependencies] + bar = "0.2*" + "#) + .file("src/lib.rs", "") + .publish(); + Package::new("bar", "0.2.0").publish(); + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +[UPDATING] [..] +[DOWNLOADING] [..] +warning: parsed version requirement `0.2*` is no longer valid + +Previous versions of Cargo accepted this malformed requirement, +but it is being deprecated. This was found when parsing the manifest +of remote 0.3.0, and the correct version requirement is `0.2.*`. + +This will soon become a hard error, so it's either recommended to +update to a fixed version or contact the upstream maintainer about +this warning. + +[COMPILING] [..] +[COMPILING] [..] +[FINISHED] [..] +")); +} From a8aaaafeb71ed1032119ca1356eabec08c90a57f Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 7 Oct 2016 16:03:08 -0400 Subject: [PATCH 0767/3888] Bump to semver@0.5.0 --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a43b2b6208..fabedb41a84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.4.1 (git+https://github.com/steveklabnik/semver?branch=deprecation)", + "semver 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -522,8 +522,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "semver" -version = "0.4.1" -source = "git+https://github.com/steveklabnik/semver?branch=deprecation#a3b67d654d7e00ea0a05a37851f49352d79834a3" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -702,7 +702,7 @@ dependencies = [ "checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2" "checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199" "checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" -"checksum semver 0.4.1 (git+https://github.com/steveklabnik/semver?branch=deprecation)" = "" +"checksum semver 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a15f0ab63f6018942339e2c038253dba1eb4f8718fbca869b09f9a019572d954" "checksum semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e88e43a5a74dd2a11707f9c21dfd4a423c66bd871df813227bb0a3e78f3a1ae9" "checksum strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4d73a2c36a4d095ed1a6df5cbeac159863173447f7a82b3f4757426844ab825" "checksum tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "12e1b959f637c2e4c69dbdbf4d7dc609edbaada9b8c35d0c2fc9802d02383b65" diff --git a/Cargo.toml b/Cargo.toml index 563c865278d..99b15db7d2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ num_cpus = "1.0" psapi-sys = "0.1" regex = "0.1" rustc-serialize = "0.3" -semver = { git = "https://github.com/steveklabnik/semver", branch = "deprecation" } +semver = "0.5.0" tar = { version = "0.4", default-features = false } tempdir = "0.3" term = "0.4.4" From 597e1e30598a6e4c7ec7430a8fbd22eb436d4c18 Mon Sep 17 00:00:00 2001 From: Jake Goldsborough Date: Sat, 8 Oct 2016 17:30:55 -0700 Subject: [PATCH 0768/3888] removing return false causing links to break --- src/doc/javascripts/all.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/javascripts/all.js b/src/doc/javascripts/all.js index d2124a9528f..3fb0eef24c6 100644 --- a/src/doc/javascripts/all.js +++ b/src/doc/javascripts/all.js @@ -35,7 +35,6 @@ $(function() { var toggles = $('button.dropdown.active, a.dropdown.active'); toggles.toggleClass('active').siblings('ul').toggleClass('open'); - return false; } }); }); From 4b0e776fc6722309ec097a163643fdfe24331778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 10 Oct 2016 12:08:48 +0200 Subject: [PATCH 0769/3888] bump hamcrest to 0.1.1 --- Cargo.lock | 75 +++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fabedb41a84..c13d37a17af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ dependencies = [ "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "hamcrest 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -25,7 +25,7 @@ dependencies = [ "num_cpus 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -77,7 +77,7 @@ dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "hamcrest 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,7 +146,7 @@ version = "0.6.82" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -157,7 +157,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -230,10 +230,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hamcrest" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -361,34 +362,34 @@ dependencies = [ [[package]] name = "num" -version = "0.1.34" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-bigint 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "num-complex 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-complex 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "num-rational 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-bigint" -version = "0.1.33" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-complex" -version = "0.1.33" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -397,7 +398,7 @@ name = "num-integer" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -406,23 +407,23 @@ version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-rational" -version = "0.1.32" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-bigint 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.1.34" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -500,19 +501,19 @@ dependencies = [ [[package]] name = "regex" -version = "0.1.73" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -534,7 +535,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -650,7 +651,7 @@ dependencies = [ [metadata] "checksum advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e06588080cb19d0acb6739808aafa5f26bfb2ca015b2b6370028b44cf7cb8a9a" -"checksum aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2b3fb52b09c1710b961acb35390d514be82e4ac96a9969a8e38565a29b878dc9" +"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" "checksum bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a6577517ecd0ee0934f48a7295a89aaef3e6dfafeac404f94c0b3448518ddfe" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074" @@ -669,7 +670,7 @@ dependencies = [ "checksum git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "33a96eeef227403006cdb59ea6e05baad8cddde6b79abed753d96ccee136bad2" "checksum git2-curl 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d5f766d804e3cf2b90e16ab77c3ddedcb1ca5d2456cadb7b3f907345f8c3498" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" -"checksum hamcrest 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "27c180b409b988760a018e5cb5f0812bd67e87f40236e41d3b9375d3046e04ab" +"checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" "checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" @@ -684,13 +685,13 @@ dependencies = [ "checksum miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d1f4d337a01c32e1f2122510fed46393d53ca35a7f429cb0450abaedfa3ed54" "checksum miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5bfc6782530ac8ace97af10a540054a37126b63b0702ddaaa243b73b5745b9a" "checksum net2 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "5edf9cb6be97212423aed9413dd4729d62b370b5e1c571750e882cebbbc1e3e2" -"checksum num 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "d2ee34a0338c16ae67afb55824aaf8852700eb0f77ccd977807ccb7606b295f6" -"checksum num-bigint 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc450723a2fe91d332a29edd8660e099b937d29e1a3ebe914e0da3f77ac1ad3" -"checksum num-complex 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "8aabbc079e1855ce8415141fee0ebebf171f56505373b3a966e2716ad7c0e555" +"checksum num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "bde7c03b09e7c6a301ee81f6ddf66d7a28ec305699e3d3b056d2fc56470e3120" +"checksum num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "88b14378471f7c2adc5262f05b4701ef53e8da376453a8d8fee48e51db745e49" +"checksum num-complex 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c78e054dd19c3fd03419ade63fa661e9c49bb890ce3beb4eee5b7baf93f92f" "checksum num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "fb24d9bfb3f222010df27995441ded1e954f8f69cd35021f6bef02ca9552fb92" "checksum num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "287a1c9969a847055e1122ec0ea7a5c5d6f72aad97934e131c83d5c08ab4e45c" -"checksum num-rational 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "48cdcc9ff4ae2a8296805ac15af88b3d88ce62128ded0cb74ffb63a587502a84" -"checksum num-traits 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "95e58eac34596aac30ab134c8a8da9aa2dc99caa4b4b4838e6fc6e298016278f" +"checksum num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "54ff603b8334a72fbb27fe66948aac0abaaa40231b3cecd189e76162f6f38aaf" +"checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c" "checksum num_cpus 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a859041cbf7a70ea1ece4b87d1a2c6ef364dcb68749c88db1f97304b9ec09d5f" "checksum openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c4117b6244aac42ed0150a6019b4d953d28247c5dd6ae6f46ae469b5f2318733" "checksum openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ac5e9d911dd4c3202bbf4139b73bc7a1231f7d0a39432c6f893745f0e04120" @@ -699,8 +700,8 @@ dependencies = [ "checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b" "checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" "checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5" -"checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2" -"checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199" +"checksum regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)" = "64b03446c466d35b42f2a8b203c8e03ed8b91c0f17b56e1f84f7210a257aa665" +"checksum regex-syntax 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279401017ae31cf4e15344aa3f085d0e2e5c1e70067289ef906906fdbe92c8fd" "checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" "checksum semver 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a15f0ab63f6018942339e2c038253dba1eb4f8718fbca869b09f9a019572d954" "checksum semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e88e43a5a74dd2a11707f9c21dfd4a423c66bd871df813227bb0a3e78f3a1ae9" From 4e51c2d16724e5a077b6cf4a001ad93a1871e37c Mon Sep 17 00:00:00 2001 From: "E. Dunham" Date: Mon, 10 Oct 2016 15:15:08 -0700 Subject: [PATCH 0770/3888] empty path is not a thing on Windows --- tests/version.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/version.rs b/tests/version.rs index b017830b272..2171cef5e13 100644 --- a/tests/version.rs +++ b/tests/version.rs @@ -51,6 +51,7 @@ Options: } #[test] +#[cfg_attr(target_os = "windows", ignore)] fn version_works_without_rustc() { let p = project("foo"); assert_that(p.cargo_process("version").env("PATH", ""), From 2b3a4c0038ed23852b6e195dba105f6cbf3ee0fe Mon Sep 17 00:00:00 2001 From: "E. Dunham" Date: Mon, 10 Oct 2016 11:11:56 -0700 Subject: [PATCH 0771/3888] Expand matrix for #3186 --- appveyor.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index a6009fa5f1e..7c9839c2f9c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,19 +1,25 @@ environment: CFG_DISABLE_CROSS_TESTS: 1 matrix: - - MSVC: 1 + - TARGET: i686-pc-windows-msvc + MSVC: 1 BITS: 32 - TARGET: i686-pc-windows-msvc ARCH: x86 - - MSVC: 1 + - TARGET: x86_64-pc-windows-msvc + MSVC: 1 BITS: 64 - TARGET: x86_64-pc-windows-msvc ARCH: amd64 + - TARGET: x86_64-pc-windows-gnu + ARCH: amd64 + BITS: 32 + - TARGET: i686-pc-windows-gnu + ARCH: x86 + BITS: 64 install: + - IF "%MSVC%"=="" set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% - python src/etc/install-deps.py - python src/etc/dl-snapshot.py %TARGET% - - call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %ARCH% - SET PATH=%PATH%;%cd%/rustc/bin - SET PATH=%PATH%;%cd%/target/snapshot/bin - rustc -V @@ -23,7 +29,3 @@ build: false test_script: - cargo test - -branches: - only: - - master From e5ffcdac4ad83abadd40232cc933458120e95ba2 Mon Sep 17 00:00:00 2001 From: "E. Dunham" Date: Mon, 10 Oct 2016 12:33:22 -0700 Subject: [PATCH 0772/3888] Use a MinGW that doesn't break pthreads Also correct the bits to triples mapping, because tyops --- appveyor.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7c9839c2f9c..3017466e488 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,13 +11,19 @@ environment: ARCH: amd64 - TARGET: x86_64-pc-windows-gnu ARCH: amd64 - BITS: 32 + BITS: 64 - TARGET: i686-pc-windows-gnu ARCH: x86 - BITS: 64 + BITS: 32 + MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z + MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download + MINGW_DIR: mingw32 install: - IF "%MSVC%"=="" set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% + - if defined MINGW_ARCHIVE appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%" + - if defined MINGW_ARCHIVE 7z x -y "%MINGW_ARCHIVE%" > nul + - if defined MINGW_ARCHIVE set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% - python src/etc/install-deps.py - python src/etc/dl-snapshot.py %TARGET% - SET PATH=%PATH%;%cd%/rustc/bin From 2e226e47bf328cddad2eff6bac436ffc372bf8ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 12 Oct 2016 14:39:46 +0300 Subject: [PATCH 0773/3888] Remove command prototype --- src/cargo/ops/cargo_run.rs | 3 +- src/cargo/ops/cargo_rustc/command.rs | 89 ----------------------- src/cargo/ops/cargo_rustc/compilation.rs | 35 ++++++--- src/cargo/ops/cargo_rustc/custom_build.rs | 49 ++++++------- src/cargo/ops/cargo_rustc/job_queue.rs | 5 +- src/cargo/ops/cargo_rustc/mod.rs | 31 ++++---- src/cargo/ops/cargo_test.rs | 4 +- src/cargo/ops/mod.rs | 1 - 8 files changed, 68 insertions(+), 149 deletions(-) delete mode 100644 src/cargo/ops/cargo_rustc/command.rs diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index f994541cc02..34c28dbc4cb 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -48,8 +48,7 @@ pub fn run(ws: &Workspace, Some(path) => path.to_path_buf(), None => exe.to_path_buf(), }; - let mut process = try!(compile.target_process(exe, &root)) - .into_process_builder(); + let mut process = try!(compile.target_process(exe, &root)); process.args(args).cwd(config.cwd()); try!(config.shell().status("Running", process.to_string())); diff --git a/src/cargo/ops/cargo_rustc/command.rs b/src/cargo/ops/cargo_rustc/command.rs deleted file mode 100644 index d49951c8a12..00000000000 --- a/src/cargo/ops/cargo_rustc/command.rs +++ /dev/null @@ -1,89 +0,0 @@ -use std::collections::HashMap; -use std::ffi::{OsStr, OsString}; -use std::fmt; -use std::path::Path; - -use util::{CargoResult, ProcessBuilder, process}; -use util::Config; - -/// Prototype for a command that must be executed. -#[derive(Clone)] -pub struct CommandPrototype { - ty: CommandType, - builder: ProcessBuilder, -} - -impl CommandPrototype { - pub fn new(ty: CommandType, config: &Config) - -> CargoResult { - Ok(CommandPrototype { - builder: { - let mut p = match ty { - CommandType::Rustc => try!(config.rustc()).process(), - CommandType::Rustdoc => process(&*try!(config.rustdoc())), - CommandType::Target(ref s) | - CommandType::Host(ref s) => process(s), - }; - p.cwd(config.cwd()); - p - }, - ty: ty, - }) - } - - pub fn get_type(&self) -> &CommandType { &self.ty } - - pub fn arg>(&mut self, arg: T) -> &mut CommandPrototype { - self.builder.arg(arg); - self - } - - pub fn args>(&mut self, arguments: &[T]) -> &mut CommandPrototype { - self.builder.args(arguments); - self - } - - pub fn cwd>(&mut self, path: T) -> &mut CommandPrototype { - self.builder.cwd(path); - self - } - - pub fn env>(&mut self, key: &str, val: T) - -> &mut CommandPrototype { - self.builder.env(key, val); - self - } - - pub fn get_args(&self) -> &[OsString] { self.builder.get_args() } - pub fn get_cwd(&self) -> Option<&Path> { self.builder.get_cwd() } - - pub fn get_env(&self, var: &str) -> Option { - self.builder.get_env(var) - } - - pub fn get_envs(&self) -> &HashMap> { - self.builder.get_envs() - } - - pub fn into_process_builder(self) -> ProcessBuilder { - self.builder - } -} - -impl fmt::Display for CommandPrototype { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.builder.fmt(f) - } -} - -#[derive(Clone, Debug)] -pub enum CommandType { - Rustc, - Rustdoc, - - /// The command is to be executed for the target architecture. - Target(OsString), - - /// The command is to be executed for the host architecture. - Host(OsString), -} diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 23f0a044fcf..0c60751698f 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -1,12 +1,10 @@ use std::collections::{HashMap, HashSet}; -use std::ffi::OsStr; +use std::ffi::{OsStr, OsString}; use std::path::PathBuf; use semver::Version; use core::{PackageId, Package, Target}; -use util::{self, CargoResult, Config}; - -use super::{CommandType, CommandPrototype}; +use util::{self, CargoResult, Config, ProcessBuilder, process}; /// A structure returning the result of a compilation. pub struct Compilation<'cfg> { @@ -49,6 +47,18 @@ pub struct Compilation<'cfg> { config: &'cfg Config, } +#[derive(Clone, Debug)] +pub enum CommandType { + Rustc, + Rustdoc, + + /// The command is to be executed for the target architecture. + Target(OsString), + + /// The command is to be executed for the host architecture. + Host(OsString), +} + impl<'cfg> Compilation<'cfg> { pub fn new(config: &'cfg Config) -> Compilation<'cfg> { Compilation { @@ -67,25 +77,25 @@ impl<'cfg> Compilation<'cfg> { } /// See `process`. - pub fn rustc_process(&self, pkg: &Package) -> CargoResult { + pub fn rustc_process(&self, pkg: &Package) -> CargoResult { self.process(CommandType::Rustc, pkg) } /// See `process`. pub fn rustdoc_process(&self, pkg: &Package) - -> CargoResult { + -> CargoResult { self.process(CommandType::Rustdoc, pkg) } /// See `process`. pub fn target_process>(&self, cmd: T, pkg: &Package) - -> CargoResult { + -> CargoResult { self.process(CommandType::Target(cmd.as_ref().to_os_string()), pkg) } /// See `process`. pub fn host_process>(&self, cmd: T, pkg: &Package) - -> CargoResult { + -> CargoResult { self.process(CommandType::Host(cmd.as_ref().to_os_string()), pkg) } @@ -95,7 +105,7 @@ impl<'cfg> Compilation<'cfg> { /// The package argument is also used to configure environment variables as /// well as the working directory of the child process. pub fn process(&self, cmd: CommandType, pkg: &Package) - -> CargoResult { + -> CargoResult { let mut search_path = vec![]; // Add -L arguments, after stripping off prefixes like "native=" or "framework=". @@ -121,7 +131,12 @@ impl<'cfg> Compilation<'cfg> { search_path.extend(util::dylib_path().into_iter()); let search_path = try!(util::join_paths(&search_path, util::dylib_path_envvar())); - let mut cmd = try!(CommandPrototype::new(cmd, self.config)); + let mut cmd = match cmd { + CommandType::Rustc => try!(self.config.rustc()).process(), + CommandType::Rustdoc => process(&*try!(self.config.rustdoc())), + CommandType::Target(ref s) | + CommandType::Host(ref s) => process(s), + }; cmd.env(util::dylib_path_envvar(), &search_path); if let Some(env) = self.extra_env.get(pkg.package_id()) { for &(ref k, ref v) in env { diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 5a15e85a853..73dd34e6dd2 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -10,7 +10,7 @@ use util::{internal, ChainError, profile, paths}; use super::job::Work; use super::{fingerprint, Kind, Context, Unit}; -use super::CommandType; +use super::compilation::CommandType; /// Contains the parsed output of a custom build script. #[derive(Clone, Debug, Hash)] @@ -98,30 +98,30 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // package's library profile. let profile = cx.lib_profile(unit.pkg.package_id()); let to_exec = to_exec.into_os_string(); - let mut p = try!(super::process(CommandType::Host(to_exec), unit.pkg, cx)); - p.env("OUT_DIR", &build_output) - .env("CARGO_MANIFEST_DIR", unit.pkg.root()) - .env("NUM_JOBS", &cx.jobs().to_string()) - .env("TARGET", &match unit.kind { - Kind::Host => cx.host_triple(), - Kind::Target => cx.target_triple(), - }) - .env("DEBUG", &profile.debuginfo.to_string()) - .env("OPT_LEVEL", &profile.opt_level) - .env("PROFILE", if cx.build_config.release {"release"} else {"debug"}) - .env("HOST", cx.host_triple()) - .env("RUSTC", &try!(cx.config.rustc()).path) - .env("RUSTDOC", &*try!(cx.config.rustdoc())); - - if let Some(links) = unit.pkg.manifest().links(){ - p.env("CARGO_MANIFEST_LINKS", links); - } + let mut cmd = try!(super::process(CommandType::Host(to_exec), unit.pkg, cx)); + cmd.env("OUT_DIR", &build_output) + .env("CARGO_MANIFEST_DIR", unit.pkg.root()) + .env("NUM_JOBS", &cx.jobs().to_string()) + .env("TARGET", &match unit.kind { + Kind::Host => cx.host_triple(), + Kind::Target => cx.target_triple(), + }) + .env("DEBUG", &profile.debuginfo.to_string()) + .env("OPT_LEVEL", &profile.opt_level) + .env("PROFILE", if cx.build_config.release { "release" } else { "debug" }) + .env("HOST", cx.host_triple()) + .env("RUSTC", &try!(cx.config.rustc()).path) + .env("RUSTDOC", &*try!(cx.config.rustdoc())); + + if let Some(links) = unit.pkg.manifest().links() { + cmd.env("CARGO_MANIFEST_LINKS", links); + } // Be sure to pass along all enabled features for this package, this is the // last piece of statically known information that we have. if let Some(features) = cx.resolve.features(unit.pkg.package_id()) { for feat in features.iter() { - p.env(&format!("CARGO_FEATURE_{}", super::envify(feat)), "1"); + cmd.env(&format!("CARGO_FEATURE_{}", super::envify(feat)), "1"); } } @@ -192,19 +192,18 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) })); let data = &state.metadata; for &(ref key, ref value) in data.iter() { - p.env(&format!("DEP_{}_{}", super::envify(&name), - super::envify(key)), value); + cmd.env(&format!("DEP_{}_{}", super::envify(&name), + super::envify(key)), value); } } if let Some(build_scripts) = build_scripts { - try!(super::add_plugin_deps(&mut p, &build_state, + try!(super::add_plugin_deps(&mut cmd, &build_state, &build_scripts)); } } // And now finally, run the build command itself! - state.running(&p); - let cmd = p.into_process_builder(); + state.running(&cmd); let output = try!(cmd.exec_with_streaming( &mut |out_line| { state.stdout(out_line); Ok(()) }, &mut |err_line| { state.stderr(err_line); Ok(()) }, diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index d02d841b828..39d1c45a785 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -9,11 +9,10 @@ use term::color::YELLOW; use core::{PackageId, Target, Profile}; use util::{Config, DependencyQueue, Fresh, Dirty, Freshness}; -use util::{CargoResult, profile, internal}; +use util::{CargoResult, ProcessBuilder, profile, internal}; use super::{Context, Kind, Unit}; use super::job::Job; -use super::command::CommandPrototype; /// A management structure of the entire dependency graph to compile. /// @@ -64,7 +63,7 @@ enum Message { } impl<'a> JobState<'a> { - pub fn running(&self, cmd: &CommandPrototype) { + pub fn running(&self, cmd: &ProcessBuilder) { let _ = self.tx.send((self.key, Message::Run(cmd.to_string()))); } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 1efcc2b0c1d..88328cb9911 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -10,19 +10,17 @@ use rustc_serialize::json; use core::{Package, PackageId, PackageSet, Target, Resolve}; use core::{Profile, Profiles, Workspace}; use core::shell::ColorConfig; -use util::{self, CargoResult, human, machine_message}; +use util::{self, CargoResult, ProcessBuilder, human, machine_message}; use util::{Config, internal, ChainError, profile, join_paths, short_hash}; use self::job::{Job, Work}; use self::job_queue::JobQueue; -pub use self::compilation::Compilation; +pub use self::compilation::{Compilation, CommandType}; pub use self::context::{Context, Unit}; -pub use self::command::{CommandPrototype, CommandType}; pub use self::layout::{Layout, LayoutProxy}; pub use self::custom_build::{BuildOutput, BuildMap, BuildScripts}; -mod command; mod compilation; mod context; mod custom_build; @@ -270,9 +268,8 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { } state.running(&rustc); - let process_builder = rustc.into_process_builder(); try!(if json_errors { - process_builder.exec_with_streaming( + rustc.exec_with_streaming( &mut |line| if !line.is_empty() { Err(internal(&format!("compiler stdout is not empty: `{}`", line))) } else { @@ -293,7 +290,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { }, ).map(|_| ()) } else { - process_builder.exec() + rustc.exec() }.chain_error(|| { human(format!("Could not compile `{}`.", name)) })); @@ -359,7 +356,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { // Add all relevant -L and -l flags from dependencies (now calculated and // present in `state`) to the command provided - fn add_native_deps(rustc: &mut CommandPrototype, + fn add_native_deps(rustc: &mut ProcessBuilder, build_state: &BuildMap, build_scripts: &BuildScripts, pass_l_flag: bool, @@ -394,7 +391,7 @@ fn load_build_deps(cx: &Context, unit: &Unit) -> Option> { // For all plugin dependencies, add their -L paths (now calculated and // present in `state`) to the dynamic library load path for the command to // execute. -fn add_plugin_deps(rustc: &mut CommandPrototype, +fn add_plugin_deps(rustc: &mut ProcessBuilder, build_state: &BuildMap, build_scripts: &BuildScripts) -> CargoResult<()> { @@ -417,7 +414,7 @@ fn add_plugin_deps(rustc: &mut CommandPrototype, fn prepare_rustc(cx: &Context, crate_types: Vec<&str>, - unit: &Unit) -> CargoResult { + unit: &Unit) -> CargoResult { let mut base = try!(process(CommandType::Rustc, unit.pkg, cx)); build_base_args(cx, &mut base, unit, &crate_types); build_plugin_args(&mut base, cx, unit); @@ -474,7 +471,7 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { } } state.running(&rustdoc); - rustdoc.into_process_builder().exec().chain_error(|| { + rustdoc.exec().chain_error(|| { human(format!("Could not document `{}`.", name)) }) })) @@ -502,7 +499,7 @@ fn root_path(cx: &Context, unit: &Unit) -> PathBuf { } fn build_base_args(cx: &Context, - cmd: &mut CommandPrototype, + cmd: &mut ProcessBuilder, unit: &Unit, crate_types: &[&str]) { let Profile { @@ -616,8 +613,8 @@ fn build_base_args(cx: &Context, } -fn build_plugin_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) { - fn opt(cmd: &mut CommandPrototype, key: &str, prefix: &str, +fn build_plugin_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) { + fn opt(cmd: &mut ProcessBuilder, key: &str, prefix: &str, val: Option<&OsStr>) { if let Some(val) = val { let mut joined = OsString::from(prefix); @@ -637,7 +634,7 @@ fn build_plugin_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) { opt(cmd, "-C", "linker=", cx.linker(unit.kind).map(|s| s.as_ref())); } -fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) +fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) -> CargoResult<()> { let layout = cx.layout(unit); cmd.arg("-L").arg(&{ @@ -658,7 +655,7 @@ fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) return Ok(()); - fn link_to(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) + fn link_to(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) -> CargoResult<()> { for (filename, linkable) in try!(cx.target_filenames(unit)) { if !linkable { @@ -677,7 +674,7 @@ fn build_deps_args(cmd: &mut CommandPrototype, cx: &Context, unit: &Unit) } pub fn process(cmd: CommandType, pkg: &Package, - cx: &Context) -> CargoResult { + cx: &Context) -> CargoResult { // When invoking a tool, we need the *host* deps directory in the dynamic // library search path for plugins and such which have dynamic dependencies. let mut search_path = util::dylib_path(); diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index d73ec8103fa..71a22d4e461 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -98,7 +98,7 @@ fn run_unit_tests(options: &TestOptions, shell.status("Running", cmd.to_string()) })); - if let Err(e) = cmd.into_process_builder().exec() { + if let Err(e) = cmd.exec() { errors.push(e); if !options.no_fail_fast { break @@ -175,7 +175,7 @@ fn run_doc_tests(options: &TestOptions, try!(config.shell().verbose(|shell| { shell.status("Running", p.to_string()) })); - if let Err(e) = p.into_process_builder().exec() { + if let Err(e) = p.exec() { errors.push(e); if !options.no_fail_fast { return Ok(errors); diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 4d646ea3058..ff4583c569a 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -5,7 +5,6 @@ pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages}; pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind, Unit}; pub use self::cargo_rustc::{Context, LayoutProxy}; pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig}; -pub use self::cargo_rustc::{CommandType, CommandPrototype}; pub use self::cargo_run::run; pub use self::cargo_install::{install, install_list, uninstall}; pub use self::cargo_new::{new, init, NewOptions, VersionControl}; From a4b7a03da7d5299b5574a960053445c5a96f68fd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Oct 2016 18:36:12 +0300 Subject: [PATCH 0774/3888] Remove CommandType struct --- src/cargo/ops/cargo_rustc/compilation.rs | 98 +++++++++++------------ src/cargo/ops/cargo_rustc/custom_build.rs | 3 +- src/cargo/ops/cargo_rustc/mod.rs | 21 +---- src/cargo/ops/cargo_test.rs | 2 +- 4 files changed, 50 insertions(+), 74 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 0c60751698f..88a935247f5 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -1,10 +1,10 @@ use std::collections::{HashMap, HashSet}; -use std::ffi::{OsStr, OsString}; -use std::path::PathBuf; +use std::ffi::OsStr; +use std::path::{Path, PathBuf}; use semver::Version; use core::{PackageId, Package, Target}; -use util::{self, CargoResult, Config, ProcessBuilder, process}; +use util::{self, CargoResult, Config, ProcessBuilder, process, join_paths}; /// A structure returning the result of a compilation. pub struct Compilation<'cfg> { @@ -47,18 +47,6 @@ pub struct Compilation<'cfg> { config: &'cfg Config, } -#[derive(Clone, Debug)] -pub enum CommandType { - Rustc, - Rustdoc, - - /// The command is to be executed for the target architecture. - Target(OsString), - - /// The command is to be executed for the host architecture. - Host(OsString), -} - impl<'cfg> Compilation<'cfg> { pub fn new(config: &'cfg Config) -> Compilation<'cfg> { Compilation { @@ -77,26 +65,27 @@ impl<'cfg> Compilation<'cfg> { } /// See `process`. - pub fn rustc_process(&self, pkg: &Package) -> CargoResult { - self.process(CommandType::Rustc, pkg) + pub fn rustc_process(&self, pkg: &Package, host_dylib_path: &Path) + -> CargoResult { + self.fill_env(try!(self.config.rustc()).process(), pkg, Some(host_dylib_path)) } /// See `process`. - pub fn rustdoc_process(&self, pkg: &Package) + pub fn rustdoc_process(&self, pkg: &Package, host_dylib_path: Option<&Path>) -> CargoResult { - self.process(CommandType::Rustdoc, pkg) + self.fill_env(process(&*try!(self.config.rustdoc())), pkg, host_dylib_path) } /// See `process`. pub fn target_process>(&self, cmd: T, pkg: &Package) -> CargoResult { - self.process(CommandType::Target(cmd.as_ref().to_os_string()), pkg) + self.fill_env(process(cmd), pkg, None) } /// See `process`. - pub fn host_process>(&self, cmd: T, pkg: &Package) + pub fn host_process>(&self, cmd: T, pkg: &Package, host_dylib_path: &Path) -> CargoResult { - self.process(CommandType::Host(cmd.as_ref().to_os_string()), pkg) + self.fill_env(process(cmd), pkg, Some(host_dylib_path)) } /// Prepares a new process with an appropriate environment to run against @@ -104,39 +93,42 @@ impl<'cfg> Compilation<'cfg> { /// /// The package argument is also used to configure environment variables as /// well as the working directory of the child process. - pub fn process(&self, cmd: CommandType, pkg: &Package) - -> CargoResult { - let mut search_path = vec![]; - - // Add -L arguments, after stripping off prefixes like "native=" or "framework=". - for dir in self.native_dirs.iter() { - let dir = match dir.to_str() { - Some(s) => { - let mut parts = s.splitn(2, '='); - match (parts.next(), parts.next()) { - (Some("native"), Some(path)) | - (Some("crate"), Some(path)) | - (Some("dependency"), Some(path)) | - (Some("framework"), Some(path)) | - (Some("all"), Some(path)) => path.into(), - _ => dir.clone(), + fn fill_env(&self, mut cmd: ProcessBuilder, pkg: &Package, host_dylib_path: Option<&Path>) + -> CargoResult { + + let mut search_path = if let Some(host_dylib_path) = host_dylib_path { + // When invoking a tool, we need the *host* deps directory in the dynamic + // library search path for plugins and such which have dynamic dependencies. + vec![host_dylib_path.to_path_buf()] + } else { + let mut search_path = vec![]; + + // Add -L arguments, after stripping off prefixes like "native=" or "framework=". + for dir in self.native_dirs.iter() { + let dir = match dir.to_str() { + Some(s) => { + let mut parts = s.splitn(2, '='); + match (parts.next(), parts.next()) { + (Some("native"), Some(path)) | + (Some("crate"), Some(path)) | + (Some("dependency"), Some(path)) | + (Some("framework"), Some(path)) | + (Some("all"), Some(path)) => path.into(), + _ => dir.clone(), + } } - } - None => dir.clone(), - }; - search_path.push(dir); - } - search_path.push(self.root_output.clone()); - search_path.push(self.deps_output.clone()); - search_path.extend(util::dylib_path().into_iter()); - let search_path = try!(util::join_paths(&search_path, - util::dylib_path_envvar())); - let mut cmd = match cmd { - CommandType::Rustc => try!(self.config.rustc()).process(), - CommandType::Rustdoc => process(&*try!(self.config.rustdoc())), - CommandType::Target(ref s) | - CommandType::Host(ref s) => process(s), + None => dir.clone(), + }; + search_path.push(dir); + } + search_path.push(self.root_output.clone()); + search_path.push(self.deps_output.clone()); + search_path }; + + search_path.extend(util::dylib_path().into_iter()); + let search_path = try!(join_paths(&search_path, util::dylib_path_envvar())); + cmd.env(util::dylib_path_envvar(), &search_path); if let Some(env) = self.extra_env.get(pkg.package_id()) { for &(ref k, ref v) in env { diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 73dd34e6dd2..bca5d018d11 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -10,7 +10,6 @@ use util::{internal, ChainError, profile, paths}; use super::job::Work; use super::{fingerprint, Kind, Context, Unit}; -use super::compilation::CommandType; /// Contains the parsed output of a custom build script. #[derive(Clone, Debug, Hash)] @@ -98,7 +97,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // package's library profile. let profile = cx.lib_profile(unit.pkg.package_id()); let to_exec = to_exec.into_os_string(); - let mut cmd = try!(super::process(CommandType::Host(to_exec), unit.pkg, cx)); + let mut cmd = try!(cx.compilation.host_process(to_exec, unit.pkg, cx.host_dylib_path())); cmd.env("OUT_DIR", &build_output) .env("CARGO_MANIFEST_DIR", unit.pkg.root()) .env("NUM_JOBS", &cx.jobs().to_string()) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 88328cb9911..459fb81dd1b 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -16,7 +16,7 @@ use util::{Config, internal, ChainError, profile, join_paths, short_hash}; use self::job::{Job, Work}; use self::job_queue::JobQueue; -pub use self::compilation::{Compilation, CommandType}; +pub use self::compilation::Compilation; pub use self::context::{Context, Unit}; pub use self::layout::{Layout, LayoutProxy}; pub use self::custom_build::{BuildOutput, BuildMap, BuildScripts}; @@ -415,7 +415,7 @@ fn add_plugin_deps(rustc: &mut ProcessBuilder, fn prepare_rustc(cx: &Context, crate_types: Vec<&str>, unit: &Unit) -> CargoResult { - let mut base = try!(process(CommandType::Rustc, unit.pkg, cx)); + let mut base = try!(cx.compilation.rustc_process(unit.pkg, cx.host_dylib_path())); build_base_args(cx, &mut base, unit, &crate_types); build_plugin_args(&mut base, cx, unit); try!(build_deps_args(&mut base, cx, unit)); @@ -424,7 +424,7 @@ fn prepare_rustc(cx: &Context, fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { - let mut rustdoc = try!(process(CommandType::Rustdoc, unit.pkg, cx)); + let mut rustdoc = try!(cx.compilation.rustdoc_process(unit.pkg, Some(cx.host_dylib_path()))); rustdoc.arg(&root_path(cx, unit)) .cwd(cx.config.cwd()) .arg("--crate-name").arg(&unit.target.crate_name()); @@ -673,21 +673,6 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) } } -pub fn process(cmd: CommandType, pkg: &Package, - cx: &Context) -> CargoResult { - // When invoking a tool, we need the *host* deps directory in the dynamic - // library search path for plugins and such which have dynamic dependencies. - let mut search_path = util::dylib_path(); - search_path.push(cx.host_dylib_path().to_path_buf()); - - // We want to use the same environment and such as normal processes, but we - // want to override the dylib search path with the one we just calculated. - let search_path = try!(join_paths(&search_path, util::dylib_path_envvar())); - let mut cmd = try!(cx.compilation.process(cmd, pkg)); - cmd.env(util::dylib_path_envvar(), &search_path); - Ok(cmd) -} - fn envify(s: &str) -> String { s.chars() .flat_map(|c| c.to_uppercase()) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 71a22d4e461..aa4a23ba02b 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -128,7 +128,7 @@ fn run_doc_tests(options: &TestOptions, for (package, tests) in libs { for (lib, name, crate_name) in tests { try!(config.shell().status("Doc-tests", name)); - let mut p = try!(compilation.rustdoc_process(package)); + let mut p = try!(compilation.rustdoc_process(package, None)); p.arg("--test").arg(lib) .arg("--crate-name").arg(&crate_name); From f04d9d3ca6031add943b677877384b1270500329 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Oct 2016 19:30:59 +0300 Subject: [PATCH 0775/3888] Store host dylib path in compilation --- src/cargo/ops/cargo_rustc/compilation.rs | 37 ++++++++++++----------- src/cargo/ops/cargo_rustc/context.rs | 7 ++--- src/cargo/ops/cargo_rustc/custom_build.rs | 2 +- src/cargo/ops/cargo_rustc/mod.rs | 4 +-- src/cargo/ops/cargo_test.rs | 2 +- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 88a935247f5..89dfd12daa2 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -1,6 +1,6 @@ use std::collections::{HashMap, HashSet}; use std::ffi::OsStr; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use semver::Version; use core::{PackageId, Package, Target}; @@ -33,6 +33,10 @@ pub struct Compilation<'cfg> { /// Output directory for rust dependencies pub deps_output: PathBuf, + /// Library search path for compiler plugins and build scripts + /// which have dynamic dependencies. + pub plugins_dylib_path: PathBuf, + /// Extra environment variables that were passed to compilations and should /// be passed to future invocations of programs. pub extra_env: HashMap>, @@ -54,6 +58,7 @@ impl<'cfg> Compilation<'cfg> { native_dirs: HashSet::new(), // TODO: deprecated, remove root_output: PathBuf::from("/"), deps_output: PathBuf::from("/"), + plugins_dylib_path: PathBuf::from("/"), tests: Vec::new(), binaries: Vec::new(), extra_env: HashMap::new(), @@ -65,27 +70,25 @@ impl<'cfg> Compilation<'cfg> { } /// See `process`. - pub fn rustc_process(&self, pkg: &Package, host_dylib_path: &Path) - -> CargoResult { - self.fill_env(try!(self.config.rustc()).process(), pkg, Some(host_dylib_path)) + pub fn rustc_process(&self, pkg: &Package) -> CargoResult { + self.fill_env(try!(self.config.rustc()).process(), pkg, true) } /// See `process`. - pub fn rustdoc_process(&self, pkg: &Package, host_dylib_path: Option<&Path>) - -> CargoResult { - self.fill_env(process(&*try!(self.config.rustdoc())), pkg, host_dylib_path) + pub fn rustdoc_process(&self, pkg: &Package) -> CargoResult { + self.fill_env(process(&*try!(self.config.rustdoc())), pkg, true) } /// See `process`. - pub fn target_process>(&self, cmd: T, pkg: &Package) - -> CargoResult { - self.fill_env(process(cmd), pkg, None) + pub fn host_process>(&self, cmd: T, pkg: &Package) + -> CargoResult { + self.fill_env(process(cmd), pkg, true) } /// See `process`. - pub fn host_process>(&self, cmd: T, pkg: &Package, host_dylib_path: &Path) - -> CargoResult { - self.fill_env(process(cmd), pkg, Some(host_dylib_path)) + pub fn target_process>(&self, cmd: T, pkg: &Package) + -> CargoResult { + self.fill_env(process(cmd), pkg, false) } /// Prepares a new process with an appropriate environment to run against @@ -93,13 +96,11 @@ impl<'cfg> Compilation<'cfg> { /// /// The package argument is also used to configure environment variables as /// well as the working directory of the child process. - fn fill_env(&self, mut cmd: ProcessBuilder, pkg: &Package, host_dylib_path: Option<&Path>) + fn fill_env(&self, mut cmd: ProcessBuilder, pkg: &Package, is_host: bool) -> CargoResult { - let mut search_path = if let Some(host_dylib_path) = host_dylib_path { - // When invoking a tool, we need the *host* deps directory in the dynamic - // library search path for plugins and such which have dynamic dependencies. - vec![host_dylib_path.to_path_buf()] + let mut search_path = if is_host { + vec![self.plugins_dylib_path.clone()] } else { let mut search_path = vec![]; diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index e7f57fe57d2..59aa170212c 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -110,6 +110,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { None => {} } + self.compilation.plugins_dylib_path = 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(); self.compilation.deps_output = layout.deps().to_path_buf(); @@ -280,11 +282,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } - /// Returns the path for plugin/dylib dependencies - pub fn host_dylib_path(&self) -> &Path { - self.host.deps() - } - /// Returns the appropriate output directory for the specified package and /// target. pub fn out_dir(&self, unit: &Unit) -> PathBuf { diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index bca5d018d11..6a324a378a1 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -97,7 +97,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // package's library profile. let profile = cx.lib_profile(unit.pkg.package_id()); let to_exec = to_exec.into_os_string(); - let mut cmd = try!(cx.compilation.host_process(to_exec, unit.pkg, cx.host_dylib_path())); + let mut cmd = try!(cx.compilation.host_process(to_exec, unit.pkg)); cmd.env("OUT_DIR", &build_output) .env("CARGO_MANIFEST_DIR", unit.pkg.root()) .env("NUM_JOBS", &cx.jobs().to_string()) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 459fb81dd1b..33f86c0ef1b 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -415,7 +415,7 @@ fn add_plugin_deps(rustc: &mut ProcessBuilder, fn prepare_rustc(cx: &Context, crate_types: Vec<&str>, unit: &Unit) -> CargoResult { - let mut base = try!(cx.compilation.rustc_process(unit.pkg, cx.host_dylib_path())); + let mut base = try!(cx.compilation.rustc_process(unit.pkg)); build_base_args(cx, &mut base, unit, &crate_types); build_plugin_args(&mut base, cx, unit); try!(build_deps_args(&mut base, cx, unit)); @@ -424,7 +424,7 @@ fn prepare_rustc(cx: &Context, fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { - let mut rustdoc = try!(cx.compilation.rustdoc_process(unit.pkg, Some(cx.host_dylib_path()))); + let mut rustdoc = try!(cx.compilation.rustdoc_process(unit.pkg)); rustdoc.arg(&root_path(cx, unit)) .cwd(cx.config.cwd()) .arg("--crate-name").arg(&unit.target.crate_name()); diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index aa4a23ba02b..71a22d4e461 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -128,7 +128,7 @@ fn run_doc_tests(options: &TestOptions, for (package, tests) in libs { for (lib, name, crate_name) in tests { try!(config.shell().status("Doc-tests", name)); - let mut p = try!(compilation.rustdoc_process(package, None)); + let mut p = try!(compilation.rustdoc_process(package)); p.arg("--test").arg(lib) .arg("--crate-name").arg(&crate_name); From 2ee36d45759d139902e29cd8b1e9e46ba48b556d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 15 Oct 2016 00:47:47 -0700 Subject: [PATCH 0776/3888] Prepare for more cross-compiled Cargos Update deps, add support, ensure everything compiles right. --- Cargo.lock | 64 ++++++++++++++++++++--------------------- Makefile.in | 11 ++++++- configure | 16 +++++++++++ src/cargo/util/flock.rs | 2 +- 4 files changed, 59 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c13d37a17af..4652a34081d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,7 +79,7 @@ dependencies = [ "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -99,7 +99,7 @@ name = "cmake" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -122,7 +122,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -132,8 +132,8 @@ name = "curl-sys" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ name = "filetime" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -173,7 +173,7 @@ name = "flate2" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -183,13 +183,13 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gcc" -version = "0.3.32" +version = "0.3.35" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -207,7 +207,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -263,7 +263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -272,8 +272,8 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -294,7 +294,7 @@ version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -305,8 +305,8 @@ name = "libz-sys" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -325,7 +325,7 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -333,8 +333,8 @@ name = "miniz-sys" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -355,7 +355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -431,7 +431,7 @@ name = "num_cpus" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -440,9 +440,9 @@ version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys-extras 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -453,7 +453,7 @@ version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -464,8 +464,8 @@ name = "openssl-sys-extras" version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -496,7 +496,7 @@ name = "rand" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -549,7 +549,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -575,7 +575,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -665,7 +665,7 @@ dependencies = [ "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" "checksum flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "3eeb481e957304178d2e782f2da1257f1434dfecbae883bafb61ada2a9fea3bb" "checksum fs2 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bcd414e5a1a979b931bb92f41b7a54106d3f6d2e6c253e9ce943b7cd468251ef" -"checksum gcc 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb000abd6df9df4c637f75190297ebe56c1d7e66b56bbf3b4aa7aece15f61a2" +"checksum gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "91ecd03771effb0c968fd6950b37e89476a578aaf1c70297d8e92b6516ec3312" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" "checksum git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "33a96eeef227403006cdb59ea6e05baad8cddde6b79abed753d96ccee136bad2" "checksum git2-curl 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d5f766d804e3cf2b90e16ab77c3ddedcb1ca5d2456cadb7b3f907345f8c3498" @@ -674,7 +674,7 @@ dependencies = [ "checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" -"checksum libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "23e3757828fa702a20072c37ff47938e9dd331b92fac6e223d26d4b7a55f7ee2" +"checksum libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "408014cace30ee0f767b1c4517980646a573ec61a57957aeeabcac8ac0a02e8d" "checksum libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3293dc95169a6351c5a03eca4bf5549f3a9a06336a000315876ff1165a5fba10" "checksum libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc058951ab6a3ef35ca16462d7642c4867e6403520811f28537a4e2f2db3e71" "checksum libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "1debd7e56d19655eb786f827675dc55f6d530de6d7b81e76d13d1afc635d6c07" diff --git a/Makefile.in b/Makefile.in index c4f48cc820d..0b6cf33089a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -174,9 +174,12 @@ OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf OPENSSL_OS_i686-unknown-linux-gnu := linux-elf OPENSSL_OS_mips-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32 +OPENSSL_OS_mips64-unknown-linux-gnuabi64 := linux64-mips64 +OPENSSL_OS_mips64el-unknown-linux-gnuabi64 := linux64-mips64 OPENSSL_OS_powerpc-unknown-linux-gnu := linux-ppc OPENSSL_OS_powerpc64-unknown-linux-gnu := linux-ppc64 OPENSSL_OS_powerpc64le-unknown-linux-gnu := linux-ppc64le +OPENSSL_OS_s390x-unknown-linux-gnu := linux64-s390x OPENSSL_OS_x86_64-unknown-freebsd := BSD-x86_64 OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64 OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64 @@ -189,10 +192,13 @@ OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar OPENSSL_AR_i686-unknown-linux-gnu := ar OPENSSL_AR_mips-unknown-linux-gnu := mips-linux-gnu-ar +OPENSSL_AR_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-ar +OPENSSL_AR_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-ar OPENSSL_AR_mipsel-unknown-linux-gnu := mipsel-linux-gnu-ar OPENSSL_AR_powerpc-unknown-linux-gnu := powerpc-linux-gnu-ar OPENSSL_AR_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-ar OPENSSL_AR_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-ar +OPENSSL_AR_s390x-unknown-linux-gnu := s390x-linux-gnu-ar OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar OPENSSL_AR_x86_64-unknown-linux-gnu := ar OPENSSL_AR_x86_64-unknown-linux-musl := ar @@ -204,10 +210,13 @@ OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc OPENSSL_CC_i686-unknown-linux-gnu := gcc OPENSSL_CC_mips-unknown-linux-gnu := mips-linux-gnu-gcc +OPENSSL_CC_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-gcc +OPENSSL_CC_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-gcc OPENSSL_CC_mipsel-unknown-linux-gnu := mipsel-linux-gnu-gcc OPENSSL_CC_powerpc-unknown-linux-gnu := powerpc-linux-gnu-gcc -OPENSSL_CC_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-gcc +OPENSSL_CC_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-gcc-5 OPENSSL_CC_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-gcc +OPENSSL_CC_s390x-unknown-linux-gnu := s390x-linux-gnu-gcc OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc OPENSSL_CC_x86_64-unknown-linux-gnu := gcc OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc diff --git a/configure b/configure index 22108f7f88c..66400d80cef 100755 --- a/configure +++ b/configure @@ -413,6 +413,22 @@ linker = "i686-unknown-freebsd10-gcc" linker = "x86_64-unknown-freebsd10-gcc" [target.x86_64-unknown-netbsd] linker = "x86_64-unknown-netbsd-gcc" +[target.powerpc-unknown-linux-gnu] +linker = "powerpc-linux-gnu-gcc" +[target.powerpc64-unknown-linux-gnu] +linker = "powerpc64-linux-gnu-gcc-5" +[target.powerpc64le-unknown-linux-gnu] +linker = "powerpc64le-linux-gnu-gcc" +[target.mips-unknown-linux-gnu] +linker = "mips-linux-gnu-gcc" +[target.mipsel-unknown-linux-gnu] +linker = "mipsel-linux-gnu-gcc" +[target.mips64el-unknown-linux-gnuabi64] +linker = "mips64el-linux-gnuabi64-gcc" +[target.mips64-unknown-linux-gnuabi64] +linker = "mips64-linux-gnuabi64-gcc" +[target.s390x-unknown-linux-gnu] +linker = "s390x-linux-gnu-gcc" EOF fi fi diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index 3e4530b56eb..f90fa596f28 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -306,7 +306,7 @@ fn acquire(config: &Config, let mut buf: libc::statfs = mem::zeroed(); let r = libc::statfs(path.as_ptr(), &mut buf); - r == 0 && buf.f_type == libc::NFS_SUPER_MAGIC + r == 0 && buf.f_type as u32 == libc::NFS_SUPER_MAGIC as u32 } } From 62ef1df331a42b168f206c17e7d5cd092a698e25 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 17 Oct 2016 16:40:27 +0300 Subject: [PATCH 0777/3888] Pass target environment for rustdoc --- src/cargo/ops/cargo_rustc/compilation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 89dfd12daa2..93dead30743 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -76,7 +76,7 @@ impl<'cfg> Compilation<'cfg> { /// See `process`. pub fn rustdoc_process(&self, pkg: &Package) -> CargoResult { - self.fill_env(process(&*try!(self.config.rustdoc())), pkg, true) + self.fill_env(process(&*try!(self.config.rustdoc())), pkg, false) } /// See `process`. From a3a21a9d4de910ae6387b3d154569d179b961691 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 17 Oct 2016 14:42:20 -0400 Subject: [PATCH 0778/3888] bump semver to 0.5.1 Fixes #3202 --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4652a34081d..7185e3b831c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ dependencies = [ "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -523,7 +523,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "semver" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -703,7 +703,7 @@ dependencies = [ "checksum regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)" = "64b03446c466d35b42f2a8b203c8e03ed8b91c0f17b56e1f84f7210a257aa665" "checksum regex-syntax 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279401017ae31cf4e15344aa3f085d0e2e5c1e70067289ef906906fdbe92c8fd" "checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" -"checksum semver 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a15f0ab63f6018942339e2c038253dba1eb4f8718fbca869b09f9a019572d954" +"checksum semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae2ff60ecdb19c255841c066cbfa5f8c2a4ada1eb3ae47c77ab6667128da71f5" "checksum semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e88e43a5a74dd2a11707f9c21dfd4a423c66bd871df813227bb0a3e78f3a1ae9" "checksum strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4d73a2c36a4d095ed1a6df5cbeac159863173447f7a82b3f4757426844ab825" "checksum tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "12e1b959f637c2e4c69dbdbf4d7dc609edbaada9b8c35d0c2fc9802d02383b65" From bb34a9cb65b44518289dd23e824c1070e7518d63 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Tue, 18 Oct 2016 00:24:53 -0500 Subject: [PATCH 0779/3888] pkgid: add the -p flag as the output suggests When you use this command and there are multiple packages that match this spec, the help instructions tell you to rerun it with the -p argument which was previously not present. Since the code paths are shared with 'cargo build' and 'cargo update', this adds the -p argument to 'cargo pkgid' to make things more consistent. Signed-off-by: Doug Goldstein --- src/bin/pkgid.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bin/pkgid.rs b/src/bin/pkgid.rs index 13aedf257a7..f9d90523cea 100644 --- a/src/bin/pkgid.rs +++ b/src/bin/pkgid.rs @@ -11,6 +11,7 @@ pub struct Options { flag_manifest_path: Option, flag_frozen: bool, flag_locked: bool, + flag_package: Option, arg_spec: Option, } @@ -22,6 +23,7 @@ Usage: Options: -h, --help Print this message + -p SPEC, --package SPEC Argument to get the package id specifier for --manifest-path PATH Path to the manifest to the package to clean -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout @@ -60,7 +62,14 @@ pub fn execute(options: Options, let root = try!(find_root_manifest_for_wd(options.flag_manifest_path.clone(), config.cwd())); let ws = try!(Workspace::new(&root, config)); - let spec = options.arg_spec.as_ref().map(|s| &s[..]); + let spec = if options.arg_spec.is_some() { + options.arg_spec + } else if options.flag_package.is_some() { + options.flag_package + } else { + None + }; + let spec = spec.as_ref().map(|s| &s[..]); let spec = try!(ops::pkgid(&ws, spec)); println!("{}", spec); Ok(None) From b9366917dbc6ea2eb4fef7d1041c09c42e309aff Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 19 Oct 2016 20:36:41 +0300 Subject: [PATCH 0780/3888] Append only git checkouts --- src/cargo/sources/git/source.rs | 22 ++++++++-------------- src/cargo/util/config.rs | 19 +------------------ 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index eeffcb05b72..b0f1053ef1d 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -123,21 +123,13 @@ impl<'cfg> Registry for GitSource<'cfg> { impl<'cfg> Source for GitSource<'cfg> { fn update(&mut self) -> CargoResult<()> { - let lock = try!(self.config.lock_git()); + let lock = try!(self.config.git_path() + .open_rw(".cargo-lock-git", self.config, "the git checkouts")); let db_path = lock.parent().join("db").join(&self.ident); - let reference_path = match self.source_id.git_reference() { - Some(&GitReference::Branch(ref s)) | - Some(&GitReference::Tag(ref s)) | - Some(&GitReference::Rev(ref s)) => s, - None => panic!("not a git source"), - }; - let checkout_path = lock.parent().join("checkouts") - .join(&self.ident).join(reference_path); - // Resolve our reference to an actual revision, and check if the - // databaes already has that revision. If it does, we just load a + // database already has that revision. If it does, we just load a // database pinned at that revision, and if we don't we issue an update // to try to find the revision. let actual_rev = self.remote.rev_for(&db_path, &self.reference); @@ -157,9 +149,14 @@ impl<'cfg> Source for GitSource<'cfg> { (try!(self.remote.db_at(&db_path)), actual_rev.unwrap()) }; + let checkout_path = lock.parent().join("checkouts") + .join(&self.ident).join(actual_rev.to_string()); + // Copy the database to the checkout location. After this we could drop // the lock on the database as we no longer needed it, but we leave it // in scope so the destructors here won't tamper with too much. + // Checkout is immutable, so we don't need to protect it with a lock once + // it is created. try!(repo.copy_to(actual_rev.clone(), &checkout_path, &self.config)); let source_id = self.source_id.with_precise(Some(actual_rev.to_string())); @@ -167,9 +164,6 @@ impl<'cfg> Source for GitSource<'cfg> { &source_id, self.config); - // Cache the information we just learned, and crucially also cache the - // lock on the checkout location. We wouldn't want someone else to come - // swipe our checkout location to another revision while we're using it! self.path_source = Some(path_source); self.rev = Some(actual_rev); self.path_source.as_mut().unwrap().update() diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 2f207d86eab..e9988fe9496 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -16,7 +16,7 @@ use toml; use core::shell::{Verbosity, ColorConfig}; use core::MultiShell; use util::{CargoResult, CargoError, ChainError, Rustc, internal, human}; -use util::{Filesystem, FileLock, LazyCell}; +use util::{Filesystem, LazyCell}; use util::toml as cargo_toml; @@ -32,7 +32,6 @@ pub struct Config { extra_verbose: Cell, frozen: Cell, locked: Cell, - git_lock: LazyCell, } impl Config { @@ -49,7 +48,6 @@ impl Config { extra_verbose: Cell::new(false), frozen: Cell::new(false), locked: Cell::new(false), - git_lock: LazyCell::new(), } } @@ -71,21 +69,6 @@ impl Config { self.home_path.join("git") } - /// All git sources are protected by a single file lock, which is stored - /// in the `Config` struct. Ideally, we should use a lock per repository, - /// but this leads to deadlocks when several instances of Cargo acquire - /// locks in different order (see #2987). - /// - /// Holding the lock only during checkout is not enough. For example, two - /// instances of Cargo may checkout different commits from the same branch - /// to the same directory. So the lock is acquired when the first git source - /// is updated and released when the `Config` struct is destroyed. - pub fn lock_git(&self) -> CargoResult<&FileLock> { - self.git_lock.get_or_try_init(|| { - self.git_path().open_rw(".cargo-lock-git", self, "the git checkouts") - }) - } - pub fn registry_index_path(&self) -> Filesystem { self.home_path.join("registry").join("index") } From f32ac28ac815f511c9ce291329f03481782c3b73 Mon Sep 17 00:00:00 2001 From: Robin Stocker Date: Fri, 1 Jul 2016 14:31:36 +1000 Subject: [PATCH 0781/3888] Use CommandExt::exec for `cargo run` on Unix (#2343) Before, we would spawn a child process for the program. One of the problems with that is when killing the cargo process, the program continues running. With this change, the cargo process is replaced by the program, and killing it works. --- src/cargo/ops/cargo_run.rs | 2 +- src/cargo/util/process_builder.rs | 16 ++++++++++++++++ tests/run.rs | 25 +++++++++++++++++-------- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 34c28dbc4cb..897a3da5116 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -52,5 +52,5 @@ pub fn run(ws: &Workspace, process.args(args).cwd(config.cwd()); try!(config.shell().status("Running", process.to_string())); - Ok(process.exec().err()) + Ok(process.exec_replace().err()) } diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index c0d88d2ae86..b66b26ec0a4 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -89,6 +89,22 @@ impl ProcessBuilder { } } + #[cfg(unix)] + pub fn exec_replace(&self) -> Result<(), ProcessError> { + use std::os::unix::process::CommandExt; + + let mut command = self.build_command(); + let error = command.exec(); + Err(process_error(&format!("could not execute process `{}`", + self.debug_string()), + Some(Box::new(error)), None, None)) + } + + #[cfg(windows)] + pub fn exec_replace(&self) -> Result<(), ProcessError> { + self.exec() + } + pub fn exec_with_output(&self) -> Result { let mut command = self.build_command(); diff --git a/tests/run.rs b/tests/run.rs index 7c769c24515..eb438ac4170 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -126,14 +126,18 @@ fn exit_code() { fn main() { std::process::exit(2); } "#); - assert_that(p.cargo_process("run"), - execs().with_status(2) - .with_stderr("\ + let mut output = String::from("\ [COMPILING] foo v0.0.1 (file[..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[..]` +"); + if !cfg!(unix) { + output.push_str("\ [ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2) -")); +"); + } + assert_that(p.cargo_process("run"), + execs().with_status(2).with_stderr(output)); } #[test] @@ -149,15 +153,20 @@ fn exit_code_verbose() { fn main() { std::process::exit(2); } "#); - assert_that(p.cargo_process("run").arg("-v"), - execs().with_status(2) - .with_stderr("\ + let mut output = String::from("\ [COMPILING] foo v0.0.1 (file[..]) [RUNNING] `rustc [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[..]` +"); + if !cfg!(unix) { + output.push_str("\ [ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2) -")); +"); + } + + assert_that(p.cargo_process("run").arg("-v"), + execs().with_status(2).with_stderr(output)); } #[test] From 8d3839905387e17d1d67c77df39ecb90630fbfd2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Oct 2016 09:50:29 -0700 Subject: [PATCH 0782/3888] Parse --features in `cargo metadata` the same This accidentally didn't accept space-separated features passed through `--features` as the logic for doing the splitting wasn't shared. Let's share it! --- src/cargo/ops/cargo_compile.rs | 8 ++++---- src/cargo/ops/cargo_output_metadata.rs | 2 +- tests/metadata.rs | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 7b6cb1b71a9..5a9513f94cc 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -100,11 +100,14 @@ pub fn compile<'a>(ws: &Workspace<'a>, options: &CompileOptions<'a>) pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, source: Option>, - features: Vec, + features: &[String], all_features: bool, no_default_features: bool, spec: &'a [String]) -> CargoResult<(PackageSet<'a>, Resolve)> { + let features = features.iter().flat_map(|s| { + s.split_whitespace() + }).map(|s| s.to_string()).collect::>(); let mut registry = try!(PackageRegistry::new(ws.config())); @@ -161,9 +164,6 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, ref target_rustc_args } = *options; let target = target.map(|s| s.to_string()); - let features = features.iter().flat_map(|s| { - s.split(' ') - }).map(|s| s.to_string()).collect::>(); if jobs == Some(0) { bail!("jobs must be at least 1") diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 131b93825db..cda9b53e67f 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -45,7 +45,7 @@ fn metadata_full(ws: &Workspace, opt: &OutputMetadataOptions) -> CargoResult { let deps = try!(ops::resolve_dependencies(ws, None, - opt.features.clone(), + &opt.features, opt.all_features, opt.no_default_features, &[])); diff --git a/tests/metadata.rs b/tests/metadata.rs index a180aae49a9..2ed82b294a0 100644 --- a/tests/metadata.rs +++ b/tests/metadata.rs @@ -429,3 +429,23 @@ fn carg_metadata_bad_version() { execs().with_status(101) .with_stderr("[ERROR] metadata version 2 not supported, only 1 is currently supported")); } + +#[test] +fn multiple_features() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [features] + a = [] + b = [] + "#) + .file("src/lib.rs", ""); + + assert_that(p.cargo_process("metadata") + .arg("--features").arg("a b"), + execs().with_status(0)); +} From 09a49e880e12bc85c289dbb94050e9365b419c09 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 20 Oct 2016 19:02:38 -0700 Subject: [PATCH 0783/3888] Load [replace] sections from lock files This commit fixes a bug in Cargo where path-based [replace] dependencies were accidentally not loaded from lock files. This meant that even with a lock file some compilations could accidentally become nondeterministic. The fix here is to just look at all path dependencies, even those specified through [replace] Closes #3216 --- src/cargo/core/registry.rs | 20 +++++- src/cargo/core/resolver/encode.rs | 2 + src/cargo/core/resolver/mod.rs | 5 ++ src/cargo/ops/resolve.rs | 1 + tests/overrides.rs | 100 ++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 2 deletions(-) diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 854340077c6..5b7c21ac35e 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -165,6 +165,10 @@ impl<'cfg> PackageRegistry<'cfg> { } pub fn register_lock(&mut self, id: PackageId, deps: Vec) { + trace!("register_lock: {}", id); + for dep in deps.iter() { + trace!("\t-> {}", dep); + } let sub_map = self.locked.entry(id.source_id().clone()) .or_insert(HashMap::new()); let sub_vec = sub_map.entry(id.name().to_string()) @@ -224,12 +228,17 @@ impl<'cfg> PackageRegistry<'cfg> { vec.iter().find(|&&(ref id, _)| id == summary.package_id()) }); + trace!("locking summary of {}", summary.package_id()); + // Lock the summary's id if possible let summary = match pair { Some(&(ref precise, _)) => summary.override_id(precise.clone()), None => summary, }; summary.map_dependencies(|dep| { + trace!("\t{}/{}/{}", dep.name(), dep.version_req(), + dep.source_id()); + // If we've got a known set of overrides for this summary, then // one of a few cases can arise: // @@ -252,6 +261,7 @@ impl<'cfg> PackageRegistry<'cfg> { if let Some(&(_, ref locked_deps)) = pair { let locked = locked_deps.iter().find(|id| dep.matches_id(id)); if let Some(locked) = locked { + trace!("\tfirst hit on {}", locked); return dep.lock_to(locked) } } @@ -265,8 +275,14 @@ impl<'cfg> PackageRegistry<'cfg> { vec.iter().find(|&&(ref id, _)| dep.matches_id(id)) }); match v { - Some(&(ref id, _)) => dep.lock_to(id), - None => dep + Some(&(ref id, _)) => { + trace!("\tsecond hit on {}", id); + dep.lock_to(id) + } + None => { + trace!("\tremaining unlocked"); + dep + } } }) } diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index 1f79fbdc477..2e67ef6e5c7 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -185,8 +185,10 @@ fn build_path_deps(ws: &Workspace) -> HashMap { fn build(pkg: &Package, config: &Config, ret: &mut HashMap) { + let replace = pkg.manifest().replace(); let deps = pkg.dependencies() .iter() + .chain(replace.iter().map(|p| &p.1)) .filter(|d| !ret.contains_key(d.name())) .map(|d| d.source_id()) .filter(|id| id.is_path()) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 7a9e953365a..9cc723d69dc 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -864,6 +864,7 @@ impl<'a> Context<'a> { None => return Ok(Candidate { summary: summary, replace: None }), Some(replacement) => replacement, }; + debug!("found an override for {} {}", dep.name(), dep.version_req()); let mut summaries = try!(registry.query(dep)).into_iter(); let s = try!(summaries.next().chain_error(|| { @@ -903,6 +904,10 @@ impl<'a> Context<'a> { matched_spec, spec, summary.package_id()); } + for dep in summary.dependencies() { + debug!("\t{} => {}", dep.name(), dep.version_req()); + } + Ok(Candidate { summary: summary, replace: replace }) }).collect() } diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index af912b0dfba..0bde351e287 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -77,6 +77,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, // to the previously resolved version if the dependency listed // still matches the locked version. if let Some(r) = previous { + trace!("previous: {:?}", r); for node in r.iter().filter(|p| keep(p, to_avoid, &to_avoid_sources)) { let deps = r.deps_not_replaced(node) .filter(|p| keep(p, to_avoid, &to_avoid_sources)) diff --git a/tests/overrides.rs b/tests/overrides.rs index c6d8a96e446..c7d56799f60 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -775,3 +775,103 @@ http://doc.crates.io/specifying-dependencies.html#overriding-dependencies [FINISHED] [..] ")); } + +#[test] +fn override_an_override() { + Package::new("chrono", "0.2.0").dep("serde", "< 0.9").publish(); + Package::new("serde", "0.7.0") + .file("src/lib.rs", "pub fn serde07() {}") + .publish(); + Package::new("serde", "0.8.0") + .file("src/lib.rs", "pub fn serde08() {}") + .publish(); + + let p = project("local") + .file("Cargo.toml", r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + chrono = "0.2" + serde = "0.8" + + [replace] + "chrono:0.2.0" = { path = "chrono" } + "serde:0.8.0" = { path = "serde" } + "#) + .file("Cargo.lock", r#" + [root] + name = "local" + version = "0.0.1" + dependencies = [ + "chrono 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + ] + + [[package]] + name = "chrono" + version = "0.2.0" + source = "registry+https://github.com/rust-lang/crates.io-index" + replace = "chrono 0.2.0" + + [[package]] + name = "chrono" + version = "0.2.0" + dependencies = [ + "serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + ] + + [[package]] + name = "serde" + version = "0.7.0" + source = "registry+https://github.com/rust-lang/crates.io-index" + + [[package]] + name = "serde" + version = "0.8.0" + source = "registry+https://github.com/rust-lang/crates.io-index" + replace = "serde 0.8.0" + + [[package]] + name = "serde" + version = "0.8.0" + "#) + .file("src/lib.rs", " + extern crate chrono; + extern crate serde; + + pub fn local() { + chrono::chrono(); + serde::serde08_override(); + } + ") + .file("chrono/Cargo.toml", r#" + [package] + name = "chrono" + version = "0.2.0" + authors = [] + + [dependencies] + serde = "< 0.9" + "#) + .file("chrono/src/lib.rs", " + extern crate serde; + pub fn chrono() { + serde::serde07(); + } + ") + .file("serde/Cargo.toml", r#" + [package] + name = "serde" + version = "0.8.0" + authors = [] + "#) + .file("serde/src/lib.rs", " + pub fn serde08_override() {} + "); + + assert_that(p.cargo_process("build").arg("-v"), + execs().with_status(0)); +} From 425978b165852213dd80e212b4eb6ce69c63b75c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 24 Oct 2016 20:29:21 -0700 Subject: [PATCH 0784/3888] Download more cross builds --- Cargo.lock | 46 ++++++++++++++++++++--------------------- src/etc/install-deps.py | 3 +++ src/rustversion.txt | 2 +- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7185e3b831c..1d4df697bb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,7 +79,7 @@ dependencies = [ "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -122,7 +122,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -133,7 +133,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ name = "filetime" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -173,7 +173,7 @@ name = "flate2" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -183,7 +183,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -207,7 +207,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -263,7 +263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -273,7 +273,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -294,7 +294,7 @@ version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -306,7 +306,7 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -325,7 +325,7 @@ name = "memchr" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -334,7 +334,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -355,7 +355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -431,7 +431,7 @@ name = "num_cpus" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -442,7 +442,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys-extras 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -453,7 +453,7 @@ version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -465,7 +465,7 @@ version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -496,7 +496,7 @@ name = "rand" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -549,7 +549,7 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -575,7 +575,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -674,7 +674,7 @@ dependencies = [ "checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" -"checksum libc 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "408014cace30ee0f767b1c4517980646a573ec61a57957aeeabcac8ac0a02e8d" +"checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" "checksum libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3293dc95169a6351c5a03eca4bf5549f3a9a06336a000315876ff1165a5fba10" "checksum libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc058951ab6a3ef35ca16462d7642c4867e6403520811f28537a4e2f2db3e71" "checksum libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "1debd7e56d19655eb786f827675dc55f6d530de6d7b81e76d13d1afc635d6c07" diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py index a833c26c961..350bf1954e6 100644 --- a/src/etc/install-deps.py +++ b/src/etc/install-deps.py @@ -25,6 +25,9 @@ 'i686-unknown-linux-gnu', 'mips-unknown-linux-gnu', 'mipsel-unknown-linux-gnu', + 'mips64-unknown-linux-gnuabi64', + 'mips64el-unknown-linux-gnuabi64', + 's390x-unknown-linux-gnu', 'powerpc-unknown-linux-gnu', 'powerpc64-unknown-linux-gnu', 'powerpc64le-unknown-linux-gnu', diff --git a/src/rustversion.txt b/src/rustversion.txt index f96de36a9fd..53b3604545e 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-09-05 +2016-10-21 From 86a94bd4e3a04e992d353bba7e6573c384702c63 Mon Sep 17 00:00:00 2001 From: Martin Hafskjold Thoresen Date: Tue, 25 Oct 2016 20:52:47 +0200 Subject: [PATCH 0785/3888] Add fix and test for #3224 --- src/cargo/ops/cargo_rustc/layout.rs | 5 +++-- tests/build.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index f96ce5715d8..18ae026e193 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -50,7 +50,7 @@ use std::io; use std::path::{PathBuf, Path}; use core::{Package, Workspace}; -use util::{Config, FileLock, CargoResult, Filesystem}; +use util::{Config, FileLock, CargoResult, Filesystem, human}; use util::hex::short_hash; use super::Unit; @@ -78,7 +78,8 @@ impl Layout { // the target triple as a Path and then just use the file stem as the // component for the directory name. if let Some(triple) = triple { - path.push(Path::new(triple).file_stem().unwrap()); + path.push(try!(Path::new(triple).file_stem() + .ok_or(human(format!("target was empty"))))); } path.push(dest); Layout::at(ws.config(), path) diff --git a/tests/build.rs b/tests/build.rs index 739a5b9c467..5b235842576 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -2374,3 +2374,15 @@ fn no_warn_about_package_metadata() { .with_stderr("[..] foo v0.0.1 ([..])\n\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..]\n")); } + +#[test] +fn cargo_build_empty_target() { + let p = project("foo") + .file("Cargo.toml", &basic_bin_manifest("foo")) + .file("src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo_process("build").arg("--target").arg(""), + execs().with_status(101) + .with_stderr_contains("[..] target was empty")); +} From 72aec35720c4f9557de102f8b9cdc544cbf8c595 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 20 Oct 2016 15:07:18 -0700 Subject: [PATCH 0786/3888] Ignore summaries in downloaded crates Unfortunately historical Cargo bugs have made it such that the index sometimes differs from the actual crate we download. Let's respect the index, however, which should be our source of truth. Closes #3214 --- src/cargo/core/manifest.rs | 3 +- src/cargo/sources/registry/mod.rs | 14 ++++++++- tests/cargotest/support/registry.rs | 4 +-- tests/cfg.rs | 4 +-- tests/registry.rs | 44 ++++++++++++++++++++++++++++- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index e72674b9602..c26876fc2ec 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -185,7 +185,8 @@ impl Encodable for Target { } impl Manifest { - pub fn new(summary: Summary, targets: Vec, + pub fn new(summary: Summary, + targets: Vec, exclude: Vec, include: Vec, links: Option, diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 3a1babafb04..13517fc08d5 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -359,7 +359,19 @@ impl<'cfg> Source for RegistrySource<'cfg> { })); let mut src = PathSource::new(&path, &self.source_id, self.config); try!(src.update()); - src.download(package) + let pkg = try!(src.download(package)); + + // Unfortunately the index and the actual Cargo.toml in the index can + // differ due to historical Cargo bugs. To paper over these we trash the + // *summary* loaded from the Cargo.toml we just downloaded with the one + // we loaded from the index. + let summaries = try!(self.index.summaries(package.name())); + let summary = summaries.iter().map(|s| &s.0).find(|s| { + s.package_id() == package + }).expect("summary not found"); + let mut manifest = pkg.manifest().clone(); + manifest.set_summary(summary.clone()); + Ok(Package::new(manifest, pkg.manifest_path())) } fn fingerprint(&self, pkg: &Package) -> CargoResult { diff --git a/tests/cargotest/support/registry.rs b/tests/cargotest/support/registry.rs index 12e857211cc..a57dfa26327 100644 --- a/tests/cargotest/support/registry.rs +++ b/tests/cargotest/support/registry.rs @@ -141,7 +141,7 @@ impl Package { map.insert("name".to_string(), dep.name.to_json()); map.insert("req".to_string(), dep.vers.to_json()); map.insert("features".to_string(), dep.features.to_json()); - map.insert("default_features".to_string(), false.to_json()); + map.insert("default_features".to_string(), true.to_json()); map.insert("target".to_string(), dep.target.to_json()); map.insert("optional".to_string(), false.to_json()); map.insert("kind".to_string(), dep.kind.to_json()); @@ -211,7 +211,7 @@ impl Package { for dep in self.deps.iter() { let target = match dep.target { None => String::new(), - Some(ref s) => format!("target.{}.", s), + Some(ref s) => format!("target.'{}'.", s), }; let kind = match &dep.kind[..] { "build" => "build-", diff --git a/tests/cfg.rs b/tests/cfg.rs index 6712af6d869..017f0172377 100644 --- a/tests/cfg.rs +++ b/tests/cfg.rs @@ -200,8 +200,8 @@ fn works_through_the_registry() { Package::new("foo", "0.1.0").publish(); Package::new("bar", "0.1.0") - .target_dep("foo", "0.1.0", "'cfg(unix)'") - .target_dep("foo", "0.1.0", "'cfg(windows)'") + .target_dep("foo", "0.1.0", "cfg(unix)") + .target_dep("foo", "0.1.0", "cfg(windows)") .publish(); let p = project("a") diff --git a/tests/registry.rs b/tests/registry.rs index e95dc1e49ea..e3cc4d8acb2 100644 --- a/tests/registry.rs +++ b/tests/registry.rs @@ -1,9 +1,11 @@ #[macro_use] extern crate cargotest; extern crate hamcrest; +extern crate url; use std::fs::{self, File}; use std::io::prelude::*; +use std::path::PathBuf; use cargotest::cargo_process; use cargotest::support::git; @@ -11,6 +13,10 @@ use cargotest::support::paths::{self, CargoPathExt}; use cargotest::support::registry::{self, Package}; use cargotest::support::{project, execs}; use hamcrest::assert_that; +use url::Url; + +fn registry_path() -> PathBuf { paths::root().join("registry") } +fn registry() -> Url { Url::from_file_path(&*registry_path()).ok().unwrap() } #[test] fn simple() { @@ -609,7 +615,9 @@ fn bad_license_file() { .file("src/main.rs", r#" fn main() {} "#); - assert_that(p.cargo_process("publish").arg("-v"), + assert_that(p.cargo_process("publish") + .arg("-v") + .arg("--host").arg(registry().to_string()), execs().with_status(101) .with_stderr_contains("\ [ERROR] the license file `foo` does not exist")); @@ -1340,3 +1348,37 @@ this warning. [FINISHED] [..] ")); } + +#[test] +fn toml_lies_but_index_is_truth() { + Package::new("foo", "0.2.0").publish(); + Package::new("bar", "0.3.0") + .dep("foo", "0.2.0") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.3.0" + authors = [] + + [dependencies] + foo = "0.1.0" + "#) + .file("src/lib.rs", "extern crate foo;") + .publish(); + + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + bar = "0.3" + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo("build").arg("-v"), + execs().with_status(0)); +} From 2b6e1426900995bcda59c1fdbb36644c51d31653 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 25 Oct 2016 19:46:09 -0700 Subject: [PATCH 0787/3888] Download mingw from more reliable location Use the same "mirror" the rust repo uses --- appveyor.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3017466e488..88660ab3b3c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,15 +15,15 @@ environment: - TARGET: i686-pc-windows-gnu ARCH: x86 BITS: 32 + MINGW_URL: https://s3.amazonaws.com/rust-lang-ci MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z - MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download MINGW_DIR: mingw32 install: - IF "%MSVC%"=="" set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% - - if defined MINGW_ARCHIVE appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%" - - if defined MINGW_ARCHIVE 7z x -y "%MINGW_ARCHIVE%" > nul - - if defined MINGW_ARCHIVE set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% + - if defined MINGW_URL appveyor DownloadFile %MINGW_URL%/%MINGW_ARCHIVE% + - if defined MINGW_URL 7z x -y %MINGW_ARCHIVE% > nul + - if defined MINGW_URL set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% - python src/etc/install-deps.py - python src/etc/dl-snapshot.py %TARGET% - SET PATH=%PATH%;%cd%/rustc/bin From 66368d14a4360a1ccb61adc4f08799c4dc0350c0 Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Wed, 26 Oct 2016 17:25:15 +0200 Subject: [PATCH 0788/3888] Fix rust-lang/rust#35203 warning/error rust-lang/rust#35203 made patterns in functions without body into a warn by default lint (which is being `deny`ed here). --- tests/cargotest/support/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index 6de6df19764..e647b7af021 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -608,7 +608,7 @@ pub fn shell_writes(string: T) -> ShellWrites { } pub trait Tap { - fn tap(mut self, callback: F) -> Self; + fn tap(self, callback: F) -> Self; } impl Tap for T { From cc41c2d6dff7f5fbcea4b2cd8ea0fa4b2522e61b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 30 Oct 2016 19:05:39 -0700 Subject: [PATCH 0789/3888] Render machine-readable-output docs Closes #3237 --- Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 0b6cf33089a..98d5e91c805 100644 --- a/Makefile.in +++ b/Makefile.in @@ -136,7 +136,8 @@ clean: # === Documentation DOCS := index faq config guide manifest build-script pkgid-spec crates-io \ - environment-variables specifying-dependencies source-replacement policies + environment-variables specifying-dependencies source-replacement \ + policies machine-readable-output DOC_DIR := target/doc DOC_OPTS := --markdown-no-toc \ --markdown-css stylesheets/normalize.css \ From 6dceab109d41d8c7e8eeb82e59cd93fe17b047ea Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 31 Oct 2016 11:27:31 -0700 Subject: [PATCH 0790/3888] Update curl and curl-sys Pick up a few security related fixes in libcurl --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d4df697bb9..9591597eb8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ dependencies = [ "cargotest 0.1.0", "crates-io 0.4.0", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -106,7 +106,7 @@ dependencies = [ name = "crates-io" version = "0.4.0" dependencies = [ - "curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -118,10 +118,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "curl" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", @@ -217,7 +217,7 @@ name = "git2-curl" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -658,8 +658,8 @@ dependencies = [ "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" "checksum cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "dfcf5bcece56ef953b8ea042509e9dcbdfe97820b7e20d86beb53df30ed94978" "checksum crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fb974f835e90390c5f9dfac00f05b06dc117299f5ea4e85fbc7bb443af4911cc" -"checksum curl 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f0ae0143e62b183e072d8344a1c30b6281c2b2f2b4d8407d2d8adb95652112c3" -"checksum curl-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ae8698d4d2bc4b8182a11f4a5298fa03d2127c29e95dbae538d0cf003141818" +"checksum curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "faf54d927c752b092d3e99ea227d9c7c9b4a3e885a3368ac9bfa28958f215100" +"checksum curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4f198d10378a3bc1f1b0e3bc3a2de5c9bb9e08938460dec57ba6667d9a65fbc3" "checksum docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20016093b4e545dccf6ad4a01099de0b695f9bc99b08210e68f6425db2d37d" "checksum env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "82dcb9ceed3868a03b335657b85a159736c961900f7e7747d3b0b97b9ccb5ccb" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" From 58404ed2e1065b3a7195a450ca09aacdef2d2506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Mon, 31 Oct 2016 19:15:03 +0100 Subject: [PATCH 0791/3888] FIX: Call rustdoc test with the correct cfg flags of a package. There was a situation in which if you you had a lib that depends on a package with features, whenever you ran the tests for the package the `rustdoc test` call was failing because rustdoc was called with the root cfg flags, not the package cfg flags. This fix solves the issue by keeping track of the cfg flags per package, so the rustdoc command will be generated with the correct cfg flags. --- src/cargo/ops/cargo_rustc/compilation.rs | 6 +- src/cargo/ops/cargo_rustc/mod.rs | 23 ++++---- src/cargo/ops/cargo_test.rs | 6 +- tests/test.rs | 70 ++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 16 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index 93dead30743..f15032c2336 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -43,8 +43,8 @@ pub struct Compilation<'cfg> { pub to_doc_test: Vec, - /// Features enabled during this compilation. - pub cfgs: HashSet, + /// Features per package enabled during this compilation. + pub cfgs: HashMap>, pub target: String, @@ -63,7 +63,7 @@ impl<'cfg> Compilation<'cfg> { binaries: Vec::new(), extra_env: HashMap::new(), to_doc_test: Vec::new(), - cfgs: HashSet::new(), + cfgs: HashMap::new(), config: config, target: String::new(), } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 33f86c0ef1b..26edaae9e4f 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::env; use std::ffi::{OsStr, OsString}; use std::fs; @@ -81,7 +81,6 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, }) }).collect::>(); - let root = try!(ws.current()); let mut cx = try!(Context::new(ws, resolve, packages, config, build_config, profiles)); @@ -142,19 +141,21 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, cx.compilation.libraries.insert(pkgid.clone(), v); } } - } - let root_pkg = root.package_id(); - if let Some(feats) = cx.resolve.features(root_pkg) { - cx.compilation.cfgs.extend(feats.iter().map(|feat| { - format!("feature=\"{}\"", feat) - })); + if let Some(feats) = cx.resolve.features(&unit.pkg.package_id()) { + for feat in feats.iter() { + cx.compilation.cfgs.entry(unit.pkg.package_id().clone()) + .or_insert(HashSet::new()) + .insert(format!("feature=\"{}\"", feat)); + } + } } for (&(ref pkg, _), output) in cx.build_state.outputs.lock().unwrap().iter() { - if pkg == root_pkg { - cx.compilation.cfgs.extend(output.cfgs.iter().cloned()); - } + cx.compilation.cfgs.entry(pkg.clone()) + .or_insert(HashSet::new()) + .extend(output.cfgs.iter().cloned()); + for dir in output.library_paths.iter() { cx.compilation.native_dirs.insert(dir.clone()); } diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 71a22d4e461..f382a1dd128 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -145,8 +145,10 @@ fn run_doc_tests(options: &TestOptions, p.arg("--test-args").arg(&test_args.join(" ")); } - for cfg in compilation.cfgs.iter() { - p.arg("--cfg").arg(cfg); + if let Some(cfgs) = compilation.cfgs.get(&package.package_id()) { + for cfg in cfgs.iter() { + p.arg("--cfg").arg(cfg); + } } for (_, libs) in compilation.libraries.iter() { diff --git a/tests/test.rs b/tests/test.rs index 2e5d8aa57be..cefec7e24e0 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2262,3 +2262,73 @@ fn panic_abort_multiple() { .arg("-p").arg("a"), execs().with_status(0)); } + +#[test] +fn pass_correct_cfgs_flags_to_rustdoc() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [features] + default = ["a/default"] + nightly = ["a/nightly"] + + [dependencies.a] + path = "libs/a" + default-features = false + "#) + .file("src/lib.rs", r#" + #[cfg(test)] + mod tests { + #[test] + fn it_works() { + assert!(true); + } + } + "#) + .file("libs/a/Cargo.toml", r#" + [package] + name = "a" + version = "0.1.0" + authors = [] + + [features] + default = ["serde_codegen"] + nightly = ["serde_derive"] + + [dependencies] + serde_derive = { version = "0.8", optional = true } + + [build-dependencies] + serde_codegen = { version = "0.8", optional = true } + "#) + .file("libs/a/src/lib.rs", r#" + #[cfg(feature = "serde_derive")] + const MSG: &'static str = "This is safe"; + + #[cfg(feature = "serde_codegen")] + const MSG: &'static str = "This is risky"; + + pub fn get() -> &'static str { + MSG + } + "#); + + assert_that(p.cargo_process("test") + .arg("--package").arg("a") + .arg("--verbose"), + execs().with_status(0) + .with_stderr_contains("\ +[DOCTEST] a +[RUNNING] `rustdoc --test [..]--cfg feature=\\\"serde_codegen\\\"[..]`")); + + assert_that(p.cargo_process("test") + .arg("--verbose"), + execs().with_status(0) + .with_stderr_contains("\ +[DOCTEST] foo +[RUNNING] `rustdoc --test [..]--cfg feature=\\\"a\\\"[..]`")); +} From 226c9c25d9b21d8077dba597c9c98d672e6fecb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Mon, 31 Oct 2016 23:54:04 +0100 Subject: [PATCH 0792/3888] Use better iter() semantics to collect cfg flags. --- src/cargo/ops/cargo_rustc/mod.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 26edaae9e4f..00bcb866282 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -143,11 +143,9 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, } if let Some(feats) = cx.resolve.features(&unit.pkg.package_id()) { - for feat in feats.iter() { - cx.compilation.cfgs.entry(unit.pkg.package_id().clone()) - .or_insert(HashSet::new()) - .insert(format!("feature=\"{}\"", feat)); - } + cx.compilation.cfgs.entry(unit.pkg.package_id().clone()) + .or_insert(HashSet::new()) + .extend(feats.iter().map(|feat| format!("feature=\"{}\"", feat))); } } From 4dda37c8de81c59fea7d9c510654f4666b9efa70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Tue, 1 Nov 2016 18:14:41 +0100 Subject: [PATCH 0793/3888] Relax conditions in rustdoc test cfg flags tests. In Windows the rustdoc test output sets more double quotes, so the test doesn't pass. We need to relax the test so it pass in *NIX and Windows environments. --- tests/test.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index cefec7e24e0..69f22e701a4 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2273,11 +2273,11 @@ fn pass_correct_cfgs_flags_to_rustdoc() { authors = [] [features] - default = ["a/default"] - nightly = ["a/nightly"] + default = ["feature_a/default"] + nightly = ["feature_a/nightly"] - [dependencies.a] - path = "libs/a" + [dependencies.feature_a] + path = "libs/feature_a" default-features = false "#) .file("src/lib.rs", r#" @@ -2289,9 +2289,9 @@ fn pass_correct_cfgs_flags_to_rustdoc() { } } "#) - .file("libs/a/Cargo.toml", r#" + .file("libs/feature_a/Cargo.toml", r#" [package] - name = "a" + name = "feature_a" version = "0.1.0" authors = [] @@ -2305,7 +2305,7 @@ fn pass_correct_cfgs_flags_to_rustdoc() { [build-dependencies] serde_codegen = { version = "0.8", optional = true } "#) - .file("libs/a/src/lib.rs", r#" + .file("libs/feature_a/src/lib.rs", r#" #[cfg(feature = "serde_derive")] const MSG: &'static str = "This is safe"; @@ -2318,17 +2318,17 @@ fn pass_correct_cfgs_flags_to_rustdoc() { "#); assert_that(p.cargo_process("test") - .arg("--package").arg("a") + .arg("--package").arg("feature_a") .arg("--verbose"), execs().with_status(0) .with_stderr_contains("\ -[DOCTEST] a -[RUNNING] `rustdoc --test [..]--cfg feature=\\\"serde_codegen\\\"[..]`")); +[DOCTEST] feature_a +[RUNNING] `rustdoc --test [..]serde_codegen[..]`")); assert_that(p.cargo_process("test") .arg("--verbose"), execs().with_status(0) .with_stderr_contains("\ [DOCTEST] foo -[RUNNING] `rustdoc --test [..]--cfg feature=\\\"a\\\"[..]`")); +[RUNNING] `rustdoc --test [..]feature_a[..]`")); } From afacee942ec5e3fedadf85d7c68cd230a3ccd3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Hern=C3=A1ndez?= Date: Tue, 1 Nov 2016 18:16:55 +0100 Subject: [PATCH 0794/3888] Add text language to code bloks in machine-readable-output.md Travis fails when running `make doc` because of this file. This should fix the issue. --- src/doc/machine-readable-output.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/machine-readable-output.md b/src/doc/machine-readable-output.md index e486fd6c685..7b0463a5a6e 100644 --- a/src/doc/machine-readable-output.md +++ b/src/doc/machine-readable-output.md @@ -7,7 +7,7 @@ Cargo can output information about project and build in JSON format. You can use `cargo metadata` command to get information about project structure and dependencies. The output of the command looks like this: -``` +```text { // Integer version number of the format. "version": integer, @@ -59,7 +59,7 @@ without waiting for the whole build to finish. The message format looks like this: -``` +```text { // Type of the message. "reason": "compiler-message", From 91dd1b330f41859244bc70c0d3fa20edd19eb16e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 6 Oct 2016 15:32:15 -0700 Subject: [PATCH 0795/3888] Ignore `panic` configuration for test/bench profiles Both of these profiles link to libtest, so it's invalid to configure them with `panic="abort"`. To prevent confusing errors just ignore the configuration for now. Closes #3166 --- src/cargo/ops/cargo_compile.rs | 2 +- src/cargo/util/toml.rs | 4 ++++ tests/test.rs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 5a9513f94cc..324c528bf70 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -245,7 +245,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let _p = profile::start("compiling"); let mut build_config = try!(scrape_build_config(config, jobs, target)); build_config.release = release; - build_config.test = mode == CompileMode::Test; + build_config.test = mode == CompileMode::Test || mode == CompileMode::Bench; build_config.json_errors = message_format == MessageFormat::Json; if let CompileMode::Doc { deps } = mode { build_config.doc_all = deps; diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 4686eb9a29d..bc72b5ee99b 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -1239,6 +1239,10 @@ fn build_profiles(profiles: &Option) -> Profiles { profiles.and_then(|p| p.doc.as_ref())), custom_build: Profile::default_custom_build(), }; + // The test/bench targets cannot have panic=abort because they'll all get + // compiled with --test which requires the unwind runtime currently + profiles.test.panic = None; + profiles.bench.panic = None; profiles.test_deps.panic = None; profiles.bench_deps.panic = None; return profiles; diff --git a/tests/test.rs b/tests/test.rs index 69f22e701a4..5bc9d8e1bb7 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2332,3 +2332,35 @@ fn pass_correct_cfgs_flags_to_rustdoc() { [DOCTEST] foo [RUNNING] `rustdoc --test [..]feature_a[..]`")); } + +#[test] +fn test_release_ignore_panic() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a" } + + [profile.test] + panic = 'abort' + [profile.release] + panic = 'abort' + "#) + .file("src/lib.rs", "extern crate a;") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", ""); + p.build(); + println!("test"); + assert_that(p.cargo("test").arg("-v"), execs().with_status(0)); + println!("bench"); + assert_that(p.cargo("bench").arg("-v"), execs().with_status(0)); +} From 1f0a0a63d4e415cd8517f7d90e0691c9aad04969 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 Nov 2016 09:18:30 -0700 Subject: [PATCH 0796/3888] Fix some tests from the previous merge --- tests/freshness.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/freshness.rs b/tests/freshness.rs index 63a488cd3b9..03baf550ee5 100644 --- a/tests/freshness.rs +++ b/tests/freshness.rs @@ -396,10 +396,11 @@ fn no_rebuild_if_build_artifacts_move_backwards_in_time() { execs().with_status(0)); p.root().move_into_the_past(); - p.root().join("target").move_into_the_past(); - assert_that(p.cargo("build").env("RUST_LOG", ""), - execs().with_status(0).with_stdout("").with_stderr("")); + assert_that(p.cargo("build"), + execs().with_status(0).with_stdout("").with_stderr("\ +[FINISHED] [..] +")); } #[test] @@ -427,11 +428,11 @@ fn rebuild_if_build_artifacts_move_forward_in_time() { execs().with_status(0)); p.root().move_into_the_future(); - p.root().join("target").move_into_the_future(); assert_that(p.cargo("build").env("RUST_LOG", ""), execs().with_status(0).with_stdout("").with_stderr("\ [COMPILING] a v0.0.1 ([..]) [COMPILING] forwards_in_time v0.0.1 ([..]) +[FINISHED] [..] ")); } From 3e29002dcd48c832ec6ad0dc64b1898ae4705c1c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 Nov 2016 09:36:23 -0700 Subject: [PATCH 0797/3888] Add a test for the previous PR --- tests/doc.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/doc.rs b/tests/doc.rs index 25ef939c8b5..ba5ea85ac30 100644 --- a/tests/doc.rs +++ b/tests/doc.rs @@ -590,3 +590,25 @@ fn document_only_lib() { execs().with_status(0)); assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); } + +#[test] +fn plugins_no_use_target() { + if !cargotest::is_nightly() { + return + } + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [lib] + proc-macro = true + "#) + .file("src/lib.rs", ""); + assert_that(p.cargo_process("doc") + .arg("--target=x86_64-unknown-openbsd") + .arg("-v"), + execs().with_status(0)); +} From c0f432eb2660d7f51f51b580eb52a535ee2b481d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 31 Oct 2016 16:20:38 -0700 Subject: [PATCH 0798/3888] Expose rustc cfg values to build scripts This commit is Cargo's portion of the implementation of [RFC 1721] where it will expose values printed by `rustc --print cfg` to build scripts. [RFC 1721]: https://github.com/rust-lang/rfcs/blob/master/text/1721-crt-static.md This will in turn be used to communicate features like `-C target-feature=+crt-static` which can be used to compile objects for statically linking against the msvcrt on MSVC. --- src/cargo/ops/cargo_rustc/context.rs | 9 ++++++++ src/cargo/ops/cargo_rustc/custom_build.rs | 22 +++++++++++++++++- tests/build-script.rs | 27 +++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 59aa170212c..4e0cf00db6a 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -678,6 +678,15 @@ impl<'a, 'cfg> Context<'a, 'cfg> { self.target_config(kind).ar.as_ref().map(|s| s.as_ref()) } + /// Get the list of cfg printed out from the compiler for the specified kind + pub fn cfg(&self, kind: Kind) -> &[Cfg] { + let info = match kind { + Kind::Host => &self.host_info, + Kind::Target => &self.target_info, + }; + info.cfg.as_ref().map(|s| &s[..]).unwrap_or(&[]) + } + /// Get the target configuration for a particular host or target fn target_config(&self, kind: Kind) -> &TargetConfig { match kind { diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 6a324a378a1..54c688134be 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -5,7 +5,7 @@ use std::str; use std::sync::{Mutex, Arc}; use core::PackageId; -use util::{CargoResult, Human, Freshness}; +use util::{CargoResult, Human, Freshness, Cfg}; use util::{internal, ChainError, profile, paths}; use super::job::Work; @@ -124,6 +124,26 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) } } + let mut cfg_map = HashMap::new(); + for cfg in cx.cfg(unit.kind) { + match *cfg { + Cfg::Name(ref n) => { cfg_map.insert(n.clone(), None); } + Cfg::KeyPair(ref k, ref v) => { + match *cfg_map.entry(k.clone()).or_insert(Some(Vec::new())) { + Some(ref mut values) => values.push(v.clone()), + None => { /* ... */ } + } + } + } + } + for (k, v) in cfg_map { + let k = format!("CARGO_CFG_{}", super::envify(&k)); + match v { + Some(list) => { cmd.env(&k, list.join(",")); } + None => { cmd.env(&k, ""); } + } + } + // Gather the set of native dependencies that this package has along with // some other variables to close over. // diff --git a/tests/build-script.rs b/tests/build-script.rs index e0669311039..18fca1ea710 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -2259,3 +2259,30 @@ fn rustc_and_rustdoc_set_correctly() { assert_that(build.cargo_process("bench"), execs().with_status(0)); } + +#[test] +fn cfg_env_vars_available() { + let build = project("builder") + .file("Cargo.toml", r#" + [package] + name = "builder" + version = "0.0.1" + authors = [] + build = "build.rs" + "#) + .file("src/lib.rs", "") + .file("build.rs", r#" + use std::env; + + fn main() { + let fam = env::var("CARGO_CFG_TARGET_FAMILY").unwrap(); + if cfg!(unix) { + assert_eq!(fam, "unix"); + } else { + assert_eq!(fam, "windows"); + } + } + "#); + assert_that(build.cargo_process("bench"), + execs().with_status(0)); +} From 918087626d25af8cda4219fcd800eaa60bc489b2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 2 Nov 2016 18:16:44 +0300 Subject: [PATCH 0799/3888] Use a single profile set per workspace --- src/cargo/core/manifest.rs | 11 +++++- src/cargo/core/workspace.rs | 37 +++++++++++++++++- src/cargo/ops/cargo_clean.rs | 2 +- src/cargo/ops/cargo_compile.rs | 2 +- src/cargo/util/toml.rs | 3 +- tests/profiles.rs | 68 ++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 6 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index c26876fc2ec..4e693ff2b3f 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -33,6 +33,7 @@ pub struct Manifest { pub struct VirtualManifest { replace: Vec<(PackageIdSpec, Dependency)>, workspace: WorkspaceConfig, + profiles: Profiles, } /// General metadata about a package which is just blindly uploaded to the @@ -139,7 +140,7 @@ pub struct Profile { pub panic: Option, } -#[derive(Default, Clone, Debug)] +#[derive(Default, Clone, Debug, PartialEq, Eq)] pub struct Profiles { pub release: Profile, pub dev: Profile, @@ -250,10 +251,12 @@ impl Manifest { impl VirtualManifest { pub fn new(replace: Vec<(PackageIdSpec, Dependency)>, - workspace: WorkspaceConfig) -> VirtualManifest { + workspace: WorkspaceConfig, + profiles: Profiles) -> VirtualManifest { VirtualManifest { replace: replace, workspace: workspace, + profiles: profiles, } } @@ -264,6 +267,10 @@ impl VirtualManifest { pub fn workspace_config(&self) -> &WorkspaceConfig { &self.workspace } + + pub fn profiles(&self) -> &Profiles { + &self.profiles + } } impl Target { diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index afa6e3bf2b1..65f1537647c 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use std::slice; use core::{Package, VirtualManifest, EitherManifest, SourceId}; -use core::{PackageIdSpec, Dependency}; +use core::{PackageIdSpec, Dependency, Profile, Profiles}; use ops; use util::{Config, CargoResult, Filesystem, human}; use util::paths; @@ -162,6 +162,14 @@ impl<'cfg> Workspace<'cfg> { self.config } + pub fn profiles(&self) -> &Profiles { + let root = self.root_manifest.as_ref().unwrap_or(&self.current_manifest); + match *self.packages.get(root) { + MaybePackage::Package(ref p) => p.manifest().profiles(), + MaybePackage::Virtual(ref m) => m.profiles(), + } + } + /// Returns the root path of this workspace. /// /// That is, this returns the path of the directory containing the @@ -432,6 +440,33 @@ impl<'cfg> Workspace<'cfg> { extra); } + if let Some(ref root_manifest) = self.root_manifest { + let default_profiles = Profiles { + release: Profile::default_release(), + dev: Profile::default_dev(), + test: Profile::default_test(), + test_deps: Profile::default_dev(), + bench: Profile::default_bench(), + bench_deps: Profile::default_release(), + doc: Profile::default_doc(), + custom_build: Profile::default_custom_build(), + }; + + for pkg in self.members().filter(|p| p.manifest_path() != root_manifest) { + if pkg.manifest().profiles() != &default_profiles { + let message = &format!("profiles for the non root package will be ignored, \ + specify profiles at the workspace root:\n\ + package: {}\n\ + workspace: {}", + pkg.manifest_path().display(), + root_manifest.display()); + + //TODO: remove `Eq` bound from `Profiles` when the warning is removed. + try!(self.config.shell().warn(&message)); + } + } + } + Ok(()) } } diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index e19b37f116f..6d544c19be2 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -32,7 +32,7 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { let resolve = try!(ops::resolve_ws(&mut registry, ws)); let packages = ops::get_resolved_packages(&resolve, registry); - let profiles = try!(ws.current()).manifest().profiles(); + let profiles = ws.profiles(); let host_triple = try!(opts.config.rustc()).host.clone(); let mut cx = try!(Context::new(ws, &resolve, &packages, opts.config, BuildConfig { diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 5a9513f94cc..3dc8cd916d4 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -169,7 +169,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, bail!("jobs must be at least 1") } - let profiles = root_package.manifest().profiles(); + let profiles = ws.profiles(); if spec.len() == 0 { try!(generate_targets(root_package, profiles, mode, filter, release)); } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 4686eb9a29d..6a77c32bdc4 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -725,6 +725,7 @@ impl TomlManifest { platform: None, layout: layout, })); + let profiles = build_profiles(&self.profile); let workspace_config = match self.workspace { Some(ref config) => { WorkspaceConfig::Root { members: config.members.clone() } @@ -733,7 +734,7 @@ impl TomlManifest { bail!("virtual manifests must be configured with [workspace]"); } }; - Ok((VirtualManifest::new(replace, workspace_config), nested_paths)) + Ok((VirtualManifest::new(replace, workspace_config, profiles), nested_paths)) } fn replace(&self, cx: &mut Context) diff --git a/tests/profiles.rs b/tests/profiles.rs index ab060bba265..00169adaa3f 100644 --- a/tests/profiles.rs +++ b/tests/profiles.rs @@ -187,3 +187,71 @@ fn top_level_overrides_deps() { prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX))); } + +#[test] +fn profile_in_non_root_manifest_triggers_a_warning() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.1.0" + authors = [] + + [workspace] + members = ["bar"] + + [profile.dev] + debug = false + "#) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + workspace = ".." + + [profile.dev] + opt-level = 1 + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo_process("build").cwd(p.root().join("bar")).arg("-v"), + execs().with_status(0).with_stderr("\ +[WARNING] profiles for the non root package will be ignored, specify profiles at the workspace root: +package: [..] +workspace: [..] +[COMPILING] bar v0.1.0 ([..]) +[RUNNING] `rustc [..]` +[FINISHED] debug [unoptimized] target(s) in [..]")); +} + +#[test] +fn profile_in_virtual_manifest_works() { + let p = project("foo") + .file("Cargo.toml", r#" + [workspace] + members = ["bar"] + + [profile.dev] + opt-level = 1 + debug = false + "#) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + workspace = ".." + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + + assert_that(p.cargo_process("build").cwd(p.root().join("bar")).arg("-v"), + execs().with_status(0).with_stderr("\ +[COMPILING] bar v0.1.0 ([..]) +[RUNNING] `rustc [..]` +[FINISHED] debug [optimized] target(s) in [..]")); +} From f7c1e26eeb65844e9474a2447ce129260ca1d638 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 Nov 2016 10:32:35 -0700 Subject: [PATCH 0800/3888] Default urls in [replace] to crates.io The intention was to do this, and it mistakenly didn't happen! Closes #3235 --- src/cargo/core/package_id_spec.rs | 4 +++ src/cargo/util/toml.rs | 6 +++- tests/overrides.rs | 56 +++++++++++++++++++++++++++++-- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index 3299ada5738..a07b69e49f7 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -110,6 +110,10 @@ impl PackageIdSpec { pub fn version(&self) -> Option<&Version> { self.version.as_ref() } pub fn url(&self) -> Option<&Url> { self.url.as_ref() } + pub fn set_url(&mut self, url: Url) { + self.url = Some(url); + } + pub fn matches(&self, package_id: &PackageId) -> bool { if self.name() != package_id.name() { return false } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index bc72b5ee99b..dc5f92870e6 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -15,6 +15,7 @@ use core::{EitherManifest, VirtualManifest}; use core::dependency::{Kind, Platform}; use core::manifest::{LibKind, Profile, ManifestMetadata}; use core::package_id::Metadata; +use sources::CRATES_IO; use util::{self, CargoResult, human, ToUrl, ToSemver, ChainError, Config}; /// Representation of the projects file layout. @@ -740,11 +741,14 @@ impl TomlManifest { -> CargoResult> { let mut replace = Vec::new(); for (spec, replacement) in self.replace.iter().flat_map(|x| x) { - let spec = try!(PackageIdSpec::parse(spec).chain_error(|| { + let mut spec = try!(PackageIdSpec::parse(spec).chain_error(|| { human(format!("replacements must specify a valid semver \ version to replace, but `{}` does not", spec)) })); + if spec.url().is_none() { + spec.set_url(CRATES_IO.parse().unwrap()); + } let version_specified = match *replacement { TomlDependency::Detailed(ref d) => d.version.is_some(), diff --git a/tests/overrides.rs b/tests/overrides.rs index c7d56799f60..ba17e0f3253 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -73,7 +73,7 @@ fn missing_version() { error: failed to parse manifest at `[..]` Caused by: - replacements must specify a version to replace, but `foo` does not + replacements must specify a version to replace, but `[..]foo` does not ")); } @@ -468,7 +468,7 @@ fn override_wrong_name() { execs().with_status(101).with_stderr("\ [UPDATING] registry [..] [UPDATING] git repository [..] -error: no matching package for override `foo:0.1.0` found +error: no matching package for override `[..]foo:0.1.0` found location searched: file://[..] version required: = 0.1.0 ")); @@ -530,7 +530,7 @@ fn override_wrong_version() { error: failed to parse manifest at `[..]` Caused by: - replacements cannot specify a version requirement, but found one for `foo:0.1.0` + replacements cannot specify a version requirement, but found one for `[..]foo:0.1.0` ")); } @@ -875,3 +875,53 @@ fn override_an_override() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0)); } + +#[test] +fn overriding_nonexistent_no_spurious() { + Package::new("foo", "0.1.0").dep("bar", "0.1").publish(); + Package::new("bar", "0.1.0").publish(); + + let foo = git::repo(&paths::root().join("override")) + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "bar" } + "#) + .file("src/lib.rs", "pub fn foo() {}") + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/lib.rs", "pub fn foo() {}"); + foo.build(); + + + let p = project("local") + .file("Cargo.toml", &format!(r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "0.1.0" + + [replace] + "foo:0.1.0" = {{ git = '{url}' }} + "bar:0.1.0" = {{ git = '{url}' }} + "#, url = foo.url())) + .file("src/lib.rs", ""); + + assert_that(p.cargo_process("build"), + execs().with_status(0)); + assert_that(p.cargo("build"), + execs().with_status(0).with_stderr("\ +[FINISHED] [..] +").with_stdout("")); +} From ea35ec5111d66e106b60384034a8d614762f12c6 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Fri, 4 Nov 2016 16:21:43 +1100 Subject: [PATCH 0801/3888] Add an [EXE] hamcrest substitution for file extension This should make the testing a bit more precise as to whether we expect targets of the form foo.exe vs foo-abc123.exe. I was also considering adding a [/] substitution for the fwd slash vs backslash [..], but thought I would leave that to another PR if we thought that was a good idea. --- tests/bench.rs | 58 +++++++++++------------ tests/build-script.rs | 44 ++++++++--------- tests/cargotest/support/mod.rs | 1 + tests/clean.rs | 2 +- tests/cross-compile.rs | 14 +++--- tests/git.rs | 6 +-- tests/path.rs | 4 +- tests/run.rs | 18 +++---- tests/test.rs | 86 +++++++++++++++++----------------- 9 files changed, 117 insertions(+), 116 deletions(-) diff --git a/tests/bench.rs b/tests/bench.rs index bba5278e1dc..8ccbe643678 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -43,7 +43,7 @@ fn cargo_bench_simple() { execs().with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..]", p.url())) +[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test bench_hello ... bench: [..] 0 ns/iter (+/- 0) @@ -78,7 +78,7 @@ fn bench_tarname() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]bin2[..] +[RUNNING] target[..]release[..]bin2-[..][EXE] ", dir = prj.url())) .with_stdout(" running 1 test @@ -107,7 +107,7 @@ fn cargo_bench_verbose() { [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc src[..]foo.rs [..]` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[..]release[..]foo-[..] hello --bench`", url = p.url())) +[RUNNING] `[..]target[..]release[..]foo-[..][EXE] hello --bench`", url = p.url())) .with_stdout(" running 1 test test bench_hello ... bench: [..] 0 ns/iter (+/- 0) @@ -190,7 +190,7 @@ test bench_hello ... ") .with_stderr_contains(format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..] +[RUNNING] target[..]release[..]foo-[..][EXE] thread '[..]' panicked at 'assertion failed: \ `(left == right)` (left: \ `\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:14 @@ -243,8 +243,8 @@ fn bench_with_lib_dep() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]baz-[..] -[RUNNING] target[..]release[..]foo-[..]", p.url())) +[RUNNING] target[..]release[..]baz-[..][EXE] +[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test bin_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -307,7 +307,7 @@ fn bench_with_deep_lib_dep() { [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]", dir = p.url())) +[RUNNING] target[..]release[..]deps[..]bar-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bar_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -353,8 +353,8 @@ fn external_bench_explicit() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]bench-[..] -[RUNNING] target[..]release[..]foo-[..]", p.url())) +[RUNNING] target[..]release[..]bench-[..][EXE] +[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test external_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -403,8 +403,8 @@ fn external_bench_implicit() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]external-[..] -[RUNNING] target[..]release[..]foo-[..]", p.url())) +[RUNNING] target[..]release[..]external-[..][EXE] +[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test external_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -464,7 +464,7 @@ fn pass_through_command_line() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..]", dir = p.url())) +[RUNNING] target[..]release[..]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bar ... bench: [..] 0 ns/iter (+/- 0) @@ -476,7 +476,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured assert_that(p.cargo("bench").arg("foo"), execs().with_status(0) .with_stderr("[FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..]") +[RUNNING] target[..]release[..]foo-[..][EXE]") .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -546,8 +546,8 @@ fn lib_bin_same_name() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..] -[RUNNING] target[..]release[..]foo-[..]", p.url())) +[RUNNING] target[..]release[..]foo-[..][EXE] +[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test [..] ... bench: [..] 0 ns/iter (+/- 0) @@ -600,8 +600,8 @@ fn lib_with_standard_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]bench-[..] -[RUNNING] target[..]release[..]syntax-[..]", dir = p.url())) +[RUNNING] target[..]release[..]bench-[..][EXE] +[RUNNING] target[..]release[..]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bench ... bench: [..] 0 ns/iter (+/- 0) @@ -652,7 +652,7 @@ fn lib_with_standard_name2() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]syntax-[..]", dir = p.url())) +[RUNNING] target[..]release[..]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bench ... bench: [..] 0 ns/iter (+/- 0) @@ -722,8 +722,8 @@ fn bench_dylib() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] -[RUNNING] [..]target[..]release[..]bench-[..] -[RUNNING] [..]target[..]release[..]foo-[..]", dir = p.url())) +[RUNNING] [..]target[..]release[..]bench-[..][EXE] +[RUNNING] [..]target[..]release[..]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -744,8 +744,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured [FRESH] bar v0.0.1 ({dir}/bar) [FRESH] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] [..]target[..]release[..]bench-[..] -[RUNNING] [..]target[..]release[..]foo-[..]", dir = p.url())) +[RUNNING] [..]target[..]release[..]bench-[..][EXE] +[RUNNING] [..]target[..]release[..]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -786,7 +786,7 @@ fn bench_twice_with_build_cmd() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..]", dir = p.url())) +[RUNNING] target[..]release[..]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -798,7 +798,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured assert_that(p.cargo("bench"), execs().with_status(0) .with_stderr("[FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..]") +[RUNNING] target[..]release[..]foo-[..][EXE]") .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -871,8 +871,8 @@ fn bench_with_examples() { [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `{dir}[..]target[..]release[..]testb1-[..] --bench` -[RUNNING] `{dir}[..]target[..]release[..]testbench-[..] --bench`", +[RUNNING] `{dir}[..]target[..]release[..]testb1-[..][EXE] --bench` +[RUNNING] `{dir}[..]target[..]release[..]testbench-[..][EXE] --bench`", dir = p.root().display(), url = p.url())) .with_stdout(" running 1 test @@ -920,7 +920,7 @@ fn test_a_bench() { .with_stderr("\ [COMPILING] foo v0.1.0 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]debug[..]b-[..]") +[RUNNING] target[..]debug[..]b-[..][EXE]") .with_stdout(" running 1 test test foo ... ok @@ -1030,7 +1030,7 @@ fn test_bench_multiple_packages() { assert_that(p.cargo_process("bench").arg("-p").arg("bar").arg("-p").arg("baz"), execs().with_status(0) .with_stderr_contains("\ -[RUNNING] target[..]release[..]bbaz-[..]") +[RUNNING] target[..]release[..]bbaz-[..][EXE]") .with_stdout_contains(" running 1 test test bench_baz ... bench: 0 ns/iter (+/- 0) @@ -1038,7 +1038,7 @@ test bench_baz ... bench: 0 ns/iter (+/- 0) test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured ") .with_stderr_contains("\ -[RUNNING] target[..]release[..]bbar-[..]") +[RUNNING] target[..]release[..]bbar-[..][EXE]") .with_stdout_contains(" running 1 test test bench_bar ... bench: 0 ns/iter (+/- 0) diff --git a/tests/build-script.rs b/tests/build-script.rs index 18fca1ea710..619838fd330 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -34,7 +34,7 @@ fn custom_build_script_failed() { .with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin [..]` -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [ERROR] failed to run custom build command for `foo v0.5.0 ({url})` process didn't exit successfully: `[..]build-script-build[..]` (exit code: 101)", url = p.url()))); @@ -407,7 +407,7 @@ fn only_rerun_build_script() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -495,11 +495,11 @@ fn testing_and_such() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc [..] --crate-name foo [..]` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]foo-[..][..]` +[RUNNING] `[..]foo-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc --test [..]`") .with_stdout(" @@ -530,7 +530,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target[..]foo[..]` +[RUNNING] `target[..]foo[EXE]` ")); } @@ -674,7 +674,7 @@ fn build_deps_simple() { [RUNNING] `rustc [..] --crate-name a [..]` [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..] --extern a=[..]` -[RUNNING] `[..]foo-[..]build-script-build[..]` +[RUNNING] `[..]foo-[..]build-script-build[EXE]` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -764,7 +764,7 @@ fn build_cmd_with_a_build_cmd() { [RUNNING] `rustc [..] --crate-name b [..]` [COMPILING] a v0.5.0 (file://[..]) [RUNNING] `rustc a[..]build.rs [..] --extern b=[..]` -[RUNNING] `[..]a-[..]build-script-build[..]` +[RUNNING] `[..]a-[..]build-script-build[EXE]` [RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \ -C metadata=[..] \ --out-dir [..]target[..]deps --emit=dep-info,link \ @@ -774,7 +774,7 @@ fn build_cmd_with_a_build_cmd() { -g -C metadata=[..] --out-dir [..] --emit=dep-info,link \ -L [..]target[..]deps \ --extern a=[..]liba[..].rlib` -[RUNNING] `[..]foo-[..]build-script-build[..]` +[RUNNING] `[..]foo-[..]build-script-build[EXE]` [RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] --emit=dep-info,link \ @@ -854,7 +854,7 @@ fn output_separate_lines() { .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]foo-[..]build-script-build[..]` +[RUNNING] `[..]foo-[..]build-script-build[EXE]` [RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); @@ -882,7 +882,7 @@ fn output_separate_lines_new() { .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]foo-[..]build-script-build[..]` +[RUNNING] `[..]foo-[..]build-script-build[EXE]` [RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); @@ -1364,13 +1364,13 @@ fn cfg_test() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [RUNNING] [..] build.rs [..] -[RUNNING] [..]build-script-build[..] +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..]foo-[..] -[RUNNING] [..]test-[..] +[RUNNING] [..]foo-[..][EXE] +[RUNNING] [..]test-[..][EXE] [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", dir = p.url())) .with_stdout(" @@ -1486,8 +1486,8 @@ fn cfg_override_test() { [RUNNING] `[..]` [RUNNING] `[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..]foo-[..] -[RUNNING] [..]test-[..] +[RUNNING] [..]foo-[..][EXE] +[RUNNING] [..]test-[..][EXE] [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", dir = p.url())) .with_stdout(" @@ -1598,7 +1598,7 @@ fn flags_go_into_tests() { .with_stderr("\ [COMPILING] a v0.5.0 ([..] [RUNNING] `rustc a[..]build.rs [..]` -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc a[..]src[..]lib.rs [..] -L test[..]` [COMPILING] b v0.5.0 ([..] [RUNNING] `rustc b[..]src[..]lib.rs [..] -L test[..]` @@ -1606,7 +1606,7 @@ fn flags_go_into_tests() { [RUNNING] `rustc src[..]lib.rs [..] -L test[..]` [RUNNING] `rustc tests[..]foo.rs [..] -L test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]foo-[..]`") +[RUNNING] `[..]foo-[..][EXE]`") .with_stdout(" running 0 tests @@ -1621,7 +1621,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured [COMPILING] b v0.5.0 ([..] [RUNNING] `rustc b[..]src[..]lib.rs [..] -L test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]b-[..]`") +[RUNNING] `[..]b-[..][EXE]`") .with_stdout(" running 0 tests @@ -1802,7 +1802,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1816,7 +1816,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1845,7 +1845,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1856,7 +1856,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index e647b7af021..3fd2def2f53 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -672,6 +672,7 @@ fn substitute_macros(input: &str) -> String { ("[INSTALLING]", " Installing"), ("[REPLACING]", " Replacing"), ("[UNPACKING]", " Unpacking"), + ("[EXE]", if cfg!(windows) {".exe"} else {""}), ]; let mut result = input.to_owned(); for &(pat, subst) in macros.iter() { diff --git a/tests/clean.rs b/tests/clean.rs index 0b1cd0f7e6f..e7bf93fb891 100644 --- a/tests/clean.rs +++ b/tests/clean.rs @@ -172,7 +172,7 @@ fn build_script() { execs().with_status(0).with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc src[..]main.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); diff --git a/tests/cross-compile.rs b/tests/cross-compile.rs index fa09e451b4b..6575e674903 100644 --- a/tests/cross-compile.rs +++ b/tests/cross-compile.rs @@ -473,8 +473,8 @@ fn cross_tests() { .with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({foo}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]{triple}[..]bar-[..] -[RUNNING] target[..]{triple}[..]foo-[..]", foo = p.url(), triple = target)) +[RUNNING] target[..]{triple}[..]bar-[..][EXE] +[RUNNING] target[..]{triple}[..]foo-[..][EXE]", foo = p.url(), triple = target)) .with_stdout(" running 1 test test test ... ok @@ -511,7 +511,7 @@ fn no_cross_doctests() { let host_output = format!("\ [COMPILING] foo v0.0.0 ({foo}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo ", foo = p.url()); @@ -533,7 +533,7 @@ fn no_cross_doctests() { .with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({foo}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]{triple}[..]foo-[..] +[RUNNING] target[..]{triple}[..]foo-[..][EXE] ", foo = p.url(), triple = target))); } @@ -674,7 +674,7 @@ fn build_script_needed_for_host_and_target() { [RUNNING] `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`", dir = p.root().display())) .with_stderr_contains(&format!("\ -[RUNNING] `{dir}[..]target[..]build[..]d1-[..]build-script-build`", +[RUNNING] `{dir}[..]target[..]build[..]d1-[..]build-script-build[EXE]`", dir = p.root().display())) .with_stderr_contains("\ [RUNNING] `rustc d1[..]src[..]lib.rs [..]`") @@ -800,7 +800,7 @@ fn plugin_build_script_right_arch() { .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]build-script-build[..]` +[RUNNING] `[..]build-script-build[EXE]` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -852,7 +852,7 @@ fn build_script_with_platform_specific_dependencies() { [RUNNING] `rustc d1[..]src[..]lib.rs [..]` [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `{dir}[..]target[..]build[..]foo-[..]build-script-build` +[RUNNING] `{dir}[..]target[..]build[..]foo-[..]build-script-build[EXE]` [RUNNING] `rustc src[..]lib.rs [..] --target {target} [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), target = target))); diff --git a/tests/git.rs b/tests/git.rs index bba21b20451..146aa8fae7f 100644 --- a/tests/git.rs +++ b/tests/git.rs @@ -936,7 +936,7 @@ fn dep_with_changed_submodule() { [COMPILING] foo v0.5.0 ([..])\n\ [FINISHED] debug [unoptimized + debuginfo] target(s) in \ [..]\n\ - [RUNNING] `target[..]foo[..]`\n") + [RUNNING] `target[..]foo[EXE]`\n") .with_stdout("project2\n") .with_status(0)); @@ -978,7 +978,7 @@ fn dep_with_changed_submodule() { [COMPILING] foo v0.5.0 ([..])\n\ [FINISHED] debug [unoptimized + debuginfo] target(s) in \ [..]\n\ - [RUNNING] `target[..]foo[..]`\n") + [RUNNING] `target[..]foo[EXE]`\n") .with_stdout("project3\n") .with_status(0)); } @@ -1035,7 +1035,7 @@ fn dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..]") +[RUNNING] target[..]foo-[..][EXE]") .with_stdout(" running 1 test test tests::foo ... ok diff --git a/tests/path.rs b/tests/path.rs index 394b5ff8010..31e81e9a48a 100644 --- a/tests/path.rs +++ b/tests/path.rs @@ -189,7 +189,7 @@ fn cargo_compile_with_root_dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..]") +[RUNNING] target[..]foo-[..][EXE]") .with_stdout(" running 0 tests @@ -798,7 +798,7 @@ fn dev_deps_no_rebuild_lib() { [COMPILING] [..] v0.5.0 ({url}[..]) [COMPILING] [..] v0.5.0 ({url}[..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..]", url = p.url())) +[RUNNING] target[..]foo-[..][EXE]", url = p.url())) .with_stdout(" running 0 tests diff --git a/tests/run.rs b/tests/run.rs index eb438ac4170..66b821ba6b9 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -26,7 +26,7 @@ fn simple() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}foo[..]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target{sep}debug{sep}foo[EXE]`", dir = path2url(p.root()), sep = SEP)) .with_stdout("\ hello ")); @@ -232,7 +232,7 @@ fn specify_name() { [RUNNING] `rustc src[..]lib.rs [..]` [RUNNING] `rustc src[..]a.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}a[..]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target{sep}debug{sep}a[EXE]`", dir = path2url(p.root()), sep = SEP)) .with_stdout("\ hello a.rs ")); @@ -243,7 +243,7 @@ hello a.rs [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc src[..]b.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}b[..]`", sep = SEP)) +[RUNNING] `target{sep}debug{sep}b[EXE]`", sep = SEP)) .with_stdout("\ hello b.rs ")); @@ -271,7 +271,7 @@ fn run_example() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}examples{sep}a[..]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target{sep}debug{sep}examples{sep}a[EXE]`", dir = path2url(p.root()), sep = SEP)) .with_stdout("\ example ")); @@ -364,7 +364,7 @@ fn one_bin_multiple_examples() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}main[..]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target{sep}debug{sep}main[EXE]`", dir = path2url(p.root()), sep = SEP)) .with_stdout("\ hello main.rs ")); @@ -433,7 +433,7 @@ fn example_with_release_flag() { -L dependency={dir}{sep}target{sep}release{sep}deps \ --extern bar={dir}{sep}target{sep}release{sep}deps{sep}libbar.rlib` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `target{sep}release{sep}examples{sep}a[..]` +[RUNNING] `target{sep}release{sep}examples{sep}a[EXE]` ", dir = p.root().display(), url = path2url(p.root()), @@ -461,7 +461,7 @@ fast2")); -L dependency={dir}{sep}target{sep}debug{sep}deps \ --extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar.rlib` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}examples{sep}a[..]` +[RUNNING] `target{sep}debug{sep}examples{sep}a[EXE]` ", dir = p.root().display(), url = path2url(p.root()), @@ -520,7 +520,7 @@ fn release_works() { execs().with_status(0).with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `target{sep}release{sep}foo[..]` +[RUNNING] `target{sep}release{sep}foo[EXE]` ", dir = path2url(p.root()), sep = SEP))); @@ -591,7 +591,7 @@ fn run_from_executable_folder() { execs().with_status(0) .with_stderr(&format!("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..]\n\ -[RUNNING] `.{sep}foo[..]`", sep = SEP)) +[RUNNING] `.{sep}foo[EXE]`", sep = SEP)) .with_stdout("\ hello ")); diff --git a/tests/test.rs b/tests/test.rs index 5bc9d8e1bb7..cef4a18c579 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -40,7 +40,7 @@ fn cargo_test_simple() { execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..]", p.url())) +[RUNNING] target[..]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test test_hello ... ok @@ -92,8 +92,8 @@ fn cargo_test_release() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[..]foo-[..]` -[RUNNING] `[..]target[..]test-[..]` +[RUNNING] `[..]target[..]foo-[..][EXE]` +[RUNNING] `[..]target[..]test-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc --test [..]lib.rs[..]`", dir = p.url())) .with_stdout(" @@ -130,7 +130,7 @@ fn cargo_test_verbose() { [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc src[..]foo.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target[..]foo-[..] hello`", url = p.url())) +[RUNNING] `[..]target[..]foo-[..][EXE] hello`", url = p.url())) .with_stdout(" running 1 test test test_hello ... ok @@ -198,7 +198,7 @@ fn cargo_test_failing_test() { execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({url}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] [ERROR] test failed", url = p.url())) .with_stdout_contains(" running 1 test @@ -258,8 +258,8 @@ fn test_with_lib_dep() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]baz-[..] -[RUNNING] target[..]foo[..] +[RUNNING] target[..]baz-[..][EXE] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -374,8 +374,8 @@ fn external_test_explicit() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] -[RUNNING] target[..]test-[..] +[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[..]test-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -423,8 +423,8 @@ fn external_test_implicit() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]external-[..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]external-[..][EXE] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -483,7 +483,7 @@ fn pass_through_command_line() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo", dir = p.url())) .with_stdout(" running 1 test @@ -502,7 +502,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured execs().with_status(0) .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo") .with_stdout(" running 1 test @@ -567,8 +567,8 @@ fn lib_bin_same_name() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -620,8 +620,8 @@ fn lib_with_standard_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]syntax-[..] -[RUNNING] target[..]test-[..] +[RUNNING] target[..]syntax-[..][EXE] +[RUNNING] target[..]test-[..][EXE] [DOCTEST] syntax", dir = p.url())) .with_stdout(" running 1 test @@ -675,7 +675,7 @@ fn lib_with_standard_name2() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]syntax-[..]", dir = p.url())) +[RUNNING] target[..]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test test ... ok @@ -715,7 +715,7 @@ fn lib_without_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]syntax-[..]", dir = p.url())) +[RUNNING] target[..]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test test ... ok @@ -973,8 +973,8 @@ fn test_dylib() { [COMPILING] bar v0.0.1 ({dir}/bar) [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] -[RUNNING] target[..]test-[..]", dir = p.url())) +[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[..]test-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test foo ... ok @@ -993,8 +993,8 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured execs().with_status(0) .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] -[RUNNING] target[..]test-[..]") +[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[..]test-[..][EXE]") .with_stdout(" running 1 test test foo ... ok @@ -1032,7 +1032,7 @@ fn test_twice_with_build_cmd() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo", dir = p.url())) .with_stdout(" running 1 test @@ -1051,7 +1051,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured execs().with_status(0) .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo") .with_stdout(" running 1 test @@ -1086,7 +1086,7 @@ fn test_then_build() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..] +[RUNNING] target[..]foo-[..][EXE] [DOCTEST] foo", dir = p.url())) .with_stdout(" running 1 test @@ -1154,7 +1154,7 @@ fn test_run_specific_bin_target() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]bin2-[..]", dir = prj.url())) +[RUNNING] target[..]bin2-[..][EXE]", dir = prj.url())) .with_stdout(" running 1 test test test2 ... ok @@ -1183,7 +1183,7 @@ fn test_run_specific_test_target() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]b-[..]", dir = prj.url())) +[RUNNING] target[..]b-[..][EXE]", dir = prj.url())) .with_stdout(" running 1 test test test_b ... ok @@ -1219,7 +1219,7 @@ fn test_no_harness() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]bar-[..] +[RUNNING] target[..]bar-[..][EXE] ", dir = p.url()))); } @@ -1275,8 +1275,8 @@ fn selective_testing() { .with_stderr(&format!("\ [COMPILING] d1 v0.0.1 ({dir}/d1) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]d1-[..] -[RUNNING] target[..]d1-[..]", dir = p.url())) +[RUNNING] target[..]d1-[..][EXE] +[RUNNING] target[..]d1-[..][EXE]", dir = p.url())) .with_stdout(" running 0 tests @@ -1295,8 +1295,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr(&format!("\ [COMPILING] d2 v0.0.1 ({dir}/d2) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]d2-[..] -[RUNNING] target[..]d2-[..]", dir = p.url())) +[RUNNING] target[..]d2-[..][EXE] +[RUNNING] target[..]d2-[..][EXE]", dir = p.url())) .with_stdout(" running 0 tests @@ -1315,7 +1315,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..]", dir = p.url())) +[RUNNING] target[..]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 0 tests @@ -1477,7 +1477,7 @@ fn selective_testing_with_docs() { .with_stderr(&format!("\ [COMPILING] d1 v0.0.1 ({dir}/d1) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]deps[..]d1[..] +[RUNNING] target[..]deps[..]d1[..][EXE] [DOCTEST] d1", dir = p.url())) .with_stdout(" running 0 tests @@ -1659,7 +1659,7 @@ fn doctest_feature() { .with_stderr("\ [COMPILING] foo [..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo[..] +[RUNNING] target[..]foo[..][EXE] [DOCTEST] foo") .with_stdout(" running 0 tests @@ -1746,7 +1746,7 @@ fn filter_no_doc_tests() { execs().with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]debug[..]foo[..]") +[RUNNING] target[..]debug[..]foo[..][EXE]") .with_stdout(" running 0 tests @@ -1850,7 +1850,7 @@ fn cyclic_dev_dep_doc_test() { [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo[..] +[RUNNING] target[..]foo[..][EXE] [DOCTEST] foo") .with_stdout(" running 0 tests @@ -1943,8 +1943,8 @@ fn no_fail_fast() { .with_stderr_contains("\ [COMPILING] foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo[..] -[RUNNING] target[..]test_add_one[..]") +[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[..]test_add_one-[..][EXE]") .with_stdout_contains(" running 0 tests @@ -1952,7 +1952,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ") .with_stderr_contains("\ -[RUNNING] target[..]test_sub_one[..] +[RUNNING] target[..]test_sub_one-[..][EXE] [DOCTEST] foo") .with_stdout_contains("\ test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured @@ -2018,14 +2018,14 @@ fn test_multiple_packages() { assert_that(p.cargo("test").arg("-p").arg("d1").arg("-p").arg("d2"), execs().with_status(0) .with_stderr_contains("\ -[RUNNING] target[..]debug[..]d1-[..]") +[RUNNING] target[..]debug[..]d1-[..][EXE]") .with_stdout_contains(" running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ") .with_stderr_contains("\ -[RUNNING] target[..]debug[..]d2-[..]") +[RUNNING] target[..]debug[..]d2-[..][EXE]") .with_stdout_contains(" running 0 tests From 67de0f34f4ee5d6ae9c01f8875942730f1704fe8 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Fri, 4 Nov 2016 17:29:05 +1100 Subject: [PATCH 0802/3888] Fix bench_dylib for win --- tests/bench.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/bench.rs b/tests/bench.rs index 8ccbe643678..3fb461e506f 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -722,8 +722,8 @@ fn bench_dylib() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] -[RUNNING] [..]target[..]release[..]bench-[..][EXE] -[RUNNING] [..]target[..]release[..]foo-[..][EXE]", dir = p.url())) +[RUNNING] `[..]target[..]release[..]bench-[..][EXE] --bench` +[RUNNING] `[..]target[..]release[..]foo-[..][EXE] --bench`", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -744,8 +744,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured [FRESH] bar v0.0.1 ({dir}/bar) [FRESH] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] [..]target[..]release[..]bench-[..][EXE] -[RUNNING] [..]target[..]release[..]foo-[..][EXE]", dir = p.url())) +[RUNNING] `[..]target[..]release[..]bench-[..][EXE] --bench` +[RUNNING] `[..]target[..]release[..]foo-[..][EXE] --bench`", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) From c222090ae858c7e1427ac69f3e234c125b001eb3 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Fri, 4 Nov 2016 18:37:02 +1100 Subject: [PATCH 0803/3888] Build scripts don't have .exe appended --- tests/build-script.rs | 28 ++++++++++++++-------------- tests/clean.rs | 2 +- tests/cross-compile.rs | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/build-script.rs b/tests/build-script.rs index 619838fd330..cad562eb7e8 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -34,7 +34,7 @@ fn custom_build_script_failed() { .with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin [..]` -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [ERROR] failed to run custom build command for `foo v0.5.0 ({url})` process didn't exit successfully: `[..]build-script-build[..]` (exit code: 101)", url = p.url()))); @@ -407,7 +407,7 @@ fn only_rerun_build_script() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -495,7 +495,7 @@ fn testing_and_such() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..]` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] @@ -674,7 +674,7 @@ fn build_deps_simple() { [RUNNING] `rustc [..] --crate-name a [..]` [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..] --extern a=[..]` -[RUNNING] `[..]foo-[..]build-script-build[EXE]` +[RUNNING] `[..]foo-[..]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -764,7 +764,7 @@ fn build_cmd_with_a_build_cmd() { [RUNNING] `rustc [..] --crate-name b [..]` [COMPILING] a v0.5.0 (file://[..]) [RUNNING] `rustc a[..]build.rs [..] --extern b=[..]` -[RUNNING] `[..]a-[..]build-script-build[EXE]` +[RUNNING] `[..]a-[..]build-script-build` [RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \ -C metadata=[..] \ --out-dir [..]target[..]deps --emit=dep-info,link \ @@ -774,7 +774,7 @@ fn build_cmd_with_a_build_cmd() { -g -C metadata=[..] --out-dir [..] --emit=dep-info,link \ -L [..]target[..]deps \ --extern a=[..]liba[..].rlib` -[RUNNING] `[..]foo-[..]build-script-build[EXE]` +[RUNNING] `[..]foo-[..]build-script-build` [RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] --emit=dep-info,link \ @@ -854,7 +854,7 @@ fn output_separate_lines() { .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]foo-[..]build-script-build[EXE]` +[RUNNING] `[..]foo-[..]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); @@ -882,7 +882,7 @@ fn output_separate_lines_new() { .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]foo-[..]build-script-build[EXE]` +[RUNNING] `[..]foo-[..]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); @@ -1364,7 +1364,7 @@ fn cfg_test() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [RUNNING] [..] build.rs [..] -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] @@ -1598,7 +1598,7 @@ fn flags_go_into_tests() { .with_stderr("\ [COMPILING] a v0.5.0 ([..] [RUNNING] `rustc a[..]build.rs [..]` -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc a[..]src[..]lib.rs [..] -L test[..]` [COMPILING] b v0.5.0 ([..] [RUNNING] `rustc b[..]src[..]lib.rs [..] -L test[..]` @@ -1802,7 +1802,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1816,7 +1816,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1845,7 +1845,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1856,7 +1856,7 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); diff --git a/tests/clean.rs b/tests/clean.rs index e7bf93fb891..c10b58b050a 100644 --- a/tests/clean.rs +++ b/tests/clean.rs @@ -172,7 +172,7 @@ fn build_script() { execs().with_status(0).with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc src[..]main.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); diff --git a/tests/cross-compile.rs b/tests/cross-compile.rs index 6575e674903..13ddec2c7fc 100644 --- a/tests/cross-compile.rs +++ b/tests/cross-compile.rs @@ -674,7 +674,7 @@ fn build_script_needed_for_host_and_target() { [RUNNING] `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`", dir = p.root().display())) .with_stderr_contains(&format!("\ -[RUNNING] `{dir}[..]target[..]build[..]d1-[..]build-script-build[EXE]`", +[RUNNING] `{dir}[..]target[..]build[..]d1-[..]build-script-build`", dir = p.root().display())) .with_stderr_contains("\ [RUNNING] `rustc d1[..]src[..]lib.rs [..]`") @@ -800,7 +800,7 @@ fn plugin_build_script_right_arch() { .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]build-script-build[EXE]` +[RUNNING] `[..]build-script-build` [RUNNING] `rustc src[..]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -852,7 +852,7 @@ fn build_script_with_platform_specific_dependencies() { [RUNNING] `rustc d1[..]src[..]lib.rs [..]` [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `{dir}[..]target[..]build[..]foo-[..]build-script-build[EXE]` +[RUNNING] `{dir}[..]target[..]build[..]foo-[..]build-script-build` [RUNNING] `rustc src[..]lib.rs [..] --target {target} [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), target = target))); From 0644804fd42254dfb3a48f670b5cb8a110d9c133 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Fri, 4 Nov 2016 19:00:09 +1100 Subject: [PATCH 0804/3888] Backticks to tests/build-script.rs --- tests/build-script.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/build-script.rs b/tests/build-script.rs index cad562eb7e8..8f66550b803 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -1369,8 +1369,8 @@ fn cfg_test() { [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..]foo-[..][EXE] -[RUNNING] [..]test-[..][EXE] +[RUNNING] `[..]foo-[..][EXE]` +[RUNNING] `[..]test-[..][EXE]` [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", dir = p.url())) .with_stdout(" @@ -1486,8 +1486,8 @@ fn cfg_override_test() { [RUNNING] `[..]` [RUNNING] `[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..]foo-[..][EXE] -[RUNNING] [..]test-[..][EXE] +[RUNNING] `[..]foo-[..][EXE]` +[RUNNING] `[..]test-[..][EXE]` [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", dir = p.url())) .with_stdout(" From 13a66bea5ab1916d9178610885a1289431ad94f9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 4 Nov 2016 13:16:28 -0700 Subject: [PATCH 0805/3888] Un-ignore proc-macro tests --- tests/proc-macro.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/proc-macro.rs b/tests/proc-macro.rs index daae388e0ce..c1a2306e6aa 100644 --- a/tests/proc-macro.rs +++ b/tests/proc-macro.rs @@ -6,7 +6,6 @@ use cargotest::support::{project, execs}; use hamcrest::assert_that; #[test] -#[ignore] fn noop() { if !is_nightly() { return; @@ -63,7 +62,6 @@ fn noop() { } #[test] -#[ignore] fn impl_and_derive() { if !is_nightly() { return; @@ -148,7 +146,6 @@ fn impl_and_derive() { } #[test] -#[ignore] fn plugin_and_proc_macro() { if !is_nightly() { return; From df0c8f99d77da8dd7531b61568f4770ed651938a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 4 Nov 2016 15:44:46 -0700 Subject: [PATCH 0806/3888] Update makefile to 0.14.0 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 98d5e91c805..08dc61626ee 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -CFG_RELEASE_NUM=0.13.0 +CFG_RELEASE_NUM=0.14.0 CFG_RELEASE_LABEL= OPENSSL_VERS=1.0.2j From 7d436e97f3b337eb1a2c7abedda35bc2cb82b920 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sun, 6 Nov 2016 13:14:16 +1100 Subject: [PATCH 0807/3888] Add a [/] macro expansion for tests Converts to backslash on windows. Currently, we're using [..], so this will tighten up the tests. --- tests/bench.rs | 62 ++++++++++----------- tests/build-script.rs | 78 +++++++++++++-------------- tests/build.rs | 31 ++++++----- tests/cargotest/support/mod.rs | 1 + tests/cross-compile.rs | 51 ++++++++++-------- tests/git.rs | 6 +-- tests/path.rs | 6 +-- tests/run.rs | 6 +-- tests/rustc.rs | 2 +- tests/test.rs | 98 +++++++++++++++++----------------- 10 files changed, 173 insertions(+), 168 deletions(-) diff --git a/tests/bench.rs b/tests/bench.rs index 3fb461e506f..7048c57890f 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -43,7 +43,7 @@ fn cargo_bench_simple() { execs().with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) +[RUNNING] target[/]release[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test bench_hello ... bench: [..] 0 ns/iter (+/- 0) @@ -78,7 +78,7 @@ fn bench_tarname() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]bin2-[..][EXE] +[RUNNING] target[/]release[/]bin2-[..][EXE] ", dir = prj.url())) .with_stdout(" running 1 test @@ -105,9 +105,9 @@ fn cargo_bench_verbose() { assert_that(p.cargo_process("bench").arg("-v").arg("hello"), execs().with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({url}) -[RUNNING] `rustc src[..]foo.rs [..]` +[RUNNING] `rustc src[/]foo.rs [..]` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[..]release[..]foo-[..][EXE] hello --bench`", url = p.url())) +[RUNNING] `[..]target[/]release[/]foo-[..][EXE] hello --bench`", url = p.url())) .with_stdout(" running 1 test test bench_hello ... bench: [..] 0 ns/iter (+/- 0) @@ -190,10 +190,10 @@ test bench_hello ... ") .with_stderr_contains(format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..][EXE] +[RUNNING] target[/]release[/]foo-[..][EXE] thread '[..]' panicked at 'assertion failed: \ `(left == right)` (left: \ - `\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:14 + `\"hello\"`, right: `\"nope\"`)', src[/]foo.rs:14 [..] ", p.url())) .with_status(101)); @@ -243,8 +243,8 @@ fn bench_with_lib_dep() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]baz-[..][EXE] -[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) +[RUNNING] target[/]release[/]baz-[..][EXE] +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test bin_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -307,7 +307,7 @@ fn bench_with_deep_lib_dep() { [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]deps[..]bar-[..][EXE]", dir = p.url())) +[RUNNING] target[/]release[/]deps[/]bar-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bar_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -353,8 +353,8 @@ fn external_bench_explicit() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]bench-[..][EXE] -[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) +[RUNNING] target[/]release[/]bench-[..][EXE] +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test external_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -403,8 +403,8 @@ fn external_bench_implicit() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]external-[..][EXE] -[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) +[RUNNING] target[/]release[/]external-[..][EXE] +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test external_bench ... bench: [..] 0 ns/iter (+/- 0) @@ -464,7 +464,7 @@ fn pass_through_command_line() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..][EXE]", dir = p.url())) +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bar ... bench: [..] 0 ns/iter (+/- 0) @@ -476,7 +476,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured assert_that(p.cargo("bench").arg("foo"), execs().with_status(0) .with_stderr("[FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..][EXE]") +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]") .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -546,8 +546,8 @@ fn lib_bin_same_name() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..][EXE] -[RUNNING] target[..]release[..]foo-[..][EXE]", p.url())) +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE] +[RUNNING] target[/]release[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test [..] ... bench: [..] 0 ns/iter (+/- 0) @@ -600,8 +600,8 @@ fn lib_with_standard_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]bench-[..][EXE] -[RUNNING] target[..]release[..]syntax-[..][EXE]", dir = p.url())) +[RUNNING] target[/]release[/]bench-[..][EXE] +[RUNNING] target[/]release[/]deps[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bench ... bench: [..] 0 ns/iter (+/- 0) @@ -652,7 +652,7 @@ fn lib_with_standard_name2() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]syntax-[..][EXE]", dir = p.url())) +[RUNNING] target[/]release[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bench ... bench: [..] 0 ns/iter (+/- 0) @@ -722,8 +722,8 @@ fn bench_dylib() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[..]release[..]bench-[..][EXE] --bench` -[RUNNING] `[..]target[..]release[..]foo-[..][EXE] --bench`", dir = p.url())) +[RUNNING] `[..]target[/]release[/]bench-[..][EXE] --bench` +[RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] --bench`", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -744,8 +744,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured [FRESH] bar v0.0.1 ({dir}/bar) [FRESH] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[..]release[..]bench-[..][EXE] --bench` -[RUNNING] `[..]target[..]release[..]foo-[..][EXE] --bench`", dir = p.url())) +[RUNNING] `[..]target[/]release[/]bench-[..][EXE] --bench` +[RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] --bench`", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -786,7 +786,7 @@ fn bench_twice_with_build_cmd() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..][EXE]", dir = p.url())) +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -798,7 +798,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured assert_that(p.cargo("bench"), execs().with_status(0) .with_stderr("[FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[..]release[..]foo-[..][EXE]") +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]") .with_stdout(" running 1 test test foo ... bench: [..] 0 ns/iter (+/- 0) @@ -871,8 +871,8 @@ fn bench_with_examples() { [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `{dir}[..]target[..]release[..]testb1-[..][EXE] --bench` -[RUNNING] `{dir}[..]target[..]release[..]testbench-[..][EXE] --bench`", +[RUNNING] `{dir}[/]target[/]release[/]testb1-[..][EXE] --bench` +[RUNNING] `{dir}[/]target[/]release[/]deps[/]testbench-[..][EXE] --bench`", dir = p.root().display(), url = p.url())) .with_stdout(" running 1 test @@ -920,7 +920,7 @@ fn test_a_bench() { .with_stderr("\ [COMPILING] foo v0.1.0 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]debug[..]b-[..][EXE]") +[RUNNING] target[/]debug[/]b-[..][EXE]") .with_stdout(" running 1 test test foo ... ok @@ -1030,7 +1030,7 @@ fn test_bench_multiple_packages() { assert_that(p.cargo_process("bench").arg("-p").arg("bar").arg("-p").arg("baz"), execs().with_status(0) .with_stderr_contains("\ -[RUNNING] target[..]release[..]bbaz-[..][EXE]") +[RUNNING] target[/]release[/]deps[/]bbaz-[..][EXE]") .with_stdout_contains(" running 1 test test bench_baz ... bench: 0 ns/iter (+/- 0) @@ -1038,7 +1038,7 @@ test bench_baz ... bench: 0 ns/iter (+/- 0) test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured ") .with_stderr_contains("\ -[RUNNING] target[..]release[..]bbar-[..][EXE]") +[RUNNING] target[/]release[/]deps[/]bbar-[..][EXE]") .with_stdout_contains(" running 1 test test bench_bar ... bench: 0 ns/iter (+/- 0) diff --git a/tests/build-script.rs b/tests/build-script.rs index 8f66550b803..fb1f0ea534f 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -34,9 +34,9 @@ fn custom_build_script_failed() { .with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin [..]` -[RUNNING] `[..]build-script-build` +[RUNNING] `[..][/]build-script-build` [ERROR] failed to run custom build command for `foo v0.5.0 ({url})` -process didn't exit successfully: `[..]build-script-build[..]` (exit code: 101)", +process didn't exit successfully: `[..][/]build-script-build[EXE]` (exit code: 101)", url = p.url()))); } @@ -407,7 +407,7 @@ fn only_rerun_build_script() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `[..]build-script-build` +[RUNNING] `[..][/]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -495,11 +495,11 @@ fn testing_and_such() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `[..]build-script-build` +[RUNNING] `[..][/]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..]` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]foo-[..][EXE]` +[RUNNING] `[..][/]foo-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc --test [..]`") .with_stdout(" @@ -530,7 +530,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target[..]foo[EXE]` +[RUNNING] `target[/]debug[/]foo[EXE]` ")); } @@ -674,7 +674,7 @@ fn build_deps_simple() { [RUNNING] `rustc [..] --crate-name a [..]` [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..] --extern a=[..]` -[RUNNING] `[..]foo-[..]build-script-build` +[RUNNING] `[..][/]foo-[..][/]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -763,22 +763,22 @@ fn build_cmd_with_a_build_cmd() { [COMPILING] b v0.5.0 (file://[..]) [RUNNING] `rustc [..] --crate-name b [..]` [COMPILING] a v0.5.0 (file://[..]) -[RUNNING] `rustc a[..]build.rs [..] --extern b=[..]` -[RUNNING] `[..]a-[..]build-script-build` +[RUNNING] `rustc a[/]build.rs [..] --extern b=[..]` +[RUNNING] `[..][/]a-[..][/]build-script-build` [RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \ -C metadata=[..] \ - --out-dir [..]target[..]deps --emit=dep-info,link \ - -L [..]target[..]deps` + --out-dir [..]target[/]debug[/]deps --emit=dep-info,link \ + -L [..]target[/]debug[/]deps` [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin \ -g -C metadata=[..] --out-dir [..] --emit=dep-info,link \ - -L [..]target[..]deps \ + -L [..]target[/]debug[/]deps \ --extern a=[..]liba[..].rlib` -[RUNNING] `[..]foo-[..]build-script-build` +[RUNNING] `[..][/]foo-[..][/]build-script-build` [RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] --emit=dep-info,link \ - -L [..]target[..]deps` + -L [..]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -854,7 +854,7 @@ fn output_separate_lines() { .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]foo-[..]build-script-build` +[RUNNING] `[..][/]foo-[..][/]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); @@ -882,7 +882,7 @@ fn output_separate_lines_new() { .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]foo-[..]build-script-build` +[RUNNING] `[..][/]foo-[..][/]build-script-build` [RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); @@ -927,7 +927,7 @@ fn code_generation() { .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target[..]foo`") +[RUNNING] `target[/]debug[/]foo`") .with_stdout("\ Hello, World! ")); @@ -1364,13 +1364,13 @@ fn cfg_test() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [RUNNING] [..] build.rs [..] -[RUNNING] `[..]build-script-build` +[RUNNING] `[..][/]build-script-build` [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] [RUNNING] [..] --cfg foo[..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]foo-[..][EXE]` -[RUNNING] `[..]test-[..][EXE]` +[RUNNING] `[..][/]foo-[..][EXE]` +[RUNNING] `[..][/]test-[..][EXE]` [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", dir = p.url())) .with_stdout(" @@ -1486,8 +1486,8 @@ fn cfg_override_test() { [RUNNING] `[..]` [RUNNING] `[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]foo-[..][EXE]` -[RUNNING] `[..]test-[..][EXE]` +[RUNNING] `[..][/]foo-[..][EXE]` +[RUNNING] `[..][/]test-[..][EXE]` [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", dir = p.url())) .with_stdout(" @@ -1597,16 +1597,16 @@ fn flags_go_into_tests() { execs().with_status(0) .with_stderr("\ [COMPILING] a v0.5.0 ([..] -[RUNNING] `rustc a[..]build.rs [..]` -[RUNNING] `[..]build-script-build` -[RUNNING] `rustc a[..]src[..]lib.rs [..] -L test[..]` +[RUNNING] `rustc a[/]build.rs [..]` +[RUNNING] `[..][/]build-script-build` +[RUNNING] `rustc a[/]src[/]lib.rs [..] -L test[..]` [COMPILING] b v0.5.0 ([..] -[RUNNING] `rustc b[..]src[..]lib.rs [..] -L test[..]` +[RUNNING] `rustc b[/]src[/]lib.rs [..] -L test[..]` [COMPILING] foo v0.5.0 ([..] -[RUNNING] `rustc src[..]lib.rs [..] -L test[..]` -[RUNNING] `rustc tests[..]foo.rs [..] -L test[..]` +[RUNNING] `rustc src[/]lib.rs [..] -L test[..]` +[RUNNING] `rustc tests[/]foo.rs [..] -L test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]foo-[..][EXE]`") +[RUNNING] `[..][/]foo-[..][EXE]`") .with_stdout(" running 0 tests @@ -1619,9 +1619,9 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr("\ [FRESH] a v0.5.0 ([..] [COMPILING] b v0.5.0 ([..] -[RUNNING] `rustc b[..]src[..]lib.rs [..] -L test[..]` +[RUNNING] `rustc b[/]src[/]lib.rs [..] -L test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]b-[..][EXE]`") +[RUNNING] `[..][/]b-[..][EXE]`") .with_stdout(" running 0 tests @@ -1802,8 +1802,8 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build` -[RUNNING] `rustc src[..]lib.rs [..]` +[RUNNING] `[..][/]build-script-build` +[RUNNING] `rustc src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1816,8 +1816,8 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build` -[RUNNING] `rustc src[..]lib.rs [..]` +[RUNNING] `[..][/]build-script-build` +[RUNNING] `rustc src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1845,8 +1845,8 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build` -[RUNNING] `rustc src[..]lib.rs [..]` +[RUNNING] `[..][/]build-script-build` +[RUNNING] `rustc src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1856,8 +1856,8 @@ fn rebuild_only_on_explicit_paths() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) -[RUNNING] `[..]build-script-build` -[RUNNING] `rustc src[..]lib.rs [..]` +[RUNNING] `[..][/]build-script-build` +[RUNNING] `rustc src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } diff --git a/tests/build.rs b/tests/build.rs index 5b235842576..2bf78d7ba7c 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -98,7 +98,7 @@ fn cargo_compile_with_invalid_manifest3() { Caused by: could not parse input as TOML\n\ -src[..]Cargo.toml:1:5-1:6 expected a value\n\n")) +src[/]Cargo.toml:1:5-1:6 expected a value\n\n")) } #[test] @@ -1051,13 +1051,13 @@ fn lto_build() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[..]main.rs --crate-name test --crate-type bin \ +[RUNNING] `rustc src[/]main.rs --crate-name test --crate-type bin \ -C opt-level=3 \ -C lto \ -C metadata=[..] \ - --out-dir {dir}[..]target[..]release \ + --out-dir {dir}[/]target[/]release \ --emit=dep-info,link \ - -L dependency={dir}[..]target[..]release[..]deps` + -L dependency={dir}[/]target[/]release[/]deps` [FINISHED] release [optimized] target(s) in [..] ", dir = p.root().display(), @@ -1080,11 +1080,11 @@ fn verbose_build() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib -g \ +[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}[..]target[..]debug[..]deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), @@ -1107,12 +1107,12 @@ fn verbose_release_build() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ -C opt-level=3 \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}[..]target[..]release[..]deps` + -L dependency={dir}[/]target[/]release[/]deps` [FINISHED] release [optimized] target(s) in [..] ", dir = p.root().display(), @@ -1150,23 +1150,22 @@ fn verbose_release_build_deps() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({url}/foo) -[RUNNING] `rustc foo[..]src[..]lib.rs --crate-name foo \ +[RUNNING] `rustc foo[/]src[/]lib.rs --crate-name foo \ --crate-type dylib --crate-type rlib -C prefer-dynamic \ -C opt-level=3 \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}[..]target[..]release[..]deps` + -L dependency={dir}[/]target[/]release[/]deps` [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[..]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ -C opt-level=3 \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}[..]target[..]release[..]deps \ - --extern foo={dir}[..]target[..]release[..]deps[..]\ - {prefix}foo{suffix} \ - --extern foo={dir}[..]target[..]release[..]deps[..]libfoo.rlib` + -L dependency={dir}[/]target[/]release[/]deps \ + --extern foo={dir}[/]target[/]release[/]deps[/]{prefix}foo{suffix} \ + --extern foo={dir}[/]target[/]release[/]deps[/]libfoo.rlib` [FINISHED] release [optimized] target(s) in [..] ", dir = p.root().display(), @@ -2266,7 +2265,7 @@ fn explicit_color_config_is_propagated_to_rustc() { assert_that(p.cargo_process("build").arg("-v").arg("--color").arg("always"), execs().with_status(0).with_stderr_contains( - "[..]rustc src[..]lib.rs --color always[..]")); + "[..]rustc src[/]lib.rs --color always[..]")); assert_that(p.cargo_process("build").arg("-v").arg("--color").arg("never"), execs().with_status(0).with_stderr("\ diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index 3fd2def2f53..cef108bcc38 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -673,6 +673,7 @@ fn substitute_macros(input: &str) -> String { ("[REPLACING]", " Replacing"), ("[UNPACKING]", " Unpacking"), ("[EXE]", if cfg!(windows) {".exe"} else {""}), + ("[/]", if cfg!(windows) {"\\"} else {"/"}), ]; let mut result = input.to_owned(); for &(pat, subst) in macros.iter() { diff --git a/tests/cross-compile.rs b/tests/cross-compile.rs index 13ddec2c7fc..d5db5635263 100644 --- a/tests/cross-compile.rs +++ b/tests/cross-compile.rs @@ -357,13 +357,13 @@ fn linker_and_ar() { execs().with_status(101) .with_stderr_contains(&format!("\ [COMPILING] foo v0.5.0 ({url}) -[RUNNING] `rustc src[..]foo.rs --crate-name foo --crate-type bin -g \ +[RUNNING] `rustc src[/]foo.rs --crate-name foo --crate-type bin -g \ -C metadata=[..] \ - --out-dir {dir}[..]target[..]{target}[..]debug \ + --out-dir {dir}[/]target[/]{target}[/]debug \ --emit=dep-info,link \ --target {target} \ -C ar=my-ar-tool -C linker=my-linker-tool \ - -L dependency={dir}[..]target[..]{target}[..]debug[..]deps` + -L dependency={dir}[/]target[/]{target}[/]debug[/]deps` ", dir = p.root().display(), url = p.url(), @@ -473,8 +473,8 @@ fn cross_tests() { .with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({foo}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]{triple}[..]bar-[..][EXE] -[RUNNING] target[..]{triple}[..]foo-[..][EXE]", foo = p.url(), triple = target)) +[RUNNING] target[/]{triple}[/]debug[/]bar-[..][EXE] +[RUNNING] target[/]{triple}[/]debug[/]deps[/]foo-[..][EXE]", foo = p.url(), triple = target)) .with_stdout(" running 1 test test test ... ok @@ -511,7 +511,7 @@ fn no_cross_doctests() { let host_output = format!("\ [COMPILING] foo v0.0.0 ({foo}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo ", foo = p.url()); @@ -524,7 +524,12 @@ fn no_cross_doctests() { let target = host(); assert_that(p.cargo_process("test").arg("--target").arg(&target), execs().with_status(0) - .with_stderr(&host_output)); + .with_stderr(&format!("\ +[COMPILING] foo v0.0.0 ({foo}) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] target[/]{triple}[/]debug[/]deps[/]foo-[..][EXE] +[DOCTEST] foo +", foo = p.url(), triple = target))); println!("c"); let target = alternate(); @@ -533,7 +538,7 @@ fn no_cross_doctests() { .with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({foo}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]{triple}[..]foo-[..][EXE] +[RUNNING] target[/]{triple}[/]debug[/]deps[/]foo-[..][EXE] ", foo = p.url(), triple = target))); } @@ -599,9 +604,9 @@ fn cross_with_a_build_script() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] foo v0.0.0 (file://[..]) -[RUNNING] `rustc build.rs [..] --out-dir {dir}[..]target[..]build[..]foo-[..]` -[RUNNING] `{dir}[..]target[..]build[..]foo-[..]build-script-build` -[RUNNING] `rustc src[..]main.rs [..] --target {target} [..]` +[RUNNING] `rustc build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]foo-[..]` +[RUNNING] `{dir}[/]target[/]debug[/]build[/]foo-[..][/]build-script-build` +[RUNNING] `rustc src[/]main.rs [..] --target {target} [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", target = target, dir = p.root().display()))); @@ -671,25 +676,25 @@ fn build_script_needed_for_host_and_target() { .with_stderr_contains(&format!("\ [COMPILING] d1 v0.0.0 ({url}/d1)", url = p.url())) .with_stderr_contains(&format!("\ -[RUNNING] `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`", +[RUNNING] `rustc d1[/]build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]d1-[..]`", dir = p.root().display())) .with_stderr_contains(&format!("\ -[RUNNING] `{dir}[..]target[..]build[..]d1-[..]build-script-build`", +[RUNNING] `{dir}[/]target[/]debug[/]build[/]d1-[..][/]build-script-build`", dir = p.root().display())) .with_stderr_contains("\ -[RUNNING] `rustc d1[..]src[..]lib.rs [..]`") +[RUNNING] `rustc d1[/]src[/]lib.rs [..]`") .with_stderr_contains(&format!("\ [COMPILING] d2 v0.0.0 ({url}/d2)", url = p.url())) .with_stderr_contains(&format!("\ -[RUNNING] `rustc d2[..]src[..]lib.rs [..] \ +[RUNNING] `rustc d2[/]src[/]lib.rs [..] \ -L /path/to/{host}`", host = host)) .with_stderr_contains(&format!("\ [COMPILING] foo v0.0.0 ({url})", url = p.url())) .with_stderr_contains(&format!("\ -[RUNNING] `rustc build.rs [..] --out-dir {dir}[..]target[..]build[..]foo-[..] \ +[RUNNING] `rustc build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]foo-[..] \ -L /path/to/{host}`", dir = p.root().display(), host = host)) .with_stderr_contains(&format!("\ -[RUNNING] `rustc src[..]main.rs [..] --target {target} [..] \ +[RUNNING] `rustc src[/]main.rs [..] --target {target} [..] \ -L /path/to/{target}`", target = target))); } @@ -800,8 +805,8 @@ fn plugin_build_script_right_arch() { .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `[..]build-script-build` -[RUNNING] `rustc src[..]lib.rs [..]` +[RUNNING] `[..][/]build-script-build` +[RUNNING] `rustc src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -847,13 +852,13 @@ fn build_script_with_platform_specific_dependencies() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] d2 v0.0.0 ([..]) -[RUNNING] `rustc d2[..]src[..]lib.rs [..]` +[RUNNING] `rustc d2[/]src[/]lib.rs [..]` [COMPILING] d1 v0.0.0 ([..]) -[RUNNING] `rustc d1[..]src[..]lib.rs [..]` +[RUNNING] `rustc d1[/]src[/]lib.rs [..]` [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` -[RUNNING] `{dir}[..]target[..]build[..]foo-[..]build-script-build` -[RUNNING] `rustc src[..]lib.rs [..] --target {target} [..]` +[RUNNING] `{dir}[/]target[/]debug[/]build[/]foo-[..][/]build-script-build` +[RUNNING] `rustc src[/]lib.rs [..] --target {target} [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), target = target))); } diff --git a/tests/git.rs b/tests/git.rs index 146aa8fae7f..02c42b3ff7f 100644 --- a/tests/git.rs +++ b/tests/git.rs @@ -936,7 +936,7 @@ fn dep_with_changed_submodule() { [COMPILING] foo v0.5.0 ([..])\n\ [FINISHED] debug [unoptimized + debuginfo] target(s) in \ [..]\n\ - [RUNNING] `target[..]foo[EXE]`\n") + [RUNNING] `target[/]debug[/]foo[EXE]`\n") .with_stdout("project2\n") .with_status(0)); @@ -978,7 +978,7 @@ fn dep_with_changed_submodule() { [COMPILING] foo v0.5.0 ([..])\n\ [FINISHED] debug [unoptimized + debuginfo] target(s) in \ [..]\n\ - [RUNNING] `target[..]foo[EXE]`\n") + [RUNNING] `target[/]debug[/]foo[EXE]`\n") .with_stdout("project3\n") .with_status(0)); } @@ -1035,7 +1035,7 @@ fn dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE]") +[RUNNING] target[/]debug[/]foo-[..][EXE]") .with_stdout(" running 1 test test tests::foo ... ok diff --git a/tests/path.rs b/tests/path.rs index 31e81e9a48a..b9c89b1d10e 100644 --- a/tests/path.rs +++ b/tests/path.rs @@ -189,7 +189,7 @@ fn cargo_compile_with_root_dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE]") +[RUNNING] target[/]debug[/]foo-[..][EXE]") .with_stdout(" running 0 tests @@ -555,7 +555,7 @@ Caused by: Unable to update file://[..] Caused by: - failed to read `[..]bar[..]Cargo.toml` + failed to read `[..]bar[/]Cargo.toml` Caused by: [..] (os error [..]) @@ -798,7 +798,7 @@ fn dev_deps_no_rebuild_lib() { [COMPILING] [..] v0.5.0 ({url}[..]) [COMPILING] [..] v0.5.0 ({url}[..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE]", url = p.url())) +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", url = p.url())) .with_stdout(" running 0 tests diff --git a/tests/run.rs b/tests/run.rs index 66b821ba6b9..13a8472ce85 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -229,8 +229,8 @@ fn specify_name() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) -[RUNNING] `rustc src[..]lib.rs [..]` -[RUNNING] `rustc src[..]a.rs [..]` +[RUNNING] `rustc src[/]lib.rs [..]` +[RUNNING] `rustc src[/]bin[/]a.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target{sep}debug{sep}a[EXE]`", dir = path2url(p.root()), sep = SEP)) .with_stdout("\ @@ -241,7 +241,7 @@ hello a.rs execs().with_status(0) .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc src[..]b.rs [..]` +[RUNNING] `rustc src[/]bin[/]b.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target{sep}debug{sep}b[EXE]`", sep = SEP)) .with_stdout("\ diff --git a/tests/rustc.rs b/tests/rustc.rs index ce9c6213555..85684280c74 100644 --- a/tests/rustc.rs +++ b/tests/rustc.rs @@ -101,7 +101,7 @@ fn build_main_and_allow_unstable_options() { --out-dir [..] \ --emit=dep-info,link \ -L dependency={dir}{sep}target{sep}debug{sep}deps \ - --extern {name}={dir}{sep}target[..]lib{name}.rlib` + --extern {name}={dir}{sep}target[/]debug[/]deps[/]lib{name}.rlib` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", sep = SEP, dir = p.root().display(), url = p.url(), diff --git a/tests/test.rs b/tests/test.rs index cef4a18c579..b3ca52f8ce9 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -40,7 +40,7 @@ fn cargo_test_simple() { execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE]", p.url())) +[RUNNING] target[/]debug[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test test_hello ... ok @@ -92,8 +92,8 @@ fn cargo_test_release() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[..]foo-[..][EXE]` -[RUNNING] `[..]target[..]test-[..][EXE]` +[RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE]` +[RUNNING] `[..]target[/]release[/]test-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc --test [..]lib.rs[..]`", dir = p.url())) .with_stdout(" @@ -128,9 +128,9 @@ fn cargo_test_verbose() { assert_that(p.cargo_process("test").arg("-v").arg("hello"), execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({url}) -[RUNNING] `rustc src[..]foo.rs [..]` +[RUNNING] `rustc src[/]foo.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target[..]foo-[..][EXE] hello`", url = p.url())) +[RUNNING] `[..]target[/]debug[/]foo-[..][EXE] hello`", url = p.url())) .with_stdout(" running 1 test test test_hello ... ok @@ -198,7 +198,7 @@ fn cargo_test_failing_test() { execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({url}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]foo-[..][EXE] [ERROR] test failed", url = p.url())) .with_stdout_contains(" running 1 test @@ -209,7 +209,7 @@ failures: ---- test_hello stdout ---- thread 'test_hello' panicked at 'assertion failed: \ `(left == right)` (left: \ - `\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:12 + `\"hello\"`, right: `\"nope\"`)', src[/]foo.rs:12 ") .with_stdout_contains("\ failures: @@ -258,8 +258,8 @@ fn test_with_lib_dep() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]baz-[..][EXE] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]baz-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -374,8 +374,8 @@ fn external_test_explicit() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] -[RUNNING] target[..]test-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] +[RUNNING] target[/]debug[/]test-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -423,8 +423,8 @@ fn external_test_implicit() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]external-[..][EXE] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]external-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -483,7 +483,7 @@ fn pass_through_command_line() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", dir = p.url())) .with_stdout(" running 1 test @@ -502,7 +502,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured execs().with_status(0) .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo") .with_stdout(" running 1 test @@ -567,8 +567,8 @@ fn lib_bin_same_name() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] +[RUNNING] target[/]debug[/]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -620,8 +620,8 @@ fn lib_with_standard_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]syntax-[..][EXE] -[RUNNING] target[..]test-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]syntax-[..][EXE] +[RUNNING] target[/]debug[/]test-[..][EXE] [DOCTEST] syntax", dir = p.url())) .with_stdout(" running 1 test @@ -675,7 +675,7 @@ fn lib_with_standard_name2() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]syntax-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test test ... ok @@ -715,7 +715,7 @@ fn lib_without_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]syntax-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test test ... ok @@ -973,8 +973,8 @@ fn test_dylib() { [COMPILING] bar v0.0.1 ({dir}/bar) [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] -[RUNNING] target[..]test-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] +[RUNNING] target[/]debug[/]test-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test foo ... ok @@ -993,8 +993,8 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured execs().with_status(0) .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] -[RUNNING] target[..]test-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] +[RUNNING] target[/]debug[/]test-[..][EXE]") .with_stdout(" running 1 test test foo ... ok @@ -1032,7 +1032,7 @@ fn test_twice_with_build_cmd() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", dir = p.url())) .with_stdout(" running 1 test @@ -1051,7 +1051,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured execs().with_status(0) .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo") .with_stdout(" running 1 test @@ -1086,7 +1086,7 @@ fn test_then_build() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", dir = p.url())) .with_stdout(" running 1 test @@ -1154,7 +1154,7 @@ fn test_run_specific_bin_target() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]bin2-[..][EXE]", dir = prj.url())) +[RUNNING] target[/]debug[/]bin2-[..][EXE]", dir = prj.url())) .with_stdout(" running 1 test test test2 ... ok @@ -1183,7 +1183,7 @@ fn test_run_specific_test_target() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]b-[..][EXE]", dir = prj.url())) +[RUNNING] target[/]debug[/]b-[..][EXE]", dir = prj.url())) .with_stdout(" running 1 test test test_b ... ok @@ -1219,7 +1219,7 @@ fn test_no_harness() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]bar-[..][EXE] +[RUNNING] target[/]debug[/]bar-[..][EXE] ", dir = p.url()))); } @@ -1275,8 +1275,8 @@ fn selective_testing() { .with_stderr(&format!("\ [COMPILING] d1 v0.0.1 ({dir}/d1) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]d1-[..][EXE] -[RUNNING] target[..]d1-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]deps[/]d1-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]d1-[..][EXE]", dir = p.url())) .with_stdout(" running 0 tests @@ -1295,8 +1295,8 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr(&format!("\ [COMPILING] d2 v0.0.1 ({dir}/d2) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]d2-[..][EXE] -[RUNNING] target[..]d2-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]deps[/]d2-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]d2-[..][EXE]", dir = p.url())) .with_stdout(" running 0 tests @@ -1315,7 +1315,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", dir = p.url())) .with_stdout(" running 0 tests @@ -1477,7 +1477,7 @@ fn selective_testing_with_docs() { .with_stderr(&format!("\ [COMPILING] d1 v0.0.1 ({dir}/d1) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]deps[..]d1[..][EXE] +[RUNNING] target[/]debug[/]deps[/]d1[..][EXE] [DOCTEST] d1", dir = p.url())) .with_stdout(" running 0 tests @@ -1659,7 +1659,7 @@ fn doctest_feature() { .with_stderr("\ [COMPILING] foo [..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo[..][EXE] [DOCTEST] foo") .with_stdout(" running 0 tests @@ -1746,7 +1746,7 @@ fn filter_no_doc_tests() { execs().with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]debug[..]foo[..][EXE]") +[RUNNING] target[/]debug[/]foo[..][EXE]") .with_stdout(" running 0 tests @@ -1850,7 +1850,7 @@ fn cyclic_dev_dep_doc_test() { [COMPILING] foo v0.0.1 ([..]) [COMPILING] bar v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo[..][EXE] [DOCTEST] foo") .with_stdout(" running 0 tests @@ -1943,8 +1943,8 @@ fn no_fail_fast() { .with_stderr_contains("\ [COMPILING] foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[..]foo-[..][EXE] -[RUNNING] target[..]test_add_one-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] +[RUNNING] target[/]debug[/]test_add_one-[..][EXE]") .with_stdout_contains(" running 0 tests @@ -1952,7 +1952,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ") .with_stderr_contains("\ -[RUNNING] target[..]test_sub_one-[..][EXE] +[RUNNING] target[/]debug[/]test_sub_one-[..][EXE] [DOCTEST] foo") .with_stdout_contains("\ test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured @@ -2018,14 +2018,14 @@ fn test_multiple_packages() { assert_that(p.cargo("test").arg("-p").arg("d1").arg("-p").arg("d2"), execs().with_status(0) .with_stderr_contains("\ -[RUNNING] target[..]debug[..]d1-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]d1-[..][EXE]") .with_stdout_contains(" running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ") .with_stderr_contains("\ -[RUNNING] target[..]debug[..]d2-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]d2-[..][EXE]") .with_stdout_contains(" running 0 tests @@ -2058,8 +2058,8 @@ fn bin_does_not_rebuild_tests() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc src[..]main.rs [..]` -[RUNNING] `rustc src[..]main.rs [..]` +[RUNNING] `rustc src[/]main.rs [..]` +[RUNNING] `rustc src[/]main.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -2120,8 +2120,8 @@ fn selective_test_optional_dep() { .arg("--features").arg("a").arg("-p").arg("a"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.0.1 ([..]) -[RUNNING] `rustc a[..]src[..]lib.rs [..]` -[RUNNING] `rustc a[..]src[..]lib.rs [..]` +[RUNNING] `rustc a[/]src[/]lib.rs [..]` +[RUNNING] `rustc a[/]src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } From 95480d9677a5760ed6f17e842ab9a6f7325c1773 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sun, 6 Nov 2016 15:05:10 +1100 Subject: [PATCH 0808/3888] Fix error in build-script --- tests/build-script.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build-script.rs b/tests/build-script.rs index fb1f0ea534f..53c359f22e6 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -36,7 +36,7 @@ fn custom_build_script_failed() { [RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin [..]` [RUNNING] `[..][/]build-script-build` [ERROR] failed to run custom build command for `foo v0.5.0 ({url})` -process didn't exit successfully: `[..][/]build-script-build[EXE]` (exit code: 101)", +process didn't exit successfully: `[..][/]build-script-build` (exit code: 101)", url = p.url()))); } From cd1912b9eb850df2c892c8d81d888ac932a19ea1 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sun, 6 Nov 2016 15:53:21 +1100 Subject: [PATCH 0809/3888] Replace {sep} with [/] as well --- tests/build-lib.rs | 8 +++---- tests/profiles.rs | 34 +++++++++++++-------------- tests/run.rs | 58 ++++++++++++++++++++++------------------------ tests/rustc.rs | 43 +++++++++++++++------------------- tests/rustdoc.rs | 40 ++++++++++++++------------------ 5 files changed, 83 insertions(+), 100 deletions(-) diff --git a/tests/build-lib.rs b/tests/build-lib.rs index f0390194b22..44c41b8f3d1 100644 --- a/tests/build-lib.rs +++ b/tests/build-lib.rs @@ -1,21 +1,19 @@ extern crate cargotest; extern crate hamcrest; -use std::path::MAIN_SEPARATOR as SEP; - use cargotest::support::{basic_bin_manifest, execs, project, ProjectBuilder}; use hamcrest::{assert_that}; fn verbose_output_for_lib(p: &ProjectBuilder) -> String { format!("\ [COMPILING] {name} v{version} ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \ +[RUNNING] `rustc src[/]lib.rs --crate-name {name} --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, +", dir = p.root().display(), url = p.url(), name = "foo", version = "0.0.1") } diff --git a/tests/profiles.rs b/tests/profiles.rs index ab060bba265..6135acc5468 100644 --- a/tests/profiles.rs +++ b/tests/profiles.rs @@ -2,7 +2,6 @@ extern crate cargotest; extern crate hamcrest; use std::env; -use std::path::MAIN_SEPARATOR as SEP; use cargotest::is_nightly; use cargotest::support::{project, execs}; @@ -28,16 +27,16 @@ fn profile_overrides() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ -C opt-level=1 \ -C debug-assertions=on \ -C metadata=[..] \ -C rpath \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [optimized] target(s) in [..] -", sep = SEP, +", dir = p.root().display(), url = p.url(), ))); @@ -61,14 +60,14 @@ fn opt_level_override_0() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] [..] target(s) in [..] -", sep = SEP, +", dir = p.root().display(), url = p.url() ))); @@ -91,16 +90,16 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ -C opt-level={level} \ -g \ -C debug-assertions=on \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] [..] target(s) in [..] -", sep = SEP, +", dir = p.root().display(), url = p.url(), level = rustc_level @@ -160,30 +159,29 @@ fn top_level_overrides_deps() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({url}/foo) -[RUNNING] `rustc foo{sep}src{sep}lib.rs --crate-name foo \ +[RUNNING] `rustc foo[/]src[/]lib.rs --crate-name foo \ --crate-type dylib --crate-type rlib -C prefer-dynamic \ -C opt-level=1 \ -g \ -C metadata=[..] \ - --out-dir {dir}{sep}target{sep}release{sep}deps \ + --out-dir {dir}[/]target[/]release[/]deps \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}release{sep}deps` + -L dependency={dir}[/]target[/]release[/]deps` [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ -C opt-level=1 \ -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}release{sep}deps \ - --extern foo={dir}{sep}target{sep}release{sep}deps{sep}\ + -L dependency={dir}[/]target[/]release[/]deps \ + --extern foo={dir}[/]target[/]release[/]deps[/]\ {prefix}foo[..]{suffix} \ - --extern foo={dir}{sep}target{sep}release{sep}deps{sep}libfoo.rlib` + --extern foo={dir}[/]target[/]release[/]deps[/]libfoo.rlib` [FINISHED] release [optimized + debuginfo] target(s) in [..] ", dir = p.root().display(), url = p.url(), - sep = SEP, prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX))); } diff --git a/tests/run.rs b/tests/run.rs index 13a8472ce85..14607613866 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -2,8 +2,6 @@ extern crate cargo; extern crate cargotest; extern crate hamcrest; -use std::path::MAIN_SEPARATOR as SEP; - use cargo::util::paths::dylib_path_envvar; use cargotest::support::{project, execs, path2url}; use hamcrest::{assert_that, existing_file}; @@ -26,7 +24,7 @@ fn simple() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}foo[EXE]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target[/]debug[/]foo[EXE]`", dir = path2url(p.root()))) .with_stdout("\ hello ")); @@ -232,18 +230,18 @@ fn specify_name() { [RUNNING] `rustc src[/]lib.rs [..]` [RUNNING] `rustc src[/]bin[/]a.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}a[EXE]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target[/]debug[/]a[EXE]`", dir = path2url(p.root()))) .with_stdout("\ hello a.rs ")); assert_that(p.cargo("run").arg("--bin").arg("b").arg("-v"), execs().with_status(0) - .with_stderr(&format!("\ + .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc src[/]bin[/]b.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}b[EXE]`", sep = SEP)) +[RUNNING] `target[/]debug[/]b[EXE]`") .with_stdout("\ hello b.rs ")); @@ -271,7 +269,7 @@ fn run_example() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}examples{sep}a[EXE]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target[/]debug[/]examples[/]a[EXE]`", dir = path2url(p.root()))) .with_stdout("\ example ")); @@ -364,7 +362,7 @@ fn one_bin_multiple_examples() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}main[EXE]`", dir = path2url(p.root()), sep = SEP)) +[RUNNING] `target[/]debug[/]main[EXE]`", dir = path2url(p.root()))) .with_stdout("\ hello main.rs ")); @@ -418,26 +416,26 @@ fn example_with_release_flag() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] bar v0.0.1 ({url}/bar) -[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \ +[RUNNING] `rustc bar[/]src[/]bar.rs --crate-name bar --crate-type lib \ -C opt-level=3 \ -C metadata=[..] \ - --out-dir {dir}{sep}target{sep}release{sep}deps \ + --out-dir {dir}[/]target[/]release[/]deps \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}release{sep}deps` + -L dependency={dir}[/]target[/]release[/]deps` [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \ +[RUNNING] `rustc examples[/]a.rs --crate-name a --crate-type bin \ -C opt-level=3 \ -C metadata=[..] \ - --out-dir {dir}{sep}target{sep}release{sep}examples \ + --out-dir {dir}[/]target[/]release[/]examples \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}release{sep}deps \ - --extern bar={dir}{sep}target{sep}release{sep}deps{sep}libbar.rlib` + -L dependency={dir}[/]target[/]release[/]deps \ + --extern bar={dir}[/]target[/]release[/]deps[/]libbar.rlib` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `target{sep}release{sep}examples{sep}a[EXE]` +[RUNNING] `target[/]release[/]examples[/]a[EXE]` ", dir = p.root().display(), url = path2url(p.root()), - sep = SEP)) + )) .with_stdout("\ fast1 fast2")); @@ -446,26 +444,26 @@ fast2")); execs().with_status(0) .with_stderr(&format!("\ [COMPILING] bar v0.0.1 ({url}/bar) -[RUNNING] `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \ +[RUNNING] `rustc bar[/]src[/]bar.rs --crate-name bar --crate-type lib \ -g \ -C metadata=[..] \ - --out-dir {dir}{sep}target{sep}debug{sep}deps \ + --out-dir {dir}[/]target[/]debug[/]deps \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc examples{sep}a.rs --crate-name a --crate-type bin \ +[RUNNING] `rustc examples[/]a.rs --crate-name a --crate-type bin \ -g \ -C metadata=[..] \ - --out-dir {dir}{sep}target{sep}debug{sep}examples \ + --out-dir {dir}[/]target[/]debug[/]examples \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps \ - --extern bar={dir}{sep}target{sep}debug{sep}deps{sep}libbar.rlib` + -L dependency={dir}[/]target[/]debug[/]deps \ + --extern bar={dir}[/]target[/]debug[/]deps[/]libbar.rlib` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `target{sep}debug{sep}examples{sep}a[EXE]` +[RUNNING] `target[/]debug[/]examples[/]a[EXE]` ", dir = p.root().display(), url = path2url(p.root()), - sep = SEP)) + )) .with_stdout("\ slow1 slow2")); @@ -520,10 +518,10 @@ fn release_works() { execs().with_status(0).with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `target{sep}release{sep}foo[EXE]` +[RUNNING] `target[/]release[/]foo[EXE]` ", dir = path2url(p.root()), - sep = SEP))); + ))); assert_that(&p.release_bin("foo"), existing_file()); } @@ -589,9 +587,9 @@ fn run_from_executable_folder() { assert_that(p.cargo("run").cwd(cwd), execs().with_status(0) - .with_stderr(&format!("\ + .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..]\n\ -[RUNNING] `.{sep}foo[EXE]`", sep = SEP)) +[RUNNING] `.[/]foo[EXE]`") .with_stdout("\ hello ")); diff --git a/tests/rustc.rs b/tests/rustc.rs index 85684280c74..5e54bae5a6e 100644 --- a/tests/rustc.rs +++ b/tests/rustc.rs @@ -1,8 +1,6 @@ extern crate cargotest; extern crate hamcrest; -use std::path::MAIN_SEPARATOR as SEP; - use cargotest::support::{execs, project}; use hamcrest::assert_that; @@ -29,14 +27,13 @@ fn build_lib_for_foo() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, - dir = p.root().display(), url = p.url()))); +", dir = p.root().display(), url = p.url()))); } #[test] @@ -59,15 +56,14 @@ fn lib() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ -C debug-assertions=off \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, - dir = p.root().display(), url = p.url()))) +", dir = p.root().display(), url = p.url()))) } #[test] @@ -90,20 +86,20 @@ fn build_main_and_allow_unstable_options() { .with_status(0) .with_stderr(&format!("\ [COMPILING] {name} v{version} ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name {name} --crate-type lib -g \ +[RUNNING] `rustc src[/]lib.rs --crate-name {name} --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` -[RUNNING] `rustc src{sep}main.rs --crate-name {name} --crate-type bin -g \ + -L dependency={dir}[/]target[/]debug[/]deps` +[RUNNING] `rustc src[/]main.rs --crate-name {name} --crate-type bin -g \ -C debug-assertions \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ - -L dependency={dir}{sep}target{sep}debug{sep}deps \ - --extern {name}={dir}{sep}target[/]debug[/]deps[/]lib{name}.rlib` + -L dependency={dir}[/]target[/]debug[/]deps \ + --extern {name}={dir}[/]target[/]debug[/]deps[/]lib{name}.rlib` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, +", dir = p.root().display(), url = p.url(), name = "foo", version = "0.0.1"))); } @@ -155,13 +151,13 @@ fn build_with_args_to_one_of_multiple_binaries() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ -C metadata=[..] \ --out-dir [..]` -[RUNNING] `rustc src{sep}bin{sep}bar.rs --crate-name bar --crate-type bin -g \ +[RUNNING] `rustc src[/]bin[/]bar.rs --crate-name bar --crate-type bin -g \ -C debug-assertions [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, url = p.url()))); +", url = p.url()))); } #[test] @@ -211,13 +207,13 @@ fn build_with_args_to_one_of_multiple_tests() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ -C metadata=[..] \ --out-dir [..]` -[RUNNING] `rustc tests{sep}bar.rs --crate-name bar -g \ +[RUNNING] `rustc tests[/]bar.rs --crate-name bar -g \ -C debug-assertions [..]--test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, url = p.url()))); +", url = p.url()))); } #[test] @@ -259,8 +255,7 @@ fn build_foo_with_bar_dependency() { [COMPILING] foo v0.0.1 ({url}) [RUNNING] `[..] -g -C debug-assertions [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", - url = foo.url()))); +", url = foo.url()))); } #[test] diff --git a/tests/rustdoc.rs b/tests/rustdoc.rs index da1336f05bb..71f7fc507cd 100644 --- a/tests/rustdoc.rs +++ b/tests/rustdoc.rs @@ -1,8 +1,6 @@ extern crate cargotest; extern crate hamcrest; -use std::path::MAIN_SEPARATOR as SEP; - use cargotest::support::{execs, project}; use hamcrest::{assert_that}; @@ -22,12 +20,11 @@ fn rustdoc_simple() { .with_status(0) .with_stderr(format!("\ [DOCUMENTING] foo v0.0.1 ({url}) -[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \ - -o {dir}{sep}target{sep}doc \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` +[RUNNING] `rustdoc src[/]lib.rs --crate-name foo \ + -o {dir}[/]target[/]doc \ + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, - dir = p.root().display(), url = p.url()))); +", dir = p.root().display(), url = p.url()))); } #[test] @@ -46,13 +43,12 @@ fn rustdoc_args() { .with_status(0) .with_stderr(format!("\ [DOCUMENTING] foo v0.0.1 ({url}) -[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \ - -o {dir}{sep}target{sep}doc \ +[RUNNING] `rustdoc src[/]lib.rs --crate-name foo \ + -o {dir}[/]target[/]doc \ --no-defaults \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, - dir = p.root().display(), url = p.url()))); +", dir = p.root().display(), url = p.url()))); } @@ -90,16 +86,15 @@ fn rustdoc_foo_with_bar_dependency() { .with_status(0) .with_stderr(format!("\ [COMPILING] bar v0.0.1 ([..]) -[RUNNING] `rustc [..]bar{sep}src{sep}lib.rs [..]` +[RUNNING] `rustc [..]bar[/]src[/]lib.rs [..]` [DOCUMENTING] foo v0.0.1 ({url}) -[RUNNING] `rustdoc src{sep}lib.rs --crate-name foo \ - -o {dir}{sep}target{sep}doc \ +[RUNNING] `rustdoc src[/]lib.rs --crate-name foo \ + -o {dir}[/]target[/]doc \ --no-defaults \ - -L dependency={dir}{sep}target{sep}debug{sep}deps \ + -L dependency={dir}[/]target[/]debug[/]deps \ --extern [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, - dir = foo.root().display(), url = foo.url()))); +", dir = foo.root().display(), url = foo.url()))); } #[test] @@ -138,13 +133,12 @@ fn rustdoc_only_bar_dependency() { .with_status(0) .with_stderr(format!("\ [DOCUMENTING] bar v0.0.1 ([..]) -[RUNNING] `rustdoc [..]bar{sep}src{sep}lib.rs --crate-name bar \ - -o {dir}{sep}target{sep}doc \ +[RUNNING] `rustdoc [..]bar[/]src[/]lib.rs --crate-name bar \ + -o {dir}[/]target[/]doc \ --no-defaults \ - -L dependency={dir}{sep}target{sep}debug{sep}deps` + -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -", sep = SEP, - dir = foo.root().display()))); +", dir = foo.root().display()))); } From 1acacb1db7505e0d7d8454234bdce62db1a79009 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sun, 6 Nov 2016 23:33:49 +1100 Subject: [PATCH 0810/3888] Replace instances of src[..]*.rs with [/] --- tests/cargotest/support/mod.rs | 3 ++- tests/clean.rs | 2 +- tests/doc.rs | 2 +- tests/metadata.rs | 20 ++++++++++---------- tests/package.rs | 2 +- tests/read-manifest.rs | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index cef108bcc38..ea63261892b 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -351,7 +351,7 @@ impl Execs { description: &str, extra: &[u8], partial: bool) -> ham::MatchResult { let out = match expected { - Some(out) => substitute_macros(out), + Some(out) => out, None => return ham::success(), }; let actual = match str::from_utf8(actual) { @@ -432,6 +432,7 @@ impl Execs { } pub fn lines_match(expected: &str, mut actual: &str) -> bool { + let expected = substitute_macros(expected); for (i, part) in expected.split("[..]").enumerate() { match actual.find(part) { Some(j) => { diff --git a/tests/clean.rs b/tests/clean.rs index c10b58b050a..59170ed708b 100644 --- a/tests/clean.rs +++ b/tests/clean.rs @@ -173,7 +173,7 @@ fn build_script() { [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc build.rs [..]` [RUNNING] `[..]build-script-build` -[RUNNING] `rustc src[..]main.rs [..]` +[RUNNING] `rustc src[/]main.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } diff --git a/tests/doc.rs b/tests/doc.rs index ba5ea85ac30..457e53c25d1 100644 --- a/tests/doc.rs +++ b/tests/doc.rs @@ -445,7 +445,7 @@ fn doc_release() { execs().with_status(0) .with_stderr("\ [DOCUMENTING] foo v0.0.1 ([..]) -[RUNNING] `rustdoc src[..]lib.rs [..]` +[RUNNING] `rustdoc src[/]lib.rs [..]` ")); } diff --git a/tests/metadata.rs b/tests/metadata.rs index 2ed82b294a0..84664712339 100644 --- a/tests/metadata.rs +++ b/tests/metadata.rs @@ -27,7 +27,7 @@ fn cargo_metadata_simple() { "bin" ], "name": "foo", - "src_path": "src[..]foo.rs" + "src_path": "src[/]foo.rs" } ], "features": {}, @@ -212,11 +212,11 @@ fn workspace_metadata() { { "kind": [ "lib" ], "name": "bar", - "src_path": "[..]bar[..]src[..]lib.rs" + "src_path": "[..]bar[/]src[/]lib.rs" } ], "features": {}, - "manifest_path": "[..]bar[..]Cargo.toml" + "manifest_path": "[..]bar[/]Cargo.toml" }, { "name": "baz", @@ -230,11 +230,11 @@ fn workspace_metadata() { { "kind": [ "lib" ], "name": "baz", - "src_path": "[..]baz[..]src[..]lib.rs" + "src_path": "[..]baz[/]src[/]lib.rs" } ], "features": {}, - "manifest_path": "[..]baz[..]Cargo.toml" + "manifest_path": "[..]baz[/]Cargo.toml" } ], "workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"], @@ -283,11 +283,11 @@ fn workspace_metadata_no_deps() { { "kind": [ "lib" ], "name": "bar", - "src_path": "[..]bar[..]src[..]lib.rs" + "src_path": "[..]bar[/]src[/]lib.rs" } ], "features": {}, - "manifest_path": "[..]bar[..]Cargo.toml" + "manifest_path": "[..]bar[/]Cargo.toml" }, { "name": "baz", @@ -301,11 +301,11 @@ fn workspace_metadata_no_deps() { { "kind": [ "lib" ], "name": "baz", - "src_path": "[..]baz[..]src[..]lib.rs" + "src_path": "[..]baz[/]src[/]lib.rs" } ], "features": {}, - "manifest_path": "[..]baz[..]Cargo.toml" + "manifest_path": "[..]baz[/]Cargo.toml" } ], "workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"], @@ -341,7 +341,7 @@ const MANIFEST_OUTPUT: &'static str= "targets":[{ "kind":["bin"], "name":"foo", - "src_path":"src[..]foo.rs" + "src_path":"src[/]foo.rs" }], "features":{}, "manifest_path":"[..]Cargo.toml" diff --git a/tests/package.rs b/tests/package.rs index 7f3712f3724..f7b3d870cfe 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -48,7 +48,7 @@ See [..] assert_that(p.cargo("package").arg("-l"), execs().with_status(0).with_stdout("\ Cargo.toml -src[..]main.rs +src[/]main.rs ")); assert_that(p.cargo("package"), execs().with_status(0).with_stdout("")); diff --git a/tests/read-manifest.rs b/tests/read-manifest.rs index 44f7fa6f9ea..e13f8ba8066 100644 --- a/tests/read-manifest.rs +++ b/tests/read-manifest.rs @@ -21,7 +21,7 @@ fn read_manifest_output() -> String { "targets":[{ "kind":["bin"], "name":"foo", - "src_path":"src[..]foo.rs" + "src_path":"src[/]foo.rs" }], "features":{}, "manifest_path":"[..]Cargo.toml" From 675161b26b991acf5ede66c2bb98a128507aee8d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 6 Nov 2016 09:06:55 -0800 Subject: [PATCH 0811/3888] Open crate files readonly first This allows Cargo to work with read-only `CARGO_HOME` directories where the cache was prepared ahead of time. Closes #3256 --- src/cargo/sources/registry/remote.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index d470618b544..fd301b0b6f7 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -116,6 +116,19 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { -> CargoResult { let filename = format!("{}-{}.crate", pkg.name(), pkg.version()); let path = Path::new(&filename); + + // Attempt to open an read-only copy first to avoid an exclusive write + // lock and also work with read-only filesystems. Note that we check the + // length of the file like below to handle interrupted downloads. + // + // If this fails then we fall through to the exclusive path where we may + // have to redownload the file. + if let Ok(dst) = self.cache_path.open_ro(path, self.config, &filename) { + let meta = try!(dst.file().metadata()); + if meta.len() > 0 { + return Ok(dst) + } + } let mut dst = try!(self.cache_path.open_rw(path, self.config, &filename)); let meta = try!(dst.file().metadata()); if meta.len() > 0 { From cee8f620819590cf664398b24ad1e6b011180936 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Mon, 7 Nov 2016 09:27:49 +1100 Subject: [PATCH 0812/3888] Revert tests/read-manifest.rs --- tests/read-manifest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/read-manifest.rs b/tests/read-manifest.rs index e13f8ba8066..44f7fa6f9ea 100644 --- a/tests/read-manifest.rs +++ b/tests/read-manifest.rs @@ -21,7 +21,7 @@ fn read_manifest_output() -> String { "targets":[{ "kind":["bin"], "name":"foo", - "src_path":"src[/]foo.rs" + "src_path":"src[..]foo.rs" }], "features":{}, "manifest_path":"[..]Cargo.toml" From eb24598f6ad847926c4446b454e61b72a60e6f4c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 24 Oct 2016 23:48:39 -0700 Subject: [PATCH 0813/3888] Continuously publish Cargo builds This commit tweaks Cargo's automation to continuously publish builds on Travis an AppVeyor. Once this is merged we can hopefully turn off all buildbot automation related to Cargo and purely rely on Travis and AppVeyor for this repository. All CI matrices are ported over to Travis and AppVeyor and a new musl build of Cargo is even added just to test out adding that for a spin. Currently Cargo will upload the final artifact for each target to a directory keyed by the commit hash to a new bucket on S3, rust-lang-cargo-dev. Once we're happy with the builds then we can change this to `rust-lang-cargo` or anything else at that point. --- .travis.yml | 186 ++++++++++++++++++++------- Makefile.in | 55 ++++---- appveyor.yml | 64 ++++++--- configure | 43 +++---- src/ci/docker/cross/Dockerfile | 2 + src/ci/docker/dist/Dockerfile | 2 + src/ci/docker/run.sh | 49 +++++++ src/ci/docker/x86_64-musl/Dockerfile | 11 ++ src/ci/run.sh | 32 +++++ src/etc/install-deps.py | 7 + tests/init.rs | 4 +- tests/package.rs | 3 +- 12 files changed, 346 insertions(+), 112 deletions(-) create mode 100644 src/ci/docker/cross/Dockerfile create mode 100644 src/ci/docker/dist/Dockerfile create mode 100755 src/ci/docker/run.sh create mode 100644 src/ci/docker/x86_64-musl/Dockerfile create mode 100755 src/ci/run.sh diff --git a/.travis.yml b/.travis.yml index 731d1a5f272..be844a9c8a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,149 @@ language: rust -rust: - - stable - - beta - - nightly -sudo: false -script: - - ./configure --prefix=$HOME/cargo-install --disable-cross-tests --disable-optimize - - make - - make test - - make distcheck - - make doc - - make install - - make uninstall -after_success: | - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - [ $(uname -s) = Linux ] && - pip install ghp-import --user $USER && - $HOME/.local/bin/ghp-import -n target/doc && - git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages -env: - global: - # apparently we use too much memory and if there's more than one rustc then - # when compiling Cargo's unit tests some compilers will be randomly kill - # -9'd - - CARGOFLAGS=-j1 - - secure: scGpeetUfba5RWyuS4yt10bPoFAI9wpHEReIFqEx7eH5vr2Anajk6+70jW6GdrWVdUvdINiArlQ3An2DeB9vEUWcBjw8WvuPtOH0tDMoSsuVloPlFD8yn1Ac0Bx9getAO5ofxqtoNg+OV4MDVuGabEesqAOWqURNrBC7XK+ntC8= +rust: stable +sudo: required +dist: trusty +os: linux +services: + - docker matrix: include: - - os: osx - rust: stable + # stable linux builds, tested + - env: TARGET=x86_64-unknown-linux-gnu + ALT=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS="test distcheck doc install uninstall" + - env: TARGET=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS=test-unit-i686-unknown-linux-gnu + CFG_DISABLE_CROSS_TESTS=1 + + # stable osx builds, tested + - env: TARGET=x86_64-apple-darwin + ALT=i686-apple-darwin + MAKE_TARGETS="test distcheck doc install uninstall" + MACOSX_DEPLOYMENT_TARGET=10.7 + os: osx + before_install: + - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include + - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include + - env: TARGET=i686-apple-darwin + MAKE_TARGETS=test + MACOSX_DEPLOYMENT_TARGET=10.7 + CFG_DISABLE_CROSS_TESTS=1 + os: osx before_install: - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - - export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib - -branches: - only: - - master - -addons: - apt: - sources: - - kalakris-cmake - packages: - - cmake - - g++-multilib - - lib32stdc++6 + - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include + + # stable musl target, tested + - env: TARGET=x86_64-unknown-linux-musl + IMAGE=x86_64-musl + CFG_DISABLE_CROSS_TESTS=1 + MAKE_TARGETS=test-unit-$TARGET + + # cross compiled targets + - env: TARGET=arm-unknown-linux-gnueabi + IMAGE=cross + - env: TARGET=arm-unknown-linux-gnueabihf + IMAGE=cross + - env: TARGET=armv7-unknown-linux-gnueabihf + IMAGE=cross + - env: TARGET=aarch64-unknown-linux-gnu + IMAGE=cross + - env: TARGET=i686-unknown-freebsd + IMAGE=cross + - env: TARGET=x86_64-unknown-freebsd + IMAGE=cross + - env: TARGET=x86_64-unknown-netbsd + IMAGE=cross + - env: TARGET=mips-unknown-linux-gnu + IMAGE=cross + - env: TARGET=mipsel-unknown-linux-gnu + IMAGE=cross + - env: TARGET=mips64-unknown-linux-gnuabi64 + IMAGE=cross + rust: nightly + - env: TARGET=mips64el-unknown-linux-gnuabi64 + IMAGE=cross + rust: nightly + - env: TARGET=s390x-unknown-linux-gnu + IMAGE=cross + rust: nightly + - env: TARGET=powerpc-unknown-linux-gnu + IMAGE=cross + rust: beta + - env: TARGET=powerpc64-unknown-linux-gnu + IMAGE=cross + rust: beta + - env: TARGET=powerpc64le-unknown-linux-gnu + IMAGE=cross + rust: beta + + # beta/nightly builds + - env: TARGET=x86_64-unknown-linux-gnu + ALT=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS="test distcheck doc install uninstall" + DEPLOY=0 + rust: beta + - env: TARGET=x86_64-unknown-linux-gnu + ALT=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS="test distcheck doc install uninstall" + DEPLOY=0 + rust: nightly + + exclude: + - rust: stable + +before_script: + - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH + - curl https://static.rust-lang.org/rustup.sh | + sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot` + - if [ ! -z "$ALT" ]; then + curl https://static.rust-lang.org/rustup.sh | + sh -s -- --add-target=$ALT --disable-sudo -y --prefix=`rustc --print sysroot`; + fi +script: + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then + SRC=. src/ci/run.sh $TARGET; + else + src/ci/docker/run.sh $IMAGE $TARGET; + fi +after_success: + - travis-cargo --only nightly doc-upload + +env: + global: + - DEPLOY=1 + - secure: LB2o9UL90Z4CVOLVQsTbZr7ZBLA1dCLxFODuCkPkbdqG3Kl5z1yMIPMRvSbjp9KwBlIgm+Mg0R1iqphKVq+rVP5zo96K4+kEQMG+zWsPb23ZKTxiL8MK5VgCZ7s9AONCvNeCTCNAG3EyeciFr5Zr9eygVCfo0WF6JsPujYYQZx0= + +notifications: + email: + on_success: never + +before_deploy: + - mkdir -p deploy/$TRAVIS_COMMIT + - cp target/$TARGET/release/dist/cargo-nightly-$TARGET.tar.gz + deploy/$TRAVIS_COMMIT + +deploy: + - provider: s3 + bucket: rust-lang-cargo-dev + skip_cleanup: true + local_dir: deploy + upload_dir: cargo-master + acl: public_read + region: us-west-1 + access_key_id: AKIAJYHGN72KKCN4DFBQ + secret_access_key: + secure: wKKDMYBVTdWLuc7+ffpjTqJs1EdM2pXpV6keUfZGv9RLRta+esh/r/cgc+UQ7+m9JHAliH8eWhlMm5ws6WDgkTvM0PTdqWBgwd24BRbAitsXX2kWfi9WgAeSJVSkIJdZ999TRpRIJu7Zc+1++fbfdD/tDv5XBirQGOJv1HynVWY= + on: + branch: auto + condition: $DEPLOY = 1 + +cache: + directories: + - $HOME/.cargo + - target/openssl diff --git a/Makefile.in b/Makefile.in index 0b6cf33089a..55e571522d2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,11 +6,6 @@ OPENSSL_SHA256=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431 include config.mk -ifneq ($(CFG_LOCAL_RUST_ROOT),) -export LD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(LD_LIBRARY_PATH) -export DYLD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(DYLD_LIBRARY_PATH) -endif - export PATH := $(dir $(CFG_RUSTC)):$(PATH) ifdef CFG_ENABLE_NIGHTLY @@ -84,44 +79,45 @@ $(foreach target,$(CFG_TARGET),$(eval $(call DIST_TARGET,$(target)))) ifdef CFG_LOCAL_CARGO CARGO := $(CFG_LOCAL_CARGO) else -CARGO := $(TARGET_ROOT)/snapshot/bin/cargo$(X) +CARGO := $(CFG_CARGO) endif all: $(foreach target,$(CFG_TARGET),cargo-$(target)) define CARGO_TARGET -cargo-$(1): $$(CARGO) target/openssl/$(1).stamp +cargo-$(1): target/openssl/$(1).stamp $$(CFG_RUSTC) -V $$(CARGO) --version $$(CARGO) build --target $(1) \ --manifest-path $(S)Cargo.toml \ $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(ARGS) -test-unit-$(1): $$(CARGO) - @mkdir -p target/$(1)/cit - $$(CARGO) test --target $(1) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) +test-unit-$(1): target/openssl/$(1).stamp cargo-$(1) + @mkdir -p $$(CFG_BUILD_DIR)/target/$(1)/cit + $$(CARGO) test --target $(1) \ + --manifest-path $(S)Cargo.toml \ + $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) endef $(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target)))) -$(TARGET_ROOT)/snapshot/bin/cargo$(X): $(S)src/snapshots.txt - $(CFG_PYTHON) $(S)src/etc/dl-snapshot.py $(CFG_BUILD) - touch $@ - - # === Tests test: style no-exes $(foreach target,$(CFG_TARGET),test-unit-$(target)) style: - sh tests/check-style.sh + (cd $(S) && sh tests/check-style.sh) +ifeq ($(CFG_GIT),) +no-exes: +else no-exes: - find $$(git ls-files) -type f \ + (cd $(S) && find $$($(CFG_GIT) ls-files) -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ -not -name configure -not -name '*.sh' -not -name '*.rs' \ -not -name '*.py' -not -wholename "*/rust-installer/*" | \ grep '.*' \ - && exit 1 || exit 0 + && exit 1 || exit 0) +endif # === Misc @@ -142,9 +138,9 @@ DOC_OPTS := --markdown-no-toc \ --markdown-css stylesheets/normalize.css \ --markdown-css stylesheets/all.css \ --markdown-css stylesheets/prism.css \ - --html-in-header src/doc/html-headers.html \ - --html-before-content src/doc/header.html \ - --html-after-content src/doc/footer.html + --html-in-header $(S)src/doc/html-headers.html \ + --html-before-content $(S)src/doc/header.html \ + --html-after-content $(S)src/doc/footer.html ASSETS := CNAME images/noise.png images/forkme.png images/Cargo-Logo-Small.png \ stylesheets/all.css stylesheets/normalize.css javascripts/prism.js \ javascripts/all.js stylesheets/prism.css images/circle-with-i.png \ @@ -155,14 +151,19 @@ doc: $(foreach doc,$(DOCS),target/doc/$(doc).html) \ $(foreach asset,$(ASSETS),target/doc/$(asset)) \ target/doc/cargo/index.html -target/doc/cargo/index.html: - $(CARGO) doc --no-deps +target/doc/cargo/index.html: target/openssl/$(CFG_BUILD).stamp cargo-$(CFG_BUILD) + $(CARGO) doc --no-deps --target $(CFG_BUILD) \ + --manifest-path $(S)Cargo.toml $(OPT_FLAG) -$(DOC_DIR)/%.html: src/doc/%.md src/doc/html-headers.html src/doc/header.html src/doc/footer.html +$(DOC_DIR)/%.html: \ + $(S)src/doc/%.md \ + $(S)src/doc/html-headers.html \ + $(S)src/doc/header.html \ + $(S)src/doc/footer.html @mkdir -p $(@D) $(CFG_RUSTDOC) $< -o $(@D) $(DOC_OPTS) -$(DOC_DIR)/%: src/doc/% +$(DOC_DIR)/%: $(S)src/doc/% @mkdir -p $(@D) cp $< $@ @@ -172,6 +173,7 @@ OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf OPENSSL_OS_i686-unknown-linux-gnu := linux-elf +OPENSSL_OS_i686-unknown-linux-musl := linux-elf OPENSSL_OS_mips-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mips64-unknown-linux-gnuabi64 := linux64-mips64 @@ -191,6 +193,7 @@ OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar OPENSSL_AR_i686-unknown-linux-gnu := ar +OPENSSL_AR_i686-unknown-linux-musl := ar OPENSSL_AR_mips-unknown-linux-gnu := mips-linux-gnu-ar OPENSSL_AR_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-ar OPENSSL_AR_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-ar @@ -209,6 +212,7 @@ OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc OPENSSL_CC_i686-unknown-linux-gnu := gcc +OPENSSL_CC_i686-unknown-linux-musl := musl-gcc OPENSSL_CC_mips-unknown-linux-gnu := mips-linux-gnu-gcc OPENSSL_CC_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-gcc OPENSSL_CC_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-gcc @@ -224,6 +228,7 @@ OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc SETARCH_i686-unknown-linux-gnu := setarch i386 OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32 +OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32 define BUILD_OPENSSL ifdef OPENSSL_OS_$(1) diff --git a/appveyor.yml b/appveyor.yml index 88660ab3b3c..07d98a26b4e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,37 +1,71 @@ environment: - CFG_DISABLE_CROSS_TESTS: 1 matrix: - - TARGET: i686-pc-windows-msvc - MSVC: 1 - BITS: 32 - ARCH: x86 - - TARGET: x86_64-pc-windows-msvc - MSVC: 1 - BITS: 64 - ARCH: amd64 - TARGET: x86_64-pc-windows-gnu ARCH: amd64 BITS: 64 + CFG_DISABLE_CROSS_TESTS: 1 + MAKE_TARGETS: test-unit-x86_64-pc-windows-gnu - TARGET: i686-pc-windows-gnu ARCH: x86 BITS: 32 MINGW_URL: https://s3.amazonaws.com/rust-lang-ci MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z MINGW_DIR: mingw32 + CFG_DISABLE_CROSS_TESTS: 1 + MAKE_TARGETS: test-unit-i686-pc-windows-gnu + - TARGET: i686-pc-windows-msvc + BITS: 32 + ARCH: x86 + MAKE_TARGETS: test-unit-i686-pc-windows-msvc + CFG_DISABLE_CROSS_TESTS: 1 + - TARGET: x86_64-pc-windows-msvc + OTHER_TARGET: i686-pc-windows-msvc + BITS: 64 + ARCH: amd64 + MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc install: - - IF "%MSVC%"=="" set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% + - set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% - if defined MINGW_URL appveyor DownloadFile %MINGW_URL%/%MINGW_ARCHIVE% - if defined MINGW_URL 7z x -y %MINGW_ARCHIVE% > nul - if defined MINGW_URL set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% - - python src/etc/install-deps.py - - python src/etc/dl-snapshot.py %TARGET% - - SET PATH=%PATH%;%cd%/rustc/bin - - SET PATH=%PATH%;%cd%/target/snapshot/bin + - curl -sSf -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host x86_64-pc-windows-msvc + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET% + - if defined OTHER_TARGET rustup target add %OTHER_TARGET% - rustc -V - cargo -V + - git submodule update --init build: false test_script: - - cargo test + - sh src/ci/run.sh %TARGET% + +cache: + - target + - C:\Users\appveyor\.cargo\registry + +after_test: + - mkdir %APPVEYOR_REPO_COMMIT% + - copy target\%TARGET%\release\dist\cargo-nightly-%TARGET%.tar.gz + %APPVEYOR_REPO_COMMIT% + +artifacts: + - path: $(APPVEYOR_REPO_COMMIT)\cargo-nightly-$(TARGET).tar.gz + name: cargo + +deploy: + - provider: S3 + skip_cleanup: true + access_key_id: AKIAIIBSE766REJRCHEA + secret_access_key: + secure: S3MCw/gXyWBuq8cW+eFQjbfjccxrH1koYqQxsYDvCDkM7D2PLqd88yv8lND7dVt0 + bucket: rust-lang-cargo-dev + set_public: true + region: us-west-1 + artifact: cargo + folder: cargo-master + on: + branch: auto diff --git a/configure b/configure index 66400d80cef..1ead582545e 100755 --- a/configure +++ b/configure @@ -270,9 +270,7 @@ need_cmd date need_cmd tr need_cmd sed need_cmd cmake -if [ "${OS}" != "Windows_NT" ]; then - need_cmd curl -fi +need_cmd make CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" CFG_BUILD_DIR="$(pwd)/" @@ -309,20 +307,20 @@ opt cross-tests 1 "run cross-compilation tests" valopt prefix "/usr/local" "set installation prefix" valopt local-rust-root "" "set prefix for local rust binary" +if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then + export LD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$LD_LIBRARY_PATH" + export DYLD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$DYLD_LIBRARY_PATH" + export PATH="${CFG_LOCAL_RUST_ROOT}/bin:$PATH" +fi + +valopt cargo "cargo" "cargo to bootstrap from" +valopt rustc "rustc" "rustc to compile with" +valopt rustdoc "rustdoc" "rustdoc to document with" + if [ $HELP -eq 0 ]; then - if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then - export LD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$LD_LIBRARY_PATH" - export DYLD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$DYLD_LIBRARY_PATH" - LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version` - if [ $? -eq 0 ]; then - step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: $LRV" - else - err "failed to run rustc at: ${CFG_LOCAL_RUST_ROOT}" - fi - CFG_RUSTC="${CFG_LOCAL_RUST_ROOT}/bin/rustc" - else - probe_need CFG_RUSTC rustc - fi + probe_need CFG_CARGO $CFG_CARGO + probe_need CFG_RUSTC $CFG_RUSTC + probe_need CFG_RUSTDOC $CFG_RUSTDOC DEFAULT_BUILD=$("${CFG_RUSTC}" -vV | grep 'host: ' | sed 's/host: //') fi @@ -337,7 +335,6 @@ valopt infodir "${CFG_PREFIX}/share/info" "install additional info" valopt docdir "${CFG_PREFIX}/share/doc/cargo" "install extra docs" valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH" valopt libdir "${CFG_PREFIX}/lib" "install libraries" -valopt local-cargo "" "local cargo to bootstrap from" if [ $HELP -eq 1 ] then @@ -354,15 +351,8 @@ fi step_msg "looking for build programs" -probe_need CFG_CURLORWGET curl wget -probe_need CFG_PYTHON python2.7 python2 python probe_need CFG_CC cc gcc clang - -if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then - CFG_RUSTDOC="${CFG_LOCAL_RUST_ROOT}/bin/rustdoc" -else - probe_need CFG_RUSTDOC rustdoc -fi +probe GIT git # a little post-processing of various config values CFG_PREFIX=${CFG_PREFIX%/} @@ -396,6 +386,7 @@ if [ "$CFG_SRC_DIR" != "$CFG_BUILD_DIR" ]; then fi if [ ! -z "$CFG_ENABLE_NIGHTLY" ]; then + need_cmd curl if [ ! -f .cargo/config ]; then mkdir -p .cargo cat > .cargo/config <<-EOF @@ -449,6 +440,8 @@ putvar CFG_MANDIR putvar CFG_LIBDIR putvar CFG_RUSTC putvar CFG_RUSTDOC +putvar CFG_CARGO +putvar CFG_GIT msg copy_if_changed ${CFG_SRC_DIR}Makefile.in ./Makefile diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile new file mode 100644 index 00000000000..e0a9840e05c --- /dev/null +++ b/src/ci/docker/cross/Dockerfile @@ -0,0 +1,2 @@ +FROM alexcrichton/rust-slave-linux-cross:2016-10-11c +ENTRYPOINT [] diff --git a/src/ci/docker/dist/Dockerfile b/src/ci/docker/dist/Dockerfile new file mode 100644 index 00000000000..d87d8f71998 --- /dev/null +++ b/src/ci/docker/dist/Dockerfile @@ -0,0 +1,2 @@ +FROM alexcrichton/rust-slave-dist:2016-09-26 +ENTRYPOINT [] diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh new file mode 100755 index 00000000000..a8f71fab1e7 --- /dev/null +++ b/src/ci/docker/run.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -e + +script=`cd $(dirname $0) && pwd`/`basename $0` +image=$1 +TARGET=$2 + +docker_dir="`dirname $script`" +ci_dir="`dirname $docker_dir`" +src_dir="`dirname $ci_dir`" +root_dir="`dirname $src_dir`" + +docker build \ + --rm \ + -t rust-ci \ + "`dirname "$script"`/$image" + +mkdir -p $HOME/.cargo +mkdir -p target + +exec docker run \ + --user `id -u`:`id -g` \ + --volume "$root_dir:/checkout:ro" \ + --workdir /tmp \ + --env CFG_DISABLE_CROSS_TESTS=$CFG_DISABLE_CROSS_TESTS \ + --env MAKE_TARGETS="$MAKE_TARGETS" \ + --env SRC=/checkout \ + --env CARGO_HOME=/cargo \ + --volume "$HOME/.cargo:/cargo" \ + --volume `rustc --print sysroot`:/rust:ro \ + --volume `pwd`/target:/tmp/target \ + --interactive \ + --tty \ + rust-ci \ + sh -c "\ + PATH=\$PATH:/rust/bin \ + LD_LIBRARY_PATH=/rust/lib:\$LD_LIBRARY_PATH \ + /checkout/src/ci/run.sh $TARGET" + diff --git a/src/ci/docker/x86_64-musl/Dockerfile b/src/ci/docker/x86_64-musl/Dockerfile new file mode 100644 index 00000000000..4206c3120c7 --- /dev/null +++ b/src/ci/docker/x86_64-musl/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:16.04 + +RUN apt-get update -y && apt-get install -y --no-install-recommends \ + cmake \ + make \ + gcc \ + musl-tools \ + curl \ + ca-certificates \ + libc6-dev \ + git diff --git a/src/ci/run.sh b/src/ci/run.sh new file mode 100755 index 00000000000..456c3f8b2b1 --- /dev/null +++ b/src/ci/run.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +TARGET=$1 + +if [ -z "$SRC" ]; then + SRC=. +fi + +$SRC/configure \ + --prefix=/tmp/obj/install \ + --target=$TARGET \ + --enable-nightly + +make cargo-$TARGET +make dist-$TARGET + +if [ ! -z "$MAKE_TARGETS" ]; then + for target in "$MAKE_TARGETS"; do + make $target + done +fi diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py index 350bf1954e6..5f4b650c9f2 100644 --- a/src/etc/install-deps.py +++ b/src/etc/install-deps.py @@ -55,12 +55,19 @@ rust_date = open('src/rustversion.txt').read().strip() url = 'https://static.rust-lang.org/dist/' + rust_date +cargo_url = 'https://static.rust-lang.org/cargo-dist/2016-03-21' def install_via_tarballs(): if os.path.isdir("rustc-install"): shutil.rmtree("rustc-install") + # Download cargo + host_fname = 'cargo-nightly-' + host + '.tar.gz' + download.get(cargo_url + '/' + host_fname, host_fname) + download.unpack(host_fname, "rustc-install", quiet=True, strip=2) + os.remove(host_fname) + # Download the compiler host_fname = 'rustc-nightly-' + host + '.tar.gz' download.get(url + '/' + host_fname, host_fname) diff --git a/tests/init.rs b/tests/init.rs index 315394359d9..cd64118929f 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -7,13 +7,13 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::env; -use cargo::util::{process, ProcessBuilder}; +use cargo::util::ProcessBuilder; use cargotest::support::{execs, paths, cargo_dir}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; use tempdir::TempDir; fn cargo_process(s: &str) -> ProcessBuilder { - let mut p = process(&cargo_dir().join("cargo")); + let mut p = cargotest::process(&cargo_dir().join("cargo")); p.arg(s).cwd(&paths::root()).env("HOME", &paths::home()); return p; } diff --git a/tests/package.rs b/tests/package.rs index 7f3712f3724..05968914549 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -10,8 +10,7 @@ use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::path::{Path, PathBuf}; -use cargo::util::process; -use cargotest::cargo_process; +use cargotest::{cargo_process, process}; use cargotest::support::{project, execs, paths, git, path2url, cargo_dir}; use flate2::read::GzDecoder; use hamcrest::{assert_that, existing_file, contains}; From e99008f93418ea5127960cbd3ca9d18f273a8656 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Tue, 4 Oct 2016 15:21:16 -0700 Subject: [PATCH 0814/3888] Add tests for feature freshness --- tests/freshness.rs | 187 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 186 insertions(+), 1 deletion(-) diff --git a/tests/freshness.rs b/tests/freshness.rs index 03baf550ee5..49ab26a8c7c 100644 --- a/tests/freshness.rs +++ b/tests/freshness.rs @@ -145,7 +145,7 @@ fn rebuild_sub_package_then_while_package() { } #[test] -fn changing_features_is_ok() { +fn changing_lib_features_caches_targets() { let p = project("foo") .file("Cargo.toml", r#" [package] @@ -170,18 +170,203 @@ fn changing_features_is_ok() { .with_stderr("\ [..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + + /* Targets should be cached from the first build */ + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); assert_that(p.cargo("build"), + execs().with_status(0) + .with_stdout("")); + + assert_that(p.cargo("build").arg("--features").arg("foo"), + execs().with_status(0) + .with_stderr("\ +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); +} + +#[test] +fn changing_bin_paths_common_target_features_caches_targets() { + /// Make sure dep_cache crate is built once per feature + let p = project("foo") + .file(".cargo/config", r#" + [build] + target-dir = "./target" + "#) + .file("dep_crate/Cargo.toml", r#" + [package] + name = "dep_crate" + version = "0.0.1" + authors = [] + + [features] + ftest = [] + "#) + .file("dep_crate/src/lib.rs", r#" + #[cfg(feature = "ftest")] + pub fn yo() { + println!("ftest on") + } + #[cfg(not(feature = "ftest"))] + pub fn yo() { + println!("ftest off") + } + "#) + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + + [dependencies] + dep_crate = {path = "../dep_crate", features = []} + "#) + .file("a/src/lib.rs", "") + .file("a/src/main.rs", r#" + extern crate dep_crate; + use dep_crate::yo; + fn main() { + yo(); + } + "#) + .file("b/Cargo.toml", r#" + [package] + name = "b" + version = "0.0.1" + authors = [] + + [dependencies] + dep_crate = {path = "../dep_crate", features = ["ftest"]} + "#) + .file("b/src/lib.rs", "") + .file("b/src/main.rs", r#" + extern crate dep_crate; + use dep_crate::yo; + fn main() { + yo(); + } + "#); + + /* Build and rebuild a/. Ensure dep_crate only builds once */ + assert_that(p.cargo_process("run").cwd(p.root().join("a")), + execs().with_status(0) + .with_stdout("ftest off") + .with_stderr("\ +[..]Compiling dep_crate v0.0.1 ([..]) +[..]Compiling a v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `[..]target/debug/a` +")); + assert_that(p.cargo("clean").arg("-p").arg("a").cwd(p.root().join("a")), + execs().with_status(0)); + assert_that(p.cargo("run").cwd(p.root().join("a")), + execs().with_status(0) + .with_stdout("ftest off") + .with_stderr("\ +[..]Compiling a v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `[..]target/debug/a` +")); + + /* Build and rebuild b/. Ensure dep_crate only builds once */ + assert_that(p.cargo("run").cwd(p.root().join("b")), + execs().with_status(0) + .with_stdout("ftest on") + .with_stderr("\ +[..]Compiling dep_crate v0.0.1 ([..]) +[..]Compiling b v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `[..]target/debug/b` +")); + assert_that(p.cargo("clean").arg("-p").arg("b").cwd(p.root().join("b")), + execs().with_status(0)); + assert_that(p.cargo("run").cwd(p.root().join("b")), + execs().with_status(0) + .with_stdout("ftest on") + .with_stderr("\ +[..]Compiling b v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `[..]target/debug/b` +")); + + /* Build a/ package again. If we cache different feature dep builds correctly, + * this should not cause a rebuild of dep_crate */ + assert_that(p.cargo("clean").arg("-p").arg("a").cwd(p.root().join("a")), + execs().with_status(0)); + assert_that(p.cargo("run").cwd(p.root().join("a")), + execs().with_status(0) + .with_stdout("ftest off") + .with_stderr("\ +[..]Compiling a v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `[..]target/debug/a` +")); + + /* Build b/ package again. If we cache different feature dep builds correctly, + * this should not cause a rebuild */ + assert_that(p.cargo("clean").arg("-p").arg("b").cwd(p.root().join("b")), + execs().with_status(0)); + assert_that(p.cargo("run").cwd(p.root().join("b")), + execs().with_status(0) + .with_stdout("ftest on") + .with_stderr("\ +[..]Compiling b v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `[..]target/debug/b` +")); +} + +#[test] +fn changing_bin_features_caches_targets() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + authors = [] + version = "0.0.1" + + [features] + foo = [] + "#) + .file("src/main.rs", "fn main() {}"); + + assert_that(p.cargo_process("build"), + execs().with_status(0) + .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + + assert_that(p.cargo("build").arg("--features").arg("foo"), execs().with_status(0) .with_stderr("\ [..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + + /* Targets should be cached from the first build */ + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); assert_that(p.cargo("build"), execs().with_status(0) .with_stdout("")); + + assert_that(p.cargo("build").arg("--features").arg("foo"), + execs().with_status(0) + .with_stderr("\ +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); } #[test] From 1ded88447b43b3415ff749f094b2384cf3d4fd4b Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Tue, 4 Oct 2016 16:16:30 -0700 Subject: [PATCH 0815/3888] Mix feature flags into fingerprint/metadata shorthash Since building dependencies results in different libraries depending on the feature flags, I added the feature flags into the short_hash. This solves an issue when multiple crates share a target directory or multiple targets share a common library with divergent feature flag choice. - Only link binaries, build scripts, and top level deps - Handle dylibs differently (no metadata filename / linking) - Fingerprint based on link_dst rather than file_stem. This (sadly) limits the effects of dep caching to things which don't produce a hard-link. Currently, this is only dependent library crates. Stil a big win. --- src/cargo/core/manifest.rs | 7 ++ src/cargo/ops/cargo_clean.rs | 8 +- src/cargo/ops/cargo_rustc/context.rs | 124 ++++++++++++++++------- src/cargo/ops/cargo_rustc/fingerprint.rs | 21 ++-- src/cargo/ops/cargo_rustc/layout.rs | 2 +- src/cargo/ops/cargo_rustc/mod.rs | 76 +++++++------- tests/bench.rs | 28 ++--- tests/build-script.rs | 6 +- tests/build.rs | 8 +- tests/clean.rs | 4 +- tests/cross-compile.rs | 4 +- tests/freshness.rs | 116 +++++++++++++++++---- tests/git.rs | 2 +- tests/path.rs | 2 +- tests/plugins.rs | 3 +- tests/run.rs | 4 +- tests/rustc.rs | 2 +- tests/test.rs | 38 +++---- 18 files changed, 301 insertions(+), 154 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 4e693ff2b3f..f5f4217da81 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -395,6 +395,13 @@ impl Target { } } + pub fn is_dylib(&self) -> bool { + match self.kind { + TargetKind::Lib(ref libs) => libs.iter().any(|l| *l == LibKind::Dylib), + _ => false + } + } + pub fn linkable(&self) -> bool { match self.kind { TargetKind::Lib(ref kinds) => { diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 6d544c19be2..738417a4bf8 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -77,9 +77,11 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { try!(rm_rf(&layout.proxy().fingerprint(&unit.pkg))); try!(rm_rf(&layout.build(&unit.pkg))); - let root = cx.out_dir(&unit); - for (filename, _) in try!(cx.target_filenames(&unit)) { - try!(rm_rf(&root.join(&filename))); + for (src, link_dst, _) in try!(cx.target_filenames(&unit)) { + try!(rm_rf(&src)); + if let Some(dst) = link_dst { + try!(rm_rf(&dst)); + } } } diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 4e0cf00db6a..9c4a34c48d4 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -309,11 +309,41 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Get the metadata for a target in a specific profile pub fn target_metadata(&self, unit: &Unit) -> Option { - let metadata = unit.target.metadata(); + // No metadata for dylibs because of a couple issues + // - OSX encodes the dylib name in the executable + // - Windows rustc multiple files of which we can't easily link all of them + if !unit.profile.test && unit.target.is_dylib() { + return None; + } + + let metadata = unit.target.metadata().cloned().map(|mut m| { + if let Some(features) = self.resolve.features(unit.pkg.package_id()) { + let mut feat_vec: Vec<&String> = features.iter().collect(); + feat_vec.sort(); + for feat in feat_vec { + m.mix(feat); + } + } + m.mix(unit.profile); + m + }); + let mut pkg_metadata = { + let mut m = unit.pkg.generate_metadata(); + if let Some(features) = self.resolve.features(unit.pkg.package_id()) { + let mut feat_vec: Vec<&String> = features.iter().collect(); + feat_vec.sort(); + for feat in feat_vec { + m.mix(feat); + } + } + m.mix(unit.profile); + m + }; + if unit.target.is_lib() && unit.profile.test { // Libs and their tests are built in parallel, so we need to make // sure that their metadata is different. - metadata.cloned().map(|mut m| { + metadata.map(|mut m| { m.mix(&"test"); m }) @@ -321,37 +351,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // Make sure that the name of this test executable doesn't // conflict with a library that has the same name and is // being tested - let mut metadata = unit.pkg.generate_metadata(); - metadata.mix(&format!("bin-{}", unit.target.name())); - Some(metadata) + pkg_metadata.mix(&format!("bin-{}", unit.target.name())); + Some(pkg_metadata) } else if unit.pkg.package_id().source_id().is_path() && !unit.profile.test { - // If we're not building a unit test but we're building a path - // dependency, then we're likely compiling the "current package" or - // some package in a workspace. In this situation we pass no - // metadata by default so we'll have predictable - // file names like `target/debug/libfoo.{a,so,rlib}` and such. - // - // Note, though, that the compiler's build system at least wants - // path dependencies to have hashes in filenames. To account for - // that we have an extra hack here which reads the - // `__CARGO_DEFAULT_METADATA` environment variable and creates a - // hash in the filename if that's present. - // - // This environment variable should not be relied on! It's basically - // just here for rustbuild. We need a more principled method of - // doing this eventually. - if unit.target.is_lib() { - env::var("__CARGO_DEFAULT_LIB_METADATA").ok().map(|meta| { - let mut metadata = unit.pkg.generate_metadata(); - metadata.mix(&meta); - metadata - }) - } else { - None - } + Some(pkg_metadata) } else { - metadata.cloned() + metadata } } @@ -360,19 +366,57 @@ impl<'a, 'cfg> Context<'a, 'cfg> { match self.target_metadata(unit) { Some(ref metadata) => format!("{}{}", unit.target.crate_name(), metadata.extra_filename), - None if unit.target.allows_underscores() => { - unit.target.name().to_string() + None => self.bin_stem(unit), + } + } + + fn bin_stem(&self, unit: &Unit) -> String { + if unit.target.allows_underscores() { + unit.target.name().to_string() + } else { + unit.target.crate_name() + } + } + + pub fn link_stem(&self, unit: &Unit) -> Option<(PathBuf, String)> { + let src_dir = self.out_dir(unit); + let bin_stem = self.bin_stem(unit); + let file_stem = self.file_stem(unit); + + // We currently only lift files up from the `deps` directory. If + // it was compiled into something like `example/` or `doc/` then + // we don't want to link it up. + if src_dir.ends_with("deps") { + // Don't lift up library dependencies + if unit.pkg.package_id() != &self.current_package && !unit.target.is_bin() { + None + } else { + Some(( + src_dir.parent().unwrap().to_owned(), + if unit.profile.test {file_stem} else {bin_stem}, + )) } - None => unit.target.crate_name(), + } else if bin_stem == file_stem { + None + } else if src_dir.ends_with("examples") { + Some((src_dir, bin_stem)) + } else if src_dir.parent().unwrap().ends_with("build") { + Some((src_dir, bin_stem)) + } else { + None } } /// Return the filenames that the given target for the given profile will - /// generate, along with whether you can link against that file (e.g. it's a - /// library). + /// generate as a list of 3-tuples (filename, link_dst, linkable) + /// filename: filename rustc compiles to. (Often has metadata suffix). + /// link_dst: Optional file to link/copy the result to (without metadata suffix) + /// linkable: Whether possible to link against file (eg it's a library) pub fn target_filenames(&self, unit: &Unit) - -> CargoResult> { + -> CargoResult, bool)>> { + let out_dir = self.out_dir(unit); let stem = self.file_stem(unit); + let link_stem = self.link_stem(unit); let info = if unit.target.for_host() { &self.host_info } else { @@ -386,8 +430,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let crate_type = if crate_type == "lib" {"rlib"} else {crate_type}; match info.crate_types.get(crate_type) { Some(&Some((ref prefix, ref suffix))) => { - ret.push((format!("{}{}{}", prefix, stem, suffix), - linkable)); + let filename = out_dir.join(format!("{}{}{}", prefix, stem, suffix)); + let link_dst = link_stem.clone().map(|(ld, ls)| { + ld.join(format!("{}{}{}", prefix, ls, suffix)) + }); + ret.push((filename, link_dst, linkable)); Ok(()) } // not supported, don't worry about it @@ -429,6 +476,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { support any of the output crate types", unit.pkg, self.target_triple()); } + info!("Target filenames: {:?}", ret); Ok(ret) } diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index b16cf7f90df..a5d3e53e14a 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -49,7 +49,7 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, let _p = profile::start(format!("fingerprint: {} / {}", unit.pkg.package_id(), unit.target.name())); let new = dir(cx, unit); - let loc = new.join(&filename(unit)); + let loc = new.join(&filename(cx, unit)); debug!("fingerprint at: {}", loc.display()); @@ -82,8 +82,11 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, missing_outputs = !root.join(unit.target.crate_name()) .join("index.html").exists(); } else { - for (filename, _) in try!(cx.target_filenames(unit)) { - missing_outputs |= fs::metadata(root.join(filename)).is_err(); + for (src, link_dst, _) in try!(cx.target_filenames(unit)) { + missing_outputs |= fs::metadata(&src).is_err(); + if let Some(link_dst) = link_dst { + missing_outputs |= fs::metadata(link_dst).is_err(); + } } } @@ -529,7 +532,7 @@ pub fn dir(cx: &Context, unit: &Unit) -> PathBuf { /// Returns the (old, new) location for the dep info file of a target. pub fn dep_info_loc(cx: &Context, unit: &Unit) -> PathBuf { - dir(cx, unit).join(&format!("dep-{}", filename(unit))) + dir(cx, unit).join(&format!("dep-{}", filename(cx, unit))) } fn compare_old_fingerprint(loc: &Path, new_fingerprint: &Fingerprint) @@ -650,7 +653,13 @@ fn mtime_if_fresh(output: &Path, paths: I) -> Option } } -fn filename(unit: &Unit) -> String { +fn filename(cx: &Context, unit: &Unit) -> String { + // If there exists a link stem, we have to use that since multiple target filenames + // may hardlink to the same target stem. If there's no link, we can use the original + // file_stem (which can include a suffix) + let file_stem = cx.link_stem(unit) + .map(|(_path, stem)| stem) + .unwrap_or_else(|| cx.file_stem(unit)); let kind = match *unit.target.kind() { TargetKind::Lib(..) => "lib", TargetKind::Bin => "bin", @@ -666,7 +675,7 @@ fn filename(unit: &Unit) -> String { } else { "" }; - format!("{}{}-{}", flavor, kind, unit.target.name()) + format!("{}{}-{}", flavor, kind, file_stem) } // The dep-info files emitted by the compiler all have their listed paths diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index 18ae026e193..0c7723f401d 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -175,7 +175,7 @@ impl<'a> LayoutProxy<'a> { } else if unit.target.is_lib() { self.deps().to_path_buf() } else { - self.root().to_path_buf() + self.deps().to_path_buf() } } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 6db0bb6f35e..82014c49323 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -110,14 +110,18 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, .or_insert(Vec::new()) .push(("OUT_DIR".to_string(), out_dir)); - for (filename, _linkable) in try!(cx.target_filenames(unit)) { - let dst = cx.out_dir(unit).join(filename); + for (dst, link_dst, _linkable) in try!(cx.target_filenames(unit)) { + let bindst = match link_dst { + Some(link_dst) => link_dst, + None => dst.clone(), + }; + if unit.profile.test { cx.compilation.tests.push((unit.pkg.clone(), unit.target.name().to_string(), dst)); } else if unit.target.is_bin() || unit.target.is_example() { - cx.compilation.binaries.push(dst); + cx.compilation.binaries.push(bindst); } else if unit.target.is_lib() { let pkgid = unit.pkg.package_id().clone(); cx.compilation.libraries.entry(pkgid).or_insert(Vec::new()) @@ -135,8 +139,8 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, } let v = try!(cx.target_filenames(unit)); - let v = v.into_iter().map(|(f, _)| { - (unit.target.clone(), cx.out_dir(unit).join(f)) + let v = v.into_iter().map(|(f, _, _)| { + (unit.target.clone(), f) }).collect::>(); cx.compilation.libraries.insert(pkgid.clone(), v); } @@ -228,9 +232,9 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { let do_rename = unit.target.allows_underscores() && !unit.profile.test; let real_name = unit.target.name().to_string(); let crate_name = unit.target.crate_name(); - let move_outputs_up = unit.pkg.package_id() == &cx.current_package; - let rustc_dep_info_loc = if do_rename { + // XXX(Rely on target_filenames iterator as source of truth rather than rederiving filestem) + let rustc_dep_info_loc = if do_rename && cx.target_metadata(unit).is_none() { root.join(&crate_name) } else { root.join(&cx.file_stem(unit)) @@ -257,8 +261,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { // FIXME(rust-lang/rust#18913): we probably shouldn't have to do // this manually - for &(ref filename, _linkable) in filenames.iter() { - let dst = root.join(filename); + for &(ref dst, ref _link_dst, _linkable) in filenames.iter() { if fs::metadata(&dst).is_ok() { try!(fs::remove_file(&dst).chain_error(|| { human(format!("Could not remove file: {}.", dst.display())) @@ -295,7 +298,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { })); if do_rename && real_name != crate_name { - let dst = root.join(&filenames[0].0); + let dst = &filenames[0].0; let src = dst.with_file_name(dst.file_name().unwrap() .to_str().unwrap() .replace(&real_name, &crate_name)); @@ -307,6 +310,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { } if !has_custom_args || fs::metadata(&rustc_dep_info_loc).is_ok() { + info!("Renaming dep_info {:?} to {:?}", rustc_dep_info_loc, dep_info_loc); try!(fs::rename(&rustc_dep_info_loc, &dep_info_loc).chain_error(|| { internal(format!("could not rename dep info: {:?}", rustc_dep_info_loc)) @@ -318,36 +322,30 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { // hard link our outputs out of the `deps` directory into the directory // above. This means that `cargo build` will produce binaries in // `target/debug` which one probably expects. - if move_outputs_up { - for &(ref filename, _linkable) in filenames.iter() { - let src = root.join(filename); - // This may have been a `cargo rustc` command which changes the - // output, so the source may not actually exist. - if !src.exists() { - continue - } + for (src, link_dst, _linkable) in filenames { + // This may have been a `cargo rustc` command which changes the + // output, so the source may not actually exist. + debug!("Thinking about linking {} to {:?}", src.display(), link_dst); + if !src.exists() || link_dst.is_none() { + continue + } + let dst = link_dst.unwrap(); - // We currently only lift files up from the `deps` directory. If - // it was compiled into something like `example/` or `doc/` then - // we don't want to link it up. - let src_dir = src.parent().unwrap(); - if !src_dir.ends_with("deps") { - continue - } - let dst = src_dir.parent().unwrap() - .join(src.file_name().unwrap()); - if dst.exists() { - try!(fs::remove_file(&dst).chain_error(|| { - human(format!("failed to remove: {}", dst.display())) - })); - } - try!(fs::hard_link(&src, &dst) - .or_else(|_| fs::copy(&src, &dst).map(|_| ())) - .chain_error(|| { - human(format!("failed to link or copy `{}` to `{}`", - src.display(), dst.display())) + debug!("linking {} to {}", src.display(), dst.display()); + if dst.exists() { + try!(fs::remove_file(&dst).chain_error(|| { + human(format!("failed to remove: {}", dst.display())) })); } + try!(fs::hard_link(&src, &dst) + .or_else(|err| { + debug!("hard link failed {}. falling back to fs::copy", err); + fs::copy(&src, &dst).map(|_| ()) + }) + .chain_error(|| { + human(format!("failed to link or copy `{}` to `{}`", + src.display(), dst.display())) + })); } Ok(()) @@ -658,7 +656,7 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) fn link_to(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) -> CargoResult<()> { - for (filename, linkable) in try!(cx.target_filenames(unit)) { + for (dst, _link_dst, linkable) in try!(cx.target_filenames(unit)) { if !linkable { continue } @@ -667,7 +665,7 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) v.push("="); v.push(cx.out_dir(unit)); v.push(&path::MAIN_SEPARATOR.to_string()); - v.push(&filename); + v.push(&dst.file_name().unwrap()); cmd.arg("--extern").arg(&v); } Ok(()) diff --git a/tests/bench.rs b/tests/bench.rs index 7048c57890f..fdaa7160a5f 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -43,7 +43,7 @@ fn cargo_bench_simple() { execs().with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]foo-[..][EXE]", p.url())) +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test bench_hello ... bench: [..] 0 ns/iter (+/- 0) @@ -78,7 +78,7 @@ fn bench_tarname() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]bin2-[..][EXE] +[RUNNING] target[/]release[/]deps[/]bin2-[..][EXE] ", dir = prj.url())) .with_stdout(" running 1 test @@ -107,7 +107,7 @@ fn cargo_bench_verbose() { [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc src[/]foo.rs [..]` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[/]release[/]foo-[..][EXE] hello --bench`", url = p.url())) +[RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] hello --bench`", url = p.url())) .with_stdout(" running 1 test test bench_hello ... bench: [..] 0 ns/iter (+/- 0) @@ -190,7 +190,7 @@ test bench_hello ... ") .with_stderr_contains(format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]foo-[..][EXE] +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE] thread '[..]' panicked at 'assertion failed: \ `(left == right)` (left: \ `\"hello\"`, right: `\"nope\"`)', src[/]foo.rs:14 @@ -243,7 +243,7 @@ fn bench_with_lib_dep() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]baz-[..][EXE] +[RUNNING] target[/]release[/]deps[/]baz-[..][EXE] [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test @@ -353,7 +353,7 @@ fn external_bench_explicit() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]bench-[..][EXE] +[RUNNING] target[/]release[/]deps[/]bench-[..][EXE] [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test @@ -403,7 +403,7 @@ fn external_bench_implicit() { execs().with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]external-[..][EXE] +[RUNNING] target[/]release[/]deps[/]external-[..][EXE] [RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test @@ -547,7 +547,7 @@ fn lib_bin_same_name() { [COMPILING] foo v0.0.1 ({}) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target[/]release[/]deps[/]foo-[..][EXE] -[RUNNING] target[/]release[/]foo-[..][EXE]", p.url())) +[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test [..] ... bench: [..] 0 ns/iter (+/- 0) @@ -600,7 +600,7 @@ fn lib_with_standard_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]bench-[..][EXE] +[RUNNING] target[/]release[/]deps[/]bench-[..][EXE] [RUNNING] target[/]release[/]deps[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test @@ -652,7 +652,7 @@ fn lib_with_standard_name2() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] target[/]release[/]syntax-[..][EXE]", dir = p.url())) +[RUNNING] target[/]release[/]deps[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test bench ... bench: [..] 0 ns/iter (+/- 0) @@ -722,7 +722,7 @@ fn bench_dylib() { [RUNNING] [..] -C opt-level=3 [..] [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[/]release[/]bench-[..][EXE] --bench` +[RUNNING] `[..]target[/]release[/]deps[/]bench-[..][EXE] --bench` [RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] --bench`", dir = p.url())) .with_stdout(" running 1 test @@ -744,7 +744,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured [FRESH] bar v0.0.1 ({dir}/bar) [FRESH] foo v0.0.1 ({dir}) [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `[..]target[/]release[/]bench-[..][EXE] --bench` +[RUNNING] `[..]target[/]release[/]deps[/]bench-[..][EXE] --bench` [RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] --bench`", dir = p.url())) .with_stdout(" running 1 test @@ -871,7 +871,7 @@ fn bench_with_examples() { [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` [FINISHED] release [optimized] target(s) in [..] -[RUNNING] `{dir}[/]target[/]release[/]testb1-[..][EXE] --bench` +[RUNNING] `{dir}[/]target[/]release[/]deps[/]testb1-[..][EXE] --bench` [RUNNING] `{dir}[/]target[/]release[/]deps[/]testbench-[..][EXE] --bench`", dir = p.root().display(), url = p.url())) .with_stdout(" @@ -920,7 +920,7 @@ fn test_a_bench() { .with_stderr("\ [COMPILING] foo v0.1.0 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]b-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]b-[..][EXE]") .with_stdout(" running 1 test test foo ... ok diff --git a/tests/build-script.rs b/tests/build-script.rs index 53c359f22e6..e6bcef0fbe9 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -1141,7 +1141,8 @@ fn build_script_with_dynamic_native_dependency() { #[no_mangle] pub extern fn foo() {} "#); - assert_that(build.cargo_process("build"), + assert_that(build.cargo_process("build").arg("-v") + .env("RUST_LOG", "cargo::ops::cargo_rustc"), execs().with_status(0)); let foo = project("foo") @@ -1186,7 +1187,8 @@ fn build_script_with_dynamic_native_dependency() { } "#); - assert_that(foo.cargo_process("build").env("SRC", build.root()), + assert_that(foo.cargo_process("build").arg("-v").env("SRC", build.root()) + .env("RUST_LOG", "cargo::ops::cargo_rustc"), execs().with_status(0)); } diff --git a/tests/build.rs b/tests/build.rs index 2bf78d7ba7c..ac274de22a6 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -1055,7 +1055,7 @@ fn lto_build() { -C opt-level=3 \ -C lto \ -C metadata=[..] \ - --out-dir {dir}[/]target[/]release \ + --out-dir {dir}[/]target[/]release[/]deps \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]release[/]deps` [FINISHED] release [optimized] target(s) in [..] @@ -1789,6 +1789,7 @@ fn example_bin_same_name() { .unwrap(); assert_that(&p.bin("foo"), is_not(existing_file())); + // We expect a file of the form bin/foo-{metadata_hash} assert_that(&p.bin("examples/foo"), existing_file()); p.cargo("test").arg("--no-run").arg("-v") @@ -1796,6 +1797,7 @@ fn example_bin_same_name() { .unwrap(); assert_that(&p.bin("foo"), is_not(existing_file())); + // We expect a file of the form bin/foo-{metadata_hash} assert_that(&p.bin("examples/foo"), existing_file()); } @@ -2162,9 +2164,9 @@ fn build_multiple_packages() { assert_that(process(&p.bin("foo")), execs().with_stdout("i am foo\n")); - let d1_path = &p.build_dir().join("debug").join("deps") + let d1_path = &p.build_dir().join("debug") .join(format!("d1{}", env::consts::EXE_SUFFIX)); - let d2_path = &p.build_dir().join("debug").join("deps") + let d2_path = &p.build_dir().join("debug") .join(format!("d2{}", env::consts::EXE_SUFFIX)); assert_that(d1_path, existing_file()); diff --git a/tests/clean.rs b/tests/clean.rs index 59170ed708b..39cc5287203 100644 --- a/tests/clean.rs +++ b/tests/clean.rs @@ -80,9 +80,9 @@ fn clean_multiple_packages() { .arg("-p").arg("foo"), execs().with_status(0)); - let d1_path = &p.build_dir().join("debug").join("deps") + let d1_path = &p.build_dir().join("debug") .join(format!("d1{}", env::consts::EXE_SUFFIX)); - let d2_path = &p.build_dir().join("debug").join("deps") + let d2_path = &p.build_dir().join("debug") .join(format!("d2{}", env::consts::EXE_SUFFIX)); diff --git a/tests/cross-compile.rs b/tests/cross-compile.rs index d5db5635263..bbb534f8d3d 100644 --- a/tests/cross-compile.rs +++ b/tests/cross-compile.rs @@ -359,7 +359,7 @@ fn linker_and_ar() { [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc src[/]foo.rs --crate-name foo --crate-type bin -g \ -C metadata=[..] \ - --out-dir {dir}[/]target[/]{target}[/]debug \ + --out-dir {dir}[/]target[/]{target}[/]debug[/]deps \ --emit=dep-info,link \ --target {target} \ -C ar=my-ar-tool -C linker=my-linker-tool \ @@ -473,7 +473,7 @@ fn cross_tests() { .with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({foo}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]{triple}[/]debug[/]bar-[..][EXE] +[RUNNING] target[/]{triple}[/]debug[/]deps[/]bar-[..][EXE] [RUNNING] target[/]{triple}[/]debug[/]deps[/]foo-[..][EXE]", foo = p.url(), triple = target)) .with_stdout(" running 1 test diff --git a/tests/freshness.rs b/tests/freshness.rs index 49ab26a8c7c..786aef22275 100644 --- a/tests/freshness.rs +++ b/tests/freshness.rs @@ -172,11 +172,17 @@ fn changing_lib_features_caches_targets() { [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); - /* Targets should be cached from the first build */ + /* Targets should be cached from the first build + XXX Sadly these cannot be cached since the "symlink" step is + not separate from the "compile" step. Packages which link + to top level binaries eg (deps/foo-abc123 -> foo) are forced + to do an extra recompile here. + */ assert_that(p.cargo("build"), execs().with_status(0) .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -187,13 +193,71 @@ fn changing_lib_features_caches_targets() { assert_that(p.cargo("build").arg("--features").arg("foo"), execs().with_status(0) .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } +#[test] +fn changing_profiles_caches_targets() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + authors = [] + version = "0.0.1" + + [profile.dev] + panic = "abort" + + [profile.test] + panic = "unwind" + "#) + .file("src/lib.rs", ""); + + assert_that(p.cargo_process("build"), + execs().with_status(0) + .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + + assert_that(p.cargo("test"), + execs().with_status(0) + .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] target[..]debug[..]deps[..]foo-[..][EXE] +[DOCTEST] foo +")); + + /* Targets should be cached from the first build + XXX Sadly these cannot be cached since the "symlink" step is + not separate from the "compile" step. Packages which link + to top level binaries eg (deps/foo-abc123 -> foo) are forced + to do an extra recompile here. + */ + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + + assert_that(p.cargo("test").arg("foo"), + execs().with_status(0) + .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] target[..]debug[..]deps[..]foo-[..][EXE] +[DOCTEST] foo +")); +} + #[test] fn changing_bin_paths_common_target_features_caches_targets() { - /// Make sure dep_cache crate is built once per feature + // Make sure dep_cache crate is built once per feature let p = project("foo") .file(".cargo/config", r#" [build] @@ -261,7 +325,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { [..]Compiling dep_crate v0.0.1 ([..]) [..]Compiling a v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/a` +[RUNNING] `[..]target[/]debug[/]a[EXE]` ")); assert_that(p.cargo("clean").arg("-p").arg("a").cwd(p.root().join("a")), execs().with_status(0)); @@ -271,7 +335,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { .with_stderr("\ [..]Compiling a v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/a` +[RUNNING] `[..]target[/]debug[/]a[EXE]` ")); /* Build and rebuild b/. Ensure dep_crate only builds once */ @@ -282,7 +346,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { [..]Compiling dep_crate v0.0.1 ([..]) [..]Compiling b v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/b` +[RUNNING] `[..]target[/]debug[/]b[EXE]` ")); assert_that(p.cargo("clean").arg("-p").arg("b").cwd(p.root().join("b")), execs().with_status(0)); @@ -292,7 +356,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { .with_stderr("\ [..]Compiling b v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/b` +[RUNNING] `[..]target[/]debug[/]b[EXE]` ")); /* Build a/ package again. If we cache different feature dep builds correctly, @@ -305,7 +369,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { .with_stderr("\ [..]Compiling a v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/a` +[RUNNING] `[..]target[/]debug[/]a[EXE]` ")); /* Build b/ package again. If we cache different feature dep builds correctly, @@ -318,7 +382,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { .with_stderr("\ [..]Compiling b v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target/debug/b` +[RUNNING] `[..]target[/]debug[/]b[EXE]` ")); } @@ -334,38 +398,54 @@ fn changing_bin_features_caches_targets() { [features] foo = [] "#) - .file("src/main.rs", "fn main() {}"); + .file("src/main.rs", r#" + fn main() { + let msg = if cfg!(feature = "foo") { "feature on" } else { "feature off" }; + println!("{}", msg); + } + "#); - assert_that(p.cargo_process("build"), + assert_that(p.cargo_process("run"), execs().with_status(0) + .with_stdout("feature off") .with_stderr("\ [..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `target[/]debug[/]foo[EXE]` ")); - assert_that(p.cargo("build").arg("--features").arg("foo"), + assert_that(p.cargo("run").arg("--features").arg("foo"), execs().with_status(0) + .with_stdout("feature on") .with_stderr("\ [..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `target[/]debug[/]foo[EXE]` ")); - /* Targets should be cached from the first build */ + /* Targets should be cached from the first build + XXX Sadly these cannot be cached since the "symlink" step is + not separate from the "compile" step. Packages which link + to top level binaries eg (deps/foo-abc123 -> foo) are forced + to do an extra recompile here. + */ - assert_that(p.cargo("build"), + assert_that(p.cargo("run"), execs().with_status(0) + .with_stdout("feature off") .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `target[/]debug[/]foo[EXE]` ")); - assert_that(p.cargo("build"), - execs().with_status(0) - .with_stdout("")); - - assert_that(p.cargo("build").arg("--features").arg("foo"), + assert_that(p.cargo("run").arg("--features").arg("foo"), execs().with_status(0) + .with_stdout("feature on") .with_stderr("\ +[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +[RUNNING] `target[/]debug[/]foo[EXE]` ")); } diff --git a/tests/git.rs b/tests/git.rs index 02c42b3ff7f..c60076f62f4 100644 --- a/tests/git.rs +++ b/tests/git.rs @@ -1035,7 +1035,7 @@ fn dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..] [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]foo-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]") .with_stdout(" running 1 test test tests::foo ... ok diff --git a/tests/path.rs b/tests/path.rs index b9c89b1d10e..7d057ae75b6 100644 --- a/tests/path.rs +++ b/tests/path.rs @@ -189,7 +189,7 @@ fn cargo_compile_with_root_dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..]) [COMPILING] [..] v0.5.0 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]foo-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]") .with_stdout(" running 0 tests diff --git a/tests/plugins.rs b/tests/plugins.rs index cd762377ab9..8ad26ba3678 100644 --- a/tests/plugins.rs +++ b/tests/plugins.rs @@ -147,8 +147,7 @@ fn plugin_with_dynamic_native_dependency() { fn main() { let src = PathBuf::from(env::var("SRC").unwrap()); - println!("cargo:rustc-flags=-L {}/deps", src.parent().unwrap() - .display()); + println!("cargo:rustc-flags=-L {}/deps", src.parent().unwrap().display()); } "#) .file("bar/src/lib.rs", r#" diff --git a/tests/run.rs b/tests/run.rs index 14607613866..ce007bef645 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -429,7 +429,7 @@ fn example_with_release_flag() { --out-dir {dir}[/]target[/]release[/]examples \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]release[/]deps \ - --extern bar={dir}[/]target[/]release[/]deps[/]libbar.rlib` + --extern bar={dir}[/]target[/]release[/]deps[/]libbar-[..].rlib` [FINISHED] release [optimized] target(s) in [..] [RUNNING] `target[/]release[/]examples[/]a[EXE]` ", @@ -457,7 +457,7 @@ fast2")); --out-dir {dir}[/]target[/]debug[/]examples \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps \ - --extern bar={dir}[/]target[/]debug[/]deps[/]libbar.rlib` + --extern bar={dir}[/]target[/]debug[/]deps[/]libbar-[..].rlib` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[/]debug[/]examples[/]a[EXE]` ", diff --git a/tests/rustc.rs b/tests/rustc.rs index 5e54bae5a6e..b8475e16f44 100644 --- a/tests/rustc.rs +++ b/tests/rustc.rs @@ -97,7 +97,7 @@ fn build_main_and_allow_unstable_options() { --out-dir [..] \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps \ - --extern {name}={dir}[/]target[/]debug[/]deps[/]lib{name}.rlib` + --extern {name}={dir}[/]target[/]debug[/]deps[/]lib{name}-[..].rlib` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), url = p.url(), diff --git a/tests/test.rs b/tests/test.rs index b3ca52f8ce9..a9f78b2be40 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -40,7 +40,7 @@ fn cargo_test_simple() { execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]foo-[..][EXE]", p.url())) +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE]", p.url())) .with_stdout(" running 1 test test test_hello ... ok @@ -93,7 +93,7 @@ fn cargo_test_release() { [RUNNING] [..] -C opt-level=3 [..] [FINISHED] release [optimized] target(s) in [..] [RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE]` -[RUNNING] `[..]target[/]release[/]test-[..][EXE]` +[RUNNING] `[..]target[/]release[/]deps[/]test-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc --test [..]lib.rs[..]`", dir = p.url())) .with_stdout(" @@ -130,7 +130,7 @@ fn cargo_test_verbose() { [COMPILING] foo v0.5.0 ({url}) [RUNNING] `rustc src[/]foo.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] `[..]target[/]debug[/]foo-[..][EXE] hello`", url = p.url())) +[RUNNING] `[..]target[/]debug[/]deps[/]foo-[..][EXE] hello`", url = p.url())) .with_stdout(" running 1 test test test_hello ... ok @@ -198,7 +198,7 @@ fn cargo_test_failing_test() { execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({url}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [ERROR] test failed", url = p.url())) .with_stdout_contains(" running 1 test @@ -258,7 +258,7 @@ fn test_with_lib_dep() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]baz-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]baz-[..][EXE] [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" @@ -375,7 +375,7 @@ fn external_test_explicit() { [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] -[RUNNING] target[/]debug[/]test-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]test-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -423,7 +423,7 @@ fn external_test_implicit() { execs().with_stderr(format!("\ [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]external-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]external-[..][EXE] [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" @@ -568,7 +568,7 @@ fn lib_bin_same_name() { [COMPILING] foo v0.0.1 ({}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] -[RUNNING] target[/]debug[/]foo-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] [DOCTEST] foo", p.url())) .with_stdout(" running 1 test @@ -621,7 +621,7 @@ fn lib_with_standard_name() { [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[/]debug[/]deps[/]syntax-[..][EXE] -[RUNNING] target[/]debug[/]test-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]test-[..][EXE] [DOCTEST] syntax", dir = p.url())) .with_stdout(" running 1 test @@ -675,7 +675,7 @@ fn lib_with_standard_name2() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]syntax-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]deps[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test test ... ok @@ -715,7 +715,7 @@ fn lib_without_name() { .with_stderr(&format!("\ [COMPILING] syntax v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]syntax-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]deps[/]syntax-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test test ... ok @@ -974,7 +974,7 @@ fn test_dylib() { [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] -[RUNNING] target[/]debug[/]test-[..][EXE]", dir = p.url())) +[RUNNING] target[/]debug[/]deps[/]test-[..][EXE]", dir = p.url())) .with_stdout(" running 1 test test foo ... ok @@ -994,7 +994,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured .with_stderr("\ [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] -[RUNNING] target[/]debug[/]test-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]test-[..][EXE]") .with_stdout(" running 1 test test foo ... ok @@ -1154,7 +1154,7 @@ fn test_run_specific_bin_target() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]bin2-[..][EXE]", dir = prj.url())) +[RUNNING] target[/]debug[/]deps[/]bin2-[..][EXE]", dir = prj.url())) .with_stdout(" running 1 test test test2 ... ok @@ -1183,7 +1183,7 @@ fn test_run_specific_test_target() { .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]b-[..][EXE]", dir = prj.url())) +[RUNNING] target[/]debug[/]deps[/]b-[..][EXE]", dir = prj.url())) .with_stdout(" running 1 test test test_b ... ok @@ -1219,7 +1219,7 @@ fn test_no_harness() { .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]bar-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]bar-[..][EXE] ", dir = p.url()))); } @@ -1746,7 +1746,7 @@ fn filter_no_doc_tests() { execs().with_stderr("\ [COMPILING] foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target[/]debug[/]foo[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]foo[..][EXE]") .with_stdout(" running 0 tests @@ -1944,7 +1944,7 @@ fn no_fail_fast() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[/]debug[/]deps[/]foo-[..][EXE] -[RUNNING] target[/]debug[/]test_add_one-[..][EXE]") +[RUNNING] target[/]debug[/]deps[/]test_add_one-[..][EXE]") .with_stdout_contains(" running 0 tests @@ -1952,7 +1952,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ") .with_stderr_contains("\ -[RUNNING] target[/]debug[/]test_sub_one-[..][EXE] +[RUNNING] target[/]debug[/]deps[/]test_sub_one-[..][EXE] [DOCTEST] foo") .with_stdout_contains("\ test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured From c34c96a4edea7546bbff1897663c129870cd3360 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 8 Nov 2016 02:09:22 +0000 Subject: [PATCH 0816/3888] Revert "Continuously publish Cargo builds" This reverts commit 7799014dc7330445f62e2f925573ca15dd8e8e03. --- .travis.yml | 186 +++++++-------------------- Makefile.in | 55 ++++---- appveyor.yml | 64 +++------ configure | 43 ++++--- src/ci/docker/cross/Dockerfile | 2 - src/ci/docker/dist/Dockerfile | 2 - src/ci/docker/run.sh | 49 ------- src/ci/docker/x86_64-musl/Dockerfile | 11 -- src/ci/run.sh | 32 ----- src/etc/install-deps.py | 7 - tests/init.rs | 4 +- tests/package.rs | 3 +- 12 files changed, 112 insertions(+), 346 deletions(-) delete mode 100644 src/ci/docker/cross/Dockerfile delete mode 100644 src/ci/docker/dist/Dockerfile delete mode 100755 src/ci/docker/run.sh delete mode 100644 src/ci/docker/x86_64-musl/Dockerfile delete mode 100755 src/ci/run.sh diff --git a/.travis.yml b/.travis.yml index be844a9c8a3..731d1a5f272 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,149 +1,49 @@ language: rust -rust: stable -sudo: required -dist: trusty -os: linux -services: - - docker +rust: + - stable + - beta + - nightly +sudo: false +script: + - ./configure --prefix=$HOME/cargo-install --disable-cross-tests --disable-optimize + - make + - make test + - make distcheck + - make doc + - make install + - make uninstall +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $(uname -s) = Linux ] && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +env: + global: + # apparently we use too much memory and if there's more than one rustc then + # when compiling Cargo's unit tests some compilers will be randomly kill + # -9'd + - CARGOFLAGS=-j1 + - secure: scGpeetUfba5RWyuS4yt10bPoFAI9wpHEReIFqEx7eH5vr2Anajk6+70jW6GdrWVdUvdINiArlQ3An2DeB9vEUWcBjw8WvuPtOH0tDMoSsuVloPlFD8yn1Ac0Bx9getAO5ofxqtoNg+OV4MDVuGabEesqAOWqURNrBC7XK+ntC8= matrix: include: - # stable linux builds, tested - - env: TARGET=x86_64-unknown-linux-gnu - ALT=i686-unknown-linux-gnu - IMAGE=dist - MAKE_TARGETS="test distcheck doc install uninstall" - - env: TARGET=i686-unknown-linux-gnu - IMAGE=dist - MAKE_TARGETS=test-unit-i686-unknown-linux-gnu - CFG_DISABLE_CROSS_TESTS=1 - - # stable osx builds, tested - - env: TARGET=x86_64-apple-darwin - ALT=i686-apple-darwin - MAKE_TARGETS="test distcheck doc install uninstall" - MACOSX_DEPLOYMENT_TARGET=10.7 - os: osx - before_install: - - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include - - env: TARGET=i686-apple-darwin - MAKE_TARGETS=test - MACOSX_DEPLOYMENT_TARGET=10.7 - CFG_DISABLE_CROSS_TESTS=1 - os: osx + - os: osx + rust: stable before_install: - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include - - # stable musl target, tested - - env: TARGET=x86_64-unknown-linux-musl - IMAGE=x86_64-musl - CFG_DISABLE_CROSS_TESTS=1 - MAKE_TARGETS=test-unit-$TARGET - - # cross compiled targets - - env: TARGET=arm-unknown-linux-gnueabi - IMAGE=cross - - env: TARGET=arm-unknown-linux-gnueabihf - IMAGE=cross - - env: TARGET=armv7-unknown-linux-gnueabihf - IMAGE=cross - - env: TARGET=aarch64-unknown-linux-gnu - IMAGE=cross - - env: TARGET=i686-unknown-freebsd - IMAGE=cross - - env: TARGET=x86_64-unknown-freebsd - IMAGE=cross - - env: TARGET=x86_64-unknown-netbsd - IMAGE=cross - - env: TARGET=mips-unknown-linux-gnu - IMAGE=cross - - env: TARGET=mipsel-unknown-linux-gnu - IMAGE=cross - - env: TARGET=mips64-unknown-linux-gnuabi64 - IMAGE=cross - rust: nightly - - env: TARGET=mips64el-unknown-linux-gnuabi64 - IMAGE=cross - rust: nightly - - env: TARGET=s390x-unknown-linux-gnu - IMAGE=cross - rust: nightly - - env: TARGET=powerpc-unknown-linux-gnu - IMAGE=cross - rust: beta - - env: TARGET=powerpc64-unknown-linux-gnu - IMAGE=cross - rust: beta - - env: TARGET=powerpc64le-unknown-linux-gnu - IMAGE=cross - rust: beta - - # beta/nightly builds - - env: TARGET=x86_64-unknown-linux-gnu - ALT=i686-unknown-linux-gnu - IMAGE=dist - MAKE_TARGETS="test distcheck doc install uninstall" - DEPLOY=0 - rust: beta - - env: TARGET=x86_64-unknown-linux-gnu - ALT=i686-unknown-linux-gnu - IMAGE=dist - MAKE_TARGETS="test distcheck doc install uninstall" - DEPLOY=0 - rust: nightly - - exclude: - - rust: stable - -before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH - - curl https://static.rust-lang.org/rustup.sh | - sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot` - - if [ ! -z "$ALT" ]; then - curl https://static.rust-lang.org/rustup.sh | - sh -s -- --add-target=$ALT --disable-sudo -y --prefix=`rustc --print sysroot`; - fi -script: - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - SRC=. src/ci/run.sh $TARGET; - else - src/ci/docker/run.sh $IMAGE $TARGET; - fi -after_success: - - travis-cargo --only nightly doc-upload - -env: - global: - - DEPLOY=1 - - secure: LB2o9UL90Z4CVOLVQsTbZr7ZBLA1dCLxFODuCkPkbdqG3Kl5z1yMIPMRvSbjp9KwBlIgm+Mg0R1iqphKVq+rVP5zo96K4+kEQMG+zWsPb23ZKTxiL8MK5VgCZ7s9AONCvNeCTCNAG3EyeciFr5Zr9eygVCfo0WF6JsPujYYQZx0= - -notifications: - email: - on_success: never - -before_deploy: - - mkdir -p deploy/$TRAVIS_COMMIT - - cp target/$TARGET/release/dist/cargo-nightly-$TARGET.tar.gz - deploy/$TRAVIS_COMMIT - -deploy: - - provider: s3 - bucket: rust-lang-cargo-dev - skip_cleanup: true - local_dir: deploy - upload_dir: cargo-master - acl: public_read - region: us-west-1 - access_key_id: AKIAJYHGN72KKCN4DFBQ - secret_access_key: - secure: wKKDMYBVTdWLuc7+ffpjTqJs1EdM2pXpV6keUfZGv9RLRta+esh/r/cgc+UQ7+m9JHAliH8eWhlMm5ws6WDgkTvM0PTdqWBgwd24BRbAitsXX2kWfi9WgAeSJVSkIJdZ999TRpRIJu7Zc+1++fbfdD/tDv5XBirQGOJv1HynVWY= - on: - branch: auto - condition: $DEPLOY = 1 - -cache: - directories: - - $HOME/.cargo - - target/openssl + - export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib + +branches: + only: + - master + +addons: + apt: + sources: + - kalakris-cmake + packages: + - cmake + - g++-multilib + - lib32stdc++6 diff --git a/Makefile.in b/Makefile.in index 43fbf333daf..08dc61626ee 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,6 +6,11 @@ OPENSSL_SHA256=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431 include config.mk +ifneq ($(CFG_LOCAL_RUST_ROOT),) +export LD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(LD_LIBRARY_PATH) +export DYLD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(DYLD_LIBRARY_PATH) +endif + export PATH := $(dir $(CFG_RUSTC)):$(PATH) ifdef CFG_ENABLE_NIGHTLY @@ -79,45 +84,44 @@ $(foreach target,$(CFG_TARGET),$(eval $(call DIST_TARGET,$(target)))) ifdef CFG_LOCAL_CARGO CARGO := $(CFG_LOCAL_CARGO) else -CARGO := $(CFG_CARGO) +CARGO := $(TARGET_ROOT)/snapshot/bin/cargo$(X) endif all: $(foreach target,$(CFG_TARGET),cargo-$(target)) define CARGO_TARGET -cargo-$(1): target/openssl/$(1).stamp +cargo-$(1): $$(CARGO) target/openssl/$(1).stamp $$(CFG_RUSTC) -V $$(CARGO) --version $$(CARGO) build --target $(1) \ --manifest-path $(S)Cargo.toml \ $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(ARGS) -test-unit-$(1): target/openssl/$(1).stamp cargo-$(1) - @mkdir -p $$(CFG_BUILD_DIR)/target/$(1)/cit - $$(CARGO) test --target $(1) \ - --manifest-path $(S)Cargo.toml \ - $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) +test-unit-$(1): $$(CARGO) + @mkdir -p target/$(1)/cit + $$(CARGO) test --target $(1) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) endef $(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target)))) +$(TARGET_ROOT)/snapshot/bin/cargo$(X): $(S)src/snapshots.txt + $(CFG_PYTHON) $(S)src/etc/dl-snapshot.py $(CFG_BUILD) + touch $@ + + # === Tests test: style no-exes $(foreach target,$(CFG_TARGET),test-unit-$(target)) style: - (cd $(S) && sh tests/check-style.sh) + sh tests/check-style.sh -ifeq ($(CFG_GIT),) -no-exes: -else no-exes: - (cd $(S) && find $$($(CFG_GIT) ls-files) -type f \ + find $$(git ls-files) -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ -not -name configure -not -name '*.sh' -not -name '*.rs' \ -not -name '*.py' -not -wholename "*/rust-installer/*" | \ grep '.*' \ - && exit 1 || exit 0) -endif + && exit 1 || exit 0 # === Misc @@ -139,9 +143,9 @@ DOC_OPTS := --markdown-no-toc \ --markdown-css stylesheets/normalize.css \ --markdown-css stylesheets/all.css \ --markdown-css stylesheets/prism.css \ - --html-in-header $(S)src/doc/html-headers.html \ - --html-before-content $(S)src/doc/header.html \ - --html-after-content $(S)src/doc/footer.html + --html-in-header src/doc/html-headers.html \ + --html-before-content src/doc/header.html \ + --html-after-content src/doc/footer.html ASSETS := CNAME images/noise.png images/forkme.png images/Cargo-Logo-Small.png \ stylesheets/all.css stylesheets/normalize.css javascripts/prism.js \ javascripts/all.js stylesheets/prism.css images/circle-with-i.png \ @@ -152,19 +156,14 @@ doc: $(foreach doc,$(DOCS),target/doc/$(doc).html) \ $(foreach asset,$(ASSETS),target/doc/$(asset)) \ target/doc/cargo/index.html -target/doc/cargo/index.html: target/openssl/$(CFG_BUILD).stamp cargo-$(CFG_BUILD) - $(CARGO) doc --no-deps --target $(CFG_BUILD) \ - --manifest-path $(S)Cargo.toml $(OPT_FLAG) +target/doc/cargo/index.html: + $(CARGO) doc --no-deps -$(DOC_DIR)/%.html: \ - $(S)src/doc/%.md \ - $(S)src/doc/html-headers.html \ - $(S)src/doc/header.html \ - $(S)src/doc/footer.html +$(DOC_DIR)/%.html: src/doc/%.md src/doc/html-headers.html src/doc/header.html src/doc/footer.html @mkdir -p $(@D) $(CFG_RUSTDOC) $< -o $(@D) $(DOC_OPTS) -$(DOC_DIR)/%: $(S)src/doc/% +$(DOC_DIR)/%: src/doc/% @mkdir -p $(@D) cp $< $@ @@ -174,7 +173,6 @@ OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf OPENSSL_OS_i686-unknown-linux-gnu := linux-elf -OPENSSL_OS_i686-unknown-linux-musl := linux-elf OPENSSL_OS_mips-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mips64-unknown-linux-gnuabi64 := linux64-mips64 @@ -194,7 +192,6 @@ OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar OPENSSL_AR_i686-unknown-linux-gnu := ar -OPENSSL_AR_i686-unknown-linux-musl := ar OPENSSL_AR_mips-unknown-linux-gnu := mips-linux-gnu-ar OPENSSL_AR_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-ar OPENSSL_AR_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-ar @@ -213,7 +210,6 @@ OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc OPENSSL_CC_i686-unknown-linux-gnu := gcc -OPENSSL_CC_i686-unknown-linux-musl := musl-gcc OPENSSL_CC_mips-unknown-linux-gnu := mips-linux-gnu-gcc OPENSSL_CC_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-gcc OPENSSL_CC_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-gcc @@ -229,7 +225,6 @@ OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc SETARCH_i686-unknown-linux-gnu := setarch i386 OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32 -OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32 define BUILD_OPENSSL ifdef OPENSSL_OS_$(1) diff --git a/appveyor.yml b/appveyor.yml index 07d98a26b4e..88660ab3b3c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,71 +1,37 @@ environment: + CFG_DISABLE_CROSS_TESTS: 1 matrix: + - TARGET: i686-pc-windows-msvc + MSVC: 1 + BITS: 32 + ARCH: x86 + - TARGET: x86_64-pc-windows-msvc + MSVC: 1 + BITS: 64 + ARCH: amd64 - TARGET: x86_64-pc-windows-gnu ARCH: amd64 BITS: 64 - CFG_DISABLE_CROSS_TESTS: 1 - MAKE_TARGETS: test-unit-x86_64-pc-windows-gnu - TARGET: i686-pc-windows-gnu ARCH: x86 BITS: 32 MINGW_URL: https://s3.amazonaws.com/rust-lang-ci MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z MINGW_DIR: mingw32 - CFG_DISABLE_CROSS_TESTS: 1 - MAKE_TARGETS: test-unit-i686-pc-windows-gnu - - TARGET: i686-pc-windows-msvc - BITS: 32 - ARCH: x86 - MAKE_TARGETS: test-unit-i686-pc-windows-msvc - CFG_DISABLE_CROSS_TESTS: 1 - - TARGET: x86_64-pc-windows-msvc - OTHER_TARGET: i686-pc-windows-msvc - BITS: 64 - ARCH: amd64 - MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc install: - - set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% + - IF "%MSVC%"=="" set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% - if defined MINGW_URL appveyor DownloadFile %MINGW_URL%/%MINGW_ARCHIVE% - if defined MINGW_URL 7z x -y %MINGW_ARCHIVE% > nul - if defined MINGW_URL set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% - - curl -sSf -o rustup-init.exe https://win.rustup.rs/ - - rustup-init.exe -y --default-host x86_64-pc-windows-msvc - - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - - if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET% - - if defined OTHER_TARGET rustup target add %OTHER_TARGET% + - python src/etc/install-deps.py + - python src/etc/dl-snapshot.py %TARGET% + - SET PATH=%PATH%;%cd%/rustc/bin + - SET PATH=%PATH%;%cd%/target/snapshot/bin - rustc -V - cargo -V - - git submodule update --init build: false test_script: - - sh src/ci/run.sh %TARGET% - -cache: - - target - - C:\Users\appveyor\.cargo\registry - -after_test: - - mkdir %APPVEYOR_REPO_COMMIT% - - copy target\%TARGET%\release\dist\cargo-nightly-%TARGET%.tar.gz - %APPVEYOR_REPO_COMMIT% - -artifacts: - - path: $(APPVEYOR_REPO_COMMIT)\cargo-nightly-$(TARGET).tar.gz - name: cargo - -deploy: - - provider: S3 - skip_cleanup: true - access_key_id: AKIAIIBSE766REJRCHEA - secret_access_key: - secure: S3MCw/gXyWBuq8cW+eFQjbfjccxrH1koYqQxsYDvCDkM7D2PLqd88yv8lND7dVt0 - bucket: rust-lang-cargo-dev - set_public: true - region: us-west-1 - artifact: cargo - folder: cargo-master - on: - branch: auto + - cargo test diff --git a/configure b/configure index 1ead582545e..66400d80cef 100755 --- a/configure +++ b/configure @@ -270,7 +270,9 @@ need_cmd date need_cmd tr need_cmd sed need_cmd cmake -need_cmd make +if [ "${OS}" != "Windows_NT" ]; then + need_cmd curl +fi CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" CFG_BUILD_DIR="$(pwd)/" @@ -307,20 +309,20 @@ opt cross-tests 1 "run cross-compilation tests" valopt prefix "/usr/local" "set installation prefix" valopt local-rust-root "" "set prefix for local rust binary" -if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then - export LD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$LD_LIBRARY_PATH" - export DYLD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$DYLD_LIBRARY_PATH" - export PATH="${CFG_LOCAL_RUST_ROOT}/bin:$PATH" -fi - -valopt cargo "cargo" "cargo to bootstrap from" -valopt rustc "rustc" "rustc to compile with" -valopt rustdoc "rustdoc" "rustdoc to document with" - if [ $HELP -eq 0 ]; then - probe_need CFG_CARGO $CFG_CARGO - probe_need CFG_RUSTC $CFG_RUSTC - probe_need CFG_RUSTDOC $CFG_RUSTDOC + if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then + export LD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$LD_LIBRARY_PATH" + export DYLD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$DYLD_LIBRARY_PATH" + LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version` + if [ $? -eq 0 ]; then + step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: $LRV" + else + err "failed to run rustc at: ${CFG_LOCAL_RUST_ROOT}" + fi + CFG_RUSTC="${CFG_LOCAL_RUST_ROOT}/bin/rustc" + else + probe_need CFG_RUSTC rustc + fi DEFAULT_BUILD=$("${CFG_RUSTC}" -vV | grep 'host: ' | sed 's/host: //') fi @@ -335,6 +337,7 @@ valopt infodir "${CFG_PREFIX}/share/info" "install additional info" valopt docdir "${CFG_PREFIX}/share/doc/cargo" "install extra docs" valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH" valopt libdir "${CFG_PREFIX}/lib" "install libraries" +valopt local-cargo "" "local cargo to bootstrap from" if [ $HELP -eq 1 ] then @@ -351,8 +354,15 @@ fi step_msg "looking for build programs" +probe_need CFG_CURLORWGET curl wget +probe_need CFG_PYTHON python2.7 python2 python probe_need CFG_CC cc gcc clang -probe GIT git + +if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then + CFG_RUSTDOC="${CFG_LOCAL_RUST_ROOT}/bin/rustdoc" +else + probe_need CFG_RUSTDOC rustdoc +fi # a little post-processing of various config values CFG_PREFIX=${CFG_PREFIX%/} @@ -386,7 +396,6 @@ if [ "$CFG_SRC_DIR" != "$CFG_BUILD_DIR" ]; then fi if [ ! -z "$CFG_ENABLE_NIGHTLY" ]; then - need_cmd curl if [ ! -f .cargo/config ]; then mkdir -p .cargo cat > .cargo/config <<-EOF @@ -440,8 +449,6 @@ putvar CFG_MANDIR putvar CFG_LIBDIR putvar CFG_RUSTC putvar CFG_RUSTDOC -putvar CFG_CARGO -putvar CFG_GIT msg copy_if_changed ${CFG_SRC_DIR}Makefile.in ./Makefile diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile deleted file mode 100644 index e0a9840e05c..00000000000 --- a/src/ci/docker/cross/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM alexcrichton/rust-slave-linux-cross:2016-10-11c -ENTRYPOINT [] diff --git a/src/ci/docker/dist/Dockerfile b/src/ci/docker/dist/Dockerfile deleted file mode 100644 index d87d8f71998..00000000000 --- a/src/ci/docker/dist/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM alexcrichton/rust-slave-dist:2016-09-26 -ENTRYPOINT [] diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh deleted file mode 100755 index a8f71fab1e7..00000000000 --- a/src/ci/docker/run.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -set -e - -script=`cd $(dirname $0) && pwd`/`basename $0` -image=$1 -TARGET=$2 - -docker_dir="`dirname $script`" -ci_dir="`dirname $docker_dir`" -src_dir="`dirname $ci_dir`" -root_dir="`dirname $src_dir`" - -docker build \ - --rm \ - -t rust-ci \ - "`dirname "$script"`/$image" - -mkdir -p $HOME/.cargo -mkdir -p target - -exec docker run \ - --user `id -u`:`id -g` \ - --volume "$root_dir:/checkout:ro" \ - --workdir /tmp \ - --env CFG_DISABLE_CROSS_TESTS=$CFG_DISABLE_CROSS_TESTS \ - --env MAKE_TARGETS="$MAKE_TARGETS" \ - --env SRC=/checkout \ - --env CARGO_HOME=/cargo \ - --volume "$HOME/.cargo:/cargo" \ - --volume `rustc --print sysroot`:/rust:ro \ - --volume `pwd`/target:/tmp/target \ - --interactive \ - --tty \ - rust-ci \ - sh -c "\ - PATH=\$PATH:/rust/bin \ - LD_LIBRARY_PATH=/rust/lib:\$LD_LIBRARY_PATH \ - /checkout/src/ci/run.sh $TARGET" - diff --git a/src/ci/docker/x86_64-musl/Dockerfile b/src/ci/docker/x86_64-musl/Dockerfile deleted file mode 100644 index 4206c3120c7..00000000000 --- a/src/ci/docker/x86_64-musl/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update -y && apt-get install -y --no-install-recommends \ - cmake \ - make \ - gcc \ - musl-tools \ - curl \ - ca-certificates \ - libc6-dev \ - git diff --git a/src/ci/run.sh b/src/ci/run.sh deleted file mode 100755 index 456c3f8b2b1..00000000000 --- a/src/ci/run.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -set -ex - -TARGET=$1 - -if [ -z "$SRC" ]; then - SRC=. -fi - -$SRC/configure \ - --prefix=/tmp/obj/install \ - --target=$TARGET \ - --enable-nightly - -make cargo-$TARGET -make dist-$TARGET - -if [ ! -z "$MAKE_TARGETS" ]; then - for target in "$MAKE_TARGETS"; do - make $target - done -fi diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py index 5f4b650c9f2..350bf1954e6 100644 --- a/src/etc/install-deps.py +++ b/src/etc/install-deps.py @@ -55,19 +55,12 @@ rust_date = open('src/rustversion.txt').read().strip() url = 'https://static.rust-lang.org/dist/' + rust_date -cargo_url = 'https://static.rust-lang.org/cargo-dist/2016-03-21' def install_via_tarballs(): if os.path.isdir("rustc-install"): shutil.rmtree("rustc-install") - # Download cargo - host_fname = 'cargo-nightly-' + host + '.tar.gz' - download.get(cargo_url + '/' + host_fname, host_fname) - download.unpack(host_fname, "rustc-install", quiet=True, strip=2) - os.remove(host_fname) - # Download the compiler host_fname = 'rustc-nightly-' + host + '.tar.gz' download.get(url + '/' + host_fname, host_fname) diff --git a/tests/init.rs b/tests/init.rs index cd64118929f..315394359d9 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -7,13 +7,13 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::env; -use cargo::util::ProcessBuilder; +use cargo::util::{process, ProcessBuilder}; use cargotest::support::{execs, paths, cargo_dir}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; use tempdir::TempDir; fn cargo_process(s: &str) -> ProcessBuilder { - let mut p = cargotest::process(&cargo_dir().join("cargo")); + let mut p = process(&cargo_dir().join("cargo")); p.arg(s).cwd(&paths::root()).env("HOME", &paths::home()); return p; } diff --git a/tests/package.rs b/tests/package.rs index 394482cfd4d..f7b3d870cfe 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -10,7 +10,8 @@ use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::path::{Path, PathBuf}; -use cargotest::{cargo_process, process}; +use cargo::util::process; +use cargotest::cargo_process; use cargotest::support::{project, execs, paths, git, path2url, cargo_dir}; use flate2::read::GzDecoder; use hamcrest::{assert_that, existing_file, contains}; From ad2c607231e8ea37ea7e1db23eef95eb93b27a34 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 8 Nov 2016 07:04:09 -0800 Subject: [PATCH 0817/3888] Revert "Revert "Continuously publish Cargo builds"" This reverts commit b008422e92295c2e4de5b7de2284d963b55a6f8c. --- .travis.yml | 186 ++++++++++++++++++++------- Makefile.in | 55 ++++---- appveyor.yml | 64 ++++++--- configure | 43 +++---- src/ci/docker/cross/Dockerfile | 2 + src/ci/docker/dist/Dockerfile | 2 + src/ci/docker/run.sh | 49 +++++++ src/ci/docker/x86_64-musl/Dockerfile | 11 ++ src/ci/run.sh | 32 +++++ src/etc/install-deps.py | 7 + tests/init.rs | 4 +- tests/package.rs | 3 +- 12 files changed, 346 insertions(+), 112 deletions(-) create mode 100644 src/ci/docker/cross/Dockerfile create mode 100644 src/ci/docker/dist/Dockerfile create mode 100755 src/ci/docker/run.sh create mode 100644 src/ci/docker/x86_64-musl/Dockerfile create mode 100755 src/ci/run.sh diff --git a/.travis.yml b/.travis.yml index 731d1a5f272..be844a9c8a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,149 @@ language: rust -rust: - - stable - - beta - - nightly -sudo: false -script: - - ./configure --prefix=$HOME/cargo-install --disable-cross-tests --disable-optimize - - make - - make test - - make distcheck - - make doc - - make install - - make uninstall -after_success: | - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - [ $(uname -s) = Linux ] && - pip install ghp-import --user $USER && - $HOME/.local/bin/ghp-import -n target/doc && - git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages -env: - global: - # apparently we use too much memory and if there's more than one rustc then - # when compiling Cargo's unit tests some compilers will be randomly kill - # -9'd - - CARGOFLAGS=-j1 - - secure: scGpeetUfba5RWyuS4yt10bPoFAI9wpHEReIFqEx7eH5vr2Anajk6+70jW6GdrWVdUvdINiArlQ3An2DeB9vEUWcBjw8WvuPtOH0tDMoSsuVloPlFD8yn1Ac0Bx9getAO5ofxqtoNg+OV4MDVuGabEesqAOWqURNrBC7XK+ntC8= +rust: stable +sudo: required +dist: trusty +os: linux +services: + - docker matrix: include: - - os: osx - rust: stable + # stable linux builds, tested + - env: TARGET=x86_64-unknown-linux-gnu + ALT=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS="test distcheck doc install uninstall" + - env: TARGET=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS=test-unit-i686-unknown-linux-gnu + CFG_DISABLE_CROSS_TESTS=1 + + # stable osx builds, tested + - env: TARGET=x86_64-apple-darwin + ALT=i686-apple-darwin + MAKE_TARGETS="test distcheck doc install uninstall" + MACOSX_DEPLOYMENT_TARGET=10.7 + os: osx + before_install: + - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include + - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include + - env: TARGET=i686-apple-darwin + MAKE_TARGETS=test + MACOSX_DEPLOYMENT_TARGET=10.7 + CFG_DISABLE_CROSS_TESTS=1 + os: osx before_install: - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - - export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib - -branches: - only: - - master - -addons: - apt: - sources: - - kalakris-cmake - packages: - - cmake - - g++-multilib - - lib32stdc++6 + - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include + + # stable musl target, tested + - env: TARGET=x86_64-unknown-linux-musl + IMAGE=x86_64-musl + CFG_DISABLE_CROSS_TESTS=1 + MAKE_TARGETS=test-unit-$TARGET + + # cross compiled targets + - env: TARGET=arm-unknown-linux-gnueabi + IMAGE=cross + - env: TARGET=arm-unknown-linux-gnueabihf + IMAGE=cross + - env: TARGET=armv7-unknown-linux-gnueabihf + IMAGE=cross + - env: TARGET=aarch64-unknown-linux-gnu + IMAGE=cross + - env: TARGET=i686-unknown-freebsd + IMAGE=cross + - env: TARGET=x86_64-unknown-freebsd + IMAGE=cross + - env: TARGET=x86_64-unknown-netbsd + IMAGE=cross + - env: TARGET=mips-unknown-linux-gnu + IMAGE=cross + - env: TARGET=mipsel-unknown-linux-gnu + IMAGE=cross + - env: TARGET=mips64-unknown-linux-gnuabi64 + IMAGE=cross + rust: nightly + - env: TARGET=mips64el-unknown-linux-gnuabi64 + IMAGE=cross + rust: nightly + - env: TARGET=s390x-unknown-linux-gnu + IMAGE=cross + rust: nightly + - env: TARGET=powerpc-unknown-linux-gnu + IMAGE=cross + rust: beta + - env: TARGET=powerpc64-unknown-linux-gnu + IMAGE=cross + rust: beta + - env: TARGET=powerpc64le-unknown-linux-gnu + IMAGE=cross + rust: beta + + # beta/nightly builds + - env: TARGET=x86_64-unknown-linux-gnu + ALT=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS="test distcheck doc install uninstall" + DEPLOY=0 + rust: beta + - env: TARGET=x86_64-unknown-linux-gnu + ALT=i686-unknown-linux-gnu + IMAGE=dist + MAKE_TARGETS="test distcheck doc install uninstall" + DEPLOY=0 + rust: nightly + + exclude: + - rust: stable + +before_script: + - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH + - curl https://static.rust-lang.org/rustup.sh | + sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot` + - if [ ! -z "$ALT" ]; then + curl https://static.rust-lang.org/rustup.sh | + sh -s -- --add-target=$ALT --disable-sudo -y --prefix=`rustc --print sysroot`; + fi +script: + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then + SRC=. src/ci/run.sh $TARGET; + else + src/ci/docker/run.sh $IMAGE $TARGET; + fi +after_success: + - travis-cargo --only nightly doc-upload + +env: + global: + - DEPLOY=1 + - secure: LB2o9UL90Z4CVOLVQsTbZr7ZBLA1dCLxFODuCkPkbdqG3Kl5z1yMIPMRvSbjp9KwBlIgm+Mg0R1iqphKVq+rVP5zo96K4+kEQMG+zWsPb23ZKTxiL8MK5VgCZ7s9AONCvNeCTCNAG3EyeciFr5Zr9eygVCfo0WF6JsPujYYQZx0= + +notifications: + email: + on_success: never + +before_deploy: + - mkdir -p deploy/$TRAVIS_COMMIT + - cp target/$TARGET/release/dist/cargo-nightly-$TARGET.tar.gz + deploy/$TRAVIS_COMMIT + +deploy: + - provider: s3 + bucket: rust-lang-cargo-dev + skip_cleanup: true + local_dir: deploy + upload_dir: cargo-master + acl: public_read + region: us-west-1 + access_key_id: AKIAJYHGN72KKCN4DFBQ + secret_access_key: + secure: wKKDMYBVTdWLuc7+ffpjTqJs1EdM2pXpV6keUfZGv9RLRta+esh/r/cgc+UQ7+m9JHAliH8eWhlMm5ws6WDgkTvM0PTdqWBgwd24BRbAitsXX2kWfi9WgAeSJVSkIJdZ999TRpRIJu7Zc+1++fbfdD/tDv5XBirQGOJv1HynVWY= + on: + branch: auto + condition: $DEPLOY = 1 + +cache: + directories: + - $HOME/.cargo + - target/openssl diff --git a/Makefile.in b/Makefile.in index 08dc61626ee..43fbf333daf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,11 +6,6 @@ OPENSSL_SHA256=e7aff292be21c259c6af26469c7a9b3ba26e9abaaffd325e3dccc9785256c431 include config.mk -ifneq ($(CFG_LOCAL_RUST_ROOT),) -export LD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(LD_LIBRARY_PATH) -export DYLD_LIBRARY_PATH := $(CFG_LOCAL_RUST_ROOT)/lib:$(DYLD_LIBRARY_PATH) -endif - export PATH := $(dir $(CFG_RUSTC)):$(PATH) ifdef CFG_ENABLE_NIGHTLY @@ -84,44 +79,45 @@ $(foreach target,$(CFG_TARGET),$(eval $(call DIST_TARGET,$(target)))) ifdef CFG_LOCAL_CARGO CARGO := $(CFG_LOCAL_CARGO) else -CARGO := $(TARGET_ROOT)/snapshot/bin/cargo$(X) +CARGO := $(CFG_CARGO) endif all: $(foreach target,$(CFG_TARGET),cargo-$(target)) define CARGO_TARGET -cargo-$(1): $$(CARGO) target/openssl/$(1).stamp +cargo-$(1): target/openssl/$(1).stamp $$(CFG_RUSTC) -V $$(CARGO) --version $$(CARGO) build --target $(1) \ --manifest-path $(S)Cargo.toml \ $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(ARGS) -test-unit-$(1): $$(CARGO) - @mkdir -p target/$(1)/cit - $$(CARGO) test --target $(1) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) +test-unit-$(1): target/openssl/$(1).stamp cargo-$(1) + @mkdir -p $$(CFG_BUILD_DIR)/target/$(1)/cit + $$(CARGO) test --target $(1) \ + --manifest-path $(S)Cargo.toml \ + $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) endef $(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target)))) -$(TARGET_ROOT)/snapshot/bin/cargo$(X): $(S)src/snapshots.txt - $(CFG_PYTHON) $(S)src/etc/dl-snapshot.py $(CFG_BUILD) - touch $@ - - # === Tests test: style no-exes $(foreach target,$(CFG_TARGET),test-unit-$(target)) style: - sh tests/check-style.sh + (cd $(S) && sh tests/check-style.sh) +ifeq ($(CFG_GIT),) +no-exes: +else no-exes: - find $$(git ls-files) -type f \ + (cd $(S) && find $$($(CFG_GIT) ls-files) -type f \ \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ -not -name configure -not -name '*.sh' -not -name '*.rs' \ -not -name '*.py' -not -wholename "*/rust-installer/*" | \ grep '.*' \ - && exit 1 || exit 0 + && exit 1 || exit 0) +endif # === Misc @@ -143,9 +139,9 @@ DOC_OPTS := --markdown-no-toc \ --markdown-css stylesheets/normalize.css \ --markdown-css stylesheets/all.css \ --markdown-css stylesheets/prism.css \ - --html-in-header src/doc/html-headers.html \ - --html-before-content src/doc/header.html \ - --html-after-content src/doc/footer.html + --html-in-header $(S)src/doc/html-headers.html \ + --html-before-content $(S)src/doc/header.html \ + --html-after-content $(S)src/doc/footer.html ASSETS := CNAME images/noise.png images/forkme.png images/Cargo-Logo-Small.png \ stylesheets/all.css stylesheets/normalize.css javascripts/prism.js \ javascripts/all.js stylesheets/prism.css images/circle-with-i.png \ @@ -156,14 +152,19 @@ doc: $(foreach doc,$(DOCS),target/doc/$(doc).html) \ $(foreach asset,$(ASSETS),target/doc/$(asset)) \ target/doc/cargo/index.html -target/doc/cargo/index.html: - $(CARGO) doc --no-deps +target/doc/cargo/index.html: target/openssl/$(CFG_BUILD).stamp cargo-$(CFG_BUILD) + $(CARGO) doc --no-deps --target $(CFG_BUILD) \ + --manifest-path $(S)Cargo.toml $(OPT_FLAG) -$(DOC_DIR)/%.html: src/doc/%.md src/doc/html-headers.html src/doc/header.html src/doc/footer.html +$(DOC_DIR)/%.html: \ + $(S)src/doc/%.md \ + $(S)src/doc/html-headers.html \ + $(S)src/doc/header.html \ + $(S)src/doc/footer.html @mkdir -p $(@D) $(CFG_RUSTDOC) $< -o $(@D) $(DOC_OPTS) -$(DOC_DIR)/%: src/doc/% +$(DOC_DIR)/%: $(S)src/doc/% @mkdir -p $(@D) cp $< $@ @@ -173,6 +174,7 @@ OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf OPENSSL_OS_i686-unknown-linux-gnu := linux-elf +OPENSSL_OS_i686-unknown-linux-musl := linux-elf OPENSSL_OS_mips-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mips64-unknown-linux-gnuabi64 := linux64-mips64 @@ -192,6 +194,7 @@ OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar OPENSSL_AR_i686-unknown-linux-gnu := ar +OPENSSL_AR_i686-unknown-linux-musl := ar OPENSSL_AR_mips-unknown-linux-gnu := mips-linux-gnu-ar OPENSSL_AR_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-ar OPENSSL_AR_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-ar @@ -210,6 +213,7 @@ OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc OPENSSL_CC_i686-unknown-linux-gnu := gcc +OPENSSL_CC_i686-unknown-linux-musl := musl-gcc OPENSSL_CC_mips-unknown-linux-gnu := mips-linux-gnu-gcc OPENSSL_CC_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-gcc OPENSSL_CC_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-gcc @@ -225,6 +229,7 @@ OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc SETARCH_i686-unknown-linux-gnu := setarch i386 OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32 +OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32 define BUILD_OPENSSL ifdef OPENSSL_OS_$(1) diff --git a/appveyor.yml b/appveyor.yml index 88660ab3b3c..07d98a26b4e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,37 +1,71 @@ environment: - CFG_DISABLE_CROSS_TESTS: 1 matrix: - - TARGET: i686-pc-windows-msvc - MSVC: 1 - BITS: 32 - ARCH: x86 - - TARGET: x86_64-pc-windows-msvc - MSVC: 1 - BITS: 64 - ARCH: amd64 - TARGET: x86_64-pc-windows-gnu ARCH: amd64 BITS: 64 + CFG_DISABLE_CROSS_TESTS: 1 + MAKE_TARGETS: test-unit-x86_64-pc-windows-gnu - TARGET: i686-pc-windows-gnu ARCH: x86 BITS: 32 MINGW_URL: https://s3.amazonaws.com/rust-lang-ci MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z MINGW_DIR: mingw32 + CFG_DISABLE_CROSS_TESTS: 1 + MAKE_TARGETS: test-unit-i686-pc-windows-gnu + - TARGET: i686-pc-windows-msvc + BITS: 32 + ARCH: x86 + MAKE_TARGETS: test-unit-i686-pc-windows-msvc + CFG_DISABLE_CROSS_TESTS: 1 + - TARGET: x86_64-pc-windows-msvc + OTHER_TARGET: i686-pc-windows-msvc + BITS: 64 + ARCH: amd64 + MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc install: - - IF "%MSVC%"=="" set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% + - set PATH=C:\msys64\mingw%BITS%\bin;C:\msys64\usr\bin;%PATH% - if defined MINGW_URL appveyor DownloadFile %MINGW_URL%/%MINGW_ARCHIVE% - if defined MINGW_URL 7z x -y %MINGW_ARCHIVE% > nul - if defined MINGW_URL set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH% - - python src/etc/install-deps.py - - python src/etc/dl-snapshot.py %TARGET% - - SET PATH=%PATH%;%cd%/rustc/bin - - SET PATH=%PATH%;%cd%/target/snapshot/bin + - curl -sSf -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host x86_64-pc-windows-msvc + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET% + - if defined OTHER_TARGET rustup target add %OTHER_TARGET% - rustc -V - cargo -V + - git submodule update --init build: false test_script: - - cargo test + - sh src/ci/run.sh %TARGET% + +cache: + - target + - C:\Users\appveyor\.cargo\registry + +after_test: + - mkdir %APPVEYOR_REPO_COMMIT% + - copy target\%TARGET%\release\dist\cargo-nightly-%TARGET%.tar.gz + %APPVEYOR_REPO_COMMIT% + +artifacts: + - path: $(APPVEYOR_REPO_COMMIT)\cargo-nightly-$(TARGET).tar.gz + name: cargo + +deploy: + - provider: S3 + skip_cleanup: true + access_key_id: AKIAIIBSE766REJRCHEA + secret_access_key: + secure: S3MCw/gXyWBuq8cW+eFQjbfjccxrH1koYqQxsYDvCDkM7D2PLqd88yv8lND7dVt0 + bucket: rust-lang-cargo-dev + set_public: true + region: us-west-1 + artifact: cargo + folder: cargo-master + on: + branch: auto diff --git a/configure b/configure index 66400d80cef..1ead582545e 100755 --- a/configure +++ b/configure @@ -270,9 +270,7 @@ need_cmd date need_cmd tr need_cmd sed need_cmd cmake -if [ "${OS}" != "Windows_NT" ]; then - need_cmd curl -fi +need_cmd make CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" CFG_BUILD_DIR="$(pwd)/" @@ -309,20 +307,20 @@ opt cross-tests 1 "run cross-compilation tests" valopt prefix "/usr/local" "set installation prefix" valopt local-rust-root "" "set prefix for local rust binary" +if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then + export LD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$LD_LIBRARY_PATH" + export DYLD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$DYLD_LIBRARY_PATH" + export PATH="${CFG_LOCAL_RUST_ROOT}/bin:$PATH" +fi + +valopt cargo "cargo" "cargo to bootstrap from" +valopt rustc "rustc" "rustc to compile with" +valopt rustdoc "rustdoc" "rustdoc to document with" + if [ $HELP -eq 0 ]; then - if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then - export LD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$LD_LIBRARY_PATH" - export DYLD_LIBRARY_PATH="${CFG_LOCAL_RUST_ROOT}/lib:$DYLD_LIBRARY_PATH" - LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version` - if [ $? -eq 0 ]; then - step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: $LRV" - else - err "failed to run rustc at: ${CFG_LOCAL_RUST_ROOT}" - fi - CFG_RUSTC="${CFG_LOCAL_RUST_ROOT}/bin/rustc" - else - probe_need CFG_RUSTC rustc - fi + probe_need CFG_CARGO $CFG_CARGO + probe_need CFG_RUSTC $CFG_RUSTC + probe_need CFG_RUSTDOC $CFG_RUSTDOC DEFAULT_BUILD=$("${CFG_RUSTC}" -vV | grep 'host: ' | sed 's/host: //') fi @@ -337,7 +335,6 @@ valopt infodir "${CFG_PREFIX}/share/info" "install additional info" valopt docdir "${CFG_PREFIX}/share/doc/cargo" "install extra docs" valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH" valopt libdir "${CFG_PREFIX}/lib" "install libraries" -valopt local-cargo "" "local cargo to bootstrap from" if [ $HELP -eq 1 ] then @@ -354,15 +351,8 @@ fi step_msg "looking for build programs" -probe_need CFG_CURLORWGET curl wget -probe_need CFG_PYTHON python2.7 python2 python probe_need CFG_CC cc gcc clang - -if [ ! -z "${CFG_LOCAL_RUST_ROOT}" ]; then - CFG_RUSTDOC="${CFG_LOCAL_RUST_ROOT}/bin/rustdoc" -else - probe_need CFG_RUSTDOC rustdoc -fi +probe GIT git # a little post-processing of various config values CFG_PREFIX=${CFG_PREFIX%/} @@ -396,6 +386,7 @@ if [ "$CFG_SRC_DIR" != "$CFG_BUILD_DIR" ]; then fi if [ ! -z "$CFG_ENABLE_NIGHTLY" ]; then + need_cmd curl if [ ! -f .cargo/config ]; then mkdir -p .cargo cat > .cargo/config <<-EOF @@ -449,6 +440,8 @@ putvar CFG_MANDIR putvar CFG_LIBDIR putvar CFG_RUSTC putvar CFG_RUSTDOC +putvar CFG_CARGO +putvar CFG_GIT msg copy_if_changed ${CFG_SRC_DIR}Makefile.in ./Makefile diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile new file mode 100644 index 00000000000..e0a9840e05c --- /dev/null +++ b/src/ci/docker/cross/Dockerfile @@ -0,0 +1,2 @@ +FROM alexcrichton/rust-slave-linux-cross:2016-10-11c +ENTRYPOINT [] diff --git a/src/ci/docker/dist/Dockerfile b/src/ci/docker/dist/Dockerfile new file mode 100644 index 00000000000..d87d8f71998 --- /dev/null +++ b/src/ci/docker/dist/Dockerfile @@ -0,0 +1,2 @@ +FROM alexcrichton/rust-slave-dist:2016-09-26 +ENTRYPOINT [] diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh new file mode 100755 index 00000000000..a8f71fab1e7 --- /dev/null +++ b/src/ci/docker/run.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -e + +script=`cd $(dirname $0) && pwd`/`basename $0` +image=$1 +TARGET=$2 + +docker_dir="`dirname $script`" +ci_dir="`dirname $docker_dir`" +src_dir="`dirname $ci_dir`" +root_dir="`dirname $src_dir`" + +docker build \ + --rm \ + -t rust-ci \ + "`dirname "$script"`/$image" + +mkdir -p $HOME/.cargo +mkdir -p target + +exec docker run \ + --user `id -u`:`id -g` \ + --volume "$root_dir:/checkout:ro" \ + --workdir /tmp \ + --env CFG_DISABLE_CROSS_TESTS=$CFG_DISABLE_CROSS_TESTS \ + --env MAKE_TARGETS="$MAKE_TARGETS" \ + --env SRC=/checkout \ + --env CARGO_HOME=/cargo \ + --volume "$HOME/.cargo:/cargo" \ + --volume `rustc --print sysroot`:/rust:ro \ + --volume `pwd`/target:/tmp/target \ + --interactive \ + --tty \ + rust-ci \ + sh -c "\ + PATH=\$PATH:/rust/bin \ + LD_LIBRARY_PATH=/rust/lib:\$LD_LIBRARY_PATH \ + /checkout/src/ci/run.sh $TARGET" + diff --git a/src/ci/docker/x86_64-musl/Dockerfile b/src/ci/docker/x86_64-musl/Dockerfile new file mode 100644 index 00000000000..4206c3120c7 --- /dev/null +++ b/src/ci/docker/x86_64-musl/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:16.04 + +RUN apt-get update -y && apt-get install -y --no-install-recommends \ + cmake \ + make \ + gcc \ + musl-tools \ + curl \ + ca-certificates \ + libc6-dev \ + git diff --git a/src/ci/run.sh b/src/ci/run.sh new file mode 100755 index 00000000000..456c3f8b2b1 --- /dev/null +++ b/src/ci/run.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex + +TARGET=$1 + +if [ -z "$SRC" ]; then + SRC=. +fi + +$SRC/configure \ + --prefix=/tmp/obj/install \ + --target=$TARGET \ + --enable-nightly + +make cargo-$TARGET +make dist-$TARGET + +if [ ! -z "$MAKE_TARGETS" ]; then + for target in "$MAKE_TARGETS"; do + make $target + done +fi diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py index 350bf1954e6..5f4b650c9f2 100644 --- a/src/etc/install-deps.py +++ b/src/etc/install-deps.py @@ -55,12 +55,19 @@ rust_date = open('src/rustversion.txt').read().strip() url = 'https://static.rust-lang.org/dist/' + rust_date +cargo_url = 'https://static.rust-lang.org/cargo-dist/2016-03-21' def install_via_tarballs(): if os.path.isdir("rustc-install"): shutil.rmtree("rustc-install") + # Download cargo + host_fname = 'cargo-nightly-' + host + '.tar.gz' + download.get(cargo_url + '/' + host_fname, host_fname) + download.unpack(host_fname, "rustc-install", quiet=True, strip=2) + os.remove(host_fname) + # Download the compiler host_fname = 'rustc-nightly-' + host + '.tar.gz' download.get(url + '/' + host_fname, host_fname) diff --git a/tests/init.rs b/tests/init.rs index 315394359d9..cd64118929f 100644 --- a/tests/init.rs +++ b/tests/init.rs @@ -7,13 +7,13 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::env; -use cargo::util::{process, ProcessBuilder}; +use cargo::util::ProcessBuilder; use cargotest::support::{execs, paths, cargo_dir}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; use tempdir::TempDir; fn cargo_process(s: &str) -> ProcessBuilder { - let mut p = process(&cargo_dir().join("cargo")); + let mut p = cargotest::process(&cargo_dir().join("cargo")); p.arg(s).cwd(&paths::root()).env("HOME", &paths::home()); return p; } diff --git a/tests/package.rs b/tests/package.rs index f7b3d870cfe..394482cfd4d 100644 --- a/tests/package.rs +++ b/tests/package.rs @@ -10,8 +10,7 @@ use std::fs::{File, OpenOptions}; use std::io::prelude::*; use std::path::{Path, PathBuf}; -use cargo::util::process; -use cargotest::cargo_process; +use cargotest::{cargo_process, process}; use cargotest::support::{project, execs, paths, git, path2url, cargo_dir}; use flate2::read::GzDecoder; use hamcrest::{assert_that, existing_file, contains}; From 3d1f12037694f4c82b93e40913f0f491c89ccb82 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 8 Nov 2016 07:07:49 -0800 Subject: [PATCH 0818/3888] Don't use travis-cargo to upload docs --- .travis.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index be844a9c8a3..2bbcbe98a13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -98,7 +98,6 @@ matrix: - rust: stable before_script: - - pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH - curl https://static.rust-lang.org/rustup.sh | sh -s -- --add-target=$TARGET --disable-sudo -y --prefix=`rustc --print sysroot` - if [ ! -z "$ALT" ]; then @@ -111,8 +110,13 @@ script: else src/ci/docker/run.sh $IMAGE $TARGET; fi -after_success: - - travis-cargo --only nightly doc-upload +after_success: | + [ $TRAVIS_BRANCH = master ] && + [ $TRAVIS_PULL_REQUEST = false ] && + [ $(uname -s) = Linux ] && + pip install ghp-import --user $USER && + $HOME/.local/bin/ghp-import -n target/doc && + git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages env: global: From 7634ef3df4806f63961af1f4f6f98b138a5fe090 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Nov 2016 12:17:45 -0800 Subject: [PATCH 0819/3888] Bump to 0.15.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- Makefile.in | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9591597eb8e..79643be3bff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "cargo" -version = "0.14.0" +version = "0.15.0" dependencies = [ "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -73,7 +73,7 @@ name = "cargotest" version = "0.1.0" dependencies = [ "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cargo 0.14.0", + "cargo 0.15.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 99b15db7d2a..ee573bb094e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo" -version = "0.14.0" +version = "0.15.0" authors = ["Yehuda Katz ", "Carl Lerche ", "Alex Crichton "] diff --git a/Makefile.in b/Makefile.in index 43fbf333daf..da0b097ffea 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -CFG_RELEASE_NUM=0.14.0 +CFG_RELEASE_NUM=0.15.0 CFG_RELEASE_LABEL= OPENSSL_VERS=1.0.2j From c76a7486b30e47cb274a6fa9cdea6767577da486 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Nov 2016 15:44:39 -0800 Subject: [PATCH 0820/3888] Fix passing --features when testing multiple packages The wrong method was being passed to resolution accidentally. Features specified via `--features` and `--no-default-features` are spec'd as only applying to the *current* package, not all packages. Closes #3279 --- src/cargo/ops/cargo_compile.rs | 19 ++++++---- src/cargo/ops/cargo_output_metadata.rs | 7 +++- src/cargo/ops/resolve.rs | 52 +++++++++++++++++++------- tests/test.rs | 34 +++++++++++++++++ 4 files changed, 90 insertions(+), 22 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index bec83524419..4c385c8d169 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -103,7 +103,7 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, features: &[String], all_features: bool, no_default_features: bool, - spec: &'a [String]) + specs: &[PackageIdSpec]) -> CargoResult<(PackageSet<'a>, Resolve)> { let features = features.iter().flat_map(|s| { s.split_whitespace() @@ -137,13 +137,10 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, } }; - let specs = try!(spec.iter().map(|p| PackageIdSpec::parse(p)) - .collect::>>()); - let resolved_with_overrides = try!(ops::resolve_with_previous(&mut registry, ws, method, Some(&resolve), None, - &specs)); + specs)); let packages = ops::get_resolved_packages(&resolved_with_overrides, registry); @@ -174,8 +171,16 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, try!(generate_targets(root_package, profiles, mode, filter, release)); } - let (packages, resolve_with_overrides) = - try!(resolve_dependencies(ws, source, features, all_features, no_default_features, spec)); + let specs = try!(spec.iter().map(|p| PackageIdSpec::parse(p)) + .collect::>>()); + + let pair = try!(resolve_dependencies(ws, + source, + features, + all_features, + no_default_features, + &specs)); + let (packages, resolve_with_overrides) = pair; let mut pkgids = Vec::new(); if spec.len() > 0 { diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index cda9b53e67f..affaaa6a18e 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -1,7 +1,7 @@ use rustc_serialize::{Encodable, Encoder}; use core::resolver::Resolve; -use core::{Package, PackageId, Workspace}; +use core::{Package, PackageId, PackageIdSpec, Workspace}; use ops; use util::CargoResult; @@ -43,12 +43,15 @@ fn metadata_no_deps(ws: &Workspace, fn metadata_full(ws: &Workspace, opt: &OutputMetadataOptions) -> CargoResult { + let specs = ws.members().map(|pkg| { + PackageIdSpec::from_package_id(pkg.package_id()) + }).collect::>(); let deps = try!(ops::resolve_dependencies(ws, None, &opt.features, opt.all_features, opt.no_default_features, - &[])); + &specs)); let (packages, resolve) = deps; let packages = try!(packages.package_ids() diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 0bde351e287..87936d3f91d 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -90,24 +90,50 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, for member in ws.members() { try!(registry.add_sources(&[member.package_id().source_id() .clone()])); + let method_to_resolve = match method { + // When everything for a workspace we want to be sure to resolve all + // members in the workspace, so propagate the `Method::Everything`. + Method::Everything => Method::Everything, - // If we're resolving everything then we include all members of the - // workspace. If we want a specific set of requirements and we're - // compiling only a single workspace crate then resolve only it. This - // case should only happen after we have a previous resolution, however, - // so assert that the previous exists. - if let Method::Required { .. } = method { - assert!(previous.is_some()); - if let Some(current) = ws.current_opt() { - if member.package_id() != current.package_id() && - !specs.iter().any(|spec| spec.matches(member.package_id())) { - continue; + // If we're not resolving everything though then the workspace is + // already resolved and now we're drilling down from that to the + // exact crate graph we're going to build. Here we don't necessarily + // want to keep around all workspace crates as they may not all be + // built/tested. + // + // Additionally, the `method` specified represents command line + // flags, which really only matters for the current package + // (determined by the cwd). If other packages are specified (via + // `-p`) then the command line flags like features don't apply to + // them. + // + // As a result, if this `member` is the current member of the + // workspace, then we use `method` specified. Otherwise we use a + // base method with no features specified but using default features + // for any other packages specified with `-p`. + Method::Required { dev_deps, .. } => { + assert!(previous.is_some()); + let base = Method::Required { + dev_deps: dev_deps, + features: &[], + uses_default_features: true, + }; + let member_id = member.package_id(); + match ws.current_opt() { + Some(current) if member_id == current.package_id() => method, + _ => { + if specs.iter().any(|spec| spec.matches(member_id)) { + base + } else { + continue + } + } } } - } + }; let summary = registry.lock(member.summary().clone()); - summaries.push((summary, method)); + summaries.push((summary, method_to_resolve)); } let root_replace = ws.root_replace(); diff --git a/tests/test.rs b/tests/test.rs index b3ca52f8ce9..31b815385e3 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2364,3 +2364,37 @@ fn test_release_ignore_panic() { println!("bench"); assert_that(p.cargo("bench").arg("-v"), execs().with_status(0)); } + +#[test] +fn test_many_with_features() { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a" } + + [features] + foo = [] + + [workspace] + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", ""); + p.build(); + + assert_that(p.cargo("test").arg("-v") + .arg("-p").arg("a") + .arg("-p").arg("foo") + .arg("--features").arg("foo"), + execs().with_status(0)); +} From d2fe738afc0333d0d4b777cf0272c5d51965827a Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Fri, 11 Nov 2016 14:25:20 +0100 Subject: [PATCH 0821/3888] Changed try! macros to ? operator Since the stabilization of the ? operator (release 1.13.0) the ? operator should be used to use idiomatic Rust. --- src/bin/bench.rs | 10 +- src/bin/build.rs | 10 +- src/bin/cargo.rs | 14 +-- src/bin/clean.rs | 10 +- src/bin/doc.rs | 10 +- src/bin/fetch.rs | 10 +- src/bin/generate_lockfile.rs | 10 +- src/bin/git_checkout.rs | 8 +- src/bin/init.rs | 10 +- src/bin/install.rs | 16 +-- src/bin/locate_project.rs | 6 +- src/bin/login.rs | 16 +-- src/bin/metadata.rs | 10 +- src/bin/new.rs | 10 +- src/bin/owner.rs | 6 +- src/bin/package.rs | 12 +- src/bin/pkgid.rs | 10 +- src/bin/publish.rs | 12 +- src/bin/read_manifest.rs | 6 +- src/bin/run.rs | 10 +- src/bin/rustc.rs | 12 +- src/bin/rustdoc.rs | 12 +- src/bin/search.rs | 6 +- src/bin/test.rs | 10 +- src/bin/uninstall.rs | 6 +- src/bin/update.rs | 10 +- src/bin/verify_project.rs | 4 +- src/bin/yank.rs | 8 +- src/cargo/core/dependency.rs | 4 +- src/cargo/core/package.rs | 18 +-- src/cargo/core/package_id.rs | 20 ++-- src/cargo/core/package_id_spec.rs | 30 ++--- src/cargo/core/registry.rs | 36 +++--- src/cargo/core/resolver/encode.rs | 20 ++-- src/cargo/core/resolver/mod.rs | 60 +++++----- src/cargo/core/shell.rs | 34 +++--- src/cargo/core/source.rs | 28 ++--- src/cargo/core/workspace.rs | 30 ++--- src/cargo/lib.rs | 4 +- src/cargo/ops/cargo_clean.rs | 32 +++--- src/cargo/ops/cargo_compile.rs | 100 ++++++++--------- src/cargo/ops/cargo_doc.rs | 14 +-- src/cargo/ops/cargo_fetch.rs | 6 +- src/cargo/ops/cargo_generate_lockfile.rs | 28 ++--- src/cargo/ops/cargo_install.rs | 130 +++++++++++----------- src/cargo/ops/cargo_new.rs | 50 ++++----- src/cargo/ops/cargo_output_metadata.rs | 4 +- src/cargo/ops/cargo_package.rs | 98 ++++++++-------- src/cargo/ops/cargo_pkgid.rs | 6 +- src/cargo/ops/cargo_read_manifest.rs | 28 ++--- src/cargo/ops/cargo_run.rs | 8 +- src/cargo/ops/cargo_rustc/compilation.rs | 6 +- src/cargo/ops/cargo_rustc/context.rs | 62 +++++------ src/cargo/ops/cargo_rustc/custom_build.rs | 50 ++++----- src/cargo/ops/cargo_rustc/fingerprint.rs | 112 +++++++++---------- src/cargo/ops/cargo_rustc/job.rs | 2 +- src/cargo/ops/cargo_rustc/job_queue.rs | 34 +++--- src/cargo/ops/cargo_rustc/layout.rs | 20 ++-- src/cargo/ops/cargo_rustc/mod.rs | 114 +++++++++---------- src/cargo/ops/cargo_test.rs | 34 +++--- src/cargo/ops/lockfile.rs | 18 +-- src/cargo/ops/registry.rs | 128 ++++++++++----------- src/cargo/ops/resolve.rs | 16 +-- src/cargo/sources/config.rs | 36 +++--- src/cargo/sources/directory.rs | 26 ++--- src/cargo/sources/git/source.rs | 20 ++-- src/cargo/sources/git/utils.rs | 108 +++++++++--------- src/cargo/sources/path.rs | 48 ++++---- src/cargo/sources/registry/index.rs | 20 ++-- src/cargo/sources/registry/local.rs | 12 +- src/cargo/sources/registry/mod.rs | 30 ++--- src/cargo/sources/registry/remote.rs | 70 ++++++------ src/cargo/sources/replaced.rs | 8 +- src/cargo/util/cfg.rs | 20 ++-- src/cargo/util/config.rs | 104 ++++++++--------- src/cargo/util/errors.rs | 4 +- src/cargo/util/flock.rs | 26 ++--- src/cargo/util/graph.rs | 8 +- src/cargo/util/lazy_cell.rs | 2 +- src/cargo/util/network.rs | 4 +- src/cargo/util/paths.rs | 18 +-- src/cargo/util/process_builder.rs | 22 ++-- src/cargo/util/read2.rs | 20 ++-- src/cargo/util/rustc.rs | 10 +- src/cargo/util/toml.rs | 88 +++++++-------- src/cargo/util/vcs.rs | 6 +- src/crates-io/lib.rs | 102 ++++++++--------- tests/cargotest/support/mod.rs | 14 +-- tests/resolve.rs | 4 +- tests/shell.rs | 10 +- 90 files changed, 1249 insertions(+), 1249 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index d5bc21dd46e..18c90c6248f 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -71,12 +71,12 @@ Compilation can be customized with the `bench` profile in the manifest. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); - try!(config.configure(options.flag_verbose, + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let ops = ops::TestOptions { no_run: options.flag_no_run, no_fail_fast: false, @@ -102,8 +102,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }, }; - let ws = try!(Workspace::new(&root, config)); - let err = try!(ops::run_benches(&ws, &ops, &options.arg_args)); + let ws = Workspace::new(&root, config)?; + let err = ops::run_benches(&ws, &ops, &options.arg_args)?; match err { None => Ok(None), Some(err) => { diff --git a/src/bin/build.rs b/src/bin/build.rs index eb6673c2f9a..439201f7420 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -69,13 +69,13 @@ the --release flag will use the `release` profile instead. pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-build; args={:?}", env::args().collect::>()); - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let opts = CompileOptions { config: config, @@ -97,7 +97,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target_rustc_args: None, }; - let ws = try!(Workspace::new(&root, config)); - try!(ops::compile(&ws, &opts)); + let ws = Workspace::new(&root, config)?; + ops::compile(&ws, &opts)?; Ok(None) } diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index fdcea48c89f..94bcfbb9e99 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -116,11 +116,11 @@ each_subcommand!(declare_mod); on this top-level information. */ fn execute(flags: Flags, config: &Config) -> CliResult> { - try!(config.configure(flags.flag_verbose, + config.configure(flags.flag_verbose, flags.flag_quiet, &flags.flag_color, flags.flag_frozen, - flags.flag_locked)); + flags.flag_locked)?; init_git_transports(config); let _token = cargo::util::job::setup(); @@ -139,8 +139,8 @@ fn execute(flags: Flags, config: &Config) -> CliResult> { } if let Some(ref code) = flags.flag_explain { - let mut procss = try!(config.rustc()).process(); - try!(procss.arg("--explain").arg(code).exec().map_err(human)); + let mut procss = config.rustc()?.process(); + procss.arg("--explain").arg(code).exec().map_err(human)?; return Ok(None) } @@ -189,7 +189,7 @@ fn execute(flags: Flags, config: &Config) -> CliResult> { return Ok(None) } - let alias_list = try!(aliased_command(&config, &args[1])); + let alias_list = aliased_command(&config, &args[1])?; let args = match alias_list { Some(alias_command) => { let chain = args.iter().take(1) @@ -205,7 +205,7 @@ fn execute(flags: Flags, config: &Config) -> CliResult> { } None => args, }; - try!(execute_subcommand(config, &args[1], &args)); + execute_subcommand(config, &args[1], &args)?; Ok(None) } @@ -239,7 +239,7 @@ fn aliased_command(config: &Config, command: &String) -> CargoResult { - let value = try!(config.get_list(&alias_name)); + let value = config.get_list(&alias_name)?; if let Some(record) = value { let alias_commands: Vec = record.val.iter() .map(|s| s.0.to_string()).collect(); diff --git a/src/bin/clean.rs b/src/bin/clean.rs index c259e83c6f3..5a36aa6005c 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -44,20 +44,20 @@ and its format, see the `cargo help pkgid` command. pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-clean; args={:?}", env::args().collect::>()); - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let opts = ops::CleanOptions { config: config, spec: &options.flag_package, target: options.flag_target.as_ref().map(|s| &s[..]), release: options.flag_release, }; - let ws = try!(Workspace::new(&root, config)); - try!(ops::clean(&ws, &opts)); + let ws = Workspace::new(&root, config)?; + ops::clean(&ws, &opts)?; Ok(None) } diff --git a/src/bin/doc.rs b/src/bin/doc.rs index c250dde227c..c4de72dc078 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -62,13 +62,13 @@ the `cargo help pkgid` command. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let empty = Vec::new(); let doc_opts = ops::DocOptions { @@ -96,7 +96,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }, }; - let ws = try!(Workspace::new(&root, config)); - try!(ops::doc(&ws, &doc_opts)); + let ws = Workspace::new(&root, config)?; + ops::doc(&ws, &doc_opts)?; Ok(None) } diff --git a/src/bin/fetch.rs b/src/bin/fetch.rs index 1a970b71f05..8d191c55a79 100644 --- a/src/bin/fetch.rs +++ b/src/bin/fetch.rs @@ -39,14 +39,14 @@ all updated. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); - let ws = try!(Workspace::new(&root, config)); - try!(ops::fetch(&ws)); + options.flag_locked)?; + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; + let ws = Workspace::new(&root, config)?; + ops::fetch(&ws)?; Ok(None) } diff --git a/src/bin/generate_lockfile.rs b/src/bin/generate_lockfile.rs index 36057c1bb6e..7c170d05bc2 100644 --- a/src/bin/generate_lockfile.rs +++ b/src/bin/generate_lockfile.rs @@ -33,14 +33,14 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-generate-lockfile; args={:?}", env::args().collect::>()); - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + options.flag_locked)?; + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; - let ws = try!(Workspace::new(&root, config)); - try!(ops::generate_lockfile(&ws)); + let ws = Workspace::new(&root, config)?; + ops::generate_lockfile(&ws)?; Ok(None) } diff --git a/src/bin/git_checkout.rs b/src/bin/git_checkout.rs index f7762483ea6..ebfde445e53 100644 --- a/src/bin/git_checkout.rs +++ b/src/bin/git_checkout.rs @@ -30,21 +30,21 @@ Options: "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let Options { flag_url: url, flag_reference: reference, .. } = options; - let url = try!(url.to_url()); + let url = url.to_url()?; let reference = GitReference::Branch(reference.clone()); let source_id = SourceId::for_git(&url, reference); let mut source = GitSource::new(&source_id, config); - try!(source.update()); + source.update()?; Ok(None) } diff --git a/src/bin/init.rs b/src/bin/init.rs index 237d7663fb4..c5d5017f576 100644 --- a/src/bin/init.rs +++ b/src/bin/init.rs @@ -41,11 +41,11 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-init; args={:?}", env::args().collect::>()); - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let Options { flag_bin, flag_lib, arg_path, flag_name, flag_vcs, .. } = options; @@ -57,11 +57,11 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { flag_name.as_ref().map(|s| s.as_ref())); let opts_lib = opts.lib; - try!(ops::init(opts, config)); + ops::init(opts, config)?; - try!(config.shell().status("Created", format!("{} project", + config.shell().status("Created", format!("{} project", if opts_lib { "library" } - else {"binary (application)"}))); + else {"binary (application)"}))?; Ok(None) } diff --git a/src/bin/install.rs b/src/bin/install.rs index 319b9bdf6f4..c9e75ade072 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -95,11 +95,11 @@ The `--list` option will list all installed packages (and their versions). "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let compile_opts = ops::CompileOptions { config: config, @@ -119,7 +119,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }; let source = if let Some(url) = options.flag_git { - let url = try!(url.to_url()); + let url = url.to_url()?; let gitref = if let Some(branch) = options.flag_branch { GitReference::Branch(branch) } else if let Some(tag) = options.flag_tag { @@ -131,11 +131,11 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }; SourceId::for_git(&url, gitref) } else if let Some(path) = options.flag_path { - try!(SourceId::for_path(&config.cwd().join(path))) + SourceId::for_path(&config.cwd().join(path))? } else if options.arg_crate == None { - try!(SourceId::for_path(&config.cwd())) + SourceId::for_path(&config.cwd())? } else { - try!(SourceId::crates_io(config)) + SourceId::crates_io(config)? }; let krate = options.arg_crate.as_ref().map(|s| &s[..]); @@ -143,9 +143,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { let root = options.flag_root.as_ref().map(|s| &s[..]); if options.flag_list { - try!(ops::install_list(root, config)); + ops::install_list(root, config)?; } else { - try!(ops::install(root, krate, &source, vers, &compile_opts, options.flag_force)); + ops::install(root, krate, &source, vers, &compile_opts, options.flag_force)?; } Ok(None) } diff --git a/src/bin/locate_project.rs b/src/bin/locate_project.rs index f162788fcbd..c9a352453f2 100644 --- a/src/bin/locate_project.rs +++ b/src/bin/locate_project.rs @@ -24,13 +24,13 @@ pub struct ProjectLocation { pub fn execute(flags: LocateProjectFlags, config: &Config) -> CliResult> { - let root = try!(find_root_manifest_for_wd(flags.flag_manifest_path, config.cwd())); + let root = find_root_manifest_for_wd(flags.flag_manifest_path, config.cwd())?; - let string = try!(root.to_str() + let string = root.to_str() .chain_error(|| human("Your project path contains \ characters not representable in \ Unicode")) - .map_err(|e| CliError::new(e, 1))); + .map_err(|e| CliError::new(e, 1))?; Ok(Some(ProjectLocation { root: string.to_string() })) } diff --git a/src/bin/login.rs b/src/bin/login.rs index 53de98af66e..d93e11f8d34 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -35,31 +35,31 @@ Options: "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let token = match options.arg_token.clone() { Some(token) => token, None => { - let src = try!(SourceId::crates_io(config)); + let src = SourceId::crates_io(config)?; let mut src = RegistrySource::remote(&src, config); - try!(src.update()); - let config = try!(src.config()).unwrap(); + src.update()?; + let config = src.config()?.unwrap(); let host = options.flag_host.clone().unwrap_or(config.api); println!("please visit {}me and paste the API Token below", host); let mut line = String::new(); let input = io::stdin(); - try!(input.lock().read_line(&mut line).chain_error(|| { + input.lock().read_line(&mut line).chain_error(|| { human("failed to read stdin") - })); + })?; line } }; let token = token.trim().to_string(); - try!(ops::registry_login(config, token)); + ops::registry_login(config, token)?; Ok(None) } diff --git a/src/bin/metadata.rs b/src/bin/metadata.rs index 4553711045b..df3b21ad6b6 100644 --- a/src/bin/metadata.rs +++ b/src/bin/metadata.rs @@ -43,12 +43,12 @@ Options: "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); - let manifest = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + options.flag_locked)?; + let manifest = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let options = OutputMetadataOptions { features: options.flag_features, @@ -58,7 +58,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult CliResult> { debug!("executing; cmd=cargo-new; args={:?}", env::args().collect::>()); - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let Options { flag_bin, flag_lib, arg_path, flag_name, flag_vcs, .. } = options; @@ -56,12 +56,12 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { flag_name.as_ref().map(|s| s.as_ref())); let opts_lib = opts.lib; - try!(ops::new(opts, config)); + ops::new(opts, config)?; - try!(config.shell().status("Created", format!("{} `{}` project", + config.shell().status("Created", format!("{} `{}` project", if opts_lib { "library" } else {"binary (application)"}, - arg_path))); + arg_path))?; Ok(None) } diff --git a/src/bin/owner.rs b/src/bin/owner.rs index 9b666adfe87..f1232e99bfb 100644 --- a/src/bin/owner.rs +++ b/src/bin/owner.rs @@ -45,11 +45,11 @@ and troubleshooting. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let opts = ops::OwnersOptions { krate: options.arg_crate, token: options.flag_token, @@ -58,7 +58,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { to_remove: options.flag_remove, list: options.flag_list, }; - try!(ops::modify_owners(config, &opts)); + ops::modify_owners(config, &opts)?; Ok(None) } diff --git a/src/bin/package.rs b/src/bin/package.rs index 40eb7bac778..66cf3ada789 100644 --- a/src/bin/package.rs +++ b/src/bin/package.rs @@ -40,20 +40,20 @@ Options: "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); - let ws = try!(Workspace::new(&root, config)); - try!(ops::package(&ws, &ops::PackageOpts { + options.flag_locked)?; + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; + let ws = Workspace::new(&root, config)?; + ops::package(&ws, &ops::PackageOpts { config: config, verify: !options.flag_no_verify, list: options.flag_list, check_metadata: !options.flag_no_metadata, allow_dirty: options.flag_allow_dirty, jobs: options.flag_jobs, - })); + })?; Ok(None) } diff --git a/src/bin/pkgid.rs b/src/bin/pkgid.rs index f9d90523cea..e0588cae3ac 100644 --- a/src/bin/pkgid.rs +++ b/src/bin/pkgid.rs @@ -54,13 +54,13 @@ Example Package IDs pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path.clone(), config.cwd())); - let ws = try!(Workspace::new(&root, config)); + options.flag_locked)?; + let root = find_root_manifest_for_wd(options.flag_manifest_path.clone(), config.cwd())?; + let ws = Workspace::new(&root, config)?; let spec = if options.arg_spec.is_some() { options.arg_spec @@ -70,7 +70,7 @@ pub fn execute(options: Options, None }; let spec = spec.as_ref().map(|s| &s[..]); - let spec = try!(ops::pkgid(&ws, spec)); + let spec = ops::pkgid(&ws, spec)?; println!("{}", spec); Ok(None) } diff --git a/src/bin/publish.rs b/src/bin/publish.rs index 7c277046006..60534f4cf4d 100644 --- a/src/bin/publish.rs +++ b/src/bin/publish.rs @@ -43,11 +43,11 @@ Options: "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let Options { flag_token: token, flag_host: host, @@ -59,9 +59,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { .. } = options; - let root = try!(find_root_manifest_for_wd(flag_manifest_path.clone(), config.cwd())); - let ws = try!(Workspace::new(&root, config)); - try!(ops::publish(&ws, &ops::PublishOpts { + let root = find_root_manifest_for_wd(flag_manifest_path.clone(), config.cwd())?; + let ws = Workspace::new(&root, config)?; + ops::publish(&ws, &ops::PublishOpts { config: config, token: token, index: host, @@ -69,6 +69,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { allow_dirty: allow_dirty, jobs: jobs, dry_run: dry_run, - })); + })?; Ok(None) } diff --git a/src/bin/read_manifest.rs b/src/bin/read_manifest.rs index bd44b0ad581..dfff8a78e1b 100644 --- a/src/bin/read_manifest.rs +++ b/src/bin/read_manifest.rs @@ -28,10 +28,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-read-manifest; args={:?}", env::args().collect::>()); - try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))); + config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..]))?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; - let pkg = try!(Package::for_path(&root, config)); + let pkg = Package::for_path(&root, config)?; Ok(Some(pkg)) } diff --git a/src/bin/run.rs b/src/bin/run.rs index f9ce057319c..1de5ccbba78 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -58,13 +58,13 @@ the ones before go to Cargo. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let (mut examples, mut bins) = (Vec::new(), Vec::new()); if let Some(s) = options.flag_bin { @@ -97,8 +97,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target_rustc_args: None, }; - let ws = try!(Workspace::new(&root, config)); - match try!(ops::run(&ws, &compile_opts, &options.arg_args)) { + let ws = Workspace::new(&root, config)?; + match ops::run(&ws, &compile_opts, &options.arg_args)? { None => Ok(None), Some(err) => { // If we never actually spawned the process then that sounds pretty diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 83103198496..1268c7ba266 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -76,14 +76,14 @@ processes spawned by Cargo, use the $RUSTFLAGS environment variable or the pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-rustc; args={:?}", env::args().collect::>()); - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, - config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, + config.cwd())?; let mode = match options.flag_profile.as_ref().map(|t| &t[..]) { Some("dev") | None => CompileMode::Build, Some("test") => CompileMode::Test, @@ -115,8 +115,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { target_rustc_args: options.arg_opts.as_ref().map(|a| &a[..]), }; - let ws = try!(Workspace::new(&root, config)); - try!(ops::compile(&ws, &opts)); + let ws = Workspace::new(&root, config)?; + ops::compile(&ws, &opts)?; Ok(None) } diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index df3e4886ba1..d993a48503a 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -71,14 +71,14 @@ the `cargo help pkgid` command. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, - config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, + config.cwd())?; let doc_opts = ops::DocOptions { open_result: options.flag_open, @@ -103,8 +103,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }, }; - let ws = try!(Workspace::new(&root, config)); - try!(ops::doc(&ws, &doc_opts)); + let ws = Workspace::new(&root, config)?; + ops::doc(&ws, &doc_opts)?; Ok(None) } diff --git a/src/bin/search.rs b/src/bin/search.rs index 829039aaa0e..828356dc0d0 100644 --- a/src/bin/search.rs +++ b/src/bin/search.rs @@ -34,11 +34,11 @@ Options: "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let Options { flag_host: host, flag_limit: limit, @@ -46,6 +46,6 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { .. } = options; - try!(ops::search(&query.join("+"), config, host, cmp::min(100, limit.unwrap_or(10)) as u8)); + ops::search(&query.join("+"), config, host, cmp::min(100, limit.unwrap_or(10)) as u8)?; Ok(None) } diff --git a/src/bin/test.rs b/src/bin/test.rs index ed487aa4226..5ae7dee946a 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -89,13 +89,13 @@ To get the list of all options available for the test binaries use this: "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let empty = Vec::new(); let (mode, filter); @@ -132,8 +132,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { }, }; - let ws = try!(Workspace::new(&root, config)); - let err = try!(ops::run_tests(&ws, &ops, &options.arg_args)); + let ws = Workspace::new(&root, config)?; + let err = ops::run_tests(&ws, &ops, &options.arg_args)?; match err { None => Ok(None), Some(err) => { diff --git a/src/bin/uninstall.rs b/src/bin/uninstall.rs index 001abde41ef..659702bd9f4 100644 --- a/src/bin/uninstall.rs +++ b/src/bin/uninstall.rs @@ -38,14 +38,14 @@ only uninstall particular binaries. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); + options.flag_locked)?; let root = options.flag_root.as_ref().map(|s| &s[..]); - try!(ops::uninstall(root, &options.arg_spec, &options.flag_bin, config)); + ops::uninstall(root, &options.arg_spec, &options.flag_bin, config)?; Ok(None) } diff --git a/src/bin/update.rs b/src/bin/update.rs index 6d1d7935b9c..064bb5ee991 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -59,12 +59,12 @@ For more information about package id specifications, see `cargo help pkgid`. pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-update; args={:?}", env::args().collect::>()); - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); - let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())); + options.flag_locked)?; + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let update_opts = ops::UpdateOptions { aggressive: options.flag_aggressive, @@ -73,7 +73,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { config: config, }; - let ws = try!(Workspace::new(&root, config)); - try!(ops::update_lockfile(&ws, &update_opts)); + let ws = Workspace::new(&root, config)?; + ops::update_lockfile(&ws, &update_opts)?; Ok(None) } diff --git a/src/bin/verify_project.rs b/src/bin/verify_project.rs index 27424f7a681..447bf7a5dc8 100644 --- a/src/bin/verify_project.rs +++ b/src/bin/verify_project.rs @@ -38,11 +38,11 @@ Options: "; pub fn execute(args: Flags, config: &Config) -> CliResult> { - try!(config.configure(args.flag_verbose, + config.configure(args.flag_verbose, args.flag_quiet, &args.flag_color, args.flag_frozen, - args.flag_locked)); + args.flag_locked)?; let mut contents = String::new(); let filename = args.flag_manifest_path.unwrap_or("Cargo.toml".into()); diff --git a/src/bin/yank.rs b/src/bin/yank.rs index 7971efbb37e..bac383c4fcd 100644 --- a/src/bin/yank.rs +++ b/src/bin/yank.rs @@ -43,17 +43,17 @@ crates to be locked to any yanked version. "; pub fn execute(options: Options, config: &Config) -> CliResult> { - try!(config.configure(options.flag_verbose, + config.configure(options.flag_verbose, options.flag_quiet, &options.flag_color, options.flag_frozen, - options.flag_locked)); - try!(ops::yank(config, + options.flag_locked)?; + ops::yank(config, options.arg_crate, options.flag_vers, options.flag_token, options.flag_index, - options.flag_undo)); + options.flag_undo)?; Ok(None) } diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index b96fed73f1d..23cb71034b4 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -102,7 +102,7 @@ impl DependencyInner { deprecated_extra: Option<(&PackageId, &Config)>) -> CargoResult { let (specified_req, version_req) = match version { - Some(v) => (true, try!(DependencyInner::parse_with_deprecated(v, deprecated_extra))), + Some(v) => (true, DependencyInner::parse_with_deprecated(v, deprecated_extra)?), None => (false, VersionReq::any()) }; @@ -137,7 +137,7 @@ update to a fixed version or contact the upstream maintainer about this warning. ", req, inside.name(), inside.version(), requirement); - try!(config.shell().warn(&msg)); + config.shell().warn(&msg)?; Ok(requirement) } diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index da14b04fc33..6fa0bb7f3e0 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -72,9 +72,9 @@ impl Package { pub fn for_path(manifest_path: &Path, config: &Config) -> CargoResult { let path = manifest_path.parent().unwrap(); - let source_id = try!(SourceId::for_path(path)); - let (pkg, _) = try!(ops::read_package(&manifest_path, &source_id, - config)); + let source_id = SourceId::for_path(path)?; + let (pkg, _) = ops::read_package(&manifest_path, &source_id, + config)?; Ok(pkg) } @@ -157,20 +157,20 @@ impl<'cfg> PackageSet<'cfg> { } pub fn get(&self, id: &PackageId) -> CargoResult<&Package> { - let slot = try!(self.packages.iter().find(|p| p.0 == *id).chain_error(|| { + let slot = self.packages.iter().find(|p| p.0 == *id).chain_error(|| { internal(format!("couldn't find `{}` in package set", id)) - })); + })?; let slot = &slot.1; if let Some(pkg) = slot.borrow() { return Ok(pkg) } let mut sources = self.sources.borrow_mut(); - let source = try!(sources.get_mut(id.source_id()).chain_error(|| { + let source = sources.get_mut(id.source_id()).chain_error(|| { internal(format!("couldn't find source for `{}`", id)) - })); - let pkg = try!(source.download(id).chain_error(|| { + })?; + let pkg = source.download(id).chain_error(|| { human("unable to get packages from source") - })); + })?; assert!(slot.fill(pkg).is_ok()); Ok(slot.borrow().unwrap()) } diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs index b29b8ca11d5..8f1992a733e 100644 --- a/src/cargo/core/package_id.rs +++ b/src/cargo/core/package_id.rs @@ -36,21 +36,21 @@ impl Encodable for PackageId { impl Decodable for PackageId { fn decode(d: &mut D) -> Result { - let string: String = try!(Decodable::decode(d)); + let string: String = Decodable::decode(d)?; let regex = Regex::new(r"^([^ ]+) ([^ ]+) \(([^\)]+)\)$").unwrap(); - let captures = try!(regex.captures(&string).ok_or_else(|| { + let captures = regex.captures(&string).ok_or_else(|| { d.error("invalid serialized PackageId") - })); + })?; let name = captures.at(1).unwrap(); let version = captures.at(2).unwrap(); let url = captures.at(3).unwrap(); - let version = try!(semver::Version::parse(version).map_err(|_| { + let version = semver::Version::parse(version).map_err(|_| { d.error("invalid version") - })); - let source_id = try!(SourceId::from_url(url).map_err(|e| { + })?; + let source_id = SourceId::from_url(url).map_err(|e| { d.error(&e.to_string()) - })); + })?; Ok(PackageId { inner: Arc::new(PackageIdInner { @@ -127,7 +127,7 @@ pub struct Metadata { impl PackageId { pub fn new(name: &str, version: T, sid: &SourceId) -> CargoResult { - let v = try!(version.to_semver().map_err(PackageIdError::InvalidVersion)); + let v = version.to_semver().map_err(PackageIdError::InvalidVersion)?; Ok(PackageId { inner: Arc::new(PackageIdInner { name: name.to_string(), @@ -179,10 +179,10 @@ impl Metadata { impl fmt::Display for PackageId { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - try!(write!(f, "{} v{}", self.inner.name, self.inner.version)); + write!(f, "{} v{}", self.inner.name, self.inner.version)?; if !self.inner.source_id.is_default_registry() { - try!(write!(f, " ({})", self.inner.source_id)); + write!(f, " ({})", self.inner.source_id)?; } Ok(()) diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index a07b69e49f7..2af87fb6c01 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -29,7 +29,7 @@ impl PackageIdSpec { let mut parts = spec.splitn(2, ':'); let name = parts.next().unwrap(); let version = match parts.next() { - Some(version) => Some(try!(Version::parse(version).map_err(human))), + Some(version) => Some(Version::parse(version).map_err(human)?), None => None, }; for ch in name.chars() { @@ -47,9 +47,9 @@ impl PackageIdSpec { pub fn query_str<'a, I>(spec: &str, i: I) -> CargoResult<&'a PackageId> where I: IntoIterator { - let spec = try!(PackageIdSpec::parse(spec).chain_error(|| { + let spec = PackageIdSpec::parse(spec).chain_error(|| { human(format!("invalid package id specification: `{}`", spec)) - })); + })?; spec.query(i) } @@ -68,20 +68,20 @@ impl PackageIdSpec { let frag = url.fragment().map(|s| s.to_owned()); url.set_fragment(None); let (name, version) = { - let mut path = try!(url.path_segments().chain_error(|| { + let mut path = url.path_segments().chain_error(|| { human(format!("pkgid urls must have a path: {}", url)) - })); - let path_name = try!(path.next_back().chain_error(|| { + })?; + let path_name = path.next_back().chain_error(|| { human(format!("pkgid urls must have at least one path \ component: {}", url)) - })); + })?; match frag { Some(fragment) => { let mut parts = fragment.splitn(2, ':'); let name_or_version = parts.next().unwrap(); match parts.next() { Some(part) => { - let version = try!(part.to_semver().map_err(human)); + let version = part.to_semver().map_err(human)?; (name_or_version.to_string(), Some(version)) } None => { @@ -89,8 +89,8 @@ impl PackageIdSpec { .is_alphabetic() { (name_or_version.to_string(), None) } else { - let version = try!(name_or_version.to_semver() - .map_err(human)); + let version = name_or_version.to_semver() + .map_err(human)?; (path_name.to_string(), Some(version)) } } @@ -180,20 +180,20 @@ impl fmt::Display for PackageIdSpec { match self.url { Some(ref url) => { if url.scheme() == "cargo" { - try!(write!(f, "{}{}", url.host().unwrap(), url.path())); + write!(f, "{}{}", url.host().unwrap(), url.path())?; } else { - try!(write!(f, "{}", url)); + write!(f, "{}", url)?; } if url.path_segments().unwrap().next_back().unwrap() != &self.name { printed_name = true; - try!(write!(f, "#{}", self.name)); + write!(f, "#{}", self.name)?; } } - None => { printed_name = true; try!(write!(f, "{}", self.name)) } + None => { printed_name = true; write!(f, "{}", self.name)? } } match self.version { Some(ref v) => { - try!(write!(f, "{}{}", if printed_name {":"} else {"#"}, v)); + write!(f, "{}{}", if printed_name {":"} else {"#"}, v)?; } None => {} } diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 5b7c21ac35e..037b87a8b62 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -91,7 +91,7 @@ enum Kind { impl<'cfg> PackageRegistry<'cfg> { pub fn new(config: &'cfg Config) -> CargoResult> { - let source_config = try!(SourceConfigMap::new(config)); + let source_config = SourceConfigMap::new(config)?; Ok(PackageRegistry { sources: SourceMap::new(), source_ids: HashMap::new(), @@ -138,13 +138,13 @@ impl<'cfg> PackageRegistry<'cfg> { } } - try!(self.load(namespace, kind)); + self.load(namespace, kind)?; Ok(()) } pub fn add_sources(&mut self, ids: &[SourceId]) -> CargoResult<()> { for id in ids.iter() { - try!(self.ensure_loaded(id, Kind::Locked)); + self.ensure_loaded(id, Kind::Locked)?; } Ok(()) } @@ -178,7 +178,7 @@ impl<'cfg> PackageRegistry<'cfg> { fn load(&mut self, source_id: &SourceId, kind: Kind) -> CargoResult<()> { (|| { - let source = try!(self.source_config.load(source_id)); + let source = self.source_config.load(source_id)?; if kind == Kind::Override { self.overrides.push(source_id.clone()); @@ -196,7 +196,7 @@ impl<'cfg> PackageRegistry<'cfg> { for s in self.overrides.iter() { let src = self.sources.get_mut(s).unwrap(); let dep = Dependency::new_override(dep.name(), s); - let mut results = try!(src.query(&dep)); + let mut results = src.query(&dep)?; if results.len() > 0 { return Ok(Some(results.remove(0))) } @@ -291,17 +291,17 @@ impl<'cfg> PackageRegistry<'cfg> { override_summary: &Summary, real_summary: &Summary) -> CargoResult<()> { let real = real_summary.package_id(); - let map = try!(self.locked.get(real.source_id()).chain_error(|| { + let map = self.locked.get(real.source_id()).chain_error(|| { human(format!("failed to find lock source of {}", real)) - })); - let list = try!(map.get(real.name()).chain_error(|| { + })?; + let list = map.get(real.name()).chain_error(|| { human(format!("failed to find lock name of {}", real)) - })); - let &(_, ref real_deps) = try!(list.iter().find(|&&(ref id, _)| { + })?; + let &(_, ref real_deps) = list.iter().find(|&&(ref id, _)| { real == id }).chain_error(|| { human(format!("failed to find lock version of {}", real)) - })); + })?; let mut real_deps = real_deps.clone(); let boilerplate = "\ @@ -327,7 +327,7 @@ http://doc.crates.io/specifying-dependencies.html#overriding-dependencies dependencies; the dependency on `{}` was either added or\n\ modified to not match the previously resolved version\n\n\ {}", override_summary.package_id().name(), dep.name(), boilerplate); - try!(self.source_config.config().shell().warn(&msg)); + self.source_config.config().shell().warn(&msg)?; return Ok(()) } @@ -336,7 +336,7 @@ http://doc.crates.io/specifying-dependencies.html#overriding-dependencies path override for crate `{}` has altered the original list of dependencies; the dependency on `{}` was removed\n\n {}", override_summary.package_id().name(), id.name(), boilerplate); - try!(self.source_config.config().shell().warn(&msg)); + self.source_config.config().shell().warn(&msg)?; return Ok(()) } @@ -347,14 +347,14 @@ http://doc.crates.io/specifying-dependencies.html#overriding-dependencies impl<'cfg> Registry for PackageRegistry<'cfg> { fn query(&mut self, dep: &Dependency) -> CargoResult> { // Ensure the requested source_id is loaded - try!(self.ensure_loaded(dep.source_id(), Kind::Normal).chain_error(|| { + self.ensure_loaded(dep.source_id(), Kind::Normal).chain_error(|| { human(format!("failed to load source for a dependency \ on `{}`", dep.name())) - })); + })?; - let override_summary = try!(self.query_overrides(&dep)); + let override_summary = self.query_overrides(&dep)?; let real_summaries = match self.sources.get_mut(dep.source_id()) { - Some(src) => Some(try!(src.query(&dep))), + Some(src) => Some(src.query(&dep)?), None => None, }; @@ -363,7 +363,7 @@ impl<'cfg> Registry for PackageRegistry<'cfg> { if summaries.len() != 1 { bail!("found an override with a non-locked list"); } - try!(self.warn_bad_override(&candidate, &summaries[0])); + self.warn_bad_override(&candidate, &summaries[0])?; vec![candidate] } (Some(_), None) => bail!("override found but no real ones"), diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index 2e67ef6e5c7..47c20b89bea 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -52,7 +52,7 @@ impl EncodableResolve { // We failed to find a local package in the workspace. // It must have been removed and should be ignored. None => continue, - Some(source) => try!(PackageId::new(&pkg.name, &pkg.version, source)) + Some(source) => PackageId::new(&pkg.name, &pkg.version, source)? }; assert!(live_pkgs.insert(enc_id, (id, pkg)).is_none()) @@ -88,7 +88,7 @@ impl EncodableResolve { }; for edge in deps.iter() { - if let Some(to_depend_on) = try!(lookup_id(edge)) { + if let Some(to_depend_on) = lookup_id(edge)? { g.link(id.clone(), to_depend_on); } } @@ -101,7 +101,7 @@ impl EncodableResolve { for &(ref id, ref pkg) in live_pkgs.values() { if let Some(ref replace) = pkg.replace { assert!(pkg.dependencies.is_none()); - if let Some(replace_id) = try!(lookup_id(replace)) { + if let Some(replace_id) = lookup_id(replace)? { replacements.insert(id.clone(), replace_id); } } @@ -132,9 +132,9 @@ impl EncodableResolve { for (k, v) in metadata.iter().filter(|p| p.0.starts_with(prefix)) { to_remove.push(k.to_string()); let k = &k[prefix.len()..]; - let enc_id: EncodablePackageId = try!(k.parse().chain_error(|| { + let enc_id: EncodablePackageId = k.parse().chain_error(|| { internal("invalid encoding of checksum in lockfile") - })); + })?; let id = match lookup_id(&enc_id) { Ok(Some(id)) => id, _ => continue, @@ -222,9 +222,9 @@ pub struct EncodablePackageId { impl fmt::Display for EncodablePackageId { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "{} {}", self.name, self.version)); + write!(f, "{} {}", self.name, self.version)?; if let Some(ref s) = self.source { - try!(write!(f, " ({})", s.to_url())); + write!(f, " ({})", s.to_url())?; } Ok(()) } @@ -235,15 +235,15 @@ impl FromStr for EncodablePackageId { fn from_str(s: &str) -> CargoResult { let regex = Regex::new(r"^([^ ]+) ([^ ]+)(?: \(([^\)]+)\))?$").unwrap(); - let captures = try!(regex.captures(s).ok_or_else(|| { + let captures = regex.captures(s).ok_or_else(|| { internal("invalid serialized PackageId") - })); + })?; let name = captures.at(1).unwrap(); let version = captures.at(2).unwrap(); let source_id = match captures.at(3) { - Some(s) => Some(try!(SourceId::from_url(s))), + Some(s) => Some(SourceId::from_url(s)?), None => None, }; diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 9cc723d69dc..b67e32d56dc 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -226,10 +226,10 @@ unable to verify that `{0}` is the same as when the lockfile was generated impl fmt::Debug for Resolve { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(write!(fmt, "graph: {:?}\n", self.graph)); - try!(write!(fmt, "\nfeatures: {{\n")); + write!(fmt, "graph: {:?}\n", self.graph)?; + write!(fmt, "\nfeatures: {{\n")?; for (pkg, features) in &self.features { - try!(write!(fmt, " {}: {:?}\n", pkg, features)); + write!(fmt, " {}: {:?}\n", pkg, features)?; } write!(fmt, "}}") } @@ -274,7 +274,7 @@ pub fn resolve(summaries: &[(Summary, Method)], replacements: replacements, }; let _p = profile::start(format!("resolving")); - let cx = try!(activate_deps_loop(cx, registry, summaries)); + let cx = activate_deps_loop(cx, registry, summaries)?; let mut resolve = Resolve { graph: cx.resolve_graph, @@ -289,7 +289,7 @@ pub fn resolve(summaries: &[(Summary, Method)], resolve.checksums.insert(summary.package_id().clone(), cksum); } - try!(check_cycles(&resolve, &cx.activations)); + check_cycles(&resolve, &cx.activations)?; trace!("resolved: {:?}", resolve); Ok(resolve) @@ -333,7 +333,7 @@ fn activate(cx: &mut Context, } }; - let deps = try!(cx.build_deps(registry, &candidate, method)); + let deps = cx.build_deps(registry, &candidate, method)?; Ok(Some(DepsFrame { parent: candidate, @@ -450,8 +450,8 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, debug!("initial activation: {}", summary.package_id()); let summary = Rc::new(summary.clone()); let candidate = Candidate { summary: summary, replace: None }; - remaining_deps.extend(try!(activate(&mut cx, registry, None, candidate, - method))); + remaining_deps.extend(activate(&mut cx, registry, None, candidate, + method)?); } // Main resolution loop, this is the workhorse of the resolution algorithm. @@ -558,8 +558,8 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, }; trace!("{}[{}]>{} trying {}", parent.name(), cur, dep.name(), candidate.summary.version()); - remaining_deps.extend(try!(activate(&mut cx, registry, Some(&parent), - candidate, &method))); + remaining_deps.extend(activate(&mut cx, registry, Some(&parent), + candidate, &method)?); } Ok(cx) @@ -709,16 +709,16 @@ fn build_features(s: &Summary, method: &Method) match *method { Method::Everything => { for key in s.features().keys() { - try!(add_feature(s, key, &mut deps, &mut used, &mut visited)); + add_feature(s, key, &mut deps, &mut used, &mut visited)?; } for dep in s.dependencies().iter().filter(|d| d.is_optional()) { - try!(add_feature(s, dep.name(), &mut deps, &mut used, - &mut visited)); + add_feature(s, dep.name(), &mut deps, &mut used, + &mut visited)?; } } Method::Required { features: requested_features, .. } => { for feat in requested_features.iter() { - try!(add_feature(s, feat, &mut deps, &mut used, &mut visited)); + add_feature(s, feat, &mut deps, &mut used, &mut visited)?; } } } @@ -726,8 +726,8 @@ fn build_features(s: &Summary, method: &Method) Method::Everything | Method::Required { uses_default_features: true, .. } => { if s.features().get("default").is_some() { - try!(add_feature(s, "default", &mut deps, &mut used, - &mut visited)); + add_feature(s, "default", &mut deps, &mut used, + &mut visited)?; } } Method::Required { uses_default_features: false, .. } => {} @@ -765,7 +765,7 @@ fn build_features(s: &Summary, method: &Method) match s.features().get(feat) { Some(recursive) => { for f in recursive { - try!(add_feature(s, f, deps, used, visited)); + add_feature(s, f, deps, used, visited)?; } } None => { @@ -820,19 +820,19 @@ impl<'a> Context<'a> { // First, figure out our set of dependencies based on the requsted set // of features. This also calculates what features we're going to enable // for our own dependencies. - let deps = try!(self.resolve_features(candidate, method)); + let deps = self.resolve_features(candidate, method)?; // Next, transform all dependencies into a list of possible candidates // which can satisfy that dependency. - let mut deps = try!(deps.into_iter().map(|(dep, features)| { - let mut candidates = try!(self.query(registry, &dep)); + let mut deps = deps.into_iter().map(|(dep, features)| { + let mut candidates = self.query(registry, &dep)?; // When we attempt versions for a package, we'll want to start at // the maximum version and work our way down. candidates.sort_by(|a, b| { b.summary.version().cmp(a.summary.version()) }); Ok((dep, candidates, features)) - }).collect::>>()); + }).collect::>>()?; // Attempt to resolve dependencies with fewer candidates before trying // dependencies with more candidates. This way if the dependency with @@ -852,7 +852,7 @@ impl<'a> Context<'a> { fn query(&self, registry: &mut Registry, dep: &Dependency) -> CargoResult> { - let summaries = try!(registry.query(dep)); + let summaries = registry.query(dep)?; summaries.into_iter().map(Rc::new).map(|summary| { // get around lack of non-lexical lifetimes let summary2 = summary.clone(); @@ -866,13 +866,13 @@ impl<'a> Context<'a> { }; debug!("found an override for {} {}", dep.name(), dep.version_req()); - let mut summaries = try!(registry.query(dep)).into_iter(); - let s = try!(summaries.next().chain_error(|| { + let mut summaries = registry.query(dep)?.into_iter(); + let s = summaries.next().chain_error(|| { human(format!("no matching package for override `{}` found\n\ location searched: {}\n\ version required: {}", spec, dep.source_id(), dep.version_req())) - })); + })?; let summaries = summaries.collect::>(); if summaries.len() > 0 { let bullets = summaries.iter().map(|s| { @@ -928,8 +928,8 @@ impl<'a> Context<'a> { let deps = candidate.dependencies(); let deps = deps.iter().filter(|d| d.is_transitive() || dev_deps); - let (mut feature_deps, used_features) = try!(build_features(candidate, - method)); + let (mut feature_deps, used_features) = build_features(candidate, + method)?; let mut ret = Vec::new(); // Next, sanitize all requested features by whitelisting all the @@ -988,11 +988,11 @@ fn check_cycles(resolve: &Resolve, let mut checked = HashSet::new(); for pkg in all_packages { if !checked.contains(pkg) { - try!(visit(resolve, + visit(resolve, pkg, &summaries, &mut HashSet::new(), - &mut checked)) + &mut checked)? } } return Ok(()); @@ -1024,7 +1024,7 @@ fn check_cycles(resolve: &Resolve, }); let mut empty = HashSet::new(); let visited = if is_transitive {&mut *visited} else {&mut empty}; - try!(visit(resolve, dep, summaries, visited, checked)); + visit(resolve, dep, summaries, visited, checked)?; } } diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index b7996a36a1e..a2830787467 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -163,7 +163,7 @@ impl Shell { fn get_term(out: Box) -> CargoResult { // Check if the creation of a console will succeed if ::term::WinConsole::new(vec![0u8; 0]).is_ok() { - let t = try!(::term::WinConsole::new(out)); + let t = ::term::WinConsole::new(out)?; if !t.supports_color() { Ok(NoColor(Box::new(t))) } else { @@ -206,11 +206,11 @@ impl Shell { } pub fn say(&mut self, message: T, color: Color) -> CargoResult<()> { - try!(self.reset()); - if color != BLACK { try!(self.fg(color)); } - try!(write!(self, "{}\n", message.to_string())); - try!(self.reset()); - try!(self.flush()); + self.reset()?; + if color != BLACK { self.fg(color)?; } + write!(self, "{}\n", message.to_string())?; + self.reset()?; + self.flush()?; Ok(()) } @@ -222,17 +222,17 @@ impl Shell { -> CargoResult<()> where T: fmt::Display, U: fmt::Display { - try!(self.reset()); - if color != BLACK { try!(self.fg(color)); } - if self.supports_attr(Attr::Bold) { try!(self.attr(Attr::Bold)); } + self.reset()?; + if color != BLACK { self.fg(color)?; } + if self.supports_attr(Attr::Bold) { self.attr(Attr::Bold)?; } if justified { - try!(write!(self, "{:>12}", status.to_string())); + write!(self, "{:>12}", status.to_string())?; } else { - try!(write!(self, "{}", status)); + write!(self, "{}", status)?; } - try!(self.reset()); - try!(write!(self, " {}\n", message)); - try!(self.flush()); + self.reset()?; + write!(self, " {}\n", message)?; + self.flush()?; Ok(()) } @@ -240,7 +240,7 @@ impl Shell { let colored = self.colored(); match self.terminal { - Colored(ref mut c) if colored => try!(c.fg(color)), + Colored(ref mut c) if colored => c.fg(color)?, _ => return Ok(false), } Ok(true) @@ -250,7 +250,7 @@ impl Shell { let colored = self.colored(); match self.terminal { - Colored(ref mut c) if colored => try!(c.attr(attr)), + Colored(ref mut c) if colored => c.attr(attr)?, _ => return Ok(false) } Ok(true) @@ -269,7 +269,7 @@ impl Shell { let colored = self.colored(); match self.terminal { - Colored(ref mut c) if colored => try!(c.reset()), + Colored(ref mut c) if colored => c.reset()?, _ => () } Ok(()) diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 4a46c19294d..91d2acff789 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -131,11 +131,11 @@ impl SourceId { pub fn from_url(string: &str) -> CargoResult { let mut parts = string.splitn(2, '+'); let kind = parts.next().unwrap(); - let url = try!(parts.next().ok_or(human(format!("invalid source `{}`", string)))); + let url = parts.next().ok_or(human(format!("invalid source `{}`", string)))?; match kind { "git" => { - let mut url = try!(url.to_url()); + let mut url = url.to_url()?; let mut reference = GitReference::Branch("master".to_string()); for (k, v) in url.query_pairs() { match &k[..] { @@ -154,12 +154,12 @@ impl SourceId { Ok(SourceId::for_git(&url, reference).with_precise(precise)) }, "registry" => { - let url = try!(url.to_url()); + let url = url.to_url()?; Ok(SourceId::new(Kind::Registry, url) .with_precise(Some("locked".to_string()))) } "path" => { - let url = try!(url.to_url()); + let url = url.to_url()?; Ok(SourceId::new(Kind::Path, url)) } kind => Err(human(format!("unsupported source protocol: {}", kind))) @@ -198,7 +198,7 @@ impl SourceId { // Pass absolute path pub fn for_path(path: &Path) -> CargoResult { - let url = try!(path.to_url()); + let url = path.to_url()?; Ok(SourceId::new(Kind::Path, url)) } @@ -211,12 +211,12 @@ impl SourceId { } pub fn for_local_registry(path: &Path) -> CargoResult { - let url = try!(path.to_url()); + let url = path.to_url()?; Ok(SourceId::new(Kind::LocalRegistry, url)) } pub fn for_directory(path: &Path) -> CargoResult { - let url = try!(path.to_url()); + let url = path.to_url()?; Ok(SourceId::new(Kind::Directory, url)) } @@ -225,20 +225,20 @@ impl SourceId { /// This is the main cargo registry by default, but it can be overridden in /// a `.cargo/config`. pub fn crates_io(config: &Config) -> CargoResult { - let cfg = try!(ops::registry_configuration(config)); + let cfg = ops::registry_configuration(config)?; let url = if let Some(ref index) = cfg.index { static WARNED: AtomicBool = ATOMIC_BOOL_INIT; if !WARNED.swap(true, SeqCst) { - try!(config.shell().warn("custom registry support via \ + config.shell().warn("custom registry support via \ the `registry.index` configuration is \ being removed, this functionality \ - will not work in the future")); + will not work in the future")?; } &index[..] } else { CRATES_IO }; - let url = try!(url.to_url()); + let url = url.to_url()?; Ok(SourceId::for_registry(&url)) } @@ -348,7 +348,7 @@ impl Encodable for SourceId { impl Decodable for SourceId { fn decode(d: &mut D) -> Result { - let string: String = try!(Decodable::decode(d)); + let string: String = Decodable::decode(d)?; SourceId::from_url(&string).map_err(|e| { d.error(&e.to_string()) }) @@ -363,11 +363,11 @@ impl fmt::Display for SourceId { } SourceIdInner { kind: Kind::Git(ref reference), ref url, ref precise, .. } => { - try!(write!(f, "{}{}", url, reference.url_ref())); + write!(f, "{}{}", url, reference.url_ref())?; if let Some(ref s) = *precise { let len = cmp::min(s.len(), 8); - try!(write!(f, "#{}", &s[..len])); + write!(f, "#{}", &s[..len])?; } Ok(()) } diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 65f1537647c..95b2cd67fdb 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -82,7 +82,7 @@ impl<'cfg> Workspace<'cfg> { /// before returning it, so `Ok` is only returned for valid workspaces. pub fn new(manifest_path: &Path, config: &'cfg Config) -> CargoResult> { - let target_dir = try!(config.target_dir()); + let target_dir = config.target_dir()?; let mut ws = Workspace { config: config, @@ -95,9 +95,9 @@ impl<'cfg> Workspace<'cfg> { target_dir: target_dir, members: Vec::new(), }; - ws.root_manifest = try!(ws.find_root(manifest_path)); - try!(ws.find_members()); - try!(ws.validate()); + ws.root_manifest = ws.find_root(manifest_path)?; + ws.find_members()?; + ws.validate()?; Ok(ws) } @@ -130,7 +130,7 @@ impl<'cfg> Workspace<'cfg> { ws.target_dir = if let Some(dir) = target_dir { Some(dir) } else { - try!(ws.config.target_dir()) + ws.config.target_dir()? }; ws.members.push(ws.current_manifest.clone()); } @@ -221,7 +221,7 @@ impl<'cfg> Workspace<'cfg> { fn find_root(&mut self, manifest_path: &Path) -> CargoResult> { { - let current = try!(self.packages.load(&manifest_path)); + let current = self.packages.load(&manifest_path)?; match *current.workspace_config() { WorkspaceConfig::Root { .. } => { debug!("find_root - is root {}", manifest_path.display()); @@ -274,7 +274,7 @@ impl<'cfg> Workspace<'cfg> { } }; let members = { - let root = try!(self.packages.load(&root_manifest)); + let root = self.packages.load(&root_manifest)?; match *root.workspace_config() { WorkspaceConfig::Root { ref members } => members.clone(), _ => bail!("root of a workspace inferred but wasn't a root: {}", @@ -286,7 +286,7 @@ impl<'cfg> Workspace<'cfg> { let root = root_manifest.parent().unwrap(); for path in list { let manifest_path = root.join(path).join("Cargo.toml"); - try!(self.find_path_deps(&manifest_path)); + self.find_path_deps(&manifest_path)?; } } @@ -302,7 +302,7 @@ impl<'cfg> Workspace<'cfg> { self.members.push(manifest_path.to_path_buf()); let candidates = { - let pkg = match *try!(self.packages.load(manifest_path)) { + let pkg = match *self.packages.load(manifest_path)? { MaybePackage::Package(ref p) => p, MaybePackage::Virtual(_) => return Ok(()), }; @@ -315,7 +315,7 @@ impl<'cfg> Workspace<'cfg> { .collect::>() }; for candidate in candidates { - try!(self.find_path_deps(&candidate)); + self.find_path_deps(&candidate)?; } Ok(()) } @@ -373,7 +373,7 @@ impl<'cfg> Workspace<'cfg> { } for member in self.members.clone() { - let root = try!(self.find_root(&member)); + let root = self.find_root(&member)?; if root == self.root_manifest { continue } @@ -462,7 +462,7 @@ impl<'cfg> Workspace<'cfg> { root_manifest.display()); //TODO: remove `Eq` bound from `Profiles` when the warning is removed. - try!(self.config.shell().warn(&message)); + self.config.shell().warn(&message)?; } } } @@ -481,9 +481,9 @@ impl<'cfg> Packages<'cfg> { match self.packages.entry(key.to_path_buf()) { Entry::Occupied(e) => Ok(e.into_mut()), Entry::Vacant(v) => { - let source_id = try!(SourceId::for_path(key)); - let pair = try!(ops::read_manifest(&manifest_path, &source_id, - self.config)); + let source_id = SourceId::for_path(key)?; + let pair = ops::read_manifest(&manifest_path, &source_id, + self.config)?; let (manifest, _nested_paths) = pair; Ok(v.insert(match manifest { EitherManifest::Real(manifest) => { diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index d1a8f908866..33098ee1749 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -67,7 +67,7 @@ pub fn call_main_without_stdin( options_first: bool) -> CliResult> where V: Encodable, T: Decodable { - let flags = try!(flags_from_args::(usage, args, options_first)); + let flags = flags_from_args::(usage, args, options_first)?; exec(flags, config) } @@ -77,7 +77,7 @@ fn process(mut callback: F) { let mut config = None; let result = (|| { - config = Some(try!(Config::default())); + config = Some(Config::default()?); let args: Vec<_> = try!(env::args_os().map(|s| { s.into_string().map_err(|s| { human(format!("invalid unicode in argument: {:?}", s)) diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 6d544c19be2..4f6e6cf0353 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -28,26 +28,26 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { return rm_rf(&target_dir); } - let mut registry = try!(PackageRegistry::new(opts.config)); - let resolve = try!(ops::resolve_ws(&mut registry, ws)); + let mut registry = PackageRegistry::new(opts.config)?; + let resolve = ops::resolve_ws(&mut registry, ws)?; let packages = ops::get_resolved_packages(&resolve, registry); let profiles = ws.profiles(); - let host_triple = try!(opts.config.rustc()).host.clone(); - let mut cx = try!(Context::new(ws, &resolve, &packages, opts.config, + let host_triple = opts.config.rustc()?.host.clone(); + let mut cx = Context::new(ws, &resolve, &packages, opts.config, BuildConfig { host_triple: host_triple, requested_target: opts.target.map(|s| s.to_owned()), release: opts.release, ..BuildConfig::default() }, - profiles)); + profiles)?; let mut units = Vec::new(); for spec in opts.spec { // Translate the spec to a Package - let pkgid = try!(resolve.query(spec)); - let pkg = try!(packages.get(&pkgid)); + let pkgid = resolve.query(spec)?; + let pkg = packages.get(&pkgid)?; // Generate all relevant `Unit` targets for this package for target in pkg.targets() { @@ -70,16 +70,16 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { } } - try!(cx.probe_target_info(&units)); + cx.probe_target_info(&units)?; for unit in units.iter() { let layout = cx.layout(unit); - try!(rm_rf(&layout.proxy().fingerprint(&unit.pkg))); - try!(rm_rf(&layout.build(&unit.pkg))); + rm_rf(&layout.proxy().fingerprint(&unit.pkg))?; + rm_rf(&layout.build(&unit.pkg))?; let root = cx.out_dir(&unit); - for (filename, _) in try!(cx.target_filenames(&unit)) { - try!(rm_rf(&root.join(&filename))); + for (filename, _) in cx.target_filenames(&unit)? { + rm_rf(&root.join(&filename))?; } } @@ -89,13 +89,13 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { fn rm_rf(path: &Path) -> CargoResult<()> { let m = fs::metadata(path); if m.as_ref().map(|s| s.is_dir()).unwrap_or(false) { - try!(fs::remove_dir_all(path).chain_error(|| { + fs::remove_dir_all(path).chain_error(|| { human("could not remove build directory") - })); + })?; } else if m.is_ok() { - try!(fs::remove_file(path).chain_error(|| { + fs::remove_file(path).chain_error(|| { human("failed to remove build artifact") - })); + })?; } Ok(()) } diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 4c385c8d169..a8ebb30e2c8 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -92,8 +92,8 @@ pub enum CompileFilter<'a> { pub fn compile<'a>(ws: &Workspace<'a>, options: &CompileOptions<'a>) -> CargoResult> { - for key in try!(ws.current()).manifest().warnings().iter() { - try!(options.config.shell().warn(key)) + for key in ws.current()?.manifest().warnings().iter() { + options.config.shell().warn(key)? } compile_ws(ws, None, options) } @@ -109,23 +109,23 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, s.split_whitespace() }).map(|s| s.to_string()).collect::>(); - let mut registry = try!(PackageRegistry::new(ws.config())); + let mut registry = PackageRegistry::new(ws.config())?; if let Some(source) = source { - registry.add_preloaded(try!(ws.current()).package_id().source_id(), + registry.add_preloaded(ws.current()?.package_id().source_id(), source); } // First, resolve the root_package's *listed* dependencies, as well as // downloading and updating all remotes and such. - let resolve = try!(ops::resolve_ws(&mut registry, ws)); + let resolve = ops::resolve_ws(&mut registry, ws)?; // Second, resolve with precisely what we're doing. Filter out // transitive dependencies if necessary, specify features, handle // overrides, etc. let _p = profile::start("resolving w/ overrides..."); - try!(add_overrides(&mut registry, ws)); + add_overrides(&mut registry, ws)?; let method = if all_features { Method::Everything @@ -138,9 +138,9 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, }; let resolved_with_overrides = - try!(ops::resolve_with_previous(&mut registry, ws, + ops::resolve_with_previous(&mut registry, ws, method, Some(&resolve), None, - specs)); + specs)?; let packages = ops::get_resolved_packages(&resolved_with_overrides, registry); @@ -152,7 +152,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, source: Option>, options: &CompileOptions<'a>) -> CargoResult> { - let root_package = try!(ws.current()); + let root_package = ws.current()?; let CompileOptions { config, jobs, target, spec, features, all_features, no_default_features, release, mode, message_format, @@ -168,32 +168,32 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let profiles = ws.profiles(); if spec.len() == 0 { - try!(generate_targets(root_package, profiles, mode, filter, release)); + generate_targets(root_package, profiles, mode, filter, release)?; } - let specs = try!(spec.iter().map(|p| PackageIdSpec::parse(p)) - .collect::>>()); + let specs = spec.iter().map(|p| PackageIdSpec::parse(p)) + .collect::>>()?; - let pair = try!(resolve_dependencies(ws, + let pair = resolve_dependencies(ws, source, features, all_features, no_default_features, - &specs)); + &specs)?; let (packages, resolve_with_overrides) = pair; let mut pkgids = Vec::new(); if spec.len() > 0 { for p in spec { - pkgids.push(try!(resolve_with_overrides.query(&p))); + pkgids.push(resolve_with_overrides.query(&p)?); } } else { pkgids.push(root_package.package_id()); }; - let to_builds = try!(pkgids.iter().map(|id| { + let to_builds = pkgids.iter().map(|id| { packages.get(id) - }).collect::>>()); + }).collect::>>()?; let mut general_targets = Vec::new(); let mut package_targets = Vec::new(); @@ -204,8 +204,8 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, panic!("`rustc` and `rustdoc` should not accept multiple `-p` flags") } (Some(args), _) => { - let targets = try!(generate_targets(to_builds[0], profiles, - mode, filter, release)); + let targets = generate_targets(to_builds[0], profiles, + mode, filter, release)?; if targets.len() == 1 { let (target, profile) = targets[0]; let mut profile = profile.clone(); @@ -218,8 +218,8 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, } } (None, Some(args)) => { - let targets = try!(generate_targets(to_builds[0], profiles, - mode, filter, release)); + let targets = generate_targets(to_builds[0], profiles, + mode, filter, release)?; if targets.len() == 1 { let (target, profile) = targets[0]; let mut profile = profile.clone(); @@ -233,8 +233,8 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, } (None, None) => { for &to_build in to_builds.iter() { - let targets = try!(generate_targets(to_build, profiles, mode, - filter, release)); + let targets = generate_targets(to_build, profiles, mode, + filter, release)?; package_targets.push((to_build, targets)); } } @@ -248,7 +248,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let mut ret = { let _p = profile::start("compiling"); - let mut build_config = try!(scrape_build_config(config, jobs, target)); + let mut build_config = scrape_build_config(config, jobs, target)?; build_config.release = release; build_config.test = mode == CompileMode::Test || mode == CompileMode::Bench; build_config.json_errors = message_format == MessageFormat::Json; @@ -256,13 +256,13 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, build_config.doc_all = deps; } - try!(ops::compile_targets(ws, + ops::compile_targets(ws, &package_targets, &packages, &resolve_with_overrides, config, build_config, - profiles)) + profiles)? }; ret.to_doc_test = to_builds.iter().map(|&p| p.clone()).collect(); @@ -397,10 +397,10 @@ fn generate_targets<'a>(pkg: &'a Package, } Ok(()) }; - try!(find(bins, "bin", TargetKind::Bin, profile)); - try!(find(examples, "example", TargetKind::Example, build)); - try!(find(tests, "test", TargetKind::Test, test)); - try!(find(benches, "bench", TargetKind::Bench, &profiles.bench)); + find(bins, "bin", TargetKind::Bin, profile)?; + find(examples, "example", TargetKind::Example, build)?; + find(tests, "test", TargetKind::Test, test)?; + find(benches, "bench", TargetKind::Bench, &profiles.bench)?; } Ok(targets) } @@ -411,7 +411,7 @@ fn generate_targets<'a>(pkg: &'a Package, /// have been configured. fn add_overrides<'a>(registry: &mut PackageRegistry<'a>, ws: &Workspace<'a>) -> CargoResult<()> { - let paths = match try!(ws.config().get_list("paths")) { + let paths = match ws.config().get_list("paths")? { Some(list) => list, None => return Ok(()) }; @@ -424,13 +424,13 @@ fn add_overrides<'a>(registry: &mut PackageRegistry<'a>, }); for (path, definition) in paths { - let id = try!(SourceId::for_path(&path)); + let id = SourceId::for_path(&path)?; let mut source = PathSource::new_recursive(&path, &id, ws.config()); - try!(source.update().chain_error(|| { + source.update().chain_error(|| { human(format!("failed to update path override `{}` \ (defined in `{}`)", path.display(), definition.display())) - })); + })?; registry.add_override(&id, Box::new(source)); } Ok(()) @@ -448,7 +448,7 @@ fn scrape_build_config(config: &Config, jobs: Option, target: Option) -> CargoResult { - let cfg_jobs = match try!(config.get_i64("build.jobs")) { + let cfg_jobs = match config.get_i64("build.jobs")? { Some(v) => { if v.val <= 0 { bail!("build.jobs must be positive, but found {} in {}", @@ -463,17 +463,17 @@ fn scrape_build_config(config: &Config, None => None, }; let jobs = jobs.or(cfg_jobs).unwrap_or(::num_cpus::get() as u32); - let cfg_target = try!(config.get_string("build.target")).map(|s| s.val); + let cfg_target = config.get_string("build.target")?.map(|s| s.val); let target = target.or(cfg_target); let mut base = ops::BuildConfig { - host_triple: try!(config.rustc()).host.clone(), + host_triple: config.rustc()?.host.clone(), requested_target: target.clone(), jobs: jobs, ..Default::default() }; - base.host = try!(scrape_target_config(config, &base.host_triple)); + base.host = scrape_target_config(config, &base.host_triple)?; base.target = match target.as_ref() { - Some(triple) => try!(scrape_target_config(config, &triple)), + Some(triple) => scrape_target_config(config, &triple)?, None => base.host.clone(), }; Ok(base) @@ -484,11 +484,11 @@ fn scrape_target_config(config: &Config, triple: &str) let key = format!("target.{}", triple); let mut ret = ops::TargetConfig { - ar: try!(config.get_path(&format!("{}.ar", key))).map(|v| v.val), - linker: try!(config.get_path(&format!("{}.linker", key))).map(|v| v.val), + ar: config.get_path(&format!("{}.ar", key))?.map(|v| v.val), + linker: config.get_path(&format!("{}.linker", key))?.map(|v| v.val), overrides: HashMap::new(), }; - let table = match try!(config.get_table(&key)) { + let table = match config.get_table(&key)? { Some(table) => table.val, None => return Ok(ret), }; @@ -505,36 +505,36 @@ fn scrape_target_config(config: &Config, triple: &str) rerun_if_changed: Vec::new(), warnings: Vec::new(), }; - for (k, value) in try!(value.table(&lib_name)).0 { + for (k, value) in value.table(&lib_name)?.0 { let key = format!("{}.{}", key, k); match &k[..] { "rustc-flags" => { - let (flags, definition) = try!(value.string(&k)); + let (flags, definition) = value.string(&k)?; let whence = format!("in `{}` (in {})", key, definition.display()); - let (paths, links) = try!( + let (paths, links) = BuildOutput::parse_rustc_flags(&flags, &whence) - ); + ?; output.library_paths.extend(paths); output.library_links.extend(links); } "rustc-link-lib" => { - let list = try!(value.list(&k)); + let list = value.list(&k)?; output.library_links.extend(list.iter() .map(|v| v.0.clone())); } "rustc-link-search" => { - let list = try!(value.list(&k)); + let list = value.list(&k)?; output.library_paths.extend(list.iter().map(|v| { PathBuf::from(&v.0) })); } "rustc-cfg" => { - let list = try!(value.list(&k)); + let list = value.list(&k)?; output.cfgs.extend(list.iter().map(|v| v.0.clone())); } _ => { - let val = try!(value.string(&k)).0; + let val = value.string(&k)?.0; output.metadata.push((k.clone(), val.to_string())); } } diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index d9afaed03a9..8c27335745e 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -13,7 +13,7 @@ pub struct DocOptions<'a> { } pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { - let package = try!(ws.current()); + let package = ws.current()?; let mut lib_names = HashSet::new(); let mut bin_names = HashSet::new(); @@ -34,13 +34,13 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { } } - try!(ops::compile(ws, &options.compile_opts)); + ops::compile(ws, &options.compile_opts)?; if options.open_result { let name = if options.compile_opts.spec.len() > 1 { bail!("Passing multiple packages and `open` is not supported") } else if options.compile_opts.spec.len() == 1 { - try!(PackageIdSpec::parse(&options.compile_opts.spec[0])) + PackageIdSpec::parse(&options.compile_opts.spec[0])? .name() .replace("-", "_") } else { @@ -62,12 +62,12 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { if fs::metadata(&path).is_ok() { let mut shell = options.compile_opts.config.shell(); match open_docs(&path) { - Ok(m) => try!(shell.status("Launching", m)), + Ok(m) => shell.status("Launching", m)?, Err(e) => { - try!(shell.warn( - "warning: could not determine a browser to open docs with, tried:")); + shell.warn( + "warning: could not determine a browser to open docs with, tried:")?; for method in e { - try!(shell.warn(format!("\t{}", method))); + shell.warn(format!("\t{}", method))?; } } } diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index a0144c8f472..1c30b0b7e8b 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -5,11 +5,11 @@ use util::CargoResult; /// Executes `cargo fetch`. pub fn fetch<'a>(ws: &Workspace<'a>) -> CargoResult<(Resolve, PackageSet<'a>)> { - let mut registry = try!(PackageRegistry::new(ws.config())); - let resolve = try!(ops::resolve_ws(&mut registry, ws)); + let mut registry = PackageRegistry::new(ws.config())?; + let resolve = ops::resolve_ws(&mut registry, ws)?; let packages = get_resolved_packages(&resolve, registry); for id in resolve.iter() { - try!(packages.get(id)); + packages.get(id)?; } Ok((resolve, packages)) } diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index 25e2204ba9e..c09ee67022f 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -16,11 +16,11 @@ pub struct UpdateOptions<'a> { } pub fn generate_lockfile(ws: &Workspace) -> CargoResult<()> { - let mut registry = try!(PackageRegistry::new(ws.config())); - let resolve = try!(ops::resolve_with_previous(&mut registry, ws, + let mut registry = PackageRegistry::new(ws.config())?; + let resolve = ops::resolve_with_previous(&mut registry, ws, Method::Everything, - None, None, &[])); - try!(ops::write_pkg_lockfile(ws, &resolve)); + None, None, &[])?; + ops::write_pkg_lockfile(ws, &resolve)?; Ok(()) } @@ -35,11 +35,11 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) bail!("you can't generate a lockfile for an empty workspace.") } - let previous_resolve = match try!(ops::load_pkg_lockfile(ws)) { + let previous_resolve = match ops::load_pkg_lockfile(ws)? { Some(resolve) => resolve, None => return generate_lockfile(ws), }; - let mut registry = try!(PackageRegistry::new(opts.config)); + let mut registry = PackageRegistry::new(opts.config)?; let mut to_avoid = HashSet::new(); if opts.to_update.is_empty() { @@ -47,7 +47,7 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) } else { let mut sources = Vec::new(); for name in opts.to_update { - let dep = try!(previous_resolve.query(name)); + let dep = previous_resolve.query(name)?; if opts.aggressive { fill_with_deps(&previous_resolve, dep, &mut to_avoid, &mut HashSet::new()); @@ -71,15 +71,15 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) }); } } - try!(registry.add_sources(&sources)); + registry.add_sources(&sources)?; } - let resolve = try!(ops::resolve_with_previous(&mut registry, + let resolve = ops::resolve_with_previous(&mut registry, ws, Method::Everything, Some(&previous_resolve), Some(&to_avoid), - &[])); + &[])?; // Summarize what is changing for the user. let print_change = |status: &str, msg: String| { @@ -93,18 +93,18 @@ pub fn update_lockfile(ws: &Workspace, opts: &UpdateOptions) } else { format!("{} -> v{}", removed[0], added[0].version()) }; - try!(print_change("Updating", msg)); + print_change("Updating", msg)?; } else { for package in removed.iter() { - try!(print_change("Removing", format!("{}", package))); + print_change("Removing", format!("{}", package))?; } for package in added.iter() { - try!(print_change("Adding", format!("{}", package))); + print_change("Adding", format!("{}", package))?; } } } - try!(ops::write_pkg_lockfile(&ws, &resolve)); + ops::write_pkg_lockfile(&ws, &resolve)?; return Ok(()); fn fill_with_deps<'a>(resolve: &'a Resolve, dep: &'a PackageId, diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 93ceb40409a..b9a5aa85b06 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -53,29 +53,29 @@ pub fn install(root: Option<&str>, opts: &ops::CompileOptions, force: bool) -> CargoResult<()> { let config = opts.config; - let root = try!(resolve_root(root, config)); - let map = try!(SourceConfigMap::new(config)); + let root = resolve_root(root, config)?; + let map = SourceConfigMap::new(config)?; let (pkg, source) = if source_id.is_git() { - try!(select_pkg(GitSource::new(source_id, config), source_id, - krate, vers, &mut |git| git.read_packages())) + select_pkg(GitSource::new(source_id, config), source_id, + krate, vers, &mut |git| git.read_packages())? } else if source_id.is_path() { let path = source_id.url().to_file_path().ok() .expect("path sources must have a valid path"); let mut src = PathSource::new(&path, source_id, config); - try!(src.update().chain_error(|| { + src.update().chain_error(|| { human(format!("`{}` is not a crate root; specify a crate to \ install from crates.io, or use --path or --git to \ specify an alternate source", path.display())) - })); - try!(select_pkg(PathSource::new(&path, source_id, config), + })?; + select_pkg(PathSource::new(&path, source_id, config), source_id, krate, vers, - &mut |path| path.read_packages())) + &mut |path| path.read_packages())? } else { - try!(select_pkg(try!(map.load(source_id)), + select_pkg(map.load(source_id)?, source_id, krate, vers, &mut |_| Err(human("must specify a crate to install from \ crates.io, or use --path or --git to \ - specify alternate source")))) + specify alternate source")))? }; @@ -91,22 +91,22 @@ pub fn install(root: Option<&str>, }; let ws = match overidden_target_dir { - Some(dir) => try!(Workspace::one(pkg, config, Some(dir))), - None => try!(Workspace::new(pkg.manifest_path(), config)), + Some(dir) => Workspace::one(pkg, config, Some(dir))?, + None => Workspace::new(pkg.manifest_path(), config)?, }; - let pkg = try!(ws.current()); + let pkg = ws.current()?; // Preflight checks to check up front whether we'll overwrite something. // We have to check this again afterwards, but may as well avoid building // anything if we're gonna throw it away anyway. { - let metadata = try!(metadata(config, &root)); - let list = try!(read_crate_list(metadata.file())); + let metadata = metadata(config, &root)?; + let list = read_crate_list(metadata.file())?; let dst = metadata.parent().join("bin"); - try!(check_overwrites(&dst, pkg, &opts.filter, &list, force)); + check_overwrites(&dst, pkg, &opts.filter, &list, force)?; } - let compile = try!(ops::compile_ws(&ws, Some(source), opts).chain_error(|| { + let compile = ops::compile_ws(&ws, Some(source), opts).chain_error(|| { if let Some(td) = td_opt.take() { // preserve the temporary directory, so the user can inspect it td.into_path(); @@ -114,28 +114,28 @@ pub fn install(root: Option<&str>, human(format!("failed to compile `{}`, intermediate artifacts can be \ found at `{}`", pkg, ws.target_dir().display())) - })); - let binaries: Vec<(&str, &Path)> = try!(compile.binaries.iter().map(|bin| { + })?; + let binaries: Vec<(&str, &Path)> = compile.binaries.iter().map(|bin| { let name = bin.file_name().unwrap(); if let Some(s) = name.to_str() { Ok((s, bin.as_ref())) } else { bail!("Binary `{:?}` name can't be serialized into string", name) } - }).collect::>()); + }).collect::>()?; - let metadata = try!(metadata(config, &root)); - let mut list = try!(read_crate_list(metadata.file())); + let metadata = metadata(config, &root)?; + let mut list = read_crate_list(metadata.file())?; let dst = metadata.parent().join("bin"); - let duplicates = try!(check_overwrites(&dst, pkg, &opts.filter, - &list, force)); + let duplicates = check_overwrites(&dst, pkg, &opts.filter, + &list, force)?; - try!(fs::create_dir_all(&dst)); + fs::create_dir_all(&dst)?; // Copy all binaries to a temporary directory under `dst` first, catching // some failure modes (e.g. out of space) before touching the existing // binaries. This directory will get cleaned up via RAII. - let staging_dir = try!(TempDir::new_in(&dst, "cargo-install")); + let staging_dir = TempDir::new_in(&dst, "cargo-install")?; for &(bin, src) in binaries.iter() { let dst = staging_dir.path().join(bin); // Try to move if `target_dir` is transient. @@ -144,10 +144,10 @@ pub fn install(root: Option<&str>, continue } } - try!(fs::copy(src, &dst).chain_error(|| { + fs::copy(src, &dst).chain_error(|| { human(format!("failed to copy `{}` to `{}`", src.display(), dst.display())) - })); + })?; } let (to_replace, to_install): (Vec<&str>, Vec<&str>) = @@ -160,11 +160,11 @@ pub fn install(root: Option<&str>, for bin in to_install.iter() { let src = staging_dir.path().join(bin); let dst = dst.join(bin); - try!(config.shell().status("Installing", dst.display())); - try!(fs::rename(&src, &dst).chain_error(|| { + config.shell().status("Installing", dst.display())?; + fs::rename(&src, &dst).chain_error(|| { human(format!("failed to move `{}` to `{}`", src.display(), dst.display())) - })); + })?; installed.bins.push(dst); } @@ -176,11 +176,11 @@ pub fn install(root: Option<&str>, for &bin in to_replace.iter() { let src = staging_dir.path().join(bin); let dst = dst.join(bin); - try!(config.shell().status("Replacing", dst.display())); - try!(fs::rename(&src, &dst).chain_error(|| { + config.shell().status("Replacing", dst.display())?; + fs::rename(&src, &dst).chain_error(|| { human(format!("failed to move `{}` to `{}`", src.display(), dst.display())) - })); + })?; replaced_names.push(bin); } Ok(()) @@ -219,8 +219,8 @@ pub fn install(root: Option<&str>, match write_result { // Replacement error (if any) isn't actually caused by write error // but this seems to be the only way to show both. - Err(err) => try!(result.chain_error(|| err)), - Ok(_) => try!(result), + Err(err) => result.chain_error(|| err)?, + Ok(_) => result?, } // Reaching here means all actions have succeeded. Clean up. @@ -229,7 +229,7 @@ pub fn install(root: Option<&str>, // Don't bother grabbing a lock as we're going to blow it all away // anyway. let target_dir = ws.target_dir().into_path_unlocked(); - try!(fs::remove_dir_all(&target_dir)); + fs::remove_dir_all(&target_dir)?; } // Print a warning that if this directory isn't in PATH that they won't be @@ -241,9 +241,9 @@ pub fn install(root: Option<&str>, } } - try!(config.shell().warn(&format!("be sure to add `{}` to your PATH to be \ + config.shell().warn(&format!("be sure to add `{}` to your PATH to be \ able to run the installed binaries", - dst.display()))); + dst.display()))?; Ok(()) } @@ -255,14 +255,14 @@ fn select_pkg<'a, T>(mut source: T, -> CargoResult<(Package, Box)> where T: Source + 'a { - try!(source.update()); + source.update()?; match name { Some(name) => { - let dep = try!(Dependency::parse_no_deprecated(name, vers, source_id)); - let deps = try!(source.query(&dep)); + let dep = Dependency::parse_no_deprecated(name, vers, source_id)?; + let deps = source.query(&dep)?; match deps.iter().map(|p| p.package_id()).max() { Some(pkgid) => { - let pkg = try!(source.download(pkgid)); + let pkg = source.download(pkgid)?; Ok((pkg, Box::new(source))) } None => { @@ -274,17 +274,17 @@ fn select_pkg<'a, T>(mut source: T, } } None => { - let candidates = try!(list_all(&mut source)); + let candidates = list_all(&mut source)?; let binaries = candidates.iter().filter(|cand| { cand.targets().iter().filter(|t| t.is_bin()).count() > 0 }); let examples = candidates.iter().filter(|cand| { cand.targets().iter().filter(|t| t.is_example()).count() > 0 }); - let pkg = match try!(one(binaries, |v| multi_err("binaries", v))) { + let pkg = match one(binaries, |v| multi_err("binaries", v))? { Some(p) => p, None => { - match try!(one(examples, |v| multi_err("examples", v))) { + match one(examples, |v| multi_err("examples", v))? { Some(p) => p, None => bail!("no packages found with binaries or \ examples"), @@ -381,10 +381,10 @@ fn find_duplicates(dst: &Path, fn read_crate_list(mut file: &File) -> CargoResult { (|| -> CargoResult<_> { let mut contents = String::new(); - try!(file.read_to_string(&mut contents)); - let listing = try!(toml::decode_str(&contents).chain_error(|| { + file.read_to_string(&mut contents)?; + let listing = toml::decode_str(&contents).chain_error(|| { internal("invalid TOML found for metadata") - })); + })?; match listing { CrateListing::V1(v1) => Ok(v1), CrateListing::Empty => { @@ -398,10 +398,10 @@ fn read_crate_list(mut file: &File) -> CargoResult { fn write_crate_list(mut file: &File, listing: CrateListingV1) -> CargoResult<()> { (|| -> CargoResult<_> { - try!(file.seek(SeekFrom::Start(0))); - try!(file.set_len(0)); + file.seek(SeekFrom::Start(0))?; + file.set_len(0)?; let data = toml::encode_str::(&CrateListing::V1(listing)); - try!(file.write_all(data.as_bytes())); + file.write_all(data.as_bytes())?; Ok(()) }).chain_error(|| { human("failed to write crate metadata") @@ -409,15 +409,15 @@ fn write_crate_list(mut file: &File, listing: CrateListingV1) -> CargoResult<()> } pub fn install_list(dst: Option<&str>, config: &Config) -> CargoResult<()> { - let dst = try!(resolve_root(dst, config)); - let dst = try!(metadata(config, &dst)); - let list = try!(read_crate_list(dst.file())); + let dst = resolve_root(dst, config)?; + let dst = metadata(config, &dst)?; + let list = read_crate_list(dst.file())?; let mut shell = config.shell(); let out = shell.out(); for (k, v) in list.v1.iter() { - try!(writeln!(out, "{}:", k)); + writeln!(out, "{}:", k)?; for bin in v { - try!(writeln!(out, " {}", bin)); + writeln!(out, " {}", bin)?; } } Ok(()) @@ -427,12 +427,12 @@ pub fn uninstall(root: Option<&str>, spec: &str, bins: &[String], config: &Config) -> CargoResult<()> { - let root = try!(resolve_root(root, config)); - let crate_metadata = try!(metadata(config, &root)); - let mut metadata = try!(read_crate_list(crate_metadata.file())); + let root = resolve_root(root, config)?; + let crate_metadata = metadata(config, &root)?; + let mut metadata = read_crate_list(crate_metadata.file())?; let mut to_remove = Vec::new(); { - let result = try!(PackageIdSpec::query_str(spec, metadata.v1.keys())) + let result = PackageIdSpec::query_str(spec, metadata.v1.keys())? .clone(); let mut installed = match metadata.v1.entry(result.clone()) { Entry::Occupied(e) => e, @@ -474,10 +474,10 @@ pub fn uninstall(root: Option<&str>, installed.remove(); } } - try!(write_crate_list(crate_metadata.file(), metadata)); + write_crate_list(crate_metadata.file(), metadata)?; for bin in to_remove { - try!(config.shell().status("Removing", bin.display())); - try!(fs::remove_file(bin)); + config.shell().status("Removing", bin.display())?; + fs::remove_file(bin)?; } Ok(()) @@ -489,7 +489,7 @@ fn metadata(config: &Config, root: &Filesystem) -> CargoResult { fn resolve_root(flag: Option<&str>, config: &Config) -> CargoResult { - let config_root = try!(config.get_path("install.root")); + let config_root = config.get_path("install.root")?; Ok(flag.map(PathBuf::from).or_else(|| { env::var_os("CARGO_INSTALL_ROOT").map(PathBuf::from) }).or_else(move || { diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index fe00a74d989..6b41f3ed5d3 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -42,7 +42,7 @@ struct MkOptions<'a> { impl Decodable for VersionControl { fn decode(d: &mut D) -> Result { - Ok(match &try!(d.read_str())[..] { + Ok(match &d.read_str()?[..] { "git" => VersionControl::Git, "hg" => VersionControl::Hg, "none" => VersionControl::NoVcs, @@ -95,10 +95,10 @@ fn get_name<'a>(path: &'a Path, opts: &'a NewOptions, config: &Config) -> CargoR path.as_os_str()); } - let dir_name = try!(path.file_name().and_then(|s| s.to_str()).chain_error(|| { + let dir_name = path.file_name().and_then(|s| s.to_str()).chain_error(|| { human(&format!("cannot create a project with a non-unicode name: {:?}", path.file_name().unwrap())) - })); + })?; if opts.bin { Ok(dir_name) @@ -108,7 +108,7 @@ fn get_name<'a>(path: &'a Path, opts: &'a NewOptions, config: &Config) -> CargoR let message = format!( "note: package will be named `{}`; use --name to override", new_name); - try!(config.shell().say(&message, BLACK)); + config.shell().say(&message, BLACK)?; } Ok(new_name) } @@ -196,7 +196,7 @@ fn detect_source_paths_and_types(project_path : &Path, } } H::Detect => { - let content = try!(paths::read(&path.join(pp.clone()))); + let content = paths::read(&path.join(pp.clone()))?; let isbin = content.contains("fn main"); SourceFileInformation { relative_path: pp, @@ -265,8 +265,8 @@ pub fn new(opts: NewOptions, config: &Config) -> CargoResult<()> { bail!("can't specify both lib and binary outputs"); } - let name = try!(get_name(&path, &opts, config)); - try!(check_name(name)); + let name = get_name(&path, &opts, config)?; + check_name(name)?; let mkopts = MkOptions { version_control: opts.version_control, @@ -294,12 +294,12 @@ pub fn init(opts: NewOptions, config: &Config) -> CargoResult<()> { bail!("can't specify both lib and binary outputs"); } - let name = try!(get_name(&path, &opts, config)); - try!(check_name(name)); + let name = get_name(&path, &opts, config)?; + check_name(name)?; let mut src_paths_types = vec![]; - try!(detect_source_paths_and_types(&path, name, &mut src_paths_types)); + detect_source_paths_and_types(&path, name, &mut src_paths_types)?; if src_paths_types.len() == 0 { src_paths_types.push(plan_new_source_file(opts.bin, name.to_string())); @@ -369,7 +369,7 @@ fn existing_vcs_repo(path: &Path, cwd: &Path) -> bool { fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> { let path = opts.path; let name = opts.name; - let cfg = try!(global_config(config)); + let cfg = global_config(config)?; let mut ignore = "target\n".to_string(); let in_existing_vcs_repo = existing_vcs_repo(path.parent().unwrap(), config.cwd()); if !opts.bin { @@ -386,22 +386,22 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> { match vcs { VersionControl::Git => { if !fs::metadata(&path.join(".git")).is_ok() { - try!(GitRepo::init(path, config.cwd())); + GitRepo::init(path, config.cwd())?; } - try!(paths::append(&path.join(".gitignore"), ignore.as_bytes())); + paths::append(&path.join(".gitignore"), ignore.as_bytes())?; }, VersionControl::Hg => { if !fs::metadata(&path.join(".hg")).is_ok() { - try!(HgRepo::init(path, config.cwd())); + HgRepo::init(path, config.cwd())?; } - try!(paths::append(&path.join(".hgignore"), ignore.as_bytes())); + paths::append(&path.join(".hgignore"), ignore.as_bytes())?; }, VersionControl::NoVcs => { - try!(fs::create_dir_all(path)); + fs::create_dir_all(path)?; }, }; - let (author_name, email) = try!(discover_author()); + let (author_name, email) = discover_author()?; // Hoo boy, sure glad we've got exhaustivenes checking behind us. let author = match (cfg.name, cfg.email, author_name, email) { (Some(name), Some(email), _, _) | @@ -438,14 +438,14 @@ path = {} // Create Cargo.toml file with necessary [lib] and [[bin]] sections, if needed - try!(paths::write(&path.join("Cargo.toml"), format!( + paths::write(&path.join("Cargo.toml"), format!( r#"[package] name = "{}" version = "0.1.0" authors = [{}] [dependencies] -{}"#, name, toml::Value::String(author), cargotoml_path_specifier).as_bytes())); +{}"#, name, toml::Value::String(author), cargotoml_path_specifier).as_bytes())?; // Create all specified source files @@ -456,7 +456,7 @@ authors = [{}] let path_of_source_file = path.join(i.relative_path.clone()); if let Some(src_dir) = path_of_source_file.parent() { - try!(fs::create_dir_all(src_dir)); + fs::create_dir_all(src_dir)?; } let default_file_content : &[u8] = if i.bin { @@ -477,14 +477,14 @@ mod tests { }; if !fs::metadata(&path_of_source_file).map(|x| x.is_file()).unwrap_or(false) { - try!(paths::write(&path_of_source_file, default_file_content)); + paths::write(&path_of_source_file, default_file_content)?; } } if let Err(e) = Workspace::new(&path.join("Cargo.toml"), config) { let msg = format!("compiling this new crate may not work due to invalid \ workspace configuration\n\n{}", e); - try!(config.shell().warn(msg)); + config.shell().warn(msg)?; } Ok(()) @@ -526,9 +526,9 @@ fn discover_author() -> CargoResult<(String, Option)> { } fn global_config(config: &Config) -> CargoResult { - let name = try!(config.get_string("cargo-new.name")).map(|s| s.val); - let email = try!(config.get_string("cargo-new.email")).map(|s| s.val); - let vcs = try!(config.get_string("cargo-new.vcs")); + let name = config.get_string("cargo-new.name")?.map(|s| s.val); + let email = config.get_string("cargo-new.email")?.map(|s| s.val); + let vcs = config.get_string("cargo-new.vcs")?; let vcs = match vcs.as_ref().map(|p| (&p.val[..], &p.definition)) { Some(("git", _)) => Some(VersionControl::Git), diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index affaaa6a18e..b8dfca5ef36 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -46,12 +46,12 @@ fn metadata_full(ws: &Workspace, let specs = ws.members().map(|pkg| { PackageIdSpec::from_package_id(pkg.package_id()) }).collect::>(); - let deps = try!(ops::resolve_dependencies(ws, + let deps = ops::resolve_dependencies(ws, None, &opt.features, opt.all_features, opt.no_default_features, - &specs)); + &specs)?; let (packages, resolve) = deps; let packages = try!(packages.package_ids() diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 55f8dd64fc9..26841796ec8 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -24,22 +24,22 @@ pub struct PackageOpts<'cfg> { pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult> { - let pkg = try!(ws.current()); + let pkg = ws.current()?; let config = ws.config(); let mut src = PathSource::new(pkg.root(), pkg.package_id().source_id(), config); - try!(src.update()); + src.update()?; if opts.check_metadata { - try!(check_metadata(pkg, config)); + check_metadata(pkg, config)?; } - try!(verify_dependencies(&pkg)); + verify_dependencies(&pkg)?; if opts.list { let root = pkg.root(); - let mut list: Vec<_> = try!(src.list_files(&pkg)).iter().map(|file| { + let mut list: Vec<_> = src.list_files(&pkg)?.iter().map(|file| { util::without_prefix(&file, &root).unwrap().to_path_buf() }).collect(); list.sort(); @@ -50,38 +50,38 @@ pub fn package(ws: &Workspace, } if !opts.allow_dirty { - try!(check_not_dirty(&pkg, &src)); + check_not_dirty(&pkg, &src)?; } let filename = format!("{}-{}.crate", pkg.name(), pkg.version()); let dir = ws.target_dir().join("package"); let mut dst = { let tmp = format!(".{}", filename); - try!(dir.open_rw(&tmp, config, "package scratch space")) + dir.open_rw(&tmp, config, "package scratch space")? }; // Package up and test a temporary tarball and only move it to the final // location if it actually passes all our tests. Any previously existing // tarball can be assumed as corrupt or invalid, so we just blow it away if // it exists. - try!(config.shell().status("Packaging", pkg.package_id().to_string())); - try!(dst.file().set_len(0)); - try!(tar(ws, &src, dst.file(), &filename).chain_error(|| { + config.shell().status("Packaging", pkg.package_id().to_string())?; + dst.file().set_len(0)?; + tar(ws, &src, dst.file(), &filename).chain_error(|| { human("failed to prepare local package for uploading") - })); + })?; if opts.verify { - try!(dst.seek(SeekFrom::Start(0))); - try!(run_verify(ws, dst.file(), opts).chain_error(|| { + dst.seek(SeekFrom::Start(0))?; + run_verify(ws, dst.file(), opts).chain_error(|| { human("failed to verify package tarball") - })) + })? } - try!(dst.seek(SeekFrom::Start(0))); + dst.seek(SeekFrom::Start(0))?; { let src_path = dst.path(); let dst_path = dst.parent().join(&filename); - try!(fs::rename(&src_path, &dst_path).chain_error(|| { + fs::rename(&src_path, &dst_path).chain_error(|| { human("failed to move temporary tarball into final location") - })); + })?; } Ok(Some(dst)) } @@ -113,10 +113,10 @@ fn check_metadata(pkg: &Package, config: &Config) -> CargoResult<()> { } things.push_str(&missing.last().unwrap()); - try!(config.shell().warn( + config.shell().warn( &format!("manifest has no {things}.\n\ See http://doc.crates.io/manifest.html#package-metadata for more info.", - things = things))) + things = things))? } Ok(()) } @@ -159,7 +159,7 @@ fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> { src: &PathSource, repo: &git2::Repository) -> CargoResult<()> { let workdir = repo.workdir().unwrap(); - let dirty = try!(src.list_files(p)).iter().filter(|file| { + let dirty = src.list_files(p)?.iter().filter(|file| { let relative = file.strip_prefix(workdir).unwrap(); if let Ok(status) = repo.status_file(relative) { status != git2::STATUS_CURRENT @@ -185,27 +185,27 @@ fn tar(ws: &Workspace, filename: &str) -> CargoResult<()> { // Prepare the encoder and its header let filename = Path::new(filename); - let encoder = GzBuilder::new().filename(try!(util::path2bytes(filename))) + let encoder = GzBuilder::new().filename(util::path2bytes(filename)?) .write(dst, Compression::Best); // Put all package files into a compressed archive let mut ar = Builder::new(encoder); - let pkg = try!(ws.current()); + let pkg = ws.current()?; let config = ws.config(); let root = pkg.root(); - for file in try!(src.list_files(pkg)).iter() { + for file in src.list_files(pkg)?.iter() { let relative = util::without_prefix(&file, &root).unwrap(); - try!(check_filename(relative)); - let relative = try!(relative.to_str().chain_error(|| { + check_filename(relative)?; + let relative = relative.to_str().chain_error(|| { human(format!("non-utf8 path in source directory: {}", relative.display())) - })); - let mut file = try!(File::open(file).chain_error(|| { + })?; + let mut file = File::open(file).chain_error(|| { human(format!("failed to open for archiving: `{}`", file.display())) - })); - try!(config.shell().verbose(|shell| { + })?; + config.shell().verbose(|shell| { shell.status("Archiving", &relative) - })); + })?; let path = format!("{}-{}{}{}", pkg.name(), pkg.version(), path::MAIN_SEPARATOR, relative); @@ -228,38 +228,38 @@ fn tar(ws: &Workspace, // unpack the selectors 0.4.0 crate on crates.io. Either that or take a // look at rust-lang/cargo#2326 let mut header = Header::new_ustar(); - let metadata = try!(file.metadata().chain_error(|| { + let metadata = file.metadata().chain_error(|| { human(format!("could not learn metadata for: `{}`", relative)) - })); - try!(header.set_path(&path).chain_error(|| { + })?; + header.set_path(&path).chain_error(|| { human(format!("failed to add to archive: `{}`", relative)) - })); + })?; header.set_metadata(&metadata); header.set_cksum(); - try!(ar.append(&header, &mut file).chain_error(|| { + ar.append(&header, &mut file).chain_error(|| { internal(format!("could not archive source file `{}`", relative)) - })); + })?; } - let encoder = try!(ar.into_inner()); - try!(encoder.finish()); + let encoder = ar.into_inner()?; + encoder.finish()?; Ok(()) } fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> { let config = ws.config(); - let pkg = try!(ws.current()); + let pkg = ws.current()?; - try!(config.shell().status("Verifying", pkg)); + config.shell().status("Verifying", pkg)?; - let f = try!(GzDecoder::new(tar)); + let f = GzDecoder::new(tar)?; let dst = pkg.root().join(&format!("target/package/{}-{}", pkg.name(), pkg.version())); if fs::metadata(&dst).is_ok() { - try!(fs::remove_dir_all(&dst)); + fs::remove_dir_all(&dst)?; } let mut archive = Archive::new(f); - try!(archive.unpack(dst.parent().unwrap())); + archive.unpack(dst.parent().unwrap())?; let manifest_path = dst.join("Cargo.toml"); // When packages are uploaded to a registry, all path dependencies are @@ -270,10 +270,10 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> // location that the package was originally read from. In locking the // `SourceId` we're telling it that the corresponding `PathSource` will be // considered updated and we won't actually read any packages. - let cratesio = try!(SourceId::crates_io(config)); + let cratesio = SourceId::crates_io(config)?; let precise = Some("locked".to_string()); - let new_src = try!(SourceId::for_path(&dst)).with_precise(precise); - let new_pkgid = try!(PackageId::new(pkg.name(), pkg.version(), &new_src)); + let new_src = SourceId::for_path(&dst)?.with_precise(precise); + let new_pkgid = PackageId::new(pkg.name(), pkg.version(), &new_src)?; let new_summary = pkg.summary().clone().map_dependencies(|d| { if !d.source_id().is_path() { return d } d.clone_inner().set_source_id(cratesio.clone()).into_dependency() @@ -283,8 +283,8 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> let new_pkg = Package::new(new_manifest, &manifest_path); // Now that we've rewritten all our path dependencies, compile it! - let ws = try!(Workspace::one(new_pkg, config, None)); - try!(ops::compile_ws(&ws, None, &ops::CompileOptions { + let ws = Workspace::one(new_pkg, config, None)?; + ops::compile_ws(&ws, None, &ops::CompileOptions { config: config, jobs: opts.jobs, target: None, @@ -298,7 +298,7 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> mode: ops::CompileMode::Build, target_rustdoc_args: None, target_rustc_args: None, - })); + })?; Ok(()) } diff --git a/src/cargo/ops/cargo_pkgid.rs b/src/cargo/ops/cargo_pkgid.rs index 94737d507d4..0461bc4c87f 100644 --- a/src/cargo/ops/cargo_pkgid.rs +++ b/src/cargo/ops/cargo_pkgid.rs @@ -3,14 +3,14 @@ use core::{PackageIdSpec, Workspace}; use util::CargoResult; pub fn pkgid(ws: &Workspace, spec: Option<&str>) -> CargoResult { - let resolve = match try!(ops::load_pkg_lockfile(ws)) { + let resolve = match ops::load_pkg_lockfile(ws)? { Some(resolve) => resolve, None => bail!("a Cargo.lock must exist for this command"), }; let pkgid = match spec { - Some(spec) => try!(PackageIdSpec::query_str(spec, resolve.iter())), - None => try!(ws.current()).package_id(), + Some(spec) => PackageIdSpec::query_str(spec, resolve.iter())?, + None => ws.current()?.package_id(), }; Ok(PackageIdSpec::from_package_id(pkgid)) } diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 39028b798a2..5c25edbf1c9 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -11,7 +11,7 @@ use util::toml::Layout; pub fn read_manifest(path: &Path, source_id: &SourceId, config: &Config) -> CargoResult<(EitherManifest, Vec)> { trace!("read_package; path={}; source-id={}", path.display(), source_id); - let contents = try!(paths::read(path)); + let contents = paths::read(path)?; let layout = Layout::from_project_path(path.parent().unwrap()); let root = layout.root.clone(); @@ -24,7 +24,7 @@ pub fn read_manifest(path: &Path, source_id: &SourceId, config: &Config) pub fn read_package(path: &Path, source_id: &SourceId, config: &Config) -> CargoResult<(Package, Vec)> { trace!("read_package; path={}; source-id={}", path.display(), source_id); - let (manifest, nested) = try!(read_manifest(path, source_id, config)); + let (manifest, nested) = read_manifest(path, source_id, config)?; let manifest = match manifest { EitherManifest::Real(manifest) => manifest, EitherManifest::Virtual(..) => { @@ -43,7 +43,7 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config) trace!("looking for root package: {}, source_id={}", path.display(), source_id); - try!(walk(path, &mut |dir| { + walk(path, &mut |dir| { trace!("looking for child package: {}", dir.display()); // Don't recurse into hidden/dot directories unless we're at the toplevel @@ -66,11 +66,11 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config) } if has_manifest(dir) { - try!(read_nested_packages(dir, &mut all_packages, source_id, config, - &mut visited)); + read_nested_packages(dir, &mut all_packages, source_id, config, + &mut visited)?; } Ok(true) - })); + })?; if all_packages.is_empty() { Err(human(format!("Could not find Cargo.toml in `{}`", path.display()))) @@ -81,7 +81,7 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config) fn walk(path: &Path, callback: &mut FnMut(&Path) -> CargoResult) -> CargoResult<()> { - if !try!(callback(path)) { + if !callback(path)? { trace!("not processing {}", path.display()); return Ok(()) } @@ -100,9 +100,9 @@ fn walk(path: &Path, callback: &mut FnMut(&Path) -> CargoResult) } }; for dir in dirs { - let dir = try!(dir); - if try!(dir.file_type()).is_dir() { - try!(walk(&dir.path(), callback)); + let dir = dir?; + if dir.file_type()?.is_dir() { + walk(&dir.path(), callback)?; } } Ok(()) @@ -119,9 +119,9 @@ fn read_nested_packages(path: &Path, visited: &mut HashSet) -> CargoResult<()> { if !visited.insert(path.to_path_buf()) { return Ok(()) } - let manifest_path = try!(find_project_manifest_exact(path, "Cargo.toml")); + let manifest_path = find_project_manifest_exact(path, "Cargo.toml")?; - let (manifest, nested) = try!(read_manifest(&manifest_path, source_id, config)); + let (manifest, nested) = read_manifest(&manifest_path, source_id, config)?; let manifest = match manifest { EitherManifest::Real(manifest) => manifest, EitherManifest::Virtual(..) => return Ok(()), @@ -147,8 +147,8 @@ fn read_nested_packages(path: &Path, if !source_id.is_registry() { for p in nested.iter() { let path = util::normalize_path(&path.join(p)); - try!(read_nested_packages(&path, all_packages, source_id, - config, visited)); + read_nested_packages(&path, all_packages, source_id, + config, visited)?; } } diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 897a3da5116..1c4c4a485c1 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -8,7 +8,7 @@ pub fn run(ws: &Workspace, options: &ops::CompileOptions, args: &[String]) -> CargoResult> { let config = ws.config(); - let root = try!(ws.current()); + let root = ws.current()?; let mut bins = root.manifest().targets().iter().filter(|a| { !a.is_lib() && !a.is_custom_build() && match options.filter { @@ -40,7 +40,7 @@ pub fn run(ws: &Workspace, } } - let compile = try!(ops::compile(ws, options)); + let compile = ops::compile(ws, options)?; let exe = &compile.binaries[0]; let exe = match util::without_prefix(&exe, config.cwd()) { Some(path) if path.file_name() == Some(path.as_os_str()) @@ -48,9 +48,9 @@ pub fn run(ws: &Workspace, Some(path) => path.to_path_buf(), None => exe.to_path_buf(), }; - let mut process = try!(compile.target_process(exe, &root)); + let mut process = compile.target_process(exe, &root)?; process.args(args).cwd(config.cwd()); - try!(config.shell().status("Running", process.to_string())); + config.shell().status("Running", process.to_string())?; Ok(process.exec_replace().err()) } diff --git a/src/cargo/ops/cargo_rustc/compilation.rs b/src/cargo/ops/cargo_rustc/compilation.rs index f15032c2336..afb8962589b 100644 --- a/src/cargo/ops/cargo_rustc/compilation.rs +++ b/src/cargo/ops/cargo_rustc/compilation.rs @@ -71,12 +71,12 @@ impl<'cfg> Compilation<'cfg> { /// See `process`. pub fn rustc_process(&self, pkg: &Package) -> CargoResult { - self.fill_env(try!(self.config.rustc()).process(), pkg, true) + self.fill_env(self.config.rustc()?.process(), pkg, true) } /// See `process`. pub fn rustdoc_process(&self, pkg: &Package) -> CargoResult { - self.fill_env(process(&*try!(self.config.rustdoc())), pkg, false) + self.fill_env(process(&*self.config.rustdoc()?), pkg, false) } /// See `process`. @@ -128,7 +128,7 @@ impl<'cfg> Compilation<'cfg> { }; search_path.extend(util::dylib_path().into_iter()); - let search_path = try!(join_paths(&search_path, util::dylib_path_envvar())); + let search_path = join_paths(&search_path, util::dylib_path_envvar())?; cmd.env(util::dylib_path_envvar(), &search_path); if let Some(env) = self.extra_env.get(pkg.package_id()) { diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 4e0cf00db6a..fcdb3979583 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -62,15 +62,15 @@ impl<'a, 'cfg> Context<'a, 'cfg> { profiles: &'a Profiles) -> CargoResult> { let dest = if build_config.release { "release" } else { "debug" }; - let host_layout = try!(Layout::new(ws, None, &dest)); + let host_layout = Layout::new(ws, None, &dest)?; let target_layout = match build_config.requested_target.as_ref() { Some(target) => { - Some(try!(Layout::new(ws, Some(&target), &dest))) + Some(Layout::new(ws, Some(&target), &dest)?) } None => None, }; - let current_package = try!(ws.current()).package_id().clone(); + let current_package = ws.current()?.package_id().clone(); Ok(Context { host: host_layout, target: target_layout, @@ -98,14 +98,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> { pub fn prepare(&mut self) -> CargoResult<()> { let _p = profile::start("preparing layout"); - try!(self.host.prepare().chain_error(|| { + self.host.prepare().chain_error(|| { internal(format!("couldn't prepare build directories")) - })); + })?; match self.target { Some(ref mut target) => { - try!(target.prepare().chain_error(|| { + target.prepare().chain_error(|| { internal(format!("couldn't prepare build directories")) - })); + })?; } None => {} } @@ -128,13 +128,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> { crate_types.insert("bin".to_string()); crate_types.insert("rlib".to_string()); for unit in units { - try!(self.visit_crate_type(unit, &mut crate_types)); + self.visit_crate_type(unit, &mut crate_types)?; } - try!(self.probe_target_info_kind(&crate_types, Kind::Target)); + self.probe_target_info_kind(&crate_types, Kind::Target)?; if self.requested_target().is_none() { self.host_info = self.target_info.clone(); } else { - try!(self.probe_target_info_kind(&crate_types, Kind::Host)); + self.probe_target_info_kind(&crate_types, Kind::Host)?; } Ok(()) } @@ -152,8 +152,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } })); } - for dep in try!(self.dep_targets(&unit)) { - try!(self.visit_crate_type(&dep, crate_types)); + for dep in self.dep_targets(&unit)? { + self.visit_crate_type(&dep, crate_types)?; } Ok(()) } @@ -162,11 +162,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { crate_types: &BTreeSet, kind: Kind) -> CargoResult<()> { - let rustflags = try!(env_args(self.config, + let rustflags = env_args(self.config, &self.build_config, kind, - "RUSTFLAGS")); - let mut process = try!(self.config.rustc()).process(); + "RUSTFLAGS")?; + let mut process = self.config.rustc()?.process(); process.arg("-") .arg("--crate-name").arg("_") .arg("--print=file-names") @@ -184,13 +184,13 @@ impl<'a, 'cfg> Context<'a, 'cfg> { with_cfg.arg("--print=cfg"); let mut has_cfg = true; - let output = try!(with_cfg.exec_with_output().or_else(|_| { + let output = with_cfg.exec_with_output().or_else(|_| { has_cfg = false; process.exec_with_output() }).chain_error(|| { human(format!("failed to run `rustc` to learn about \ target-specific information")) - })); + })?; let error = str::from_utf8(&output.stderr).unwrap(); let output = str::from_utf8(&output.stdout).unwrap(); @@ -245,9 +245,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> { -> CargoResult<()> { let mut visited = HashSet::new(); for unit in units { - try!(self.walk_used_in_plugin_map(unit, + self.walk_used_in_plugin_map(unit, unit.target.for_host(), - &mut visited)); + &mut visited)?; } Ok(()) } @@ -263,10 +263,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> { if is_plugin { self.used_in_plugin.insert(*unit); } - for unit in try!(self.dep_targets(unit)) { - try!(self.walk_used_in_plugin_map(&unit, + for unit in self.dep_targets(unit)? { + self.walk_used_in_plugin_map(&unit, is_plugin || unit.target.for_host(), - visited)); + visited)?; } Ok(()) } @@ -407,14 +407,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> { TargetKind::CustomBuild | TargetKind::Bench | TargetKind::Test => { - try!(add("bin", false)); + add("bin", false)?; } TargetKind::Lib(..) if unit.profile.test => { - try!(add("bin", false)); + add("bin", false)?; } TargetKind::Lib(ref libs) => { for lib in libs { - try!(add(lib.crate_type(), lib.linkable())); + add(lib.crate_type(), lib.linkable())?; } } } @@ -443,7 +443,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let id = unit.pkg.package_id(); let deps = self.resolve.deps(id); - let mut ret = try!(deps.filter(|dep| { + let mut ret = deps.filter(|dep| { unit.pkg.dependencies().iter().filter(|d| { d.name() == dep.name() && d.version_req().matches(dep.version()) }).any(|d| { @@ -494,7 +494,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } Err(e) => Some(Err(e)) } - }).collect::>>()); + }).collect::>>()?; // If this target is a build script, then what we've collected so far is // all we need. If this isn't a build script, then it depends on the @@ -555,7 +555,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { profile: &self.profiles.dev, ..*unit }; - let deps = try!(self.dep_targets(&tmp)); + let deps = self.dep_targets(&tmp)?; Ok(deps.iter().filter_map(|unit| { if !unit.target.linkable() || unit.pkg.manifest().links().is_none() { return None @@ -589,7 +589,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // the documentation of the library being built. let mut ret = Vec::new(); for dep in deps { - let dep = try!(dep); + let dep = dep?; let lib = match dep.targets().iter().find(|t| t.is_lib()) { Some(lib) => lib, None => continue, @@ -779,14 +779,14 @@ fn env_args(config: &Config, // Then the target.*.rustflags value let target = build_config.requested_target.as_ref().unwrap_or(&build_config.host_triple); let key = format!("target.{}.{}", target, name); - if let Some(args) = try!(config.get_list(&key)) { + if let Some(args) = config.get_list(&key)? { let args = args.val.into_iter().map(|a| a.0); return Ok(args.collect()); } // Then the build.rustflags value let key = format!("build.{}", name); - if let Some(args) = try!(config.get_list(&key)) { + if let Some(args) = config.get_list(&key)? { let args = args.val.into_iter().map(|a| a.0); return Ok(args.collect()); } diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 54c688134be..375a6ea434c 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -69,13 +69,13 @@ pub fn prepare<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) let (work_dirty, work_fresh) = if overridden { (Work::new(|_| Ok(())), Work::new(|_| Ok(()))) } else { - try!(build_work(cx, unit)) + build_work(cx, unit)? }; // Now that we've prep'd our work, build the work needed to manage the // fingerprint and then start returning that upwards. let (freshness, dirty, fresh) = - try!(fingerprint::prepare_build_cmd(cx, unit)); + fingerprint::prepare_build_cmd(cx, unit)?; Ok((work_dirty.then(dirty), work_fresh.then(fresh), freshness)) } @@ -97,7 +97,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // package's library profile. let profile = cx.lib_profile(unit.pkg.package_id()); let to_exec = to_exec.into_os_string(); - let mut cmd = try!(cx.compilation.host_process(to_exec, unit.pkg)); + let mut cmd = cx.compilation.host_process(to_exec, unit.pkg)?; cmd.env("OUT_DIR", &build_output) .env("CARGO_MANIFEST_DIR", unit.pkg.root()) .env("NUM_JOBS", &cx.jobs().to_string()) @@ -109,8 +109,8 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) .env("OPT_LEVEL", &profile.opt_level) .env("PROFILE", if cx.build_config.release { "release" } else { "debug" }) .env("HOST", cx.host_triple()) - .env("RUSTC", &try!(cx.config.rustc()).path) - .env("RUSTDOC", &*try!(cx.config.rustdoc())); + .env("RUSTC", &cx.config.rustc()?.path) + .env("RUSTDOC", &*cx.config.rustdoc()?); if let Some(links) = unit.pkg.manifest().links() { cmd.env("CARGO_MANIFEST_LINKS", links); @@ -150,7 +150,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // This information will be used at build-time later on to figure out which // sorts of variables need to be discovered at that time. let lib_deps = { - try!(cx.dep_run_custom_build(unit)).iter().filter_map(|unit| { + cx.dep_run_custom_build(unit)?.iter().filter_map(|unit| { if unit.profile.run_custom_build { Some((unit.pkg.manifest().links().unwrap().to_string(), unit.pkg.package_id().clone())) @@ -177,8 +177,8 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) }; cx.build_explicit_deps.insert(*unit, (output_file.clone(), rerun_if_changed)); - try!(fs::create_dir_all(&cx.layout(&host_unit).build(unit.pkg))); - try!(fs::create_dir_all(&cx.layout(unit).build(unit.pkg))); + fs::create_dir_all(&cx.layout(&host_unit).build(unit.pkg))?; + fs::create_dir_all(&cx.layout(unit).build(unit.pkg))?; // Prepare the unit of "dirty work" which will actually run the custom build // command. @@ -191,10 +191,10 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // If we have an old build directory, then just move it into place, // otherwise create it! if fs::metadata(&build_output).is_err() { - try!(fs::create_dir(&build_output).chain_error(|| { + fs::create_dir(&build_output).chain_error(|| { internal("failed to create script output directory for \ build command") - })); + })?; } // For all our native lib dependencies, pick up their metadata to pass @@ -205,10 +205,10 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) let build_state = build_state.outputs.lock().unwrap(); for (name, id) in lib_deps { let key = (id.clone(), kind); - let state = try!(build_state.get(&key).chain_error(|| { + let state = build_state.get(&key).chain_error(|| { internal(format!("failed to locate build state for env \ vars: {}/{:?}", id, kind)) - })); + })?; let data = &state.metadata; for &(ref key, ref value) in data.iter() { cmd.env(&format!("DEP_{}_{}", super::envify(&name), @@ -216,22 +216,22 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) } } if let Some(build_scripts) = build_scripts { - try!(super::add_plugin_deps(&mut cmd, &build_state, - &build_scripts)); + super::add_plugin_deps(&mut cmd, &build_state, + &build_scripts)?; } } // And now finally, run the build command itself! state.running(&cmd); - let output = try!(cmd.exec_with_streaming( + let output = cmd.exec_with_streaming( &mut |out_line| { state.stdout(out_line); Ok(()) }, &mut |err_line| { state.stderr(err_line); Ok(()) }, ).map_err(|mut e| { e.desc = format!("failed to run custom build command for `{}`\n{}", pkg_name, e.desc); Human(e) - })); - try!(paths::write(&output_file, &output.stdout)); + })?; + paths::write(&output_file, &output.stdout)?; // After the build command has finished running, we need to be sure to // remember all of its output so we can later discover precisely what it @@ -240,7 +240,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // This is also the location where we provide feedback into the build // state informing what variables were discovered via our script as // well. - let parsed_output = try!(BuildOutput::parse(&output.stdout, &pkg_name)); + let parsed_output = BuildOutput::parse(&output.stdout, &pkg_name)?; build_state.insert(id, kind, parsed_output); Ok(()) }); @@ -252,7 +252,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) let (id, pkg_name, build_state, output_file) = all; let output = match prev_output { Some(output) => output, - None => try!(BuildOutput::parse_file(&output_file, &pkg_name)), + None => BuildOutput::parse_file(&output_file, &pkg_name)?, }; build_state.insert(id, kind, output); Ok(()) @@ -294,7 +294,7 @@ impl BuildState { impl BuildOutput { pub fn parse_file(path: &Path, pkg_name: &str) -> CargoResult { - let contents = try!(paths::read_bytes(path)); + let contents = paths::read_bytes(path)?; BuildOutput::parse(&contents, pkg_name) } @@ -336,9 +336,9 @@ impl BuildOutput { match key { "rustc-flags" => { - let (libs, links) = try!( + let (libs, links) = BuildOutput::parse_rustc_flags(value, &whence) - ); + ?; library_links.extend(links.into_iter()); library_paths.extend(libs.into_iter()); } @@ -407,7 +407,7 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, -> CargoResult<()> { let mut ret = HashMap::new(); for unit in units { - try!(build(&mut ret, cx, unit)); + build(&mut ret, cx, unit)?; } cx.build_scripts.extend(ret.into_iter().map(|(k, v)| { (k, Arc::new(v)) @@ -431,8 +431,8 @@ pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>, if !unit.target.is_custom_build() && unit.pkg.has_custom_build() { add_to_link(&mut ret, unit.pkg.package_id(), unit.kind); } - for unit in try!(cx.dep_targets(unit)).iter() { - let dep_scripts = try!(build(out, cx, unit)); + for unit in cx.dep_targets(unit)?.iter() { + let dep_scripts = build(out, cx, unit)?; if unit.target.for_host() { ret.plugins.extend(dep_scripts.to_link.iter() diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index b16cf7f90df..ae0497e716d 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -53,7 +53,7 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, debug!("fingerprint at: {}", loc.display()); - let fingerprint = try!(calculate(cx, unit)); + let fingerprint = calculate(cx, unit)?; let compare = compare_old_fingerprint(&loc, &*fingerprint); log_compare(unit, &compare); @@ -70,10 +70,10 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, if compare.is_err() { let source_id = unit.pkg.package_id().source_id(); let sources = cx.packages.sources(); - let source = try!(sources.get(source_id).chain_error(|| { + let source = sources.get(source_id).chain_error(|| { internal("missing package source") - })); - try!(source.verify(unit.pkg.package_id())); + })?; + source.verify(unit.pkg.package_id())?; } let root = cx.out_dir(unit); @@ -82,7 +82,7 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, missing_outputs = !root.join(unit.target.crate_name()) .join("index.html").exists(); } else { - for (filename, _) in try!(cx.target_filenames(unit)) { + for (filename, _) in cx.target_filenames(unit)? { missing_outputs |= fs::metadata(root.join(filename)).is_err(); } } @@ -145,9 +145,9 @@ impl Fingerprint { fn update_local(&self) -> CargoResult<()> { match self.local { LocalFingerprint::MtimeBased(ref slot, ref path) => { - let meta = try!(fs::metadata(path).chain_error(|| { + let meta = fs::metadata(path).chain_error(|| { internal(format!("failed to stat `{}`", path.display())) - })); + })?; let mtime = FileTime::from_last_modification_time(&meta); *slot.0.lock().unwrap() = Some(mtime); } @@ -242,19 +242,19 @@ impl hash::Hash for Fingerprint { impl Encodable for Fingerprint { fn encode(&self, e: &mut E) -> Result<(), E::Error> { e.emit_struct("Fingerprint", 6, |e| { - try!(e.emit_struct_field("rustc", 0, |e| self.rustc.encode(e))); - try!(e.emit_struct_field("target", 1, |e| self.target.encode(e))); - try!(e.emit_struct_field("profile", 2, |e| self.profile.encode(e))); - try!(e.emit_struct_field("local", 3, |e| self.local.encode(e))); - try!(e.emit_struct_field("features", 4, |e| { + e.emit_struct_field("rustc", 0, |e| self.rustc.encode(e))?; + e.emit_struct_field("target", 1, |e| self.target.encode(e))?; + e.emit_struct_field("profile", 2, |e| self.profile.encode(e))?; + e.emit_struct_field("local", 3, |e| self.local.encode(e))?; + e.emit_struct_field("features", 4, |e| { self.features.encode(e) - })); - try!(e.emit_struct_field("deps", 5, |e| { + })?; + e.emit_struct_field("deps", 5, |e| { self.deps.iter().map(|&(ref a, ref b)| { (a, b.hash()) }).collect::>().encode(e) - })); - try!(e.emit_struct_field("rustflags", 6, |e| self.rustflags.encode(e))); + })?; + e.emit_struct_field("rustflags", 6, |e| self.rustflags.encode(e))?; Ok(()) }) } @@ -267,15 +267,15 @@ impl Decodable for Fingerprint { } d.read_struct("Fingerprint", 6, |d| { Ok(Fingerprint { - rustc: try!(d.read_struct_field("rustc", 0, decode)), - target: try!(d.read_struct_field("target", 1, decode)), - profile: try!(d.read_struct_field("profile", 2, decode)), - local: try!(d.read_struct_field("local", 3, decode)), - features: try!(d.read_struct_field("features", 4, decode)), + rustc: d.read_struct_field("rustc", 0, decode)?, + target: d.read_struct_field("target", 1, decode)?, + profile: d.read_struct_field("profile", 2, decode)?, + local: d.read_struct_field("local", 3, decode)?, + features: d.read_struct_field("features", 4, decode)?, memoized_hash: Mutex::new(None), deps: { let decode = decode::, D>; - let v = try!(d.read_struct_field("deps", 5, decode)); + let v = d.read_struct_field("deps", 5, decode)?; v.into_iter().map(|(name, hash)| { (name, Arc::new(Fingerprint { rustc: 0, @@ -289,7 +289,7 @@ impl Decodable for Fingerprint { })) }).collect() }, - rustflags: try!(d.read_struct_field("rustflags", 6, decode)), + rustflags: d.read_struct_field("rustflags", 6, decode)?, }) }) } @@ -311,7 +311,7 @@ impl Encodable for MtimeSlot { impl Decodable for MtimeSlot { fn decode(e: &mut D) -> Result { - let kind: Option<(u64, u32)> = try!(Decodable::decode(e)); + let kind: Option<(u64, u32)> = Decodable::decode(e)?; Ok(MtimeSlot(Mutex::new(kind.map(|(s, n)| { FileTime::from_seconds_since_1970(s, n) })))) @@ -353,33 +353,33 @@ fn calculate<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // elsewhere. Also skip fingerprints of binaries because they don't actually // induce a recompile, they're just dependencies in the sense that they need // to be built. - let deps = try!(cx.dep_targets(unit)); - let deps = try!(deps.iter().filter(|u| { + let deps = cx.dep_targets(unit)?; + let deps = deps.iter().filter(|u| { !u.target.is_custom_build() && !u.target.is_bin() }).map(|unit| { calculate(cx, unit).map(|fingerprint| { (unit.pkg.package_id().to_string(), fingerprint) }) - }).collect::>>()); + }).collect::>>()?; // And finally, calculate what our own local fingerprint is let local = if use_dep_info(unit) { let dep_info = dep_info_loc(cx, unit); - let mtime = try!(dep_info_mtime_if_fresh(&dep_info)); + let mtime = dep_info_mtime_if_fresh(&dep_info)?; LocalFingerprint::MtimeBased(MtimeSlot(Mutex::new(mtime)), dep_info) } else { - let fingerprint = try!(pkg_fingerprint(cx, unit.pkg)); + let fingerprint = pkg_fingerprint(cx, unit.pkg)?; LocalFingerprint::Precalculated(fingerprint) }; let mut deps = deps; deps.sort_by(|&(ref a, _), &(ref b, _)| a.cmp(b)); let extra_flags = if unit.profile.doc { - try!(cx.rustdocflags_args(unit)) + cx.rustdocflags_args(unit)? } else { - try!(cx.rustflags_args(unit)) + cx.rustflags_args(unit)? }; let fingerprint = Arc::new(Fingerprint { - rustc: util::hash_u64(&try!(cx.config.rustc()).verbose_version), + rustc: util::hash_u64(&cx.config.rustc()?.verbose_version), target: util::hash_u64(&unit.target), profile: util::hash_u64(&unit.profile), features: format!("{:?}", features), @@ -444,7 +444,7 @@ pub fn prepare_build_cmd<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) let &(ref output, ref deps) = &cx.build_explicit_deps[unit]; let local = if deps.is_empty() { - let s = try!(pkg_fingerprint(cx, unit.pkg)); + let s = pkg_fingerprint(cx, unit.pkg)?; LocalFingerprint::Precalculated(s) } else { let deps = deps.iter().map(|p| unit.pkg.root().join(p)); @@ -490,7 +490,7 @@ pub fn prepare_build_cmd<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) let slot = MtimeSlot(Mutex::new(None)); fingerprint.local = LocalFingerprint::MtimeBased(slot, output_path); - try!(fingerprint.update_local()); + fingerprint.update_local()?; } } write_fingerprint(&loc, &fingerprint) @@ -502,9 +502,9 @@ pub fn prepare_build_cmd<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) fn write_fingerprint(loc: &Path, fingerprint: &Fingerprint) -> CargoResult<()> { let hash = fingerprint.hash(); debug!("write fingerprint: {}", loc.display()); - try!(paths::write(&loc, util::to_hex(hash).as_bytes())); - try!(paths::write(&loc.with_extension("json"), - json::encode(&fingerprint).unwrap().as_bytes())); + paths::write(&loc, util::to_hex(hash).as_bytes())?; + paths::write(&loc.with_extension("json"), + json::encode(&fingerprint).unwrap().as_bytes())?; Ok(()) } @@ -514,10 +514,10 @@ pub fn prepare_init(cx: &mut Context, unit: &Unit) -> CargoResult<()> { let new2 = new1.clone(); if fs::metadata(&new1).is_err() { - try!(fs::create_dir(&new1)); + fs::create_dir(&new1)?; } if fs::metadata(&new2).is_err() { - try!(fs::create_dir(&new2)); + fs::create_dir(&new2)?; } Ok(()) } @@ -534,17 +534,17 @@ pub fn dep_info_loc(cx: &Context, unit: &Unit) -> PathBuf { fn compare_old_fingerprint(loc: &Path, new_fingerprint: &Fingerprint) -> CargoResult<()> { - let old_fingerprint_short = try!(paths::read(loc)); + let old_fingerprint_short = paths::read(loc)?; let new_hash = new_fingerprint.hash(); if util::to_hex(new_hash) == old_fingerprint_short { return Ok(()) } - let old_fingerprint_json = try!(paths::read(&loc.with_extension("json"))); - let old_fingerprint = try!(json::decode(&old_fingerprint_json).chain_error(|| { + let old_fingerprint_json = paths::read(&loc.with_extension("json"))?; + let old_fingerprint = json::decode(&old_fingerprint_json).chain_error(|| { internal(format!("failed to deserialize json")) - })); + })?; new_fingerprint.compare(&old_fingerprint) } @@ -575,15 +575,15 @@ fn dep_info_mtime_if_fresh(dep_info: &Path) -> CargoResult> { if fs_try!(f.read_until(0, &mut cwd)) == 0 { return Ok(None) } - let cwd = try!(util::bytes2path(&cwd[..cwd.len()-1])); + let cwd = util::bytes2path(&cwd[..cwd.len()-1])?; let line = match f.lines().next() { Some(Ok(line)) => line, _ => return Ok(None), }; - let pos = try!(line.find(": ").chain_error(|| { + let pos = line.find(": ").chain_error(|| { internal(format!("dep-info not in an understood format: {}", dep_info.display())) - })); + })?; let deps = &line[pos + 2..]; let mut paths = Vec::new(); @@ -596,9 +596,9 @@ fn dep_info_mtime_if_fresh(dep_info: &Path) -> CargoResult> { while file.ends_with("\\") { file.pop(); file.push(' '); - file.push_str(try!(deps.next().chain_error(|| { + file.push_str(deps.next().chain_error(|| { internal(format!("malformed dep-info format, trailing \\")) - }))); + })?); } paths.push(cwd.join(&file)); } @@ -609,9 +609,9 @@ fn dep_info_mtime_if_fresh(dep_info: &Path) -> CargoResult> { fn pkg_fingerprint(cx: &Context, pkg: &Package) -> CargoResult { let source_id = pkg.package_id().source_id(); let sources = cx.packages.sources(); - let source = try!(sources.get(source_id).chain_error(|| { + let source = sources.get(source_id).chain_error(|| { internal("missing package source") - })); + })?; source.fingerprint(pkg) } @@ -676,12 +676,12 @@ fn filename(unit: &Unit) -> String { // next time. pub fn append_current_dir(path: &Path, cwd: &Path) -> CargoResult<()> { debug!("appending {} <- {}", path.display(), cwd.display()); - let mut f = try!(OpenOptions::new().read(true).write(true).open(path)); + let mut f = OpenOptions::new().read(true).write(true).open(path)?; let mut contents = Vec::new(); - try!(f.read_to_end(&mut contents)); - try!(f.seek(SeekFrom::Start(0))); - try!(f.write_all(try!(util::path2bytes(cwd)))); - try!(f.write_all(&[0])); - try!(f.write_all(&contents)); + f.read_to_end(&mut contents)?; + f.seek(SeekFrom::Start(0))?; + f.write_all(util::path2bytes(cwd)?)?; + f.write_all(&[0])?; + f.write_all(&contents)?; Ok(()) } diff --git a/src/cargo/ops/cargo_rustc/job.rs b/src/cargo/ops/cargo_rustc/job.rs index ae7ba303738..219a6d43749 100644 --- a/src/cargo/ops/cargo_rustc/job.rs +++ b/src/cargo/ops/cargo_rustc/job.rs @@ -38,7 +38,7 @@ impl Work { pub fn then(self, next: Work) -> Work { Work::new(move |state| { - try!(self.call(state)); + self.call(state)?; next.call(state) }) } diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 39d1c45a785..e69bd33cd91 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -100,7 +100,7 @@ impl<'a> JobQueue<'a> { job: Job, fresh: Freshness) -> CargoResult<()> { let key = Key::new(unit); - let deps = try!(key.dependencies(cx)); + let deps = key.dependencies(cx)?; self.queue.queue(Fresh, key, Vec::new(), &deps).push((job, fresh)); *self.counts.entry(key.pkg).or_insert(0) += 1; Ok(()) @@ -141,7 +141,7 @@ impl<'a> JobQueue<'a> { while error.is_none() && self.active < self.jobs { if !queue.is_empty() { let (key, job, fresh) = queue.remove(0); - try!(self.run(key, fresh, job, cx.config, scope)); + self.run(key, fresh, job, cx.config, scope)?; } else if let Some((fresh, key, jobs)) = self.queue.dequeue() { let total_fresh = jobs.iter().fold(fresh, |fresh, &(_, f)| { f.combine(fresh) @@ -165,28 +165,28 @@ impl<'a> JobQueue<'a> { match msg { Message::Run(cmd) => { - try!(cx.config.shell().verbose(|c| c.status("Running", &cmd))); + cx.config.shell().verbose(|c| c.status("Running", &cmd))?; } Message::Stdout(out) => { if cx.config.extra_verbose() { - try!(writeln!(cx.config.shell().out(), "{}", out)); + writeln!(cx.config.shell().out(), "{}", out)?; } } Message::Stderr(err) => { if cx.config.extra_verbose() { - try!(writeln!(cx.config.shell().err(), "{}", err)); + writeln!(cx.config.shell().err(), "{}", err)?; } } Message::Finish(result) => { info!("end: {:?}", key); self.active -= 1; match result { - Ok(()) => try!(self.finish(key, cx)), + Ok(()) => self.finish(key, cx)?, Err(e) => { if self.active > 0 { - try!(cx.config.shell().say( + cx.config.shell().say( "Build failed, waiting for other \ - jobs to finish...", YELLOW)); + jobs to finish...", YELLOW)?; } if error.is_none() { error = Some(e); @@ -210,10 +210,10 @@ impl<'a> JobQueue<'a> { duration.subsec_nanos() / 10000000); if self.queue.is_empty() { if !self.is_doc_all { - try!(cx.config.shell().status("Finished", format!("{} [{}] target(s) in {}", + cx.config.shell().status("Finished", format!("{} [{}] target(s) in {}", build_type, opt_type, - time_elapsed))); + time_elapsed))?; } Ok(()) } else if let Some(e) = error { @@ -247,7 +247,7 @@ impl<'a> JobQueue<'a> { }); // Print out some nice progress information - try!(self.note_working_on(config, &key, fresh)); + self.note_working_on(config, &key, fresh)?; Ok(()) } @@ -257,7 +257,7 @@ impl<'a> JobQueue<'a> { let output = cx.build_state.outputs.lock().unwrap(); if let Some(output) = output.get(&(key.pkg.clone(), key.kind)) { for warning in output.warnings.iter() { - try!(cx.config.shell().warn(warning)); + cx.config.shell().warn(warning)?; } } } @@ -293,15 +293,15 @@ impl<'a> JobQueue<'a> { Dirty => { if key.profile.doc { self.documented.insert(key.pkg); - try!(config.shell().status("Documenting", key.pkg)); + config.shell().status("Documenting", key.pkg)?; } else { self.compiled.insert(key.pkg); - try!(config.shell().status("Compiling", key.pkg)); + config.shell().status("Compiling", key.pkg)?; } } Fresh if self.counts[key.pkg] == 0 => { self.compiled.insert(key.pkg); - try!(config.shell().verbose(|c| c.status("Fresh", key.pkg))); + config.shell().verbose(|c| c.status("Fresh", key.pkg))?; } Fresh => {} } @@ -322,12 +322,12 @@ impl<'a> Key<'a> { fn dependencies<'cfg>(&self, cx: &Context<'a, 'cfg>) -> CargoResult>> { let unit = Unit { - pkg: try!(cx.get_package(self.pkg)), + pkg: cx.get_package(self.pkg)?, target: self.target, profile: self.profile, kind: self.kind, }; - let targets = try!(cx.dep_targets(&unit)); + let targets = cx.dep_targets(&unit)?; Ok(targets.iter().filter_map(|unit| { // Binaries aren't actually needed to *compile* tests, just to run // them, so we don't include this dependency edge in the job graph. diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index 18ae026e193..1e371a9517e 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -78,8 +78,8 @@ impl Layout { // the target triple as a Path and then just use the file stem as the // component for the directory name. if let Some(triple) = triple { - path.push(try!(Path::new(triple).file_stem() - .ok_or(human(format!("target was empty"))))); + path.push(Path::new(triple).file_stem() + .ok_or(human(format!("target was empty")))?); } path.push(dest); Layout::at(ws.config(), path) @@ -89,7 +89,7 @@ impl Layout { // For now we don't do any more finer-grained locking on the artifact // directory, so just lock the entire thing for the duration of this // compile. - let lock = try!(root.open_rw(".cargo-lock", config, "build directory")); + let lock = root.open_rw(".cargo-lock", config, "build directory")?; let root = root.into_path_unlocked(); Ok(Layout { @@ -105,20 +105,20 @@ impl Layout { pub fn prepare(&mut self) -> io::Result<()> { if fs::metadata(&self.root).is_err() { - try!(fs::create_dir_all(&self.root)); + fs::create_dir_all(&self.root)?; } - try!(mkdir(&self.deps)); - try!(mkdir(&self.native)); - try!(mkdir(&self.fingerprint)); - try!(mkdir(&self.examples)); - try!(mkdir(&self.build)); + mkdir(&self.deps)?; + mkdir(&self.native)?; + mkdir(&self.fingerprint)?; + mkdir(&self.examples)?; + mkdir(&self.build)?; return Ok(()); fn mkdir(dir: &Path) -> io::Result<()> { if fs::metadata(&dir).is_err() { - try!(fs::create_dir(dir)); + fs::create_dir(dir)?; } Ok(()) } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 6db0bb6f35e..a7aedbe6b75 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -81,15 +81,15 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, }) }).collect::>(); - let mut cx = try!(Context::new(ws, resolve, packages, config, - build_config, profiles)); + let mut cx = Context::new(ws, resolve, packages, config, + build_config, profiles)?; let mut queue = JobQueue::new(&cx); - try!(cx.prepare()); - try!(cx.probe_target_info(&units)); - try!(cx.build_used_in_plugin_map(&units)); - try!(custom_build::build_map(&mut cx, &units)); + cx.prepare()?; + cx.probe_target_info(&units)?; + cx.build_used_in_plugin_map(&units)?; + custom_build::build_map(&mut cx, &units)?; for unit in units.iter() { // Build up a list of pending jobs, each of which represent @@ -97,11 +97,11 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, // part of this, that's all done next as part of the `execute` // function which will run everything in order with proper // parallelism. - try!(compile(&mut cx, &mut queue, unit)); + compile(&mut cx, &mut queue, unit)?; } // Now that we've figured out everything that we're going to do, do it! - try!(queue.execute(&mut cx)); + queue.execute(&mut cx)?; for unit in units.iter() { let out_dir = cx.layout(unit).build_out(unit.pkg) @@ -110,7 +110,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, .or_insert(Vec::new()) .push(("OUT_DIR".to_string(), out_dir)); - for (filename, _linkable) in try!(cx.target_filenames(unit)) { + for (filename, _linkable) in cx.target_filenames(unit)? { let dst = cx.out_dir(unit).join(filename); if unit.profile.test { cx.compilation.tests.push((unit.pkg.clone(), @@ -126,7 +126,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, if !unit.target.is_lib() { continue } // Include immediate lib deps as well - for unit in try!(cx.dep_targets(unit)).iter() { + for unit in cx.dep_targets(unit)?.iter() { let pkgid = unit.pkg.package_id(); if !unit.target.is_lib() { continue } if unit.profile.doc { continue } @@ -134,7 +134,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, continue } - let v = try!(cx.target_filenames(unit)); + let v = cx.target_filenames(unit)?; let v = v.into_iter().map(|(f, _)| { (unit.target.clone(), cx.out_dir(unit).join(f)) }).collect::>(); @@ -173,39 +173,39 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, // we've got everything constructed. let p = profile::start(format!("preparing: {}/{}", unit.pkg, unit.target.name())); - try!(fingerprint::prepare_init(cx, unit)); - try!(cx.links.validate(unit)); + fingerprint::prepare_init(cx, unit)?; + cx.links.validate(unit)?; let (dirty, fresh, freshness) = if unit.profile.run_custom_build { - try!(custom_build::prepare(cx, unit)) + custom_build::prepare(cx, unit)? } else { - let (freshness, dirty, fresh) = try!(fingerprint::prepare_target(cx, - unit)); + let (freshness, dirty, fresh) = fingerprint::prepare_target(cx, + unit)?; let work = if unit.profile.doc { - try!(rustdoc(cx, unit)) + rustdoc(cx, unit)? } else { - try!(rustc(cx, unit)) + rustc(cx, unit)? }; let dirty = work.then(dirty); (dirty, fresh, freshness) }; - try!(jobs.enqueue(cx, unit, Job::new(dirty, fresh), freshness)); + jobs.enqueue(cx, unit, Job::new(dirty, fresh), freshness)?; drop(p); // Be sure to compile all dependencies of this target as well. - for unit in try!(cx.dep_targets(unit)).iter() { - try!(compile(cx, jobs, unit)); + for unit in cx.dep_targets(unit)?.iter() { + compile(cx, jobs, unit)?; } Ok(()) } fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { let crate_types = unit.target.rustc_crate_types(); - let mut rustc = try!(prepare_rustc(cx, crate_types, unit)); + let mut rustc = prepare_rustc(cx, crate_types, unit)?; let name = unit.pkg.name().to_string(); if !cx.show_warnings(unit.pkg.package_id()) { - if try!(cx.config.rustc()).cap_lints { + if cx.config.rustc()?.cap_lints { rustc.arg("--cap-lints").arg("allow"); } else { rustc.arg("-Awarnings"); @@ -213,7 +213,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { } let has_custom_args = unit.profile.rustc_args.is_some(); - let filenames = try!(cx.target_filenames(unit)); + let filenames = cx.target_filenames(unit)?; let root = cx.out_dir(unit); // Prepare the native lib state (extra -L and -l flags) @@ -238,7 +238,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { let dep_info_loc = fingerprint::dep_info_loc(cx, unit); let cwd = cx.config.cwd().to_path_buf(); - rustc.args(&try!(cx.rustflags_args(unit))); + rustc.args(&cx.rustflags_args(unit)?); let json_errors = cx.build_config.json_errors; let package_id = unit.pkg.package_id().clone(); let target = unit.target.clone(); @@ -250,9 +250,9 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { // located somewhere in there. if let Some(build_deps) = build_deps { let build_state = build_state.outputs.lock().unwrap(); - try!(add_native_deps(&mut rustc, &build_state, &build_deps, - pass_l_flag, ¤t_id)); - try!(add_plugin_deps(&mut rustc, &build_state, &build_deps)); + add_native_deps(&mut rustc, &build_state, &build_deps, + pass_l_flag, ¤t_id)?; + add_plugin_deps(&mut rustc, &build_state, &build_deps)?; } // FIXME(rust-lang/rust#18913): we probably shouldn't have to do @@ -260,14 +260,14 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { for &(ref filename, _linkable) in filenames.iter() { let dst = root.join(filename); if fs::metadata(&dst).is_ok() { - try!(fs::remove_file(&dst).chain_error(|| { + fs::remove_file(&dst).chain_error(|| { human(format!("Could not remove file: {}.", dst.display())) - })); + })?; } } state.running(&rustc); - try!(if json_errors { + if json_errors { rustc.exec_with_streaming( &mut |line| if !line.is_empty() { Err(internal(&format!("compiler stdout is not empty: `{}`", line))) @@ -275,9 +275,9 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { Ok(()) }, &mut |line| { - let compiler_message = try!(json::Json::from_str(line).map_err(|_| { + let compiler_message = json::Json::from_str(line).map_err(|_| { internal(&format!("compiler produced invalid json: `{}`", line)) - })); + })?; machine_message::FromCompiler::new( &package_id, @@ -292,7 +292,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { rustc.exec() }.chain_error(|| { human(format!("Could not compile `{}`.", name)) - })); + })?; if do_rename && real_name != crate_name { let dst = root.join(&filenames[0].0); @@ -300,18 +300,18 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { .to_str().unwrap() .replace(&real_name, &crate_name)); if !has_custom_args || src.exists() { - try!(fs::rename(&src, &dst).chain_error(|| { + fs::rename(&src, &dst).chain_error(|| { internal(format!("could not rename crate {:?}", src)) - })); + })?; } } if !has_custom_args || fs::metadata(&rustc_dep_info_loc).is_ok() { - try!(fs::rename(&rustc_dep_info_loc, &dep_info_loc).chain_error(|| { + fs::rename(&rustc_dep_info_loc, &dep_info_loc).chain_error(|| { internal(format!("could not rename dep info: {:?}", rustc_dep_info_loc)) - })); - try!(fingerprint::append_current_dir(&dep_info_loc, &cwd)); + })?; + fingerprint::append_current_dir(&dep_info_loc, &cwd)?; } // If we're a "root crate", e.g. the target of this compilation, then we @@ -337,16 +337,16 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { let dst = src_dir.parent().unwrap() .join(src.file_name().unwrap()); if dst.exists() { - try!(fs::remove_file(&dst).chain_error(|| { + fs::remove_file(&dst).chain_error(|| { human(format!("failed to remove: {}", dst.display())) - })); + })?; } - try!(fs::hard_link(&src, &dst) + fs::hard_link(&src, &dst) .or_else(|_| fs::copy(&src, &dst).map(|_| ())) .chain_error(|| { human(format!("failed to link or copy `{}` to `{}`", src.display(), dst.display())) - })); + })?; } } @@ -361,10 +361,10 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { pass_l_flag: bool, current_id: &PackageId) -> CargoResult<()> { for key in build_scripts.to_link.iter() { - let output = try!(build_state.get(key).chain_error(|| { + let output = build_state.get(key).chain_error(|| { internal(format!("couldn't find build state for {}/{:?}", key.0, key.1)) - })); + })?; for path in output.library_paths.iter() { rustc.arg("-L").arg(path); } @@ -399,14 +399,14 @@ fn add_plugin_deps(rustc: &mut ProcessBuilder, let mut search_path = env::split_paths(&search_path).collect::>(); for id in build_scripts.plugins.iter() { let key = (id.clone(), Kind::Host); - let output = try!(build_state.get(&key).chain_error(|| { + let output = build_state.get(&key).chain_error(|| { internal(format!("couldn't find libs for plugin dep {}", id)) - })); + })?; for path in output.library_paths.iter() { search_path.push(path.clone()); } } - let search_path = try!(join_paths(&search_path, var)); + let search_path = join_paths(&search_path, var)?; rustc.env(var, &search_path); Ok(()) } @@ -414,16 +414,16 @@ fn add_plugin_deps(rustc: &mut ProcessBuilder, fn prepare_rustc(cx: &Context, crate_types: Vec<&str>, unit: &Unit) -> CargoResult { - let mut base = try!(cx.compilation.rustc_process(unit.pkg)); + let mut base = cx.compilation.rustc_process(unit.pkg)?; build_base_args(cx, &mut base, unit, &crate_types); build_plugin_args(&mut base, cx, unit); - try!(build_deps_args(&mut base, cx, unit)); + build_deps_args(&mut base, cx, unit)?; Ok(base) } fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { - let mut rustdoc = try!(cx.compilation.rustdoc_process(unit.pkg)); + let mut rustdoc = cx.compilation.rustdoc_process(unit.pkg)?; rustdoc.arg(&root_path(cx, unit)) .cwd(cx.config.cwd()) .arg("--crate-name").arg(&unit.target.crate_name()); @@ -439,7 +439,7 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { // Create the documentation directory ahead of time as rustdoc currently has // a bug where concurrent invocations will race to create this directory if // it doesn't already exist. - try!(fs::create_dir_all(&doc_dir)); + fs::create_dir_all(&doc_dir)?; rustdoc.arg("-o").arg(doc_dir); @@ -453,13 +453,13 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { rustdoc.args(args); } - try!(build_deps_args(&mut rustdoc, cx, unit)); + build_deps_args(&mut rustdoc, cx, unit)?; if unit.pkg.has_custom_build() { rustdoc.env("OUT_DIR", &cx.layout(unit).build_out(unit.pkg)); } - rustdoc.args(&try!(cx.rustdocflags_args(unit))); + rustdoc.args(&cx.rustdocflags_args(unit)?); let name = unit.pkg.name().to_string(); let build_state = cx.build_state.clone(); @@ -648,9 +648,9 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) cmd.env("OUT_DIR", &layout.build_out(unit.pkg)); } - for unit in try!(cx.dep_targets(unit)).iter() { + for unit in cx.dep_targets(unit)?.iter() { if unit.target.linkable() && !unit.profile.doc { - try!(link_to(cmd, cx, unit)); + link_to(cmd, cx, unit)?; } } @@ -658,7 +658,7 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) fn link_to(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) -> CargoResult<()> { - for (filename, linkable) in try!(cx.target_filenames(unit)) { + for (filename, linkable) in cx.target_filenames(unit)? { if !linkable { continue } diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index f382a1dd128..6c267efb60b 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -14,15 +14,15 @@ pub struct TestOptions<'a> { pub fn run_tests(ws: &Workspace, options: &TestOptions, test_args: &[String]) -> CargoResult> { - let compilation = try!(compile_tests(ws, options)); + let compilation = compile_tests(ws, options)?; if options.no_run { return Ok(None) } let mut errors = if options.only_doc { - try!(run_doc_tests(options, test_args, &compilation)) + run_doc_tests(options, test_args, &compilation)? } else { - try!(run_unit_tests(options, test_args, &compilation)) + run_unit_tests(options, test_args, &compilation)? }; // If we have an error and want to fail fast, return @@ -39,7 +39,7 @@ pub fn run_tests(ws: &Workspace, } } - errors.extend(try!(run_doc_tests(options, test_args, &compilation))); + errors.extend(run_doc_tests(options, test_args, &compilation)?); if errors.is_empty() { Ok(None) } else { @@ -52,12 +52,12 @@ pub fn run_benches(ws: &Workspace, args: &[String]) -> CargoResult> { let mut args = args.to_vec(); args.push("--bench".to_string()); - let compilation = try!(compile_tests(ws, options)); + let compilation = compile_tests(ws, options)?; if options.no_run { return Ok(None) } - let errors = try!(run_unit_tests(options, &args, &compilation)); + let errors = run_unit_tests(options, &args, &compilation)?; match errors.len() { 0 => Ok(None), _ => Ok(Some(CargoTestError::new(errors))), @@ -67,7 +67,7 @@ pub fn run_benches(ws: &Workspace, fn compile_tests<'a>(ws: &Workspace<'a>, options: &TestOptions<'a>) -> CargoResult> { - let mut compilation = try!(ops::compile(ws, &options.compile_opts)); + let mut compilation = ops::compile(ws, &options.compile_opts)?; compilation.tests.sort_by(|a, b| { (a.0.package_id(), &a.1).cmp(&(b.0.package_id(), &b.1)) }); @@ -89,14 +89,14 @@ fn run_unit_tests(options: &TestOptions, Some(path) => path, None => &**exe, }; - let mut cmd = try!(compilation.target_process(exe, pkg)); + let mut cmd = compilation.target_process(exe, pkg)?; cmd.args(test_args); - try!(config.shell().concise(|shell| { + config.shell().concise(|shell| { shell.status("Running", to_display.display().to_string()) - })); - try!(config.shell().verbose(|shell| { + })?; + config.shell().verbose(|shell| { shell.status("Running", cmd.to_string()) - })); + })?; if let Err(e) = cmd.exec() { errors.push(e); @@ -116,7 +116,7 @@ fn run_doc_tests(options: &TestOptions, let config = options.compile_opts.config; // We don't build/rust doctests if target != host - if try!(config.rustc()).host != compilation.target { + if config.rustc()?.host != compilation.target { return Ok(errors); } @@ -127,8 +127,8 @@ fn run_doc_tests(options: &TestOptions, for (package, tests) in libs { for (lib, name, crate_name) in tests { - try!(config.shell().status("Doc-tests", name)); - let mut p = try!(compilation.rustdoc_process(package)); + config.shell().status("Doc-tests", name)?; + let mut p = compilation.rustdoc_process(package)?; p.arg("--test").arg(lib) .arg("--crate-name").arg(&crate_name); @@ -174,9 +174,9 @@ fn run_doc_tests(options: &TestOptions, } } - try!(config.shell().verbose(|shell| { + config.shell().verbose(|shell| { shell.status("Running", p.to_string()) - })); + })?; if let Err(e) = p.exec() { errors.push(e); if !options.no_fail_fast { diff --git a/src/cargo/ops/lockfile.rs b/src/cargo/ops/lockfile.rs index ac9fcbddf31..30eec985a28 100644 --- a/src/cargo/ops/lockfile.rs +++ b/src/cargo/ops/lockfile.rs @@ -14,19 +14,19 @@ pub fn load_pkg_lockfile(ws: &Workspace) -> CargoResult> { } let root = Filesystem::new(ws.root().to_path_buf()); - let mut f = try!(root.open_ro("Cargo.lock", ws.config(), "Cargo.lock file")); + let mut f = root.open_ro("Cargo.lock", ws.config(), "Cargo.lock file")?; let mut s = String::new(); - try!(f.read_to_string(&mut s).chain_error(|| { + f.read_to_string(&mut s).chain_error(|| { human(format!("failed to read file: {}", f.path().display())) - })); + })?; (|| { - let table = try!(cargo_toml::parse(&s, f.path(), ws.config())); + let table = cargo_toml::parse(&s, f.path(), ws.config())?; let table = toml::Value::Table(table); let mut d = toml::Decoder::new(table); - let v: resolver::EncodableResolve = try!(Decodable::decode(&mut d)); - Ok(Some(try!(v.into_resolve(ws)))) + let v: resolver::EncodableResolve = Decodable::decode(&mut d)?; + Ok(Some(v.into_resolve(ws)?)) }).chain_error(|| { human(format!("failed to parse lock file at: {}", f.path().display())) }) @@ -38,7 +38,7 @@ pub fn write_pkg_lockfile(ws: &Workspace, resolve: &Resolve) -> CargoResult<()> let orig = ws_root.open_ro("Cargo.lock", ws.config(), "Cargo.lock file"); let orig = orig.and_then(|mut f| { let mut s = String::new(); - try!(f.read_to_string(&mut s)); + f.read_to_string(&mut s)?; Ok(s) }); @@ -102,8 +102,8 @@ pub fn write_pkg_lockfile(ws: &Workspace, resolve: &Resolve) -> CargoResult<()> // Ok, if that didn't work just write it out ws_root.open_rw("Cargo.lock", ws.config(), "Cargo.lock file").and_then(|mut f| { - try!(f.file().set_len(0)); - try!(f.write_all(out.as_bytes())); + f.file().set_len(0)?; + f.write_all(out.as_bytes())?; Ok(()) }).chain_error(|| { human(format!("failed to write {}", diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 5866242fdab..d937976f867 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -40,32 +40,32 @@ pub struct PublishOpts<'cfg> { } pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> { - let pkg = try!(ws.current()); + let pkg = ws.current()?; if !pkg.publish() { bail!("some crates cannot be published.\n\ `{}` is marked as unpublishable", pkg.name()); } - let (mut registry, reg_id) = try!(registry(opts.config, + let (mut registry, reg_id) = registry(opts.config, opts.token.clone(), - opts.index.clone())); - try!(verify_dependencies(&pkg, ®_id)); + opts.index.clone())?; + verify_dependencies(&pkg, ®_id)?; // Prepare a tarball, with a non-surpressable warning if metadata // is missing since this is being put online. - let tarball = try!(ops::package(ws, &ops::PackageOpts { + let tarball = ops::package(ws, &ops::PackageOpts { config: opts.config, verify: opts.verify, list: false, check_metadata: true, allow_dirty: opts.allow_dirty, jobs: opts.jobs, - })).unwrap(); + })?.unwrap(); // Upload said tarball to the specified destination - try!(opts.config.shell().status("Uploading", pkg.package_id().to_string())); - try!(transmit(opts.config, &pkg, tarball.file(), &mut registry, opts.dry_run)); + opts.config.shell().status("Uploading", pkg.package_id().to_string())?; + transmit(opts.config, &pkg, tarball.file(), &mut registry, opts.dry_run)?; Ok(()) } @@ -114,7 +114,7 @@ fn transmit(config: &Config, ref keywords, ref readme, ref repository, ref license, ref license_file, } = *manifest.metadata(); let readme = match *readme { - Some(ref readme) => Some(try!(paths::read(&pkg.root().join(readme)))), + Some(ref readme) => Some(paths::read(&pkg.root().join(readme))?), None => None, }; match *license_file { @@ -128,7 +128,7 @@ fn transmit(config: &Config, // Do not upload if performing a dry run if dry_run { - try!(config.shell().warn("aborting upload due to dry run")); + config.shell().warn("aborting upload due to dry run")?; return Ok(()); } @@ -152,8 +152,8 @@ fn transmit(config: &Config, } pub fn registry_configuration(config: &Config) -> CargoResult { - let index = try!(config.get_string("registry.index")).map(|p| p.val); - let token = try!(config.get_string("registry.token")).map(|p| p.val); + let index = config.get_string("registry.index")?.map(|p| p.val); + let token = config.get_string("registry.token")?.map(|p| p.val); Ok(RegistryConfig { index: index, token: token }) } @@ -164,20 +164,20 @@ pub fn registry(config: &Config, let RegistryConfig { token: token_config, index: _index_config, - } = try!(registry_configuration(config)); + } = registry_configuration(config)?; let token = token.or(token_config); let sid = match index { - Some(index) => SourceId::for_registry(&try!(index.to_url())), - None => try!(SourceId::crates_io(config)), + Some(index) => SourceId::for_registry(&index.to_url()?), + None => SourceId::crates_io(config)?, }; let api_host = { let mut src = RegistrySource::remote(&sid, config); - try!(src.update().chain_error(|| { + src.update().chain_error(|| { human(format!("failed to update {}", sid)) - })); - (try!(src.config())).unwrap().api + })?; + (src.config()?).unwrap().api }; - let handle = try!(http_handle(config)); + let handle = http_handle(config)?; Ok((Registry::new_handle(api_host, token, handle), sid)) } @@ -193,18 +193,18 @@ pub fn http_handle(config: &Config) -> CargoResult { // connect phase as well as a "low speed" timeout so if we don't receive // many bytes in a large-ish period of time then we time out. let mut handle = Easy::new(); - try!(handle.connect_timeout(Duration::new(30, 0))); - try!(handle.low_speed_limit(10 /* bytes per second */)); - try!(handle.low_speed_time(Duration::new(30, 0))); - if let Some(proxy) = try!(http_proxy(config)) { - try!(handle.proxy(&proxy)); + handle.connect_timeout(Duration::new(30, 0))?; + handle.low_speed_limit(10 /* bytes per second */)?; + handle.low_speed_time(Duration::new(30, 0))?; + if let Some(proxy) = http_proxy(config)? { + handle.proxy(&proxy)?; } - if let Some(cainfo) = try!(config.get_path("http.cainfo")) { - try!(handle.cainfo(&cainfo.val)); + if let Some(cainfo) = config.get_path("http.cainfo")? { + handle.cainfo(&cainfo.val)?; } - if let Some(timeout) = try!(http_timeout(config)) { - try!(handle.connect_timeout(Duration::new(timeout as u64, 0))); - try!(handle.low_speed_time(Duration::new(timeout as u64, 0))); + if let Some(timeout) = http_timeout(config)? { + handle.connect_timeout(Duration::new(timeout as u64, 0))?; + handle.low_speed_time(Duration::new(timeout as u64, 0))?; } Ok(handle) } @@ -214,7 +214,7 @@ pub fn http_handle(config: &Config) -> CargoResult { /// Favor cargo's `http.proxy`, then git's `http.proxy`. Proxies specified /// via environment variables are picked up by libcurl. fn http_proxy(config: &Config) -> CargoResult> { - match try!(config.get_string("http.proxy")) { + match config.get_string("http.proxy")? { Some(s) => return Ok(Some(s.val)), None => {} } @@ -241,7 +241,7 @@ fn http_proxy(config: &Config) -> CargoResult> { /// * https_proxy env var /// * HTTPS_PROXY env var pub fn http_proxy_exists(config: &Config) -> CargoResult { - if try!(http_proxy(config)).is_some() { + if http_proxy(config)?.is_some() { Ok(true) } else { Ok(["http_proxy", "HTTP_PROXY", @@ -250,7 +250,7 @@ pub fn http_proxy_exists(config: &Config) -> CargoResult { } pub fn http_timeout(config: &Config) -> CargoResult> { - match try!(config.get_i64("http.timeout")) { + match config.get_i64("http.timeout")? { Some(s) => return Ok(Some(s.val)), None => {} } @@ -258,7 +258,7 @@ pub fn http_timeout(config: &Config) -> CargoResult> { } pub fn registry_login(config: &Config, token: String) -> CargoResult<()> { - let RegistryConfig { index, token: _ } = try!(registry_configuration(config)); + let RegistryConfig { index, token: _ } = registry_configuration(config)?; let mut map = HashMap::new(); let p = config.cwd().to_path_buf(); match index { @@ -286,23 +286,23 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> { let name = match opts.krate { Some(ref name) => name.clone(), None => { - let manifest_path = try!(find_root_manifest_for_wd(None, config.cwd())); - let pkg = try!(Package::for_path(&manifest_path, config)); + let manifest_path = find_root_manifest_for_wd(None, config.cwd())?; + let pkg = Package::for_path(&manifest_path, config)?; pkg.name().to_string() } }; - let (mut registry, _) = try!(registry(config, opts.token.clone(), - opts.index.clone())); + let (mut registry, _) = registry(config, opts.token.clone(), + opts.index.clone())?; match opts.to_add { Some(ref v) => { let v = v.iter().map(|s| &s[..]).collect::>(); - try!(config.shell().status("Owner", format!("adding {:?} to crate {}", - v, name))); - try!(registry.add_owners(&name, &v).map_err(|e| { + config.shell().status("Owner", format!("adding {:?} to crate {}", + v, name))?; + registry.add_owners(&name, &v).map_err(|e| { human(format!("failed to add owners to crate {}: {}", name, e)) - })); + })?; } None => {} } @@ -310,19 +310,19 @@ pub fn modify_owners(config: &Config, opts: &OwnersOptions) -> CargoResult<()> { match opts.to_remove { Some(ref v) => { let v = v.iter().map(|s| &s[..]).collect::>(); - try!(config.shell().status("Owner", format!("removing {:?} from crate {}", - v, name))); - try!(registry.remove_owners(&name, &v).map_err(|e| { + config.shell().status("Owner", format!("removing {:?} from crate {}", + v, name))?; + registry.remove_owners(&name, &v).map_err(|e| { human(format!("failed to remove owners from crate {}: {}", name, e)) - })); + })?; } None => {} } if opts.list { - let owners = try!(registry.list_owners(&name).map_err(|e| { + let owners = registry.list_owners(&name).map_err(|e| { human(format!("failed to list owners of crate {}: {}", name, e)) - })); + })?; for owner in owners.iter() { print!("{}", owner.login); match (owner.name.as_ref(), owner.email.as_ref()) { @@ -346,8 +346,8 @@ pub fn yank(config: &Config, let name = match krate { Some(name) => name, None => { - let manifest_path = try!(find_root_manifest_for_wd(None, config.cwd())); - let pkg = try!(Package::for_path(&manifest_path, config)); + let manifest_path = find_root_manifest_for_wd(None, config.cwd())?; + let pkg = Package::for_path(&manifest_path, config)?; pkg.name().to_string() } }; @@ -356,18 +356,18 @@ pub fn yank(config: &Config, None => bail!("a version must be specified to yank") }; - let (mut registry, _) = try!(registry(config, token, index)); + let (mut registry, _) = registry(config, token, index)?; if undo { - try!(config.shell().status("Unyank", format!("{}:{}", name, version))); - try!(registry.unyank(&name, &version).map_err(|e| { + config.shell().status("Unyank", format!("{}:{}", name, version))?; + registry.unyank(&name, &version).map_err(|e| { human(format!("failed to undo a yank: {}", e)) - })); + })?; } else { - try!(config.shell().status("Yank", format!("{}:{}", name, version))); - try!(registry.yank(&name, &version).map_err(|e| { + config.shell().status("Yank", format!("{}:{}", name, version))?; + registry.yank(&name, &version).map_err(|e| { human(format!("failed to yank: {}", e)) - })); + })?; } Ok(()) @@ -385,10 +385,10 @@ pub fn search(query: &str, } } - let (mut registry, _) = try!(registry(config, None, index)); - let (crates, total_crates) = try!(registry.search(query, limit).map_err(|e| { + let (mut registry, _) = registry(config, None, index)?; + let (crates, total_crates) = registry.search(query, limit).map_err(|e| { human(format!("failed to retrieve search results from the registry: {}", e)) - })); + })?; let list_items = crates.iter() .map(|krate| ( @@ -411,25 +411,25 @@ pub fn search(query: &str, } None => name }; - try!(config.shell().say(line, BLACK)); + config.shell().say(line, BLACK)?; } let search_max_limit = 100; if total_crates > limit as u32 && limit < search_max_limit { - try!(config.shell().say( + config.shell().say( format!("... and {} crates more (use --limit N to see more)", total_crates - limit as u32), BLACK) - ); + ?; } else if total_crates > limit as u32 && limit >= search_max_limit { - try!(config.shell().say( + config.shell().say( format!( "... and {} crates more (go to http://crates.io/search?q={} to see more)", total_crates - limit as u32, percent_encode(query.as_bytes(), QUERY_ENCODE_SET) ), BLACK) - ); + ?; } Ok(()) diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 87936d3f91d..42898b6afc9 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -13,14 +13,14 @@ use util::CargoResult; /// lockfile. pub fn resolve_ws(registry: &mut PackageRegistry, ws: &Workspace) -> CargoResult { - let prev = try!(ops::load_pkg_lockfile(ws)); - let resolve = try!(resolve_with_previous(registry, ws, + let prev = ops::load_pkg_lockfile(ws)?; + let resolve = resolve_with_previous(registry, ws, Method::Everything, - prev.as_ref(), None, &[])); + prev.as_ref(), None, &[])?; // Avoid writing a lockfile if we are `cargo install`ing a non local package. if ws.current_opt().map(|pkg| pkg.package_id().source_id().is_path()).unwrap_or(true) { - try!(ops::write_pkg_lockfile(ws, &resolve)); + ops::write_pkg_lockfile(ws, &resolve)?; } Ok(resolve) } @@ -88,8 +88,8 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, let mut summaries = Vec::new(); for member in ws.members() { - try!(registry.add_sources(&[member.package_id().source_id() - .clone()])); + registry.add_sources(&[member.package_id().source_id() + .clone()])?; let method_to_resolve = match method { // When everything for a workspace we want to be sure to resolve all // members in the workspace, so propagate the `Method::Everything`. @@ -154,9 +154,9 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, None => root_replace.to_vec(), }; - let mut resolved = try!(resolver::resolve(&summaries, &replace, registry)); + let mut resolved = resolver::resolve(&summaries, &replace, registry)?; if let Some(previous) = previous { - try!(resolved.merge_from(previous)); + resolved.merge_from(previous)?; } return Ok(resolved); diff --git a/src/cargo/sources/config.rs b/src/cargo/sources/config.rs index ac254f147ec..80a13318f65 100644 --- a/src/cargo/sources/config.rs +++ b/src/cargo/sources/config.rs @@ -40,10 +40,10 @@ struct SourceConfig { impl<'cfg> SourceConfigMap<'cfg> { pub fn new(config: &'cfg Config) -> CargoResult> { - let mut base = try!(SourceConfigMap::empty(config)); - if let Some(table) = try!(config.get_table("source")) { + let mut base = SourceConfigMap::empty(config)?; + if let Some(table) = config.get_table("source")? { for (key, value) in table.val.iter() { - try!(base.add_config(key, value)); + base.add_config(key, value)?; } } Ok(base) @@ -56,7 +56,7 @@ impl<'cfg> SourceConfigMap<'cfg> { config: config, }; base.add("crates-io", SourceConfig { - id: try!(SourceId::crates_io(config)), + id: SourceId::crates_io(config)?, replace_with: None, }); Ok(base) @@ -126,40 +126,40 @@ a lock file compatible with `{orig}` cannot be generated in this situation } fn add_config(&mut self, name: &str, cfg: &ConfigValue) -> CargoResult<()> { - let (table, _path) = try!(cfg.table(&format!("source.{}", name))); + let (table, _path) = cfg.table(&format!("source.{}", name))?; let mut srcs = Vec::new(); if let Some(val) = table.get("registry") { - let url = try!(url(val, &format!("source.{}.registry", name))); + let url = url(val, &format!("source.{}.registry", name))?; srcs.push(SourceId::for_registry(&url)); } if let Some(val) = table.get("local-registry") { - let (s, path) = try!(val.string(&format!("source.{}.local-registry", - name))); + let (s, path) = val.string(&format!("source.{}.local-registry", + name))?; let mut path = path.to_path_buf(); path.pop(); path.pop(); path.push(s); - srcs.push(try!(SourceId::for_local_registry(&path))); + srcs.push(SourceId::for_local_registry(&path)?); } if let Some(val) = table.get("directory") { - let (s, path) = try!(val.string(&format!("source.{}.directory", - name))); + let (s, path) = val.string(&format!("source.{}.directory", + name))?; let mut path = path.to_path_buf(); path.pop(); path.pop(); path.push(s); - srcs.push(try!(SourceId::for_directory(&path))); + srcs.push(SourceId::for_directory(&path)?); } if name == "crates-io" && srcs.is_empty() { - srcs.push(try!(SourceId::crates_io(self.config))); + srcs.push(SourceId::crates_io(self.config)?); } let mut srcs = srcs.into_iter(); - let src = try!(srcs.next().chain_error(|| { + let src = srcs.next().chain_error(|| { human(format!("no source URL specified for `source.{}`, need \ either `registry` or `local-registry` defined", name)) - })); + })?; if srcs.next().is_some() { return Err(human(format!("more than one source URL specified for \ `source.{}`", name))) @@ -167,8 +167,8 @@ a lock file compatible with `{orig}` cannot be generated in this situation let mut replace_with = None; if let Some(val) = table.get("replace-with") { - let (s, path) = try!(val.string(&format!("source.{}.replace-with", - name))); + let (s, path) = val.string(&format!("source.{}.replace-with", + name))?; replace_with = Some((s.to_string(), path.to_path_buf())); } @@ -180,7 +180,7 @@ a lock file compatible with `{orig}` cannot be generated in this situation return Ok(()); fn url(cfg: &ConfigValue, key: &str) -> CargoResult { - let (url, path) = try!(cfg.string(key)); + let (url, path) = cfg.string(key)?; url.to_url().chain_error(|| { human(format!("configuration key `{}` specified an invalid \ URL (in {})", key, path.display())) diff --git a/src/cargo/sources/directory.rs b/src/cargo/sources/directory.rs index 84a9501a03b..fc7abf56c73 100644 --- a/src/cargo/sources/directory.rs +++ b/src/cargo/sources/directory.rs @@ -59,34 +59,34 @@ impl<'cfg> Registry for DirectorySource<'cfg> { impl<'cfg> Source for DirectorySource<'cfg> { fn update(&mut self) -> CargoResult<()> { self.packages.clear(); - let entries = try!(self.root.read_dir().chain_error(|| { + let entries = self.root.read_dir().chain_error(|| { human(format!("failed to read root of directory source: {}", self.root.display())) - })); + })?; for entry in entries { - let entry = try!(entry); + let entry = entry?; let path = entry.path(); let mut src = PathSource::new(&path, &self.id, self.config); - try!(src.update()); - let pkg = try!(src.root_package()); + src.update()?; + let pkg = src.root_package()?; let cksum_file = path.join(".cargo-checksum.json"); - let cksum = try!(paths::read(&path.join(cksum_file)).chain_error(|| { + let cksum = paths::read(&path.join(cksum_file)).chain_error(|| { human(format!("failed to load checksum `.cargo-checksum.json` \ of {} v{}", pkg.package_id().name(), pkg.package_id().version())) - })); - let cksum: Checksum = try!(json::decode(&cksum).chain_error(|| { + })?; + let cksum: Checksum = json::decode(&cksum).chain_error(|| { human(format!("failed to decode `.cargo-checksum.json` of \ {} v{}", pkg.package_id().name(), pkg.package_id().version())) - })); + })?; let mut manifest = pkg.manifest().clone(); let summary = manifest.summary().clone(); @@ -120,10 +120,10 @@ impl<'cfg> Source for DirectorySource<'cfg> { let mut h = Sha256::new(); let file = pkg.root().join(file); - try!((|| -> CargoResult<()> { - let mut f = try!(File::open(&file)); + (|| -> CargoResult<()> { + let mut f = File::open(&file)?; loop { - match try!(f.read(&mut buf)) { + match f.read(&mut buf)? { 0 => return Ok(()), n => h.update(&buf[..n]), } @@ -131,7 +131,7 @@ impl<'cfg> Source for DirectorySource<'cfg> { }).chain_error(|| { human(format!("failed to calculate checksum of: {}", file.display())) - })); + })?; let actual = h.finish().to_hex(); if &*actual != cksum { diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index b0f1053ef1d..321fe4dfcd0 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -50,7 +50,7 @@ impl<'cfg> GitSource<'cfg> { pub fn read_packages(&mut self) -> CargoResult> { if self.path_source.is_none() { - try!(self.update()); + self.update()?; } self.path_source.as_mut().unwrap().read_packages() } @@ -104,7 +104,7 @@ pub fn canonicalize_url(url: &Url) -> Url { impl<'cfg> Debug for GitSource<'cfg> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { - try!(write!(f, "git repo at {}", self.remote.url())); + write!(f, "git repo at {}", self.remote.url())?; match self.reference.to_ref_string() { Some(s) => write!(f, " ({})", s), @@ -123,8 +123,8 @@ impl<'cfg> Registry for GitSource<'cfg> { impl<'cfg> Source for GitSource<'cfg> { fn update(&mut self) -> CargoResult<()> { - let lock = try!(self.config.git_path() - .open_rw(".cargo-lock-git", self.config, "the git checkouts")); + let lock = self.config.git_path() + .open_rw(".cargo-lock-git", self.config, "the git checkouts")?; let db_path = lock.parent().join("db").join(&self.ident); @@ -137,16 +137,16 @@ impl<'cfg> Source for GitSource<'cfg> { self.source_id.precise().is_none(); let (repo, actual_rev) = if should_update { - try!(self.config.shell().status("Updating", - format!("git repository `{}`", self.remote.url()))); + self.config.shell().status("Updating", + format!("git repository `{}`", self.remote.url()))?; trace!("updating git source `{:?}`", self.remote); - let repo = try!(self.remote.checkout(&db_path, &self.config)); - let rev = try!(repo.rev_for(&self.reference)); + let repo = self.remote.checkout(&db_path, &self.config)?; + let rev = repo.rev_for(&self.reference)?; (repo, rev) } else { - (try!(self.remote.db_at(&db_path)), actual_rev.unwrap()) + (self.remote.db_at(&db_path)?, actual_rev.unwrap()) }; let checkout_path = lock.parent().join("checkouts") @@ -157,7 +157,7 @@ impl<'cfg> Source for GitSource<'cfg> { // in scope so the destructors here won't tamper with too much. // Checkout is immutable, so we don't need to protect it with a lock once // it is created. - try!(repo.copy_to(actual_rev.clone(), &checkout_path, &self.config)); + repo.copy_to(actual_rev.clone(), &checkout_path, &self.config)?; let source_id = self.source_id.with_precise(Some(actual_rev.to_string())); let path_source = PathSource::new_recursive(&checkout_path, diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index f7dc89d7fba..7452c1dbbf8 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -105,22 +105,22 @@ impl GitRemote { pub fn rev_for(&self, path: &Path, reference: &GitReference) -> CargoResult { - let db = try!(self.db_at(path)); + let db = self.db_at(path)?; db.rev_for(reference) } pub fn checkout(&self, into: &Path, cargo_config: &Config) -> CargoResult { let repo = match git2::Repository::open(into) { Ok(repo) => { - try!(self.fetch_into(&repo, &cargo_config).chain_error(|| { + self.fetch_into(&repo, &cargo_config).chain_error(|| { human(format!("failed to fetch into {}", into.display())) - })); + })?; repo } Err(..) => { - try!(self.clone_into(into, &cargo_config).chain_error(|| { + self.clone_into(into, &cargo_config).chain_error(|| { human(format!("failed to clone into: {}", into.display())) - })) + })? } }; @@ -132,7 +132,7 @@ impl GitRemote { } pub fn db_at(&self, db_path: &Path) -> CargoResult { - let repo = try!(git2::Repository::open(db_path)); + let repo = git2::Repository::open(db_path)?; Ok(GitDatabase { remote: self.clone(), path: db_path.to_path_buf(), @@ -150,11 +150,11 @@ impl GitRemote { fn clone_into(&self, dst: &Path, cargo_config: &Config) -> CargoResult { let url = self.url.to_string(); if fs::metadata(&dst).is_ok() { - try!(fs::remove_dir_all(dst)); + fs::remove_dir_all(dst)?; } - try!(fs::create_dir_all(dst)); - let repo = try!(git2::Repository::init_bare(dst)); - try!(fetch(&repo, &url, "refs/heads/*:refs/heads/*", &cargo_config)); + fs::create_dir_all(dst)?; + let repo = git2::Repository::init_bare(dst)?; + fetch(&repo, &url, "refs/heads/*:refs/heads/*", &cargo_config)?; Ok(repo) } } @@ -170,45 +170,45 @@ impl GitDatabase { Ok(repo) => { let checkout = GitCheckout::new(dest, self, rev, repo); if !checkout.is_fresh() { - try!(checkout.fetch(&cargo_config)); - try!(checkout.reset()); + checkout.fetch(&cargo_config)?; + checkout.reset()?; assert!(checkout.is_fresh()); } checkout } - Err(..) => try!(GitCheckout::clone_into(dest, self, rev)), + Err(..) => GitCheckout::clone_into(dest, self, rev)?, }; - try!(checkout.update_submodules(&cargo_config).chain_error(|| { + checkout.update_submodules(&cargo_config).chain_error(|| { internal("failed to update submodules") - })); + })?; Ok(checkout) } pub fn rev_for(&self, reference: &GitReference) -> CargoResult { let id = match *reference { GitReference::Tag(ref s) => { - try!((|| { + (|| { let refname = format!("refs/tags/{}", s); - let id = try!(self.repo.refname_to_id(&refname)); - let obj = try!(self.repo.find_object(id, None)); - let obj = try!(obj.peel(ObjectType::Commit)); + let id = self.repo.refname_to_id(&refname)?; + let obj = self.repo.find_object(id, None)?; + let obj = obj.peel(ObjectType::Commit)?; Ok(obj.id()) }).chain_error(|| { human(format!("failed to find tag `{}`", s)) - })) + })? } GitReference::Branch(ref s) => { - try!((|| { - let b = try!(self.repo.find_branch(s, git2::BranchType::Local)); + (|| { + let b = self.repo.find_branch(s, git2::BranchType::Local)?; b.get().target().chain_error(|| { human(format!("branch `{}` did not have a target", s)) }) }).chain_error(|| { human(format!("failed to find branch `{}`", s)) - })) + })? } GitReference::Rev(ref s) => { - let obj = try!(self.repo.revparse_single(s)); + let obj = self.repo.revparse_single(s)?; obj.id() } }; @@ -216,7 +216,7 @@ impl GitDatabase { } pub fn has_ref(&self, reference: &str) -> CargoResult<()> { - try!(self.repo.revparse_single(reference)); + self.repo.revparse_single(reference)?; Ok(()) } } @@ -238,31 +238,31 @@ impl<'a> GitCheckout<'a> { revision: GitRevision) -> CargoResult> { - let repo = try!(GitCheckout::clone_repo(database.path(), into)); + let repo = GitCheckout::clone_repo(database.path(), into)?; let checkout = GitCheckout::new(into, database, revision, repo); - try!(checkout.reset()); + checkout.reset()?; Ok(checkout) } fn clone_repo(source: &Path, into: &Path) -> CargoResult { let dirname = into.parent().unwrap(); - try!(fs::create_dir_all(&dirname).chain_error(|| { + fs::create_dir_all(&dirname).chain_error(|| { human(format!("Couldn't mkdir {}", dirname.display())) - })); + })?; if fs::metadata(&into).is_ok() { - try!(fs::remove_dir_all(into).chain_error(|| { + fs::remove_dir_all(into).chain_error(|| { human(format!("Couldn't rmdir {}", into.display())) - })); + })?; } - let url = try!(source.to_url()); + let url = source.to_url()?; let url = url.to_string(); - let repo = try!(git2::Repository::clone(&url, into).chain_error(|| { + let repo = git2::Repository::clone(&url, into).chain_error(|| { internal(format!("failed to clone {} into {}", source.display(), into.display())) - })); + })?; Ok(repo) } @@ -278,10 +278,10 @@ impl<'a> GitCheckout<'a> { fn fetch(&self, cargo_config: &Config) -> CargoResult<()> { info!("fetch {}", self.repo.path().display()); - let url = try!(self.database.path.to_url()); + let url = self.database.path.to_url()?; let url = url.to_string(); let refspec = "refs/heads/*:refs/heads/*"; - try!(fetch(&self.repo, &url, refspec, &cargo_config)); + fetch(&self.repo, &url, refspec, &cargo_config)?; Ok(()) } @@ -297,9 +297,9 @@ impl<'a> GitCheckout<'a> { let ok_file = self.location.join(".cargo-ok"); let _ = fs::remove_file(&ok_file); info!("reset {} to {}", self.repo.path().display(), self.revision); - let object = try!(self.repo.find_object(self.revision.0, None)); - try!(self.repo.reset(&object, git2::ResetType::Hard, None)); - try!(File::create(ok_file)); + let object = self.repo.find_object(self.revision.0, None)?; + self.repo.reset(&object, git2::ResetType::Hard, None)?; + File::create(ok_file)?; Ok(()) } @@ -309,11 +309,11 @@ impl<'a> GitCheckout<'a> { fn update_submodules(repo: &git2::Repository, cargo_config: &Config) -> CargoResult<()> { info!("update submodules for: {:?}", repo.workdir().unwrap()); - for mut child in try!(repo.submodules()).into_iter() { - try!(child.init(false)); - let url = try!(child.url().chain_error(|| { + for mut child in repo.submodules()?.into_iter() { + child.init(false)?; + let url = child.url().chain_error(|| { internal("non-utf8 url for submodule") - })); + })?; // A submodule which is listed in .gitmodules but not actually // checked out will not have a head id, so we should ignore it. @@ -327,7 +327,7 @@ impl<'a> GitCheckout<'a> { // as the submodule's head, then we can bail out and go to the // next submodule. let head_and_repo = child.open().and_then(|repo| { - let target = try!(repo.head()).target(); + let target = repo.head()?.target(); Ok((target, repo)) }); let repo = match head_and_repo { @@ -340,20 +340,20 @@ impl<'a> GitCheckout<'a> { Err(..) => { let path = repo.workdir().unwrap().join(child.path()); let _ = fs::remove_dir_all(&path); - try!(git2::Repository::clone(url, &path)) + git2::Repository::clone(url, &path)? } }; // Fetch data from origin and reset to the head commit let refspec = "refs/heads/*:refs/heads/*"; - try!(fetch(&repo, url, refspec, &cargo_config).chain_error(|| { + fetch(&repo, url, refspec, &cargo_config).chain_error(|| { internal(format!("failed to fetch submodule `{}` from {}", child.name().unwrap_or(""), url)) - })); + })?; - let obj = try!(repo.find_object(head, None)); - try!(repo.reset(&obj, git2::ResetType::Hard, None)); - try!(update_submodules(&repo, &cargo_config)); + let obj = repo.find_object(head, None)?; + repo.reset(&obj, git2::ResetType::Hard, None)?; + update_submodules(&repo, &cargo_config)?; } Ok(()) } @@ -569,19 +569,19 @@ pub fn fetch(repo: &git2::Repository, was specified") } - with_authentication(url, &try!(repo.config()), |f| { + with_authentication(url, &repo.config()?, |f| { let mut cb = git2::RemoteCallbacks::new(); cb.credentials(f); // Create a local anonymous remote in the repository to fetch the url - let mut remote = try!(repo.remote_anonymous(&url)); + let mut remote = repo.remote_anonymous(&url)?; let mut opts = git2::FetchOptions::new(); opts.remote_callbacks(cb) .download_tags(git2::AutotagOption::All); - try!(network::with_retry(config, ||{ + network::with_retry(config, ||{ remote.fetch(&[refspec], Some(&mut opts), None) - })); + })?; Ok(()) }) } diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 052d01c7dab..197d756d66f 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -56,7 +56,7 @@ impl<'cfg> PathSource<'cfg> { pub fn root_package(&mut self) -> CargoResult { trace!("root_package; source={:?}", self); - try!(self.update()); + self.update()?; match self.packages.iter().find(|p| p.root() == &*self.path) { Some(pkg) => Ok(pkg.clone()), @@ -71,8 +71,8 @@ impl<'cfg> PathSource<'cfg> { ops::read_packages(&self.path, &self.id, self.config) } else { let path = self.path.join("Cargo.toml"); - let (pkg, _) = try!(ops::read_package(&path, &self.id, - self.config)); + let (pkg, _) = ops::read_package(&path, &self.id, + self.config)?; Ok(vec![pkg]) } } @@ -94,10 +94,10 @@ impl<'cfg> PathSource<'cfg> { human(format!("could not parse pattern `{}`: {}", p, e)) }) }; - let exclude = try!(pkg.manifest().exclude().iter() - .map(|p| parse(p)).collect::, _>>()); - let include = try!(pkg.manifest().include().iter() - .map(|p| parse(p)).collect::, _>>()); + let exclude = pkg.manifest().exclude().iter() + .map(|p| parse(p)).collect::, _>>()?; + let include = pkg.manifest().include().iter() + .map(|p| parse(p)).collect::, _>>()?; let mut filter = |p: &Path| { let relative_path = util::without_prefix(p, &root).unwrap(); @@ -122,7 +122,7 @@ impl<'cfg> PathSource<'cfg> { // check to see if we are indeed part of the index. If not, then // this is likely an unrelated git repo, so keep going. if let Ok(repo) = git2::Repository::open(cur) { - let index = try!(repo.index()); + let index = repo.index()?; let path = util::without_prefix(root, cur) .unwrap().join("Cargo.toml"); if index.get_path(&path, 0).is_some() { @@ -146,10 +146,10 @@ impl<'cfg> PathSource<'cfg> { filter: &mut FnMut(&Path) -> bool) -> CargoResult> { warn!("list_files_git {}", pkg.package_id()); - let index = try!(repo.index()); - let root = try!(repo.workdir().chain_error(|| { + let index = repo.index()?; + let root = repo.workdir().chain_error(|| { internal_error("Can't list files on a bare repository.", "") - })); + })?; let pkg_path = pkg.root(); let mut ret = Vec::::new(); @@ -171,7 +171,7 @@ impl<'cfg> PathSource<'cfg> { if let Some(suffix) = util::without_prefix(pkg_path, &root) { opts.pathspec(suffix); } - let statuses = try!(repo.statuses(Some(&mut opts))); + let statuses = repo.statuses(Some(&mut opts))?; let untracked = statuses.iter().filter_map(|entry| { match entry.status() { git2::STATUS_WT_NEW => Some((join(&root, entry.path_bytes()), None)), @@ -182,7 +182,7 @@ impl<'cfg> PathSource<'cfg> { let mut subpackages_found = Vec::new(); 'outer: for (file_path, is_dir) in index_files.chain(untracked) { - let file_path = try!(file_path); + let file_path = file_path?; // Filter out files blatantly outside this package. This is helped a // bit obove via the `pathspec` function call, but we need to filter @@ -223,20 +223,20 @@ impl<'cfg> PathSource<'cfg> { if is_dir.unwrap_or_else(|| file_path.is_dir()) { warn!(" found submodule {}", file_path.display()); let rel = util::without_prefix(&file_path, &root).unwrap(); - let rel = try!(rel.to_str().chain_error(|| { + let rel = rel.to_str().chain_error(|| { human(format!("invalid utf-8 filename: {}", rel.display())) - })); + })?; // Git submodules are currently only named through `/` path // separators, explicitly not `\` which windows uses. Who knew? let rel = rel.replace(r"\", "/"); match repo.find_submodule(&rel).and_then(|s| s.open()) { Ok(repo) => { - let files = try!(self.list_files_git(pkg, repo, filter)); + let files = self.list_files_git(pkg, repo, filter)?; ret.extend(files.into_iter()); } Err(..) => { - try!(PathSource::walk(&file_path, &mut ret, false, - filter)); + PathSource::walk(&file_path, &mut ret, false, + filter)?; } } } else if (*filter)(&file_path) { @@ -267,7 +267,7 @@ impl<'cfg> PathSource<'cfg> { fn list_files_walk(&self, pkg: &Package, filter: &mut FnMut(&Path) -> bool) -> CargoResult> { let mut ret = Vec::new(); - try!(PathSource::walk(pkg.root(), &mut ret, true, filter)); + PathSource::walk(pkg.root(), &mut ret, true, filter)?; Ok(ret) } @@ -284,8 +284,8 @@ impl<'cfg> PathSource<'cfg> { if !is_root && fs::metadata(&path.join("Cargo.toml")).is_ok() { return Ok(()) } - for dir in try!(fs::read_dir(path)) { - let dir = try!(dir).path(); + for dir in fs::read_dir(path)? { + let dir = dir?.path(); let name = dir.file_name().and_then(|s| s.to_str()); // Skip dotfile directories if name.map(|s| s.starts_with('.')) == Some(true) { @@ -297,7 +297,7 @@ impl<'cfg> PathSource<'cfg> { _ => {} } } - try!(PathSource::walk(&dir, ret, false, filter)); + PathSource::walk(&dir, ret, false, filter)?; } Ok(()) } @@ -318,7 +318,7 @@ impl<'cfg> Registry for PathSource<'cfg> { impl<'cfg> Source for PathSource<'cfg> { fn update(&mut self) -> CargoResult<()> { if !self.updated { - let packages = try!(self.read_packages()); + let packages = self.read_packages()?; self.packages.extend(packages.into_iter()); self.updated = true; } @@ -342,7 +342,7 @@ impl<'cfg> Source for PathSource<'cfg> { let mut max = FileTime::zero(); let mut max_path = PathBuf::from(""); - for file in try!(self.list_files(pkg)) { + for file in self.list_files(pkg)? { // An fs::stat error here is either because path is a // broken symlink, a permissions error, or a race // condition where this path was rm'ed - either way, diff --git a/src/cargo/sources/registry/index.rs b/src/cargo/sources/registry/index.rs index cda824676d4..86c02802942 100644 --- a/src/cargo/sources/registry/index.rs +++ b/src/cargo/sources/registry/index.rs @@ -41,7 +41,7 @@ impl<'cfg> RegistryIndex<'cfg> { return Ok(s.clone()) } // Ok, we're missing the key, so parse the index file to load it. - try!(self.summaries(pkg.name())); + self.summaries(pkg.name())?; self.hashes.get(&key).chain_error(|| { internal(format!("no hash listed for {}", pkg)) }).map(|s| s.clone()) @@ -55,7 +55,7 @@ impl<'cfg> RegistryIndex<'cfg> { if self.cache.contains_key(name) { return Ok(self.cache.get(name).unwrap()); } - let summaries = try!(self.load_summaries(name)); + let summaries = self.load_summaries(name)?; let summaries = summaries.into_iter().filter(|summary| { summary.0.package_id().name() == name }).collect(); @@ -94,7 +94,7 @@ impl<'cfg> RegistryIndex<'cfg> { match File::open(&path) { Ok(mut f) => { let mut contents = String::new(); - try!(f.read_to_string(&mut contents)); + f.read_to_string(&mut contents)?; let ret: CargoResult>; ret = contents.lines().filter(|l| l.trim().len() > 0) .map(|l| self.parse_registry_package(l)) @@ -116,13 +116,13 @@ impl<'cfg> RegistryIndex<'cfg> { -> CargoResult<(Summary, bool)> { let RegistryPackage { name, vers, cksum, deps, features, yanked - } = try!(json::decode::(line)); - let pkgid = try!(PackageId::new(&name, &vers, &self.source_id)); + } = json::decode::(line)?; + let pkgid = PackageId::new(&name, &vers, &self.source_id)?; let deps: CargoResult> = deps.into_iter().map(|dep| { self.parse_registry_dependency(dep) }).collect(); - let deps = try!(deps); - let summary = try!(Summary::new(pkgid, deps, features)); + let deps = deps?; + let summary = Summary::new(pkgid, deps, features)?; let summary = summary.set_checksum(cksum.clone()); self.hashes.insert((name, vers), cksum); Ok((summary, yanked.unwrap_or(false))) @@ -135,7 +135,7 @@ impl<'cfg> RegistryIndex<'cfg> { name, req, features, optional, default_features, target, kind } = dep; - let dep = try!(DependencyInner::parse(&name, Some(&req), &self.source_id, None)); + let dep = DependencyInner::parse(&name, Some(&req), &self.source_id, None)?; let kind = match kind.as_ref().map(|s| &s[..]).unwrap_or("") { "dev" => Kind::Development, "build" => Kind::Build, @@ -143,7 +143,7 @@ impl<'cfg> RegistryIndex<'cfg> { }; let platform = match target { - Some(target) => Some(try!(target.parse())), + Some(target) => Some(target.parse()?), None => None, }; @@ -166,7 +166,7 @@ impl<'cfg> RegistryIndex<'cfg> { impl<'cfg> Registry for RegistryIndex<'cfg> { fn query(&mut self, dep: &Dependency) -> CargoResult> { let mut summaries = { - let summaries = try!(self.summaries(dep.name())); + let summaries = self.summaries(dep.name())?; summaries.iter().filter(|&&(_, yanked)| { dep.source_id().precise().is_some() || !yanked }).map(|s| s.0.clone()).collect::>() diff --git a/src/cargo/sources/registry/local.rs b/src/cargo/sources/registry/local.rs index 46387bb6841..6c108cd9017 100644 --- a/src/cargo/sources/registry/local.rs +++ b/src/cargo/sources/registry/local.rs @@ -60,9 +60,9 @@ impl<'cfg> RegistryData for LocalRegistry<'cfg> { fn download(&mut self, pkg: &PackageId, checksum: &str) -> CargoResult { let crate_file = format!("{}-{}.crate", pkg.name(), pkg.version()); - let mut crate_file = try!(self.root.open_ro(&crate_file, + let mut crate_file = self.root.open_ro(&crate_file, self.config, - "crate file")); + "crate file")?; // If we've already got an unpacked version of this crate, then skip the // checksum below as it is in theory already verified. @@ -71,16 +71,16 @@ impl<'cfg> RegistryData for LocalRegistry<'cfg> { return Ok(crate_file) } - try!(self.config.shell().status("Unpacking", pkg)); + self.config.shell().status("Unpacking", pkg)?; // We don't actually need to download anything per-se, we just need to // verify the checksum matches the .crate file itself. let mut state = Sha256::new(); let mut buf = [0; 64 * 1024]; loop { - let n = try!(crate_file.read(&mut buf).chain_error(|| { + let n = crate_file.read(&mut buf).chain_error(|| { human(format!("failed to read `{}`", crate_file.path().display())) - })); + })?; if n == 0 { break } @@ -90,7 +90,7 @@ impl<'cfg> RegistryData for LocalRegistry<'cfg> { bail!("failed to verify the checksum of `{}`", pkg) } - try!(crate_file.seek(SeekFrom::Start(0))); + crate_file.seek(SeekFrom::Start(0))?; Ok(crate_file) } diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 13517fc08d5..dd5056be980 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -288,7 +288,7 @@ impl<'cfg> RegistrySource<'cfg> { -> CargoResult { let dst = self.src_path.join(&format!("{}-{}", pkg.name(), pkg.version())); - try!(dst.create_dir()); + dst.create_dir()?; // Note that we've already got the `tarball` locked above, and that // implies a lock on the unpacked destination as well, so this access // via `into_path_unlocked` should be ok. @@ -298,15 +298,15 @@ impl<'cfg> RegistrySource<'cfg> { return Ok(dst) } - let gz = try!(GzDecoder::new(tarball.file())); + let gz = GzDecoder::new(tarball.file())?; let mut tar = Archive::new(gz); - try!(tar.unpack(dst.parent().unwrap())); - try!(File::create(&ok)); + tar.unpack(dst.parent().unwrap())?; + File::create(&ok)?; Ok(dst) } fn do_update(&mut self) -> CargoResult<()> { - try!(self.ops.update_index()); + self.ops.update_index()?; let path = self.ops.index_path(); self.index = index::RegistryIndex::new(&self.source_id, path, @@ -323,8 +323,8 @@ impl<'cfg> Registry for RegistrySource<'cfg> { // come back with no summaries, then our registry may need to be // updated, so we fall back to performing a lazy update. if dep.source_id().precise().is_some() && !self.updated { - if try!(self.index.query(dep)).is_empty() { - try!(self.do_update()); + if self.index.query(dep)?.is_empty() { + self.do_update()?; } } @@ -346,26 +346,26 @@ impl<'cfg> Source for RegistrySource<'cfg> { // `Some("locked")` as other `Some` values indicate a `cargo update // --precise` request if self.source_id.precise() != Some("locked") { - try!(self.do_update()); + self.do_update()?; } Ok(()) } fn download(&mut self, package: &PackageId) -> CargoResult { - let hash = try!(self.index.hash(package)); - let path = try!(self.ops.download(package, &hash)); - let path = try!(self.unpack_package(package, &path).chain_error(|| { + let hash = self.index.hash(package)?; + let path = self.ops.download(package, &hash)?; + let path = self.unpack_package(package, &path).chain_error(|| { internal(format!("failed to unpack package `{}`", package)) - })); + })?; let mut src = PathSource::new(&path, &self.source_id, self.config); - try!(src.update()); - let pkg = try!(src.download(package)); + src.update()?; + let pkg = src.download(package)?; // Unfortunately the index and the actual Cargo.toml in the index can // differ due to historical Cargo bugs. To paper over these we trash the // *summary* loaded from the Cargo.toml we just downloaded with the one // we loaded from the index. - let summaries = try!(self.index.summaries(package.name())); + let summaries = self.index.summaries(package.name())?; let summary = summaries.iter().map(|s| &s.0).find(|s| { s.package_id() == package }).expect("summary not found"); diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index fd301b0b6f7..d4bc144889a 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -44,12 +44,12 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { } fn config(&self) -> CargoResult> { - let lock = try!(self.index_path.open_ro(Path::new(INDEX_LOCK), + let lock = self.index_path.open_ro(Path::new(INDEX_LOCK), self.config, - "the registry index")); + "the registry index")?; let path = lock.path().parent().unwrap(); - let contents = try!(paths::read(&path.join("config.json"))); - let config = try!(json::decode(&contents)); + let contents = paths::read(&path.join("config.json"))?; + let config = json::decode(&contents)?; Ok(Some(config)) } @@ -60,29 +60,29 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { // // This way if there's a problem the error gets printed before we even // hit the index, which may not actually read this configuration. - try!(ops::http_handle(self.config)); + ops::http_handle(self.config)?; // Then we actually update the index - try!(self.index_path.create_dir()); - let lock = try!(self.index_path.open_rw(Path::new(INDEX_LOCK), + self.index_path.create_dir()?; + let lock = self.index_path.open_rw(Path::new(INDEX_LOCK), self.config, - "the registry index")); + "the registry index")?; let path = lock.path().parent().unwrap(); - try!(self.config.shell().status("Updating", - format!("registry `{}`", self.source_id.url()))); + self.config.shell().status("Updating", + format!("registry `{}`", self.source_id.url()))?; - let repo = try!(git2::Repository::open(path).or_else(|_| { + let repo = git2::Repository::open(path).or_else(|_| { let _ = lock.remove_siblings(); git2::Repository::init(path) - })); + })?; if self.source_id.url().host_str() == Some("github.com") { if let Ok(oid) = repo.refname_to_id("refs/heads/master") { let handle = match self.handle { Some(ref mut handle) => handle, None => { - self.handle = Some(try!(ops::http_handle(self.config))); + self.handle = Some(ops::http_handle(self.config)?); self.handle.as_mut().unwrap() } }; @@ -99,16 +99,16 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { let url = self.source_id.url().to_string(); let refspec = "refs/heads/*:refs/remotes/origin/*"; - try!(git::fetch(&repo, &url, refspec, &self.config).chain_error(|| { + git::fetch(&repo, &url, refspec, &self.config).chain_error(|| { human(format!("failed to fetch `{}`", url)) - })); + })?; // git reset --hard origin/master let reference = "refs/remotes/origin/master"; - let oid = try!(repo.refname_to_id(reference)); + let oid = repo.refname_to_id(reference)?; trace!("[{}] updating to rev {}", self.source_id, oid); - let object = try!(repo.find_object(oid, None)); - try!(repo.reset(&object, git2::ResetType::Hard, None)); + let object = repo.find_object(oid, None)?; + repo.reset(&object, git2::ResetType::Hard, None)?; Ok(()) } @@ -124,20 +124,20 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { // If this fails then we fall through to the exclusive path where we may // have to redownload the file. if let Ok(dst) = self.cache_path.open_ro(path, self.config, &filename) { - let meta = try!(dst.file().metadata()); + let meta = dst.file().metadata()?; if meta.len() > 0 { return Ok(dst) } } - let mut dst = try!(self.cache_path.open_rw(path, self.config, &filename)); - let meta = try!(dst.file().metadata()); + let mut dst = self.cache_path.open_rw(path, self.config, &filename)?; + let meta = dst.file().metadata()?; if meta.len() > 0 { return Ok(dst) } - try!(self.config.shell().status("Downloading", pkg)); + self.config.shell().status("Downloading", pkg)?; - let config = try!(self.config()).unwrap(); - let mut url = try!(config.dl.to_url()); + let config = self.config()?.unwrap(); + let mut url = config.dl.to_url()?; url.path_segments_mut().unwrap() .push(pkg.name()) .push(&pkg.version().to_string()) @@ -146,30 +146,30 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { let handle = match self.handle { Some(ref mut handle) => handle, None => { - self.handle = Some(try!(ops::http_handle(self.config))); + self.handle = Some(ops::http_handle(self.config)?); self.handle.as_mut().unwrap() } }; // TODO: don't download into memory, but ensure that if we ctrl-c a // download we should resume either from the start or the middle // on the next time - try!(handle.get(true)); - try!(handle.url(&url.to_string())); - try!(handle.follow_location(true)); + handle.get(true)?; + handle.url(&url.to_string())?; + handle.follow_location(true)?; let mut state = Sha256::new(); let mut body = Vec::new(); { let mut handle = handle.transfer(); - try!(handle.write_function(|buf| { + handle.write_function(|buf| { state.update(buf); body.extend_from_slice(buf); Ok(buf.len()) - })); - try!(network::with_retry(self.config, || { + })?; + network::with_retry(self.config, || { handle.perform() - })) + })? } - let code = try!(handle.response_code()); + let code = handle.response_code()?; if code != 200 && code != 0 { bail!("failed to get 200 response from `{}`, got {}", url, code) } @@ -179,8 +179,8 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { bail!("failed to verify the checksum of `{}`", pkg) } - try!(dst.write_all(&body)); - try!(dst.seek(SeekFrom::Start(0))); + dst.write_all(&body)?; + dst.seek(SeekFrom::Start(0))?; Ok(dst) } } diff --git a/src/cargo/sources/replaced.rs b/src/cargo/sources/replaced.rs index 7fb95bdf6c8..e164a1c7cf9 100644 --- a/src/cargo/sources/replaced.rs +++ b/src/cargo/sources/replaced.rs @@ -22,10 +22,10 @@ impl<'cfg> ReplacedSource<'cfg> { impl<'cfg> Registry for ReplacedSource<'cfg> { fn query(&mut self, dep: &Dependency) -> CargoResult> { let dep = dep.clone().map_source(&self.to_replace, &self.replace_with); - let ret = try!(self.inner.query(&dep).chain_error(|| { + let ret = self.inner.query(&dep).chain_error(|| { human(format!("failed to query replaced source `{}`", self.to_replace)) - })); + })?; Ok(ret.into_iter().map(|summary| { summary.map_source(&self.replace_with, &self.to_replace) }).collect()) @@ -42,10 +42,10 @@ impl<'cfg> Source for ReplacedSource<'cfg> { fn download(&mut self, id: &PackageId) -> CargoResult { let id = id.with_source_id(&self.replace_with); - let pkg = try!(self.inner.download(&id).chain_error(|| { + let pkg = self.inner.download(&id).chain_error(|| { human(format!("failed to download replaced source `{}`", self.to_replace)) - })); + })?; Ok(pkg.map_source(&self.replace_with, &self.to_replace)) } diff --git a/src/cargo/util/cfg.rs b/src/cargo/util/cfg.rs index fbdfb919eed..bd89586bc38 100644 --- a/src/cargo/util/cfg.rs +++ b/src/cargo/util/cfg.rs @@ -42,7 +42,7 @@ impl FromStr for Cfg { fn from_str(s: &str) -> CargoResult { let mut p = Parser::new(s); - let e = try!(p.cfg()); + let e = p.cfg()?; if p.t.next().is_some() { bail!("malformed cfg value or key/value pair") } @@ -75,7 +75,7 @@ impl FromStr for CfgExpr { fn from_str(s: &str) -> CargoResult { let mut p = Parser::new(s); - let e = try!(p.expr()); + let e = p.expr()?; if p.t.next().is_some() { bail!("can only have one cfg-expression, consider using all() or \ any() explicitly") @@ -101,9 +101,9 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { for (i, v) in self.0.iter().enumerate() { if i > 0 { - try!(write!(f, ", ")); + write!(f, ", ")?; } - try!(write!(f, "{}", v)); + write!(f, "{}", v)?; } Ok(()) } @@ -125,11 +125,11 @@ impl<'a> Parser<'a> { Some(&Ok(Token::Ident(op @ "any"))) => { self.t.next(); let mut e = Vec::new(); - try!(self.eat(Token::LeftParen)); + self.eat(Token::LeftParen)?; while !self.try(Token::RightParen) { - e.push(try!(self.expr())); + e.push(self.expr()?); if !self.try(Token::Comma) { - try!(self.eat(Token::RightParen)); + self.eat(Token::RightParen)?; break } } @@ -141,9 +141,9 @@ impl<'a> Parser<'a> { } Some(&Ok(Token::Ident("not"))) => { self.t.next(); - try!(self.eat(Token::LeftParen)); - let e = try!(self.expr()); - try!(self.eat(Token::RightParen)); + self.eat(Token::LeftParen)?; + let e = self.expr()?; + self.eat(Token::RightParen)?; Ok(CfgExpr::Not(Box::new(e))) } Some(&Ok(..)) => self.cfg().map(CfgExpr::Value), diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index e9988fe9496..dc97acc0aac 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -53,13 +53,13 @@ impl Config { pub fn default() -> CargoResult { let shell = ::shell(Verbosity::Verbose, ColorConfig::Auto); - let cwd = try!(env::current_dir().chain_error(|| { + let cwd = env::current_dir().chain_error(|| { human("couldn't get the current directory of the process") - })); - let homedir = try!(homedir(&cwd).chain_error(|| { + })?; + let homedir = homedir(&cwd).chain_error(|| { human("Cargo couldn't find your home directory. \ This probably means that $HOME was not set.") - })); + })?; Ok(Config::new(shell, cwd, homedir)) } @@ -90,7 +90,7 @@ impl Config { } pub fn rustc(&self) -> CargoResult<&Rustc> { - self.rustc.get_or_try_init(|| Rustc::new(try!(self.get_tool("rustc")))) + self.rustc.get_or_try_init(|| Rustc::new(self.get_tool("rustc")?)) } pub fn values(&self) -> CargoResult<&HashMap> { @@ -102,7 +102,7 @@ impl Config { pub fn target_dir(&self) -> CargoResult> { if let Some(dir) = env::var_os("CARGO_TARGET_DIR") { Ok(Some(Filesystem::new(self.cwd.join(dir)))) - } else if let Some(val) = try!(self.get_path("build.target-dir")) { + } else if let Some(val) = self.get_path("build.target-dir")? { let val = self.cwd.join(val.val); Ok(Some(Filesystem::new(val))) } else { @@ -111,7 +111,7 @@ impl Config { } fn get(&self, key: &str) -> CargoResult> { - let vals = try!(self.values()); + let vals = self.values()?; let mut parts = key.split('.').enumerate(); let mut val = match vals.get(parts.next().unwrap().1) { Some(val) => val, @@ -152,7 +152,7 @@ impl Config { match env::var(&format!("CARGO_{}", key)) { Ok(value) => { Ok(Some(Value { - val: try!(value.parse()), + val: value.parse()?, definition: Definition::Environment, })) } @@ -161,10 +161,10 @@ impl Config { } pub fn get_string(&self, key: &str) -> CargoResult>> { - if let Some(v) = try!(self.get_env(key)) { + if let Some(v) = self.get_env(key)? { return Ok(Some(v)) } - match try!(self.get(key)) { + match self.get(key)? { Some(CV::String(i, path)) => { Ok(Some(Value { val: i, @@ -177,10 +177,10 @@ impl Config { } pub fn get_bool(&self, key: &str) -> CargoResult>> { - if let Some(v) = try!(self.get_env(key)) { + if let Some(v) = self.get_env(key)? { return Ok(Some(v)) } - match try!(self.get(key)) { + match self.get(key)? { Some(CV::Boolean(b, path)) => { Ok(Some(Value { val: b, @@ -193,7 +193,7 @@ impl Config { } pub fn get_path(&self, key: &str) -> CargoResult>> { - if let Some(val) = try!(self.get_string(&key)) { + if let Some(val) = self.get_string(&key)? { let is_path = val.val.contains('/') || (cfg!(windows) && val.val.contains('\\')); let path = if is_path { @@ -213,7 +213,7 @@ impl Config { pub fn get_list(&self, key: &str) -> CargoResult>>> { - match try!(self.get(key)) { + match self.get(key)? { Some(CV::List(i, path)) => { Ok(Some(Value { val: i, @@ -227,7 +227,7 @@ impl Config { pub fn get_table(&self, key: &str) -> CargoResult>>> { - match try!(self.get(key)) { + match self.get(key)? { Some(CV::Table(i, path)) => { Ok(Some(Value { val: i, @@ -240,10 +240,10 @@ impl Config { } pub fn get_i64(&self, key: &str) -> CargoResult>> { - if let Some(v) = try!(self.get_env(key)) { + if let Some(v) = self.get_env(key)? { return Ok(Some(v)) } - match try!(self.get(key)) { + match self.get(key)? { Some(CV::Integer(i, path)) => { Ok(Some(Value { val: i, @@ -256,7 +256,7 @@ impl Config { } pub fn net_retry(&self) -> CargoResult { - match try!(self.get_i64("net.retry")) { + match self.get_i64("net.retry")? { Some(v) => { let value = v.val; if value < 0 { @@ -316,7 +316,7 @@ impl Config { }; self.shell().set_verbosity(verbosity); - try!(self.shell().set_color_config(color.map(|s| &s[..]))); + self.shell().set_color_config(color.map(|s| &s[..]))?; self.extra_verbose.set(extra_verbose); self.frozen.set(frozen); self.locked.set(locked); @@ -339,23 +339,23 @@ impl Config { fn load_values(&self) -> CargoResult> { let mut cfg = CV::Table(HashMap::new(), PathBuf::from(".")); - try!(walk_tree(&self.cwd, |mut file, path| { + walk_tree(&self.cwd, |mut file, path| { let mut contents = String::new(); - try!(file.read_to_string(&mut contents)); - let table = try!(cargo_toml::parse(&contents, + file.read_to_string(&mut contents)?; + let table = cargo_toml::parse(&contents, &path, self).chain_error(|| { human(format!("could not parse TOML configuration in `{}`", path.display())) - })); + })?; let toml = toml::Value::Table(table); - let value = try!(CV::from_toml(&path, toml).chain_error(|| { + let value = CV::from_toml(&path, toml).chain_error(|| { human(format!("failed to load TOML configuration from `{}`", path.display())) - })); - try!(cfg.merge(value)); + })?; + cfg.merge(value)?; Ok(()) - }).chain_error(|| human("Couldn't load Cargo configuration"))); + }).chain_error(|| human("Couldn't load Cargo configuration"))?; match cfg { @@ -371,7 +371,7 @@ impl Config { } let var = format!("build.{}", tool); - if let Some(tool_path) = try!(self.get_path(&var)) { + if let Some(tool_path) = self.get_path(&var)? { return Ok(tool_path.val); } @@ -414,10 +414,10 @@ impl fmt::Debug for ConfigValue { CV::String(ref s, ref path) => write!(f, "{} (from {})", s, path.display()), CV::List(ref list, ref path) => { - try!(write!(f, "[")); + write!(f, "[")?; for (i, &(ref s, ref path)) in list.iter().enumerate() { - if i > 0 { try!(write!(f, ", ")); } - try!(write!(f, "{} (from {})", s, path.display())); + if i > 0 { write!(f, ", ")?; } + write!(f, "{} (from {})", s, path.display())?; } write!(f, "] (from {})", path.display()) } @@ -448,21 +448,21 @@ impl ConfigValue { toml::Value::Boolean(b) => Ok(CV::Boolean(b, path.to_path_buf())), toml::Value::Integer(i) => Ok(CV::Integer(i, path.to_path_buf())), toml::Value::Array(val) => { - Ok(CV::List(try!(val.into_iter().map(|toml| { + Ok(CV::List(val.into_iter().map(|toml| { match toml { toml::Value::String(val) => Ok((val, path.to_path_buf())), v => Err(human(format!("expected string but found {} \ in list", v.type_str()))), } - }).collect::>()), path.to_path_buf())) + }).collect::>()?, path.to_path_buf())) } toml::Value::Table(val) => { - Ok(CV::Table(try!(val.into_iter().map(|(key, value)| { - let value = try!(CV::from_toml(path, value).chain_error(|| { + Ok(CV::Table(val.into_iter().map(|(key, value)| { + let value = CV::from_toml(path, value).chain_error(|| { human(format!("failed to parse key `{}`", key)) - })); + })?; Ok((key, value)) - }).collect::>()), path.to_path_buf())) + }).collect::>()?, path.to_path_buf())) } v => bail!("found TOML configuration value of unknown type `{}`", v.type_str()), @@ -485,7 +485,7 @@ impl ConfigValue { Occupied(mut entry) => { let path = value.definition_path().to_path_buf(); let entry = entry.get_mut(); - try!(entry.merge(value).chain_error(|| { + entry.merge(value).chain_error(|| { human(format!("failed to merge key `{}` between \ files:\n \ file 1: {}\n \ @@ -494,7 +494,7 @@ impl ConfigValue { entry.definition_path().display(), path.display())) - })); + })?; } Vacant(entry) => { entry.insert(value); } }; @@ -664,9 +664,9 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> loop { let possible = current.join(".cargo").join("config"); if fs::metadata(&possible).is_ok() { - let file = try!(File::open(&possible)); + let file = File::open(&possible)?; - try!(walk(file, &possible)); + walk(file, &possible)?; stash.insert(possible); } @@ -680,14 +680,14 @@ fn walk_tree(pwd: &Path, mut walk: F) -> CargoResult<()> // Once we're done, also be sure to walk the home directory even if it's not // in our history to be sure we pick up that standard location for // information. - let home = try!(homedir(pwd).chain_error(|| { + let home = homedir(pwd).chain_error(|| { human("Cargo couldn't find your home directory. \ This probably means that $HOME was not set.") - })); + })?; let config = home.join("config"); if !stash.contains(&config) && fs::metadata(&config).is_ok() { - let file = try!(File::open(&config)); - try!(walk(file, &config)); + let file = File::open(&config)?; + walk(file, &config)?; } Ok(()) @@ -704,20 +704,20 @@ pub fn set_config(cfg: &Config, // 3. This blows away the previous ordering of a file. let mut file = match loc { Location::Global => { - try!(cfg.home_path.create_dir()); - try!(cfg.home_path.open_rw(Path::new("config"), cfg, - "the global config file")) + cfg.home_path.create_dir()?; + cfg.home_path.open_rw(Path::new("config"), cfg, + "the global config file")? } Location::Project => unimplemented!(), }; let mut contents = String::new(); let _ = file.read_to_string(&mut contents); - let mut toml = try!(cargo_toml::parse(&contents, file.path(), cfg)); + let mut toml = cargo_toml::parse(&contents, file.path(), cfg)?; toml.insert(key.to_string(), value.into_toml()); let contents = toml::Value::Table(toml).to_string(); - try!(file.seek(SeekFrom::Start(0))); - try!(file.write_all(contents.as_bytes())); - try!(file.file().set_len(contents.len() as u64)); + file.seek(SeekFrom::Start(0))?; + file.write_all(contents.as_bytes())?; + file.file().set_len(contents.len() as u64)?; Ok(()) } diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 0f1bfe9efb4..853b8bef9d5 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -190,9 +190,9 @@ struct ConcreteCargoError { impl fmt::Display for ConcreteCargoError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "{}", self.description)); + write!(f, "{}", self.description)?; if let Some(ref s) = self.detail { - try!(write!(f, " ({})", s)); + write!(f, " ({})", s)?; } Ok(()) } diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index f90fa596f28..a6f90afc335 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -50,16 +50,16 @@ impl FileLock { /// needs to be cleared out as it may be corrupt. pub fn remove_siblings(&self) -> io::Result<()> { let path = self.path(); - for entry in try!(path.parent().unwrap().read_dir()) { - let entry = try!(entry); + for entry in path.parent().unwrap().read_dir()? { + let entry = entry?; if Some(&entry.file_name()[..]) == path.file_name() { continue } - let kind = try!(entry.file_type()); + let kind = entry.file_type()?; if kind.is_dir() { - try!(fs::remove_dir_all(entry.path())); + fs::remove_dir_all(entry.path())?; } else { - try!(fs::remove_file(entry.path())); + fs::remove_file(entry.path())?; } } Ok(()) @@ -204,26 +204,26 @@ impl Filesystem { // If we want an exclusive lock then if we fail because of NotFound it's // likely because an intermediate directory didn't exist, so try to // create the directory and then continue. - let f = try!(opts.open(&path).or_else(|e| { + let f = opts.open(&path).or_else(|e| { if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive { - try!(create_dir_all(path.parent().unwrap())); + create_dir_all(path.parent().unwrap())?; opts.open(&path) } else { Err(e) } }).chain_error(|| { human(format!("failed to open: {}", path.display())) - })); + })?; match state { State::Exclusive => { - try!(acquire(config, msg, &path, + acquire(config, msg, &path, &|| f.try_lock_exclusive(), - &|| f.lock_exclusive())); + &|| f.lock_exclusive())?; } State::Shared => { - try!(acquire(config, msg, &path, + acquire(config, msg, &path, &|| f.try_lock_shared(), - &|| f.lock_shared())); + &|| f.lock_shared())?; } State::Unlocked => {} @@ -285,7 +285,7 @@ fn acquire(config: &Config, } } let msg = format!("waiting for file lock on {}", msg); - try!(config.shell().err().say_status("Blocking", &msg, CYAN, true)); + config.shell().err().say_status("Blocking", &msg, CYAN, true)?; return block().chain_error(|| { human(format!("failed to lock file: {}", path.display())) diff --git a/src/cargo/util/graph.rs b/src/cargo/util/graph.rs index cc0414f6188..6543c8f9179 100644 --- a/src/cargo/util/graph.rs +++ b/src/cargo/util/graph.rs @@ -69,17 +69,17 @@ impl Graph { impl fmt::Debug for Graph { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(writeln!(fmt, "Graph {{")); + writeln!(fmt, "Graph {{")?; for (n, e) in self.nodes.iter() { - try!(writeln!(fmt, " - {}", n)); + writeln!(fmt, " - {}", n)?; for n in e.iter() { - try!(writeln!(fmt, " - {}", n)); + writeln!(fmt, " - {}", n)?; } } - try!(write!(fmt, "}}")); + write!(fmt, "}}")?; Ok(()) } diff --git a/src/cargo/util/lazy_cell.rs b/src/cargo/util/lazy_cell.rs index 3cdaa641692..fc751dc3cf2 100644 --- a/src/cargo/util/lazy_cell.rs +++ b/src/cargo/util/lazy_cell.rs @@ -58,7 +58,7 @@ impl LazyCell { where F: FnOnce() -> Result { if self.borrow().is_none() { - if let Err(_) = self.fill(try!(init())) { + if let Err(_) = self.fill(init()?) { unreachable!(); } } diff --git a/src/cargo/util/network.rs b/src/cargo/util/network.rs index a53d04d2841..4bc12b7b4e6 100644 --- a/src/cargo/util/network.rs +++ b/src/cargo/util/network.rs @@ -14,14 +14,14 @@ pub fn with_retry(config: &Config, mut callback: F) -> CargoResult where F: FnMut() -> Result, E: errors::NetworkError { - let mut remaining = try!(config.net_retry()); + let mut remaining = config.net_retry()?; loop { match callback() { Ok(ret) => return Ok(ret), Err(ref e) if e.maybe_spurious() && remaining > 0 => { let msg = format!("spurious network error ({} tries \ remaining): {}", remaining, e); - try!(config.shell().warn(msg)); + config.shell().warn(msg)?; remaining -= 1; } Err(e) => return Err(Box::new(e)), diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 8444c3fd209..23a42a84c70 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -70,8 +70,8 @@ pub fn without_prefix<'a>(a: &'a Path, b: &'a Path) -> Option<&'a Path> { pub fn read(path: &Path) -> CargoResult { (|| -> CargoResult<_> { let mut ret = String::new(); - let mut f = try!(File::open(path)); - try!(f.read_to_string(&mut ret)); + let mut f = File::open(path)?; + f.read_to_string(&mut ret)?; Ok(ret) })().map_err(human).chain_error(|| { human(format!("failed to read `{}`", path.display())) @@ -81,8 +81,8 @@ pub fn read(path: &Path) -> CargoResult { pub fn read_bytes(path: &Path) -> CargoResult> { (|| -> CargoResult<_> { let mut ret = Vec::new(); - let mut f = try!(File::open(path)); - try!(f.read_to_end(&mut ret)); + let mut f = File::open(path)?; + f.read_to_end(&mut ret)?; Ok(ret) })().map_err(human).chain_error(|| { human(format!("failed to read `{}`", path.display())) @@ -91,8 +91,8 @@ pub fn read_bytes(path: &Path) -> CargoResult> { pub fn write(path: &Path, contents: &[u8]) -> CargoResult<()> { (|| -> CargoResult<()> { - let mut f = try!(File::create(path)); - try!(f.write_all(contents)); + let mut f = File::create(path)?; + f.write_all(contents)?; Ok(()) })().map_err(human).chain_error(|| { human(format!("failed to write `{}`", path.display())) @@ -101,13 +101,13 @@ pub fn write(path: &Path, contents: &[u8]) -> CargoResult<()> { pub fn append(path: &Path, contents: &[u8]) -> CargoResult<()> { (|| -> CargoResult<()> { - let mut f = try!(OpenOptions::new() + let mut f = OpenOptions::new() .write(true) .append(true) .create(true) - .open(path)); + .open(path)?; - try!(f.write_all(contents)); + f.write_all(contents)?; Ok(()) }).chain_error(|| { internal(format!("failed to write `{}`", path.display())) diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index b66b26ec0a4..ed92321896e 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -18,10 +18,10 @@ pub struct ProcessBuilder { impl fmt::Display for ProcessBuilder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "`{}", self.program.to_string_lossy())); + write!(f, "`{}", self.program.to_string_lossy())?; for arg in self.args.iter() { - try!(write!(f, " {}", escape(arg.to_string_lossy()))); + write!(f, " {}", escape(arg.to_string_lossy()))?; } write!(f, "`") @@ -74,11 +74,11 @@ impl ProcessBuilder { pub fn exec(&self) -> Result<(), ProcessError> { let mut command = self.build_command(); - let exit = try!(command.status().map_err(|e| { + let exit = command.status().map_err(|e| { process_error(&format!("could not execute process `{}`", self.debug_string()), Some(Box::new(e)), None, None) - })); + })?; if exit.success() { Ok(()) @@ -108,11 +108,11 @@ impl ProcessBuilder { pub fn exec_with_output(&self) -> Result { let mut command = self.build_command(); - let output = try!(command.output().map_err(|e| { + let output = command.output().map_err(|e| { process_error(&format!("could not execute process `{}`", self.debug_string()), Some(Box::new(e)), None, None) - })); + })?; if output.status.success() { Ok(output) @@ -136,11 +136,11 @@ impl ProcessBuilder { .stdin(Stdio::null()); let mut callback_error = None; - let status = try!((|| { - let mut child = try!(cmd.spawn()); + let status = (|| { + let mut child = cmd.spawn()?; let out = child.stdout.take().unwrap(); let err = child.stderr.take().unwrap(); - try!(read2(out, err, &mut |is_out, data, eof| { + read2(out, err, &mut |is_out, data, eof| { let idx = if eof { data.len() } else { @@ -164,13 +164,13 @@ impl ProcessBuilder { callback_error = Some(e); } } - })); + })?; child.wait() })().map_err(|e| { process_error(&format!("could not execute process `{}`", self.debug_string()), Some(Box::new(e)), None, None) - })); + })?; let output = Output { stdout: stdout, stderr: stderr, diff --git a/src/cargo/util/read2.rs b/src/cargo/util/read2.rs index 4596b260a13..7eac02783f8 100644 --- a/src/cargo/util/read2.rs +++ b/src/cargo/util/read2.rs @@ -62,11 +62,11 @@ mod imp { } } }; - if !out_done && try!(handle(out_pipe.read_to_end(&mut out))) { + if !out_done && handle(out_pipe.read_to_end(&mut out))? { out_done = true; } data(true, &mut out, out_done); - if !err_done && try!(handle(err_pipe.read_to_end(&mut err))) { + if !err_done && handle(err_pipe.read_to_end(&mut err))? { err_done = true; } data(false, &mut err, err_done); @@ -116,29 +116,29 @@ mod imp { let mut out = Vec::new(); let mut err = Vec::new(); - let port = try!(CompletionPort::new(1)); - try!(port.add_handle(0, &out_pipe)); - try!(port.add_handle(1, &err_pipe)); + let port = CompletionPort::new(1)?; + port.add_handle(0, &out_pipe)?; + port.add_handle(1, &err_pipe)?; unsafe { let mut out_pipe = Pipe::new(out_pipe, &mut out); let mut err_pipe = Pipe::new(err_pipe, &mut err); - try!(out_pipe.read()); - try!(err_pipe.read()); + out_pipe.read()?; + err_pipe.read()?; let mut status = [CompletionStatus::zero(), CompletionStatus::zero()]; while !out_pipe.done || !err_pipe.done { - for status in try!(port.get_many(&mut status, None)) { + for status in port.get_many(&mut status, None)? { if status.token() == 0 { out_pipe.complete(status); data(true, out_pipe.dst, out_pipe.done); - try!(out_pipe.read()); + out_pipe.read()?; } else { err_pipe.complete(status); data(false, err_pipe.dst, err_pipe.done); - try!(err_pipe.read()); + err_pipe.read()?; } } } diff --git a/src/cargo/util/rustc.rs b/src/cargo/util/rustc.rs index 59a6e17e1fe..954f6d88d95 100644 --- a/src/cargo/util/rustc.rs +++ b/src/cargo/util/rustc.rs @@ -25,20 +25,20 @@ impl Rustc { let (cap_lints, output) = match first.exec_with_output() { Ok(output) => (true, output), - Err(..) => (false, try!(cmd.exec_with_output())), + Err(..) => (false, cmd.exec_with_output()?), }; - let verbose_version = try!(String::from_utf8(output.stdout).map_err(|_| { + let verbose_version = String::from_utf8(output.stdout).map_err(|_| { internal("rustc -v didn't return utf8 output") - })); + })?; let host = { let triple = verbose_version.lines().find(|l| { l.starts_with("host: ") }).map(|l| &l[6..]); - let triple = try!(triple.chain_error(|| { + let triple = triple.chain_error(|| { internal("rustc -v didn't have a line for `host:`") - })); + })?; triple.to_string() }; diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 2708abd90b0..c45ef1707a7 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -112,11 +112,11 @@ pub fn to_manifest(contents: &str, Some(path) => path.to_path_buf(), None => manifest.clone(), }; - let root = try!(parse(contents, &manifest, config)); + let root = parse(contents, &manifest, config)?; let mut d = toml::Decoder::new(toml::Value::Table(root)); - let manifest: TomlManifest = try!(Decodable::decode(&mut d).map_err(|e| { + let manifest: TomlManifest = Decodable::decode(&mut d).map_err(|e| { human(e.to_string()) - })); + })?; return match manifest.to_real_manifest(source_id, &layout, config) { Ok((mut manifest, paths)) => { @@ -181,7 +181,7 @@ The TOML spec requires newlines after table definitions (e.g. `[a] b = 1` is invalid), but this file has a table header which does not have a newline after it. A newline needs to be added and this warning will soon become a hard error in the future.", file.display()); - try!(config.shell().warn(&msg)); + config.shell().warn(&msg)?; return Ok(toml) } @@ -321,7 +321,7 @@ pub struct TomlVersion { impl Decodable for TomlVersion { fn decode(d: &mut D) -> Result { - let s = try!(d.read_str()); + let s = d.read_str()?; match s.to_semver() { Ok(s) => Ok(TomlVersion { version: s }), Err(e) => Err(d.error(&e)), @@ -428,15 +428,15 @@ impl TomlManifest { let mut warnings = vec![]; let project = self.project.as_ref().or_else(|| self.package.as_ref()); - let project = try!(project.chain_error(|| { + let project = project.chain_error(|| { human("no `package` or `project` section found.") - })); + })?; if project.name.trim().is_empty() { bail!("package name cannot be an empty string.") } - let pkgid = try!(project.to_package_id(source_id)); + let pkgid = project.to_package_id(source_id)?; let metadata = pkgid.generate_metadata(); // If we have no lib at all, use the inferred lib if available @@ -445,8 +445,8 @@ impl TomlManifest { let lib = match self.lib { Some(ref lib) => { - try!(lib.validate_library_name()); - try!(lib.validate_crate_type()); + lib.validate_library_name()?; + lib.validate_crate_type()?; Some( TomlTarget { name: lib.name.clone().or(Some(project.name.clone())), @@ -465,7 +465,7 @@ impl TomlManifest { let bin = layout.main(); for target in bins { - try!(target.validate_binary_name()); + target.validate_binary_name()?; } bins.iter().map(|t| { @@ -494,7 +494,7 @@ impl TomlManifest { let examples = match self.example { Some(ref examples) => { for target in examples { - try!(target.validate_example_name()); + target.validate_example_name()?; } examples.clone() } @@ -504,7 +504,7 @@ impl TomlManifest { let tests = match self.test { Some(ref tests) => { for target in tests { - try!(target.validate_test_name()); + target.validate_test_name()?; } tests.clone() } @@ -514,7 +514,7 @@ impl TomlManifest { let benches = match self.bench { Some(ref benches) => { for target in benches { - try!(target.validate_bench_name()); + target.validate_bench_name()?; } benches.clone() } @@ -589,7 +589,7 @@ impl TomlManifest { None => return Ok(()) }; for (n, v) in dependencies.iter() { - let dep = try!(v.to_dependency(n, cx, kind)); + let dep = v.to_dependency(n, cx, kind)?; cx.deps.push(dep); } @@ -597,27 +597,27 @@ impl TomlManifest { } // Collect the deps - try!(process_dependencies(&mut cx, self.dependencies.as_ref(), - None)); - try!(process_dependencies(&mut cx, self.dev_dependencies.as_ref(), - Some(Kind::Development))); - try!(process_dependencies(&mut cx, self.build_dependencies.as_ref(), - Some(Kind::Build))); + process_dependencies(&mut cx, self.dependencies.as_ref(), + None)?; + process_dependencies(&mut cx, self.dev_dependencies.as_ref(), + Some(Kind::Development))?; + process_dependencies(&mut cx, self.build_dependencies.as_ref(), + Some(Kind::Build))?; for (name, platform) in self.target.iter().flat_map(|t| t) { - cx.platform = Some(try!(name.parse())); - try!(process_dependencies(&mut cx, + cx.platform = Some(name.parse()?); + process_dependencies(&mut cx, platform.dependencies.as_ref(), - None)); - try!(process_dependencies(&mut cx, + None)?; + process_dependencies(&mut cx, platform.build_dependencies.as_ref(), - Some(Kind::Build))); - try!(process_dependencies(&mut cx, + Some(Kind::Build))?; + process_dependencies(&mut cx, platform.dev_dependencies.as_ref(), - Some(Kind::Development))); + Some(Kind::Development))?; } - replace = try!(self.replace(&mut cx)); + replace = self.replace(&mut cx)?; } { @@ -635,9 +635,9 @@ impl TomlManifest { let exclude = project.exclude.clone().unwrap_or(Vec::new()); let include = project.include.clone().unwrap_or(Vec::new()); - let summary = try!(Summary::new(pkgid, deps, + let summary = Summary::new(pkgid, deps, self.features.clone() - .unwrap_or(HashMap::new()))); + .unwrap_or(HashMap::new()))?; let metadata = ManifestMetadata { description: project.description.clone(), homepage: project.homepage.clone(), @@ -716,7 +716,7 @@ impl TomlManifest { let mut nested_paths = Vec::new(); let mut warnings = Vec::new(); let mut deps = Vec::new(); - let replace = try!(self.replace(&mut Context { + let replace = self.replace(&mut Context { pkgid: None, deps: &mut deps, source_id: source_id, @@ -725,7 +725,7 @@ impl TomlManifest { warnings: &mut warnings, platform: None, layout: layout, - })); + })?; let profiles = build_profiles(&self.profile); let workspace_config = match self.workspace { Some(ref config) => { @@ -742,11 +742,11 @@ impl TomlManifest { -> CargoResult> { let mut replace = Vec::new(); for (spec, replacement) in self.replace.iter().flat_map(|x| x) { - let mut spec = try!(PackageIdSpec::parse(spec).chain_error(|| { + let mut spec = PackageIdSpec::parse(spec).chain_error(|| { human(format!("replacements must specify a valid semver \ version to replace, but `{}` does not", spec)) - })); + })?; if spec.url().is_none() { spec.set_url(CRATES_IO.parse().unwrap()); } @@ -760,13 +760,13 @@ impl TomlManifest { requirement, but found one for `{}`", spec); } - let dep = try!(replacement.to_dependency(spec.name(), cx, None)); + let dep = replacement.to_dependency(spec.name(), cx, None)?; let dep = { - let version = try!(spec.version().chain_error(|| { + let version = spec.version().chain_error(|| { human(format!("replacements must specify a version \ to replace, but `{}` does not", spec)) - })); + })?; let req = VersionReq::exact(version); dep.clone_inner().set_version_req(req) .into_dependency() @@ -866,7 +866,7 @@ impl TomlDependency { .or_else(|| details.tag.clone().map(GitReference::Tag)) .or_else(|| details.rev.clone().map(GitReference::Rev)) .unwrap_or_else(|| GitReference::Branch("master".to_string())); - let loc = try!(git.to_url()); + let loc = git.to_url()?; SourceId::for_git(&loc, reference) }, (None, Some(path)) => { @@ -882,21 +882,21 @@ impl TomlDependency { if cx.source_id.is_path() { let path = cx.layout.root.join(path); let path = util::normalize_path(&path); - try!(SourceId::for_path(&path)) + SourceId::for_path(&path)? } else { cx.source_id.clone() } }, - (None, None) => try!(SourceId::crates_io(cx.config)), + (None, None) => SourceId::crates_io(cx.config)?, }; let version = details.version.as_ref().map(|v| &v[..]); let mut dep = match cx.pkgid { Some(id) => { - try!(DependencyInner::parse(name, version, &new_source_id, - Some((id, cx.config)))) + DependencyInner::parse(name, version, &new_source_id, + Some((id, cx.config)))? } - None => try!(DependencyInner::parse(name, version, &new_source_id, None)), + None => DependencyInner::parse(name, version, &new_source_id, None)?, }; dep = dep.set_features(details.features.unwrap_or(Vec::new())) .set_default_features(details.default_features.unwrap_or(true)) diff --git a/src/cargo/util/vcs.rs b/src/cargo/util/vcs.rs index ffd260680a2..730200316a0 100644 --- a/src/cargo/util/vcs.rs +++ b/src/cargo/util/vcs.rs @@ -9,7 +9,7 @@ pub struct GitRepo; impl GitRepo { pub fn init(path: &Path, _: &Path) -> CargoResult { - try!(git2::Repository::init(path)); + git2::Repository::init(path)?; Ok(GitRepo) } pub fn discover(path: &Path, _: &Path) -> Result { @@ -19,11 +19,11 @@ impl GitRepo { impl HgRepo { pub fn init(path: &Path, cwd: &Path) -> CargoResult { - try!(process("hg").cwd(cwd).arg("init").arg(path).exec()); + process("hg").cwd(cwd).arg("init").arg(path).exec()?; Ok(HgRepo) } pub fn discover(path: &Path, cwd: &Path) -> CargoResult { - try!(process("hg").cwd(cwd).arg("root").cwd(path).exec_with_output()); + process("hg").cwd(cwd).arg("root").cwd(path).exec_with_output()?; Ok(HgRepo) } } diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index 8ecb932fbde..884460df290 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -127,35 +127,35 @@ impl Registry { } pub fn add_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()> { - let body = try!(json::encode(&OwnersReq { users: owners })); - let body = try!(self.put(format!("/crates/{}/owners", krate), - body.as_bytes())); - assert!(try!(json::decode::(&body)).ok); + let body = json::encode(&OwnersReq { users: owners })?; + let body = self.put(format!("/crates/{}/owners", krate), + body.as_bytes())?; + assert!(json::decode::(&body)?.ok); Ok(()) } pub fn remove_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()> { - let body = try!(json::encode(&OwnersReq { users: owners })); - let body = try!(self.delete(format!("/crates/{}/owners", krate), - Some(body.as_bytes()))); - assert!(try!(json::decode::(&body)).ok); + let body = json::encode(&OwnersReq { users: owners })?; + let body = self.delete(format!("/crates/{}/owners", krate), + Some(body.as_bytes()))?; + assert!(json::decode::(&body)?.ok); Ok(()) } pub fn list_owners(&mut self, krate: &str) -> Result> { - let body = try!(self.get(format!("/crates/{}/owners", krate))); - Ok(try!(json::decode::(&body)).users) + let body = self.get(format!("/crates/{}/owners", krate))?; + Ok(json::decode::(&body)?.users) } pub fn publish(&mut self, krate: &NewCrate, tarball: &File) -> Result<()> { - let json = try!(json::encode(krate)); + let json = json::encode(krate)?; // Prepare the body. The format of the upload request is: // // // (metadata for the package) // // - let stat = try!(tarball.metadata().map_err(Error::Io)); + let stat = tarball.metadata().map_err(Error::Io)?; let header = { let mut w = Vec::new(); w.extend([ @@ -182,57 +182,57 @@ impl Registry { Some(s) => s, None => return Err(Error::TokenMissing), }; - try!(self.handle.put(true)); - try!(self.handle.url(&url)); - try!(self.handle.in_filesize(size as u64)); + self.handle.put(true)?; + self.handle.url(&url)?; + self.handle.in_filesize(size as u64)?; let mut headers = List::new(); - try!(headers.append("Accept: application/json")); - try!(headers.append(&format!("Authorization: {}", token))); - try!(self.handle.http_headers(headers)); + headers.append("Accept: application/json")?; + headers.append(&format!("Authorization: {}", token))?; + self.handle.http_headers(headers)?; - let _body = try!(handle(&mut self.handle, &mut |buf| { + let _body = handle(&mut self.handle, &mut |buf| { body.read(buf).unwrap_or(0) - })); + })?; Ok(()) } pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec, u32)> { let formated_query = percent_encode(query.as_bytes(), QUERY_ENCODE_SET); - let body = try!(self.req( + let body = self.req( format!("/crates?q={}&per_page={}", formated_query, limit), None, Auth::Unauthorized - )); + )?; - let crates = try!(json::decode::(&body)); + let crates = json::decode::(&body)?; Ok((crates.crates, crates.meta.total)) } pub fn yank(&mut self, krate: &str, version: &str) -> Result<()> { - let body = try!(self.delete(format!("/crates/{}/{}/yank", krate, version), - None)); - assert!(try!(json::decode::(&body)).ok); + let body = self.delete(format!("/crates/{}/{}/yank", krate, version), + None)?; + assert!(json::decode::(&body)?.ok); Ok(()) } pub fn unyank(&mut self, krate: &str, version: &str) -> Result<()> { - let body = try!(self.put(format!("/crates/{}/{}/unyank", krate, version), - &[])); - assert!(try!(json::decode::(&body)).ok); + let body = self.put(format!("/crates/{}/{}/unyank", krate, version), + &[])?; + assert!(json::decode::(&body)?.ok); Ok(()) } fn put(&mut self, path: String, b: &[u8]) -> Result { - try!(self.handle.put(true)); + self.handle.put(true)?; self.req(path, Some(b), Auth::Authorized) } fn get(&mut self, path: String) -> Result { - try!(self.handle.get(true)); + self.handle.get(true)?; self.req(path, None, Auth::Authorized) } fn delete(&mut self, path: String, b: Option<&[u8]>) -> Result { - try!(self.handle.custom_request("DELETE")); + self.handle.custom_request("DELETE")?; self.req(path, b, Auth::Authorized) } @@ -240,23 +240,23 @@ impl Registry { path: String, body: Option<&[u8]>, authorized: Auth) -> Result { - try!(self.handle.url(&format!("{}/api/v1{}", self.host, path))); + self.handle.url(&format!("{}/api/v1{}", self.host, path))?; let mut headers = List::new(); - try!(headers.append("Accept: application/json")); - try!(headers.append("Content-Type: application/json")); + headers.append("Accept: application/json")?; + headers.append("Content-Type: application/json")?; if authorized == Auth::Authorized { let token = match self.token.as_ref() { Some(s) => s, None => return Err(Error::TokenMissing), }; - try!(headers.append(&format!("Authorization: {}", token))); + headers.append(&format!("Authorization: {}", token))?; } - try!(self.handle.http_headers(headers)); + self.handle.http_headers(headers)?; match body { Some(mut body) => { - try!(self.handle.upload(true)); - try!(self.handle.in_filesize(body.len() as u64)); + self.handle.upload(true)?; + self.handle.in_filesize(body.len() as u64)?; handle(&mut self.handle, &mut |buf| body.read(buf).unwrap_or(0)) } None => handle(&mut self.handle, &mut |_| 0), @@ -270,19 +270,19 @@ fn handle(handle: &mut Easy, let mut body = Vec::new(); { let mut handle = handle.transfer(); - try!(handle.read_function(|buf| Ok(read(buf)))); - try!(handle.write_function(|data| { + handle.read_function(|buf| Ok(read(buf)))?; + handle.write_function(|data| { body.extend_from_slice(data); Ok(data.len()) - })); - try!(handle.header_function(|data| { + })?; + handle.header_function(|data| { headers.push(String::from_utf8_lossy(data).into_owned()); true - })); - try!(handle.perform()); + })?; + handle.perform()?; } - match try!(handle.response_code()) { + match handle.response_code()? { 0 => {} // file upload url sometimes 200 => {} 403 => return Err(Error::Unauthorized), @@ -310,13 +310,13 @@ impl fmt::Display for Error { Error::NonUtf8Body => write!(f, "response body was not utf-8"), Error::Curl(ref err) => write!(f, "http error: {}", err), Error::NotOkResponse(code, ref headers, ref body) => { - try!(writeln!(f, "failed to get a 200 OK response, got {}", code)); - try!(writeln!(f, "headers:")); + writeln!(f, "failed to get a 200 OK response, got {}", code)?; + writeln!(f, "headers:")?; for header in headers { - try!(writeln!(f, " {}", header)); + writeln!(f, " {}", header)?; } - try!(writeln!(f, "body:")); - try!(writeln!(f, "{}", String::from_utf8_lossy(body))); + writeln!(f, "body:")?; + writeln!(f, "{}", String::from_utf8_lossy(body))?; Ok(()) } Error::Api(ref errs) => { diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index ea63261892b..6da0aa56cef 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -315,15 +315,15 @@ impl Execs { } fn match_stdout(&self, actual: &Output) -> ham::MatchResult { - try!(self.match_std(self.expect_stdout.as_ref(), &actual.stdout, - "stdout", &actual.stderr, false)); + self.match_std(self.expect_stdout.as_ref(), &actual.stdout, + "stdout", &actual.stderr, false)?; for expect in self.expect_stdout_contains.iter() { - try!(self.match_std(Some(expect), &actual.stdout, "stdout", - &actual.stderr, true)); + self.match_std(Some(expect), &actual.stdout, "stdout", + &actual.stderr, true)?; } for expect in self.expect_stderr_contains.iter() { - try!(self.match_std(Some(expect), &actual.stderr, "stderr", - &actual.stdout, true)); + self.match_std(Some(expect), &actual.stderr, "stderr", + &actual.stdout, true)?; } if let Some(ref objects) = self.expect_json { @@ -336,7 +336,7 @@ impl Execs { objects.len(), lines.len())); } for (obj, line) in objects.iter().zip(lines) { - try!(self.match_json(obj, line)); + self.match_json(obj, line)?; } } Ok(()) diff --git a/tests/resolve.rs b/tests/resolve.rs index 9129a1e6e92..b40c26f840a 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -18,9 +18,9 @@ fn resolve(pkg: PackageId, deps: Vec, -> CargoResult> { let summary = Summary::new(pkg.clone(), deps, HashMap::new()).unwrap(); let method = Method::Everything; - Ok(try!(resolver::resolve(&[(summary, method)], + Ok(resolver::resolve(&[(summary, method)], &[], - registry)).iter().map(|p| { + registry)?.iter().map(|p| { p.clone() }).collect()) } diff --git a/tests/shell.rs b/tests/shell.rs index 549070d4157..4b03aa6f636 100644 --- a/tests/shell.rs +++ b/tests/shell.rs @@ -93,10 +93,10 @@ fn no_term() { fn colored_output(string: &str, color: color::Color) -> CargoResult { let mut term = TerminfoTerminal::new(Vec::new()).unwrap(); - try!(term.reset()); - try!(term.fg(color)); - try!(write!(&mut term, "{}", string)); - try!(term.reset()); - try!(term.flush()); + term.reset()?; + term.fg(color)?; + write!(&mut term, "{}", string)?; + term.reset()?; + term.flush()?; Ok(String::from_utf8_lossy(term.get_ref()).to_string()) } From d85e893d9b38c4e7847d39ddd6ef079cb206fbd6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Nov 2016 07:27:31 -0800 Subject: [PATCH 0822/3888] Publish builds from the auto-cargo branch Cargo doesn't use auto, it uses auto-cargo --- .travis.yml | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2bbcbe98a13..7e61d7e280f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -144,7 +144,7 @@ deploy: secret_access_key: secure: wKKDMYBVTdWLuc7+ffpjTqJs1EdM2pXpV6keUfZGv9RLRta+esh/r/cgc+UQ7+m9JHAliH8eWhlMm5ws6WDgkTvM0PTdqWBgwd24BRbAitsXX2kWfi9WgAeSJVSkIJdZ999TRpRIJu7Zc+1++fbfdD/tDv5XBirQGOJv1HynVWY= on: - branch: auto + branch: auto-cargo condition: $DEPLOY = 1 cache: diff --git a/appveyor.yml b/appveyor.yml index 07d98a26b4e..c892a130c82 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -68,4 +68,4 @@ deploy: artifact: cargo folder: cargo-master on: - branch: auto + branch: auto-cargo From 2892c9aed66a475db4189b37ead7bf76c9c61f14 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Fri, 11 Nov 2016 19:16:59 +0100 Subject: [PATCH 0823/3888] Updated indent and rustversion.txt --- src/bin/bench.rs | 8 ++++---- src/bin/build.rs | 8 ++++---- src/bin/cargo.rs | 8 ++++---- src/bin/clean.rs | 8 ++++---- src/bin/doc.rs | 8 ++++---- src/bin/fetch.rs | 8 ++++---- src/bin/generate_lockfile.rs | 8 ++++---- src/bin/git_checkout.rs | 8 ++++---- src/bin/init.rs | 12 ++++++------ src/bin/install.rs | 8 ++++---- src/bin/login.rs | 8 ++++---- src/bin/metadata.rs | 8 ++++---- src/bin/new.rs | 14 ++++++------- src/bin/owner.rs | 8 ++++---- src/bin/package.rs | 8 ++++---- src/bin/pkgid.rs | 8 ++++---- src/bin/publish.rs | 8 ++++---- src/bin/run.rs | 8 ++++---- src/bin/rustc.rs | 10 +++++----- src/bin/rustdoc.rs | 10 +++++----- src/bin/search.rs | 8 ++++---- src/bin/test.rs | 8 ++++---- src/bin/uninstall.rs | 8 ++++---- src/bin/update.rs | 8 ++++---- src/bin/verify_project.rs | 8 ++++---- src/bin/yank.rs | 18 ++++++++--------- src/cargo/core/package.rs | 2 +- src/cargo/core/resolver/mod.rs | 16 +++++++-------- src/cargo/core/workspace.rs | 2 +- src/cargo/ops/cargo_compile.rs | 18 ++++++++--------- src/cargo/ops/cargo_generate_lockfile.rs | 4 ++-- src/cargo/ops/cargo_install.rs | 14 ++++++------- src/cargo/ops/cargo_output_metadata.rs | 10 +++++----- src/cargo/ops/cargo_rustc/layout.rs | 3 +-- src/cargo/ops/resolve.rs | 7 +++---- src/cargo/sources/path.rs | 6 ++---- src/cargo/sources/registry/local.rs | 4 ++-- src/cargo/sources/registry/remote.rs | 8 ++++---- src/cargo/util/flock.rs | 8 ++++---- src/cargo/util/paths.rs | 8 ++++---- src/cargo/util/toml.rs | 25 +++++++----------------- src/rustversion.txt | 2 +- tests/cargotest/support/mod.rs | 6 +++--- tests/resolve.rs | 4 +--- 44 files changed, 181 insertions(+), 198 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 18c90c6248f..774b3003cf7 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -73,10 +73,10 @@ Compilation can be customized with the `bench` profile in the manifest. pub fn execute(options: Options, config: &Config) -> CliResult> { let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let ops = ops::TestOptions { no_run: options.flag_no_run, no_fail_fast: false, diff --git a/src/bin/build.rs b/src/bin/build.rs index 439201f7420..7e6688b410f 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -70,10 +70,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-build; args={:?}", env::args().collect::>()); config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 94bcfbb9e99..05c88019b55 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -117,10 +117,10 @@ each_subcommand!(declare_mod); */ fn execute(flags: Flags, config: &Config) -> CliResult> { config.configure(flags.flag_verbose, - flags.flag_quiet, - &flags.flag_color, - flags.flag_frozen, - flags.flag_locked)?; + flags.flag_quiet, + &flags.flag_color, + flags.flag_frozen, + flags.flag_locked)?; init_git_transports(config); let _token = cargo::util::job::setup(); diff --git a/src/bin/clean.rs b/src/bin/clean.rs index 5a36aa6005c..35146c687af 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -45,10 +45,10 @@ and its format, see the `cargo help pkgid` command. pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-clean; args={:?}", env::args().collect::>()); config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let opts = ops::CleanOptions { diff --git a/src/bin/doc.rs b/src/bin/doc.rs index c4de72dc078..f8b434247a9 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -63,10 +63,10 @@ the `cargo help pkgid` command. pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; diff --git a/src/bin/fetch.rs b/src/bin/fetch.rs index 8d191c55a79..877d53869a6 100644 --- a/src/bin/fetch.rs +++ b/src/bin/fetch.rs @@ -40,10 +40,10 @@ all updated. pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let ws = Workspace::new(&root, config)?; ops::fetch(&ws)?; diff --git a/src/bin/generate_lockfile.rs b/src/bin/generate_lockfile.rs index 7c170d05bc2..40717435f04 100644 --- a/src/bin/generate_lockfile.rs +++ b/src/bin/generate_lockfile.rs @@ -34,10 +34,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-generate-lockfile; args={:?}", env::args().collect::>()); config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let ws = Workspace::new(&root, config)?; diff --git a/src/bin/git_checkout.rs b/src/bin/git_checkout.rs index ebfde445e53..268776c7b74 100644 --- a/src/bin/git_checkout.rs +++ b/src/bin/git_checkout.rs @@ -31,10 +31,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let Options { flag_url: url, flag_reference: reference, .. } = options; let url = url.to_url()?; diff --git a/src/bin/init.rs b/src/bin/init.rs index c5d5017f576..1b69a2204de 100644 --- a/src/bin/init.rs +++ b/src/bin/init.rs @@ -42,10 +42,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-init; args={:?}", env::args().collect::>()); config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let Options { flag_bin, flag_lib, arg_path, flag_name, flag_vcs, .. } = options; @@ -60,8 +60,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { ops::init(opts, config)?; config.shell().status("Created", format!("{} project", - if opts_lib { "library" } - else {"binary (application)"}))?; + if opts_lib { "library" } + else {"binary (application)"}))?; Ok(None) } diff --git a/src/bin/install.rs b/src/bin/install.rs index c9e75ade072..c27db56ffaf 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -96,10 +96,10 @@ The `--list` option will list all installed packages (and their versions). pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let compile_opts = ops::CompileOptions { config: config, diff --git a/src/bin/login.rs b/src/bin/login.rs index d93e11f8d34..6bb3618da1f 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -36,10 +36,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let token = match options.arg_token.clone() { Some(token) => token, None => { diff --git a/src/bin/metadata.rs b/src/bin/metadata.rs index df3b21ad6b6..7971d0707b7 100644 --- a/src/bin/metadata.rs +++ b/src/bin/metadata.rs @@ -44,10 +44,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let manifest = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let options = OutputMetadataOptions { diff --git a/src/bin/new.rs b/src/bin/new.rs index da505af4970..7b7ab664ba1 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -42,10 +42,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-new; args={:?}", env::args().collect::>()); config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let Options { flag_bin, flag_lib, arg_path, flag_name, flag_vcs, .. } = options; @@ -59,9 +59,9 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { ops::new(opts, config)?; config.shell().status("Created", format!("{} `{}` project", - if opts_lib { "library" } - else {"binary (application)"}, - arg_path))?; + if opts_lib { "library" } + else {"binary (application)"}, + arg_path))?; Ok(None) } diff --git a/src/bin/owner.rs b/src/bin/owner.rs index f1232e99bfb..4c6976aa7d1 100644 --- a/src/bin/owner.rs +++ b/src/bin/owner.rs @@ -46,10 +46,10 @@ and troubleshooting. pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let opts = ops::OwnersOptions { krate: options.arg_crate, token: options.flag_token, diff --git a/src/bin/package.rs b/src/bin/package.rs index 66cf3ada789..f3f95a99c64 100644 --- a/src/bin/package.rs +++ b/src/bin/package.rs @@ -41,10 +41,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let ws = Workspace::new(&root, config)?; ops::package(&ws, &ops::PackageOpts { diff --git a/src/bin/pkgid.rs b/src/bin/pkgid.rs index e0588cae3ac..e18a505bf58 100644 --- a/src/bin/pkgid.rs +++ b/src/bin/pkgid.rs @@ -55,10 +55,10 @@ Example Package IDs pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path.clone(), config.cwd())?; let ws = Workspace::new(&root, config)?; diff --git a/src/bin/publish.rs b/src/bin/publish.rs index 60534f4cf4d..56db84d1766 100644 --- a/src/bin/publish.rs +++ b/src/bin/publish.rs @@ -44,10 +44,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let Options { flag_token: token, flag_host: host, diff --git a/src/bin/run.rs b/src/bin/run.rs index 1de5ccbba78..1e7089a7572 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -59,10 +59,10 @@ the ones before go to Cargo. pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index 1268c7ba266..a73088bfd64 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -77,13 +77,13 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-rustc; args={:?}", env::args().collect::>()); config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, - config.cwd())?; + config.cwd())?; let mode = match options.flag_profile.as_ref().map(|t| &t[..]) { Some("dev") | None => CompileMode::Build, Some("test") => CompileMode::Test, diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index d993a48503a..0d159f47a8e 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -72,13 +72,13 @@ the `cargo help pkgid` command. pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, - config.cwd())?; + config.cwd())?; let doc_opts = ops::DocOptions { open_result: options.flag_open, diff --git a/src/bin/search.rs b/src/bin/search.rs index 828356dc0d0..eebe34988fb 100644 --- a/src/bin/search.rs +++ b/src/bin/search.rs @@ -35,10 +35,10 @@ Options: pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let Options { flag_host: host, flag_limit: limit, diff --git a/src/bin/test.rs b/src/bin/test.rs index 5ae7dee946a..c28ff8fc431 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -90,10 +90,10 @@ To get the list of all options available for the test binaries use this: pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; diff --git a/src/bin/uninstall.rs b/src/bin/uninstall.rs index 659702bd9f4..b5c827e7a4f 100644 --- a/src/bin/uninstall.rs +++ b/src/bin/uninstall.rs @@ -39,10 +39,10 @@ only uninstall particular binaries. pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = options.flag_root.as_ref().map(|s| &s[..]); ops::uninstall(root, &options.arg_spec, &options.flag_bin, config)?; diff --git a/src/bin/update.rs b/src/bin/update.rs index 064bb5ee991..6cf1e79864c 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -60,10 +60,10 @@ For more information about package id specifications, see `cargo help pkgid`. pub fn execute(options: Options, config: &Config) -> CliResult> { debug!("executing; cmd=cargo-update; args={:?}", env::args().collect::>()); config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; let update_opts = ops::UpdateOptions { diff --git a/src/bin/verify_project.rs b/src/bin/verify_project.rs index 447bf7a5dc8..726e1ab358b 100644 --- a/src/bin/verify_project.rs +++ b/src/bin/verify_project.rs @@ -39,10 +39,10 @@ Options: pub fn execute(args: Flags, config: &Config) -> CliResult> { config.configure(args.flag_verbose, - args.flag_quiet, - &args.flag_color, - args.flag_frozen, - args.flag_locked)?; + args.flag_quiet, + &args.flag_color, + args.flag_frozen, + args.flag_locked)?; let mut contents = String::new(); let filename = args.flag_manifest_path.unwrap_or("Cargo.toml".into()); diff --git a/src/bin/yank.rs b/src/bin/yank.rs index bac383c4fcd..760e8cb80b0 100644 --- a/src/bin/yank.rs +++ b/src/bin/yank.rs @@ -44,16 +44,16 @@ crates to be locked to any yanked version. pub fn execute(options: Options, config: &Config) -> CliResult> { config.configure(options.flag_verbose, - options.flag_quiet, - &options.flag_color, - options.flag_frozen, - options.flag_locked)?; + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; ops::yank(config, - options.arg_crate, - options.flag_vers, - options.flag_token, - options.flag_index, - options.flag_undo)?; + options.arg_crate, + options.flag_vers, + options.flag_token, + options.flag_index, + options.flag_undo)?; Ok(None) } diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 6fa0bb7f3e0..03ed7d88729 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -74,7 +74,7 @@ impl Package { let path = manifest_path.parent().unwrap(); let source_id = SourceId::for_path(path)?; let (pkg, _) = ops::read_package(&manifest_path, &source_id, - config)?; + config)?; Ok(pkg) } diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index b67e32d56dc..0469f3c2330 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -451,7 +451,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, let summary = Rc::new(summary.clone()); let candidate = Candidate { summary: summary, replace: None }; remaining_deps.extend(activate(&mut cx, registry, None, candidate, - method)?); + method)?); } // Main resolution loop, this is the workhorse of the resolution algorithm. @@ -559,7 +559,7 @@ fn activate_deps_loop<'a>(mut cx: Context<'a>, trace!("{}[{}]>{} trying {}", parent.name(), cur, dep.name(), candidate.summary.version()); remaining_deps.extend(activate(&mut cx, registry, Some(&parent), - candidate, &method)?); + candidate, &method)?); } Ok(cx) @@ -713,7 +713,7 @@ fn build_features(s: &Summary, method: &Method) } for dep in s.dependencies().iter().filter(|d| d.is_optional()) { add_feature(s, dep.name(), &mut deps, &mut used, - &mut visited)?; + &mut visited)?; } } Method::Required { features: requested_features, .. } => { @@ -727,7 +727,7 @@ fn build_features(s: &Summary, method: &Method) Method::Required { uses_default_features: true, .. } => { if s.features().get("default").is_some() { add_feature(s, "default", &mut deps, &mut used, - &mut visited)?; + &mut visited)?; } } Method::Required { uses_default_features: false, .. } => {} @@ -989,10 +989,10 @@ fn check_cycles(resolve: &Resolve, for pkg in all_packages { if !checked.contains(pkg) { visit(resolve, - pkg, - &summaries, - &mut HashSet::new(), - &mut checked)? + pkg, + &summaries, + &mut HashSet::new(), + &mut checked)? } } return Ok(()); diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 95b2cd67fdb..f35432f6469 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -483,7 +483,7 @@ impl<'cfg> Packages<'cfg> { Entry::Vacant(v) => { let source_id = SourceId::for_path(key)?; let pair = ops::read_manifest(&manifest_path, &source_id, - self.config)?; + self.config)?; let (manifest, _nested_paths) = pair; Ok(v.insert(match manifest { EitherManifest::Real(manifest) => { diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index a8ebb30e2c8..74b78769476 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -205,7 +205,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, } (Some(args), _) => { let targets = generate_targets(to_builds[0], profiles, - mode, filter, release)?; + mode, filter, release)?; if targets.len() == 1 { let (target, profile) = targets[0]; let mut profile = profile.clone(); @@ -219,7 +219,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, } (None, Some(args)) => { let targets = generate_targets(to_builds[0], profiles, - mode, filter, release)?; + mode, filter, release)?; if targets.len() == 1 { let (target, profile) = targets[0]; let mut profile = profile.clone(); @@ -234,7 +234,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, (None, None) => { for &to_build in to_builds.iter() { let targets = generate_targets(to_build, profiles, mode, - filter, release)?; + filter, release)?; package_targets.push((to_build, targets)); } } @@ -257,12 +257,12 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, } ops::compile_targets(ws, - &package_targets, - &packages, - &resolve_with_overrides, - config, - build_config, - profiles)? + &package_targets, + &packages, + &resolve_with_overrides, + config, + build_config, + profiles)? }; ret.to_doc_test = to_builds.iter().map(|&p| p.clone()).collect(); diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index c09ee67022f..989534cea79 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -18,8 +18,8 @@ pub struct UpdateOptions<'a> { pub fn generate_lockfile(ws: &Workspace) -> CargoResult<()> { let mut registry = PackageRegistry::new(ws.config())?; let resolve = ops::resolve_with_previous(&mut registry, ws, - Method::Everything, - None, None, &[])?; + Method::Everything, + None, None, &[])?; ops::write_pkg_lockfile(ws, &resolve)?; Ok(()) } diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index b9a5aa85b06..c2a348e2e99 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -57,7 +57,7 @@ pub fn install(root: Option<&str>, let map = SourceConfigMap::new(config)?; let (pkg, source) = if source_id.is_git() { select_pkg(GitSource::new(source_id, config), source_id, - krate, vers, &mut |git| git.read_packages())? + krate, vers, &mut |git| git.read_packages())? } else if source_id.is_path() { let path = source_id.url().to_file_path().ok() .expect("path sources must have a valid path"); @@ -68,14 +68,14 @@ pub fn install(root: Option<&str>, specify an alternate source", path.display())) })?; select_pkg(PathSource::new(&path, source_id, config), - source_id, krate, vers, - &mut |path| path.read_packages())? + source_id, krate, vers, + &mut |path| path.read_packages())? } else { select_pkg(map.load(source_id)?, - source_id, krate, vers, - &mut |_| Err(human("must specify a crate to install from \ - crates.io, or use --path or --git to \ - specify alternate source")))? + source_id, krate, vers, + &mut |_| Err(human("must specify a crate to install from \ + crates.io, or use --path or --git to \ + specify alternate source")))? }; diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index b8dfca5ef36..bc1a04f0cfd 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -47,11 +47,11 @@ fn metadata_full(ws: &Workspace, PackageIdSpec::from_package_id(pkg.package_id()) }).collect::>(); let deps = ops::resolve_dependencies(ws, - None, - &opt.features, - opt.all_features, - opt.no_default_features, - &specs)?; + None, + &opt.features, + opt.all_features, + opt.no_default_features, + &specs)?; let (packages, resolve) = deps; let packages = try!(packages.package_ids() diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index 1e371a9517e..dae91aae79f 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -78,8 +78,7 @@ impl Layout { // the target triple as a Path and then just use the file stem as the // component for the directory name. if let Some(triple) = triple { - path.push(Path::new(triple).file_stem() - .ok_or(human(format!("target was empty")))?); + path.push(Path::new(triple).file_stem().ok_or(human(format!("target was empty")))?); } path.push(dest); Layout::at(ws.config(), path) diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 42898b6afc9..335c06b88d7 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -15,8 +15,8 @@ pub fn resolve_ws(registry: &mut PackageRegistry, ws: &Workspace) -> CargoResult { let prev = ops::load_pkg_lockfile(ws)?; let resolve = resolve_with_previous(registry, ws, - Method::Everything, - prev.as_ref(), None, &[])?; + Method::Everything, + prev.as_ref(), None, &[])?; // Avoid writing a lockfile if we are `cargo install`ing a non local package. if ws.current_opt().map(|pkg| pkg.package_id().source_id().is_path()).unwrap_or(true) { @@ -88,8 +88,7 @@ pub fn resolve_with_previous<'a>(registry: &mut PackageRegistry, let mut summaries = Vec::new(); for member in ws.members() { - registry.add_sources(&[member.package_id().source_id() - .clone()])?; + registry.add_sources(&[member.package_id().source_id().clone()])?; let method_to_resolve = match method { // When everything for a workspace we want to be sure to resolve all // members in the workspace, so propagate the `Method::Everything`. diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 197d756d66f..e5a7ae6f8ce 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -94,10 +94,8 @@ impl<'cfg> PathSource<'cfg> { human(format!("could not parse pattern `{}`: {}", p, e)) }) }; - let exclude = pkg.manifest().exclude().iter() - .map(|p| parse(p)).collect::, _>>()?; - let include = pkg.manifest().include().iter() - .map(|p| parse(p)).collect::, _>>()?; + let exclude = pkg.manifest().exclude().iter().map(|p| parse(p)).collect::, _>>()?; + let include = pkg.manifest().include().iter().map(|p| parse(p)).collect::, _>>()?; let mut filter = |p: &Path| { let relative_path = util::without_prefix(p, &root).unwrap(); diff --git a/src/cargo/sources/registry/local.rs b/src/cargo/sources/registry/local.rs index 6c108cd9017..67e88a9c72d 100644 --- a/src/cargo/sources/registry/local.rs +++ b/src/cargo/sources/registry/local.rs @@ -61,8 +61,8 @@ impl<'cfg> RegistryData for LocalRegistry<'cfg> { -> CargoResult { let crate_file = format!("{}-{}.crate", pkg.name(), pkg.version()); let mut crate_file = self.root.open_ro(&crate_file, - self.config, - "crate file")?; + self.config, + "crate file")?; // If we've already got an unpacked version of this crate, then skip the // checksum below as it is in theory already verified. diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index d4bc144889a..480b7185950 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -45,8 +45,8 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { fn config(&self) -> CargoResult> { let lock = self.index_path.open_ro(Path::new(INDEX_LOCK), - self.config, - "the registry index")?; + self.config, + "the registry index")?; let path = lock.path().parent().unwrap(); let contents = paths::read(&path.join("config.json"))?; let config = json::decode(&contents)?; @@ -65,8 +65,8 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { // Then we actually update the index self.index_path.create_dir()?; let lock = self.index_path.open_rw(Path::new(INDEX_LOCK), - self.config, - "the registry index")?; + self.config, + "the registry index")?; let path = lock.path().parent().unwrap(); self.config.shell().status("Updating", diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index a6f90afc335..a20540d06c3 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -217,13 +217,13 @@ impl Filesystem { match state { State::Exclusive => { acquire(config, msg, &path, - &|| f.try_lock_exclusive(), - &|| f.lock_exclusive())?; + &|| f.try_lock_exclusive(), + &|| f.lock_exclusive())?; } State::Shared => { acquire(config, msg, &path, - &|| f.try_lock_shared(), - &|| f.lock_shared())?; + &|| f.try_lock_shared(), + &|| f.lock_shared())?; } State::Unlocked => {} diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 23a42a84c70..d47598a2ece 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -102,10 +102,10 @@ pub fn write(path: &Path, contents: &[u8]) -> CargoResult<()> { pub fn append(path: &Path, contents: &[u8]) -> CargoResult<()> { (|| -> CargoResult<()> { let mut f = OpenOptions::new() - .write(true) - .append(true) - .create(true) - .open(path)?; + .write(true) + .append(true) + .create(true) + .open(path)?; f.write_all(contents)?; Ok(()) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index c45ef1707a7..ca61e3a546b 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -597,24 +597,15 @@ impl TomlManifest { } // Collect the deps - process_dependencies(&mut cx, self.dependencies.as_ref(), - None)?; - process_dependencies(&mut cx, self.dev_dependencies.as_ref(), - Some(Kind::Development))?; - process_dependencies(&mut cx, self.build_dependencies.as_ref(), - Some(Kind::Build))?; + process_dependencies(&mut cx, self.dependencies.as_ref(), None)?; + process_dependencies(&mut cx, self.dev_dependencies.as_ref(), Some(Kind::Development))?; + process_dependencies(&mut cx, self.build_dependencies.as_ref(), Some(Kind::Build))?; for (name, platform) in self.target.iter().flat_map(|t| t) { cx.platform = Some(name.parse()?); - process_dependencies(&mut cx, - platform.dependencies.as_ref(), - None)?; - process_dependencies(&mut cx, - platform.build_dependencies.as_ref(), - Some(Kind::Build))?; - process_dependencies(&mut cx, - platform.dev_dependencies.as_ref(), - Some(Kind::Development))?; + process_dependencies(&mut cx, platform.dependencies.as_ref(), None)?; + process_dependencies(&mut cx, platform.build_dependencies.as_ref(), Some(Kind::Build))?; + process_dependencies(&mut cx, platform.dev_dependencies.as_ref(), Some(Kind::Development))?; } replace = self.replace(&mut cx)?; @@ -635,9 +626,7 @@ impl TomlManifest { let exclude = project.exclude.clone().unwrap_or(Vec::new()); let include = project.include.clone().unwrap_or(Vec::new()); - let summary = Summary::new(pkgid, deps, - self.features.clone() - .unwrap_or(HashMap::new()))?; + let summary = Summary::new(pkgid, deps, self.features.clone() .unwrap_or(HashMap::new()))?; let metadata = ManifestMetadata { description: project.description.clone(), homepage: project.homepage.clone(), diff --git a/src/rustversion.txt b/src/rustversion.txt index 53b3604545e..e10ea319408 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-10-21 +2016-11-11 diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index 6da0aa56cef..3a13b46baec 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -316,14 +316,14 @@ impl Execs { fn match_stdout(&self, actual: &Output) -> ham::MatchResult { self.match_std(self.expect_stdout.as_ref(), &actual.stdout, - "stdout", &actual.stderr, false)?; + "stdout", &actual.stderr, false)?; for expect in self.expect_stdout_contains.iter() { self.match_std(Some(expect), &actual.stdout, "stdout", - &actual.stderr, true)?; + &actual.stderr, true)?; } for expect in self.expect_stderr_contains.iter() { self.match_std(Some(expect), &actual.stderr, "stderr", - &actual.stdout, true)?; + &actual.stdout, true)?; } if let Some(ref objects) = self.expect_json { diff --git a/tests/resolve.rs b/tests/resolve.rs index b40c26f840a..15f583b51c1 100644 --- a/tests/resolve.rs +++ b/tests/resolve.rs @@ -18,9 +18,7 @@ fn resolve(pkg: PackageId, deps: Vec, -> CargoResult> { let summary = Summary::new(pkg.clone(), deps, HashMap::new()).unwrap(); let method = Method::Everything; - Ok(resolver::resolve(&[(summary, method)], - &[], - registry)?.iter().map(|p| { + Ok(resolver::resolve(&[(summary, method)], &[], registry)?.iter().map(|p| { p.clone() }).collect()) } From 141a5c7ccba9081aa972c03028e92fed3896f25c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 8 Nov 2016 01:36:44 -0800 Subject: [PATCH 0824/3888] Update dependencies for OpenSSL 1.1.0 compatibility The primary targets here are openssl and openssl-sys crates 0.9, bringing support for OpenSSL 1.1.0. This requires updating the curl and git2 related dependencies as well. A small change is required in cargo itself for the new Hasher API. Results from the hasher are simply unwrapped for now, matching the Windows behavior that already panics on error. --- Cargo.lock | 110 ++++++++++++++----------------------- Cargo.toml | 8 +-- src/cargo/util/sha256.rs | 8 ++- tests/build-auth.rs | 4 +- tests/cargotest/Cargo.toml | 2 +- 5 files changed, 53 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79643be3bff..2fbe5426011 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,23 +7,23 @@ dependencies = [ "cargotest 0.1.0", "crates-io 0.4.0", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "git2-curl 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2-curl 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -53,11 +53,6 @@ dependencies = [ "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "bitflags" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "0.7.0" @@ -76,7 +71,7 @@ dependencies = [ "cargo 0.15.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -106,7 +101,7 @@ dependencies = [ name = "crates-io" version = "0.4.0" dependencies = [ - "curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -118,12 +113,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "curl" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -135,7 +131,7 @@ dependencies = [ "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -203,22 +199,24 @@ dependencies = [ [[package]] name = "git2" -version = "0.4.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "git2-curl" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -268,35 +266,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.4.5" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "libressl-pnacl-sys" -version = "2.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "libssh2-sys" -version = "0.1.39" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -436,52 +427,36 @@ dependencies = [ [[package]] name = "openssl" -version = "0.7.14" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys-extras 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "openssl-probe" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "openssl-sys" -version = "0.7.14" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "openssl-sys-extras" -version = "0.7.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "pkg-config" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "pnacl-build-helper" -version = "1.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "psapi-sys" version = "0.1.0" @@ -652,13 +627,12 @@ dependencies = [ [metadata] "checksum advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e06588080cb19d0acb6739808aafa5f26bfb2ca015b2b6370028b44cf7cb8a9a" "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" -"checksum bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2a6577517ecd0ee0934f48a7295a89aaef3e6dfafeac404f94c0b3448518ddfe" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" "checksum cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "dfcf5bcece56ef953b8ea042509e9dcbdfe97820b7e20d86beb53df30ed94978" "checksum crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fb974f835e90390c5f9dfac00f05b06dc117299f5ea4e85fbc7bb443af4911cc" -"checksum curl 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "faf54d927c752b092d3e99ea227d9c7c9b4a3e885a3368ac9bfa28958f215100" +"checksum curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ad0acf8372df3d5fedd84caba1dd2f6588d93db98a268e419e3b1aadfcc9e928" "checksum curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4f198d10378a3bc1f1b0e3bc3a2de5c9bb9e08938460dec57ba6667d9a65fbc3" "checksum docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20016093b4e545dccf6ad4a01099de0b695f9bc99b08210e68f6425db2d37d" "checksum env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "82dcb9ceed3868a03b335657b85a159736c961900f7e7747d3b0b97b9ccb5ccb" @@ -667,17 +641,16 @@ dependencies = [ "checksum fs2 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bcd414e5a1a979b931bb92f41b7a54106d3f6d2e6c253e9ce943b7cd468251ef" "checksum gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "91ecd03771effb0c968fd6950b37e89476a578aaf1c70297d8e92b6516ec3312" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" -"checksum git2 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "33a96eeef227403006cdb59ea6e05baad8cddde6b79abed753d96ccee136bad2" -"checksum git2-curl 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d5f766d804e3cf2b90e16ab77c3ddedcb1ca5d2456cadb7b3f907345f8c3498" +"checksum git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51bb1cf64e8a47bbf51dd102131b97f7ae8cd228b6cf79f6b206a67acee66865" +"checksum git2-curl 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce3b9636eed8a30e48a5ae6085575e685d439a1c4d77e22c98a3a70cefbaed01" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" "checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" "checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" -"checksum libgit2-sys 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3293dc95169a6351c5a03eca4bf5549f3a9a06336a000315876ff1165a5fba10" -"checksum libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc058951ab6a3ef35ca16462d7642c4867e6403520811f28537a4e2f2db3e71" -"checksum libssh2-sys 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "1debd7e56d19655eb786f827675dc55f6d530de6d7b81e76d13d1afc635d6c07" +"checksum libgit2-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd04749dea554978df30997744fda41b71b3857d4999938ad6a1c9c633eeb2ea" +"checksum libssh2-sys 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "07bd565ee9894fc64a7e5a6fd4d1afdfa04be6c1a03cba372a3b50d1b17061aa" "checksum libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "40f2df7730b5d29426c3e44ce4d088d8c5def6471c2c93ba98585b89fb201ce6" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" "checksum matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "15305656809ce5a4805b1ff2946892810992197ce1270ff79baded852187942e" @@ -693,11 +666,10 @@ dependencies = [ "checksum num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "54ff603b8334a72fbb27fe66948aac0abaaa40231b3cecd189e76162f6f38aaf" "checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c" "checksum num_cpus 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a859041cbf7a70ea1ece4b87d1a2c6ef364dcb68749c88db1f97304b9ec09d5f" -"checksum openssl 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "c4117b6244aac42ed0150a6019b4d953d28247c5dd6ae6f46ae469b5f2318733" -"checksum openssl-sys 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ac5e9d911dd4c3202bbf4139b73bc7a1231f7d0a39432c6f893745f0e04120" -"checksum openssl-sys-extras 0.7.14 (registry+https://github.com/rust-lang/crates.io-index)" = "11c5e1dba7d3d03d80f045bf0d60111dc69213b67651e7c889527a3badabb9fa" +"checksum openssl 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62099ae76536c30307037a00b9a539d076dfa744e7931a674489dd198934d479" +"checksum openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "756d49c8424483a3df3b5d735112b4da22109ced9a8294f1f5cdf80fb3810919" +"checksum openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48b25c7337949b0e04625444efbff87bef5251e1a4d19aeac6d317d49c8a8df3" "checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa" -"checksum pnacl-build-helper 1.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "61c9231d31aea845007443d62fcbb58bb6949ab9c18081ee1e09920e0cf1118b" "checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" "checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5" "checksum regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)" = "64b03446c466d35b42f2a8b203c8e03ed8b91c0f17b56e1f84f7210a257aa665" diff --git a/Cargo.toml b/Cargo.toml index ee573bb094e..c1a67515cb3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,12 +26,12 @@ env_logger = "0.3" filetime = "0.1" flate2 = "0.2" fs2 = "0.2" -git2 = "0.4" -git2-curl = "0.5" +git2 = "0.5" +git2-curl = "0.6" glob = "0.2" kernel32-sys = "0.2" libc = "0.2" -libgit2-sys = "0.4" +libgit2-sys = "0.5" log = "0.3" miow = "0.1" num_cpus = "1.0" @@ -47,7 +47,7 @@ url = "1.1" winapi = "0.2" [target.'cfg(unix)'.dependencies] -openssl = "0.7" +openssl = "0.9" [dev-dependencies] hamcrest = "0.1" diff --git a/src/cargo/util/sha256.rs b/src/cargo/util/sha256.rs index 80a48d84b50..376455d6a71 100644 --- a/src/cargo/util/sha256.rs +++ b/src/cargo/util/sha256.rs @@ -7,13 +7,14 @@ mod imp { extern crate openssl; use std::io::Write; - use self::openssl::crypto::hash::{Hasher, Type}; + use self::openssl::hash::{Hasher, MessageDigest}; pub struct Sha256(Hasher); impl Sha256 { pub fn new() -> Sha256 { - Sha256(Hasher::new(Type::SHA256)) + let hasher = Hasher::new(MessageDigest::sha256()).unwrap(); + Sha256(hasher) } pub fn update(&mut self, bytes: &[u8]) { @@ -22,7 +23,8 @@ mod imp { pub fn finish(&mut self) -> [u8; 32] { let mut ret = [0u8; 32]; - ret.copy_from_slice(&self.0.finish()[..]); + let data = self.0.finish().unwrap(); + ret.copy_from_slice(&data[..]); ret } } diff --git a/tests/build-auth.rs b/tests/build-auth.rs index 8784329a9d6..761d319412b 100644 --- a/tests/build-auth.rs +++ b/tests/build-auth.rs @@ -41,7 +41,7 @@ fn http_auth_offered() { assert_eq!(req, vec![ "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Accept: */*", - "User-Agent: git/1.0 (libgit2 0.23.0)", + "User-Agent: git/1.0 (libgit2 0.24.0)", ].into_iter().map(|s| s.to_string()).collect()); drop(s); @@ -56,7 +56,7 @@ fn http_auth_offered() { "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Authorization: Basic Zm9vOmJhcg==", "Accept: */*", - "User-Agent: git/1.0 (libgit2 0.23.0)", + "User-Agent: git/1.0 (libgit2 0.24.0)", ].into_iter().map(|s| s.to_string()).collect()); }); diff --git a/tests/cargotest/Cargo.toml b/tests/cargotest/Cargo.toml index fd5f3431a2d..1b59c708e62 100644 --- a/tests/cargotest/Cargo.toml +++ b/tests/cargotest/Cargo.toml @@ -11,7 +11,7 @@ bufstream = "0.1" cargo = { path = "../.." } filetime = "0.1" flate2 = "0.2" -git2 = "0.4" +git2 = "0.5" hamcrest = "0.1" kernel32-sys = "0.2" libc = "0.2" From 05ef003e91588681a41dc70094401ddcfceeb813 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 8 Nov 2016 17:32:21 -0800 Subject: [PATCH 0825/3888] Set OPENSSL_DIR for CI --- .travis.yml | 2 ++ Makefile.in | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7e61d7e280f..7b946c0186b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ matrix: MACOSX_DEPLOYMENT_TARGET=10.7 os: osx before_install: + - export OPENSSL_DIR=`brew --prefix openssl` - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include - env: TARGET=i686-apple-darwin @@ -33,6 +34,7 @@ matrix: CFG_DISABLE_CROSS_TESTS=1 os: osx before_install: + - export OPENSSL_DIR=`brew --prefix openssl` - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include diff --git a/Makefile.in b/Makefile.in index da0b097ffea..0c2ca69a376 100644 --- a/Makefile.in +++ b/Makefile.in @@ -251,10 +251,12 @@ target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \ # variables read by various build scripts to find openssl cargo-$(1): export OPENSSL_STATIC := 1 +cargo-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) cargo-$(1): export OPENSSL_ROOT_DIR := $$(OPENSSL_INSTALL_$(1)) cargo-$(1): export OPENSSL_LIB_DIR := $$(OPENSSL_INSTALL_$(1))/lib cargo-$(1): export OPENSSL_INCLUDE_DIR := $$(OPENSSL_INSTALL_$(1))/include test-unit-$(1): export OPENSSL_STATIC := 1 +test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) test-unit-$(1): export OPENSSL_ROOT_DIR := $$(OPENSSL_INSTALL_$(1)) test-unit-$(1): export OPENSSL_LIB_DIR := $$(OPENSSL_INSTALL_$(1))/lib test-unit-$(1): export OPENSSL_INCLUDE_DIR := $$(OPENSSL_INSTALL_$(1))/include From 1854d5106c23240e551bb1ea6ce8931bdc4ea858 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sat, 12 Nov 2016 00:26:39 -0800 Subject: [PATCH 0826/3888] Link targets in the FRESH step as well --- src/cargo/ops/cargo_rustc/context.rs | 11 +++- src/cargo/ops/cargo_rustc/fingerprint.rs | 14 ++--- src/cargo/ops/cargo_rustc/layout.rs | 2 - src/cargo/ops/cargo_rustc/mod.rs | 74 ++++++++++++++---------- tests/freshness.rs | 27 +-------- 5 files changed, 62 insertions(+), 66 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 9c4a34c48d4..4359cbc14a9 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -361,7 +361,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } - /// Returns the file stem for a given target/profile combo + /// Returns the file stem for a given target/profile combo (with metadata) pub fn file_stem(&self, unit: &Unit) -> String { match self.target_metadata(unit) { Some(ref metadata) => format!("{}{}", unit.target.crate_name(), @@ -370,6 +370,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } + /// Returns the bin stem for a given target (without metadata) fn bin_stem(&self, unit: &Unit) -> String { if unit.target.allows_underscores() { unit.target.name().to_string() @@ -378,6 +379,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } + /// Returns a tuple with the directory and name of the hard link we expect + /// our target to be copied to. Eg, file_stem may be out_dir/deps/foo-abcdef + /// and link_stem would be out_dir/foo + /// This function returns it in two parts so the caller can add prefix/suffis + /// to filename separately + + /// Returns an Option because in some cases we don't want to link + /// (eg a dependent lib) pub fn link_stem(&self, unit: &Unit) -> Option<(PathBuf, String)> { let src_dir = self.out_dir(unit); let bin_stem = self.bin_stem(unit); diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index a5d3e53e14a..1f785609fd5 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -83,9 +83,9 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, .join("index.html").exists(); } else { for (src, link_dst, _) in try!(cx.target_filenames(unit)) { - missing_outputs |= fs::metadata(&src).is_err(); + missing_outputs |= !src.exists(); if let Some(link_dst) = link_dst { - missing_outputs |= fs::metadata(link_dst).is_err(); + missing_outputs |= !link_dst.exists(); } } } @@ -654,12 +654,10 @@ fn mtime_if_fresh(output: &Path, paths: I) -> Option } fn filename(cx: &Context, unit: &Unit) -> String { - // If there exists a link stem, we have to use that since multiple target filenames - // may hardlink to the same target stem. If there's no link, we can use the original - // file_stem (which can include a suffix) - let file_stem = cx.link_stem(unit) - .map(|(_path, stem)| stem) - .unwrap_or_else(|| cx.file_stem(unit)); + // file_stem includes metadata hash. Thus we have a different + // fingerprint for every metadata hash version. This works because + // even if the package is fresh, we'll still link the fresh target + let file_stem = cx.file_stem(unit); let kind = match *unit.target.kind() { TargetKind::Lib(..) => "lib", TargetKind::Bin => "bin", diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index 0c7723f401d..393b3defd08 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -172,8 +172,6 @@ impl<'a> LayoutProxy<'a> { self.build(unit.pkg) } else if unit.target.is_example() { self.examples().to_path_buf() - } else if unit.target.is_lib() { - self.deps().to_path_buf() } else { self.deps().to_path_buf() } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 82014c49323..435f28f5c2e 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -190,7 +190,11 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, } else { try!(rustc(cx, unit)) }; - let dirty = work.then(dirty); + let link_work1 = try!(link_targets(cx, unit)); + let link_work2 = try!(link_targets(cx, unit)); + // Need to link targets on both the dirty and fresh + let dirty = work.then(link_work1).then(dirty); + let fresh = link_work2.then(fresh); (dirty, fresh, freshness) }; try!(jobs.enqueue(cx, unit, Job::new(dirty, fresh), freshness)); @@ -318,36 +322,6 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { try!(fingerprint::append_current_dir(&dep_info_loc, &cwd)); } - // If we're a "root crate", e.g. the target of this compilation, then we - // hard link our outputs out of the `deps` directory into the directory - // above. This means that `cargo build` will produce binaries in - // `target/debug` which one probably expects. - for (src, link_dst, _linkable) in filenames { - // This may have been a `cargo rustc` command which changes the - // output, so the source may not actually exist. - debug!("Thinking about linking {} to {:?}", src.display(), link_dst); - if !src.exists() || link_dst.is_none() { - continue - } - let dst = link_dst.unwrap(); - - debug!("linking {} to {}", src.display(), dst.display()); - if dst.exists() { - try!(fs::remove_file(&dst).chain_error(|| { - human(format!("failed to remove: {}", dst.display())) - })); - } - try!(fs::hard_link(&src, &dst) - .or_else(|err| { - debug!("hard link failed {}. falling back to fs::copy", err); - fs::copy(&src, &dst).map(|_| ()) - }) - .chain_error(|| { - human(format!("failed to link or copy `{}` to `{}`", - src.display(), dst.display())) - })); - } - Ok(()) })); @@ -381,6 +355,44 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { } } +/// Link the compiled target (often of form foo-{metadata_hash}) to the +/// final target. This must happen during both "Fresh" and "Compile" +fn link_targets(cx: &mut Context, unit: &Unit) -> CargoResult { + let filenames = try!(cx.target_filenames(unit)); + Ok(Work::new(move |_| { + // If we're a "root crate", e.g. the target of this compilation, then we + // hard link our outputs out of the `deps` directory into the directory + // above. This means that `cargo build` will produce binaries in + // `target/debug` which one probably expects. + for (src, link_dst, _linkable) in filenames { + // This may have been a `cargo rustc` command which changes the + // output, so the source may not actually exist. + debug!("Thinking about linking {} to {:?}", src.display(), link_dst); + if !src.exists() || link_dst.is_none() { + continue + } + let dst = link_dst.unwrap(); + + debug!("linking {} to {}", src.display(), dst.display()); + if dst.exists() { + try!(fs::remove_file(&dst).chain_error(|| { + human(format!("failed to remove: {}", dst.display())) + })); + } + try!(fs::hard_link(&src, &dst) + .or_else(|err| { + debug!("hard link failed {}. falling back to fs::copy", err); + fs::copy(&src, &dst).map(|_| ()) + }) + .chain_error(|| { + human(format!("failed to link or copy `{}` to `{}`", + src.display(), dst.display())) + })); + } + Ok(()) + })) +} + fn load_build_deps(cx: &Context, unit: &Unit) -> Option> { cx.build_scripts.get(unit).cloned() } diff --git a/tests/freshness.rs b/tests/freshness.rs index 786aef22275..1a51f2e69b8 100644 --- a/tests/freshness.rs +++ b/tests/freshness.rs @@ -172,17 +172,11 @@ fn changing_lib_features_caches_targets() { [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); - /* Targets should be cached from the first build - XXX Sadly these cannot be cached since the "symlink" step is - not separate from the "compile" step. Packages which link - to top level binaries eg (deps/foo-abc123 -> foo) are forced - to do an extra recompile here. - */ + /* Targets should be cached from the first build */ assert_that(p.cargo("build"), execs().with_status(0) .with_stderr("\ -[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -193,7 +187,6 @@ fn changing_lib_features_caches_targets() { assert_that(p.cargo("build").arg("--features").arg("foo"), execs().with_status(0) .with_stderr("\ -[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -231,24 +224,17 @@ fn changing_profiles_caches_targets() { [DOCTEST] foo ")); - /* Targets should be cached from the first build - XXX Sadly these cannot be cached since the "symlink" step is - not separate from the "compile" step. Packages which link - to top level binaries eg (deps/foo-abc123 -> foo) are forced - to do an extra recompile here. - */ + /* Targets should be cached from the first build */ assert_that(p.cargo("build"), execs().with_status(0) .with_stderr("\ -[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); assert_that(p.cargo("test").arg("foo"), execs().with_status(0) .with_stderr("\ -[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[..]debug[..]deps[..]foo-[..][EXE] [DOCTEST] foo @@ -423,18 +409,12 @@ fn changing_bin_features_caches_targets() { [RUNNING] `target[/]debug[/]foo[EXE]` ")); - /* Targets should be cached from the first build - XXX Sadly these cannot be cached since the "symlink" step is - not separate from the "compile" step. Packages which link - to top level binaries eg (deps/foo-abc123 -> foo) are forced - to do an extra recompile here. - */ + /* Targets should be cached from the first build */ assert_that(p.cargo("run"), execs().with_status(0) .with_stdout("feature off") .with_stderr("\ -[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[/]debug[/]foo[EXE]` ")); @@ -443,7 +423,6 @@ fn changing_bin_features_caches_targets() { execs().with_status(0) .with_stdout("feature on") .with_stderr("\ -[..]Compiling foo v0.0.1 ([..]) [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[/]debug[/]foo[EXE]` ")); From 9850555fb276ccb77fb39e7e872e260fc44848a6 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Sat, 12 Nov 2016 10:19:10 +0100 Subject: [PATCH 0827/3888] Changed rustversion to latest nightly release --- src/rustversion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rustversion.txt b/src/rustversion.txt index e10ea319408..c924b247301 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-11-11 +2016-11-04 From 37a65b3be52365747da4004a68c9d1060264bd34 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Sat, 12 Nov 2016 10:33:59 +0100 Subject: [PATCH 0828/3888] Fixed too long lines --- src/cargo/sources/path.rs | 14 ++++++++++++-- src/cargo/util/toml.rs | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index e5a7ae6f8ce..18e6e35da8a 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -94,8 +94,18 @@ impl<'cfg> PathSource<'cfg> { human(format!("could not parse pattern `{}`: {}", p, e)) }) }; - let exclude = pkg.manifest().exclude().iter().map(|p| parse(p)).collect::, _>>()?; - let include = pkg.manifest().include().iter().map(|p| parse(p)).collect::, _>>()?; + + let exclude = pkg.manifest() + .exclude() + .iter() + .map(|p| parse(p)) + .collect::, _>>()?; + + let include = pkg.manifest() + .include() + .iter() + .map(|p| parse(p)) + .collect::, _>>()?; let mut filter = |p: &Path| { let relative_path = util::without_prefix(p, &root).unwrap(); diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index ca61e3a546b..c5d70b7098b 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -597,15 +597,21 @@ impl TomlManifest { } // Collect the deps - process_dependencies(&mut cx, self.dependencies.as_ref(), None)?; - process_dependencies(&mut cx, self.dev_dependencies.as_ref(), Some(Kind::Development))?; - process_dependencies(&mut cx, self.build_dependencies.as_ref(), Some(Kind::Build))?; + process_dependencies(&mut cx, self.dependencies.as_ref(), + None)?; + process_dependencies(&mut cx, self.dev_dependencies.as_ref(), + Some(Kind::Development))?; + process_dependencies(&mut cx, self.build_dependencies.as_ref(), + Some(Kind::Build))?; for (name, platform) in self.target.iter().flat_map(|t| t) { cx.platform = Some(name.parse()?); - process_dependencies(&mut cx, platform.dependencies.as_ref(), None)?; - process_dependencies(&mut cx, platform.build_dependencies.as_ref(), Some(Kind::Build))?; - process_dependencies(&mut cx, platform.dev_dependencies.as_ref(), Some(Kind::Development))?; + process_dependencies(&mut cx, platform.dependencies.as_ref(), + None)?; + process_dependencies(&mut cx, platform.build_dependencies.as_ref(), + Some(Kind::Build))?; + process_dependencies(&mut cx, platform.dev_dependencies.as_ref(), + Some(Kind::Development))?; } replace = self.replace(&mut cx)?; From 239d3f75566fd9ae8b57ec3ee5fcde979b32886a Mon Sep 17 00:00:00 2001 From: Jake Goldsborough Date: Sat, 12 Nov 2016 09:04:02 -0800 Subject: [PATCH 0829/3888] fixing build script docs mistakes --- src/doc/build-script.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doc/build-script.md b/src/doc/build-script.md index f5fe8e283fb..9844ee235d5 100644 --- a/src/doc/build-script.md +++ b/src/doc/build-script.md @@ -81,7 +81,7 @@ crate is built: out in crates.io crates are not emitted by default. Any other element is a user-defined metadata that will be passed to -dependencies. More information about this can be found in the [`links`][links] +dependents. More information about this can be found in the [`links`][links] section. [links]: #the-links-manifest-key @@ -252,9 +252,7 @@ This is where the real magic happens. The library is using the rustc-defined the generated file (`hello.rs`) into the crate’s compilation. Using the structure shown here, crates can include any number of generated files -from the build script itself. We’ve also seen a brief example of how a build -script can use a crate as a dependency purely for the build process and not for -the crate itself at runtime. +from the build script itself. # Case study: Building some native code @@ -400,6 +398,9 @@ And there we go! This should complete our example of building some C code from a Cargo package using the build script itself. This also shows why using a build dependency can be crucial in many situations and even much more concise! +We’ve also seen a brief example of how a build script can use a crate as a +dependency purely for the build process and not for the crate itself at runtime. + # Case study: Linking to system libraries The final case study here will be investigating how a Cargo library links to a From 195f72f314d6be7b7cbee29fe4816cd5c1486539 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sat, 12 Nov 2016 18:55:07 -0800 Subject: [PATCH 0830/3888] Added back __CARGO_DEFAULT_LIB_METADATA handling with comment + test --- src/cargo/ops/cargo_rustc/context.rs | 22 ++++++- tests/build.rs | 86 ++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 4359cbc14a9..a1552d63654 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -308,11 +308,31 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Get the metadata for a target in a specific profile + /// We build to the path: "{filename}-{target_metadata}" + /// We use a linking step to link/copy to a predictable filename + /// like `target/debug/libfoo.{a,so,rlib}` and such. pub fn target_metadata(&self, unit: &Unit) -> Option { // No metadata for dylibs because of a couple issues // - OSX encodes the dylib name in the executable // - Windows rustc multiple files of which we can't easily link all of them - if !unit.profile.test && unit.target.is_dylib() { + // + // Two expeptions + // 1) Upstream dependencies (we aren't exporting + need to resolve name conflict) + // 2) __CARGO_DEFAULT_LIB_METADATA env var + // + // Note, though, that the compiler's build system at least wants + // path dependencies (eg libstd) to have hashes in filenames. To account for + // that we have an extra hack here which reads the + // `__CARGO_DEFAULT_METADATA` environment variable and creates a + // hash in the filename if that's present. + // + // This environment variable should not be relied on! It's + // just here for rustbuild. We need a more principled method + // doing this eventually. + if !unit.profile.test && + unit.target.is_dylib() && + unit.pkg.package_id().source_id().is_path() && + !env::var("__CARGO_DEFAULT_LIB_METADATA").is_ok() { return None; } diff --git a/tests/build.rs b/tests/build.rs index ac274de22a6..decfa8ed52e 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -417,6 +417,8 @@ fn cargo_compile_with_nested_deps_inferred() { .unwrap(); assert_that(&p.bin("foo"), existing_file()); + assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); + assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); assert_that( process(&p.bin("foo")), @@ -476,6 +478,8 @@ fn cargo_compile_with_nested_deps_correct_bin() { .unwrap(); assert_that(&p.bin("foo"), existing_file()); + assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); + assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); assert_that( process(&p.bin("foo")), @@ -544,6 +548,8 @@ fn cargo_compile_with_nested_deps_shorthand() { .unwrap(); assert_that(&p.bin("foo"), existing_file()); + assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); + assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); assert_that( process(&p.bin("foo")), @@ -612,6 +618,8 @@ fn cargo_compile_with_nested_deps_longhand() { assert_that(p.cargo_process("build"), execs()); assert_that(&p.bin("foo"), existing_file()); + assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); + assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); assert_that(process(&p.bin("foo")), execs().with_stdout("test passed\n")); @@ -754,6 +762,84 @@ fn ignores_carriage_return_in_lockfile() { execs().with_status(0)); } +#[test] +fn cargo_default_env_metadata_env_var() { + // Ensure that path dep + dylib + env_var get metadata + // (even though path_dep + dylib should not) + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "bar" + "#) + .file("src/lib.rs", "// hi") + .file("bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + + [lib] + name = "bar" + crate_type = ["dylib"] + "#) + .file("bar/src/lib.rs", "// hello"); + + // No metadata on libbar since it's a dylib path dependency + assert_that(p.cargo_process("build").arg("-v"), + execs().with_status(0).with_stderr(&format!("\ +[COMPILING] bar v0.0.1 ({url}[/]bar) +[RUNNING] `rustc bar[/]src[/]lib.rs --crate-name bar --crate-type dylib \ + -C prefer-dynamic -g \ + -C metadata=[..] \ + --out-dir [..] \ + --emit=dep-info,link \ + -L dependency={dir}[/]target[/]debug[/]deps` +[COMPILING] foo v0.0.1 ({url}) +[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ + -C metadata=[..] \ + -C extra-filename=[..] \ + --out-dir [..] \ + --emit=dep-info,link \ + -L dependency={dir}[/]target[/]debug[/]deps \ + --extern bar={dir}[/]target[/]debug[/]deps[/]libbar.dylib` +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +", +dir = p.root().display(), +url = p.url(), +))); + + assert_that(p.cargo_process("clean"), execs().with_status(0)); + + // If you set the env-var, then we expect metadata on libbar + assert_that(p.cargo_process("build").arg("-v").env("__CARGO_DEFAULT_LIB_METADATA", "1"), + execs().with_status(0).with_stderr(&format!("\ +[COMPILING] bar v0.0.1 ({url}[/]bar) +[RUNNING] `rustc bar[/]src[/]lib.rs --crate-name bar --crate-type dylib \ + -C prefer-dynamic -g \ + -C metadata=[..] \ + --out-dir [..] \ + --emit=dep-info,link \ + -L dependency={dir}[/]target[/]debug[/]deps` +[COMPILING] foo v0.0.1 ({url}) +[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ + -C metadata=[..] \ + -C extra-filename=[..] \ + --out-dir [..] \ + --emit=dep-info,link \ + -L dependency={dir}[/]target[/]debug[/]deps \ + --extern bar={dir}[/]target[/]debug[/]deps[/]libbar-[..].dylib` +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +", +dir = p.root().display(), +url = p.url(), +))); +} + #[test] fn crate_env_vars() { let p = project("foo") From d5d95d02d02fc24249ff4e97b05de402b306230d Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sat, 12 Nov 2016 19:27:09 -0800 Subject: [PATCH 0831/3888] Fix [/] for windows on env_metadata test --- tests/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build.rs b/tests/build.rs index decfa8ed52e..344b960eba7 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -792,7 +792,7 @@ fn cargo_default_env_metadata_env_var() { // No metadata on libbar since it's a dylib path dependency assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ -[COMPILING] bar v0.0.1 ({url}[/]bar) +[COMPILING] bar v0.0.1 ({url}/bar) [RUNNING] `rustc bar[/]src[/]lib.rs --crate-name bar --crate-type dylib \ -C prefer-dynamic -g \ -C metadata=[..] \ From 9e83a45b0f54b25572f8a32af7e74de589185ed2 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sat, 12 Nov 2016 21:49:44 -0800 Subject: [PATCH 0832/3888] Fix dll prefix/suffix test for windows --- tests/build.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/build.rs b/tests/build.rs index 344b960eba7..3f742a5cfda 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -806,11 +806,13 @@ fn cargo_default_env_metadata_env_var() { --out-dir [..] \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps \ - --extern bar={dir}[/]target[/]debug[/]deps[/]libbar.dylib` + --extern bar={dir}[/]target[/]debug[/]deps[/]{prefix}bar{suffix}` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), url = p.url(), +prefix = env::consts::DLL_PREFIX, +suffix = env::consts::DLL_SUFFIX, ))); assert_that(p.cargo_process("clean"), execs().with_status(0)); @@ -832,11 +834,13 @@ url = p.url(), --out-dir [..] \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps \ - --extern bar={dir}[/]target[/]debug[/]deps[/]libbar-[..].dylib` + --extern bar={dir}[/]target[/]debug[/]deps[/]{prefix}bar-[..]{suffix}` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), url = p.url(), +prefix = env::consts::DLL_PREFIX, +suffix = env::consts::DLL_SUFFIX, ))); } From 27550a6e8f737c55024de6a8e39fee6452133ac1 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Sat, 12 Nov 2016 22:16:56 -0800 Subject: [PATCH 0833/3888] Fix one more [/] in env-var test for windows --- tests/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build.rs b/tests/build.rs index 3f742a5cfda..68a3562628c 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -820,7 +820,7 @@ suffix = env::consts::DLL_SUFFIX, // If you set the env-var, then we expect metadata on libbar assert_that(p.cargo_process("build").arg("-v").env("__CARGO_DEFAULT_LIB_METADATA", "1"), execs().with_status(0).with_stderr(&format!("\ -[COMPILING] bar v0.0.1 ({url}[/]bar) +[COMPILING] bar v0.0.1 ({url}/bar) [RUNNING] `rustc bar[/]src[/]lib.rs --crate-name bar --crate-type dylib \ -C prefer-dynamic -g \ -C metadata=[..] \ From c48984c36e9db462ef210319a585134a5a3d25b4 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Mon, 14 Nov 2016 18:02:41 +0100 Subject: [PATCH 0834/3888] Changed rustversion to 2016-11-05 --- src/rustversion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rustversion.txt b/src/rustversion.txt index c924b247301..d4da2ff74c9 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-11-04 +2016-11-05 From 8bb8ce58ff69dbc71c38f3039ce94fba82aec89f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Nov 2016 07:11:16 -0800 Subject: [PATCH 0835/3888] More updates for OpenSSL 1.1.0 --- .travis.yml | 18 ++- Cargo.lock | 224 ++++++++++++++++----------------- Cargo.toml | 10 +- Makefile.in | 6 - appveyor.yml | 9 +- src/crates-io/Cargo.toml | 2 +- tests/build-auth.rs | 7 +- tests/cargotest/Cargo.toml | 2 +- tests/cargotest/support/mod.rs | 31 +++-- tests/freshness.rs | 7 +- tests/net-config.rs | 6 +- 11 files changed, 164 insertions(+), 158 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b946c0186b..9046991de40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,19 +24,12 @@ matrix: MAKE_TARGETS="test distcheck doc install uninstall" MACOSX_DEPLOYMENT_TARGET=10.7 os: osx - before_install: - - export OPENSSL_DIR=`brew --prefix openssl` - - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include - env: TARGET=i686-apple-darwin MAKE_TARGETS=test MACOSX_DEPLOYMENT_TARGET=10.7 CFG_DISABLE_CROSS_TESTS=1 os: osx - before_install: - - export OPENSSL_DIR=`brew --prefix openssl` - - export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include - - export OPENSSL_LIB_DIR=`brew --prefix openssl`/include + install: brew uninstall openssl && brew install openssl --universal --without-test # stable musl target, tested - env: TARGET=x86_64-unknown-linux-musl @@ -129,6 +122,11 @@ notifications: email: on_success: never +branches: + only: + - master + - auto-cargo + before_deploy: - mkdir -p deploy/$TRAVIS_COMMIT - cp target/$TARGET/release/dist/cargo-nightly-$TARGET.tar.gz @@ -142,9 +140,9 @@ deploy: upload_dir: cargo-master acl: public_read region: us-west-1 - access_key_id: AKIAJYHGN72KKCN4DFBQ + access_key_id: AKIAIWZDM2B2IJOWBGTA secret_access_key: - secure: wKKDMYBVTdWLuc7+ffpjTqJs1EdM2pXpV6keUfZGv9RLRta+esh/r/cgc+UQ7+m9JHAliH8eWhlMm5ws6WDgkTvM0PTdqWBgwd24BRbAitsXX2kWfi9WgAeSJVSkIJdZ999TRpRIJu7Zc+1++fbfdD/tDv5XBirQGOJv1HynVWY= + secure: NB9b/MhIDiv8OtNiN/sHaFgA3xG2fa7MGuQQKJNj80ktvgByzDm5UPNyNeoYx9SmJ3jOWobgcPVaoUd2S+6XgO3bMBqm7sM/oMeE0KdqToh6+V2bKfyRF2U5fm697LEGepPIBYqMLDg4nr/dbknbKltzp6dAfJRyy22Nb721zPQ= on: branch: auto-cargo condition: $DEPLOY = 1 diff --git a/Cargo.lock b/Cargo.lock index 2fbe5426011..9853a26f1ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,33 +6,33 @@ dependencies = [ "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "cargotest 0.1.0", "crates-io 0.4.0", - "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", - "docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "fs2 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "git2-curl 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -71,16 +71,16 @@ dependencies = [ "cargo 0.15.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -91,69 +91,69 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cmake" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crates-io" version = "0.4.0" dependencies = [ - "curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "curl" -version = "0.3.10" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl-sys" -version = "0.2.4" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "docopt" -version = "0.6.82" +version = "0.6.86" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "env_logger" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "fs2" -version = "0.2.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -185,7 +185,7 @@ dependencies = [ [[package]] name = "gcc" -version = "0.3.35" +version = "0.3.38" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -199,26 +199,26 @@ dependencies = [ [[package]] name = "git2" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "git2-curl" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -232,7 +232,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -240,7 +240,7 @@ name = "idna" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -256,7 +256,7 @@ dependencies = [ [[package]] name = "lazy_static" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -266,37 +266,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.5.2" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libssh2-sys" -version = "0.1.40" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libz-sys" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -308,7 +308,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "matches" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -324,7 +324,7 @@ name = "miniz-sys" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -372,7 +372,7 @@ dependencies = [ "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -381,7 +381,7 @@ version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -409,7 +409,7 @@ dependencies = [ "num-bigint 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -419,7 +419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num_cpus" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -427,13 +427,13 @@ dependencies = [ [[package]] name = "openssl" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -443,7 +443,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -476,24 +476,24 @@ dependencies = [ [[package]] name = "regex" -version = "0.1.77" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-serialize" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -509,13 +509,13 @@ name = "semver-parser" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "strsim" -version = "0.3.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -555,7 +555,7 @@ dependencies = [ [[package]] name = "thread_local" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -563,10 +563,10 @@ dependencies = [ [[package]] name = "toml" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -574,7 +574,7 @@ name = "unicode-bidi" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -584,11 +584,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "url" -version = "1.2.0" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -630,30 +630,30 @@ dependencies = [ "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7b48dbe2ff0e98fa2f03377d204a9637d3c9816cd431bfe05a8abbd0ea11d074" "checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c" -"checksum cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "dfcf5bcece56ef953b8ea042509e9dcbdfe97820b7e20d86beb53df30ed94978" -"checksum crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fb974f835e90390c5f9dfac00f05b06dc117299f5ea4e85fbc7bb443af4911cc" -"checksum curl 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ad0acf8372df3d5fedd84caba1dd2f6588d93db98a268e419e3b1aadfcc9e928" -"checksum curl-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4f198d10378a3bc1f1b0e3bc3a2de5c9bb9e08938460dec57ba6667d9a65fbc3" -"checksum docopt 0.6.82 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20016093b4e545dccf6ad4a01099de0b695f9bc99b08210e68f6425db2d37d" -"checksum env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "82dcb9ceed3868a03b335657b85a159736c961900f7e7747d3b0b97b9ccb5ccb" +"checksum cmake 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0e5bcf27e097a184c1df4437654ed98df3d7a516e8508a6ba45d8b092bbdf283" +"checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97" +"checksum curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fd5a1fdcebdb1a59578c5583e66ffed2d13850eac4f51ff730edf6dd6111eac" +"checksum curl-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8e0016cc7b33b00fb7e7f6a314d8ee40748b13f377832ed9ff9e59dbb7f7ad27" +"checksum docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" = "4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9" +"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922" "checksum flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "3eeb481e957304178d2e782f2da1257f1434dfecbae883bafb61ada2a9fea3bb" -"checksum fs2 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bcd414e5a1a979b931bb92f41b7a54106d3f6d2e6c253e9ce943b7cd468251ef" -"checksum gcc 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "91ecd03771effb0c968fd6950b37e89476a578aaf1c70297d8e92b6516ec3312" +"checksum fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "640001e1bd865c7c32806292822445af576a6866175b5225aa2087ca5e3de551" +"checksum gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "553f11439bdefe755bf366b264820f1da70f3aaf3924e594b886beb9c831bcf5" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" -"checksum git2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51bb1cf64e8a47bbf51dd102131b97f7ae8cd228b6cf79f6b206a67acee66865" -"checksum git2-curl 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce3b9636eed8a30e48a5ae6085575e685d439a1c4d77e22c98a3a70cefbaed01" +"checksum git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae93eae026f17b013912629d243444e52ee5d6b1339e71d5212099d1d1b73fc2" +"checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" "checksum idna 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1053236e00ce4f668aeca4a769a09b3bf5a682d802abd6f3cb39374f6b162c11" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" +"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" "checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" -"checksum libgit2-sys 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd04749dea554978df30997744fda41b71b3857d4999938ad6a1c9c633eeb2ea" -"checksum libssh2-sys 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "07bd565ee9894fc64a7e5a6fd4d1afdfa04be6c1a03cba372a3b50d1b17061aa" -"checksum libz-sys 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "40f2df7730b5d29426c3e44ce4d088d8c5def6471c2c93ba98585b89fb201ce6" +"checksum libgit2-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ba5bccd2adaf5f251b478000c27532e050be86baa3ebf8c76bb6a7f3c82ef35" +"checksum libssh2-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "538844618f14e5e919332beaf718cf22b63b18cb9b37370560cd1bc55b2734f8" +"checksum libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "283c2d162f78c5090522e13fc809820c33181570ae40de1bea84f3864c8759f9" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" -"checksum matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "15305656809ce5a4805b1ff2946892810992197ce1270ff79baded852187942e" +"checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d1f4d337a01c32e1f2122510fed46393d53ca35a7f429cb0450abaedfa3ed54" "checksum miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5bfc6782530ac8ace97af10a540054a37126b63b0702ddaaa243b73b5745b9a" @@ -665,28 +665,28 @@ dependencies = [ "checksum num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "287a1c9969a847055e1122ec0ea7a5c5d6f72aad97934e131c83d5c08ab4e45c" "checksum num-rational 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "54ff603b8334a72fbb27fe66948aac0abaaa40231b3cecd189e76162f6f38aaf" "checksum num-traits 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a16a42856a256b39c6d3484f097f6713e14feacd9bfb02290917904fae46c81c" -"checksum num_cpus 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a859041cbf7a70ea1ece4b87d1a2c6ef364dcb68749c88db1f97304b9ec09d5f" -"checksum openssl 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62099ae76536c30307037a00b9a539d076dfa744e7931a674489dd198934d479" +"checksum num_cpus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8890e6084723d57d0df8d2720b0d60c6ee67d6c93e7169630e4371e88765dcad" +"checksum openssl 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1eb2a714828f5528e4a24a07c296539216f412364844d61fe1161f94558455d4" "checksum openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "756d49c8424483a3df3b5d735112b4da22109ced9a8294f1f5cdf80fb3810919" -"checksum openssl-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "48b25c7337949b0e04625444efbff87bef5251e1a4d19aeac6d317d49c8a8df3" +"checksum openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "95e9fb08acc32509fac299d6e5f4932e1e055bb70d764282c3ed8beaa87ab0e9" "checksum pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa" "checksum psapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "abcd5d1a07d360e29727f757a9decb3ce8bc6e0efa8969cfaad669a8317a2478" "checksum rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2791d88c6defac799c3f20d74f094ca33b9332612d9aef9078519c82e4fe04a5" -"checksum regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)" = "64b03446c466d35b42f2a8b203c8e03ed8b91c0f17b56e1f84f7210a257aa665" -"checksum regex-syntax 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279401017ae31cf4e15344aa3f085d0e2e5c1e70067289ef906906fdbe92c8fd" -"checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b" +"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" +"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)" = "bff9fc1c79f2dec76b253273d07682e94a978bd8f132ded071188122b2af9818" "checksum semver 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae2ff60ecdb19c255841c066cbfa5f8c2a4ada1eb3ae47c77ab6667128da71f5" "checksum semver-parser 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e88e43a5a74dd2a11707f9c21dfd4a423c66bd871df813227bb0a3e78f3a1ae9" -"checksum strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4d73a2c36a4d095ed1a6df5cbeac159863173447f7a82b3f4757426844ab825" +"checksum strsim 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "50c069df92e4b01425a8bf3576d5d417943a6a7272fbabaf5bd80b1aaa76442e" "checksum tar 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "12e1b959f637c2e4c69dbdbf4d7dc609edbaada9b8c35d0c2fc9802d02383b65" "checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6" "checksum term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3deff8a2b3b6607d6d7cc32ac25c0b33709453ca9cceac006caac51e963cf94a" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -"checksum thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "55dd963dbaeadc08aa7266bf7f91c3154a7805e32bb94b820b769d2ef3b4744d" -"checksum toml 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a442dfc13508e603c3f763274361db7f79d7469a0e95c411cde53662ab30fc72" +"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" +"checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum unicode-bidi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c1f7ceb96afdfeedee42bade65a0d585a6a0106f681b6749c8ff4daa8df30b3f" "checksum unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "26643a2f83bac55f1976fb716c10234485f9202dcd65cfbdf9da49867b271172" -"checksum url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afe9ec54bc4db14bc8744b7fed060d785ac756791450959b2248443319d5b119" +"checksum url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "48ccf7bd87a81b769cf84ad556e034541fb90e1cd6d4bc375c822ed9500cd9d7" "checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" diff --git a/Cargo.toml b/Cargo.toml index c1a67515cb3..fa10f385736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,18 +20,18 @@ path = "src/cargo/lib.rs" advapi32-sys = "0.2" crates-io = { path = "src/crates-io", version = "0.4" } crossbeam = "0.2" -curl = "0.3" +curl = "0.4" docopt = "0.6" env_logger = "0.3" filetime = "0.1" flate2 = "0.2" -fs2 = "0.2" -git2 = "0.5" -git2-curl = "0.6" +fs2 = "0.3" +git2 = "0.6" +git2-curl = "0.7" glob = "0.2" kernel32-sys = "0.2" libc = "0.2" -libgit2-sys = "0.5" +libgit2-sys = "0.6" log = "0.3" miow = "0.1" num_cpus = "1.0" diff --git a/Makefile.in b/Makefile.in index 0c2ca69a376..2af0c33e3b4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -252,14 +252,8 @@ target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \ # variables read by various build scripts to find openssl cargo-$(1): export OPENSSL_STATIC := 1 cargo-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) -cargo-$(1): export OPENSSL_ROOT_DIR := $$(OPENSSL_INSTALL_$(1)) -cargo-$(1): export OPENSSL_LIB_DIR := $$(OPENSSL_INSTALL_$(1))/lib -cargo-$(1): export OPENSSL_INCLUDE_DIR := $$(OPENSSL_INSTALL_$(1))/include test-unit-$(1): export OPENSSL_STATIC := 1 test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) -test-unit-$(1): export OPENSSL_ROOT_DIR := $$(OPENSSL_INSTALL_$(1)) -test-unit-$(1): export OPENSSL_LIB_DIR := $$(OPENSSL_INSTALL_$(1))/lib -test-unit-$(1): export OPENSSL_INCLUDE_DIR := $$(OPENSSL_INSTALL_$(1))/include # build libz statically into the cargo we're producing cargo-$(1): export LIBZ_SYS_STATIC := 1 diff --git a/appveyor.yml b/appveyor.yml index c892a130c82..7187fc0d5eb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,6 +52,11 @@ after_test: - copy target\%TARGET%\release\dist\cargo-nightly-%TARGET%.tar.gz %APPVEYOR_REPO_COMMIT% +branches: + only: + - master + - auto-cargo + artifacts: - path: $(APPVEYOR_REPO_COMMIT)\cargo-nightly-$(TARGET).tar.gz name: cargo @@ -59,9 +64,9 @@ artifacts: deploy: - provider: S3 skip_cleanup: true - access_key_id: AKIAIIBSE766REJRCHEA + access_key_id: AKIAIWZDM2B2IJOWBGTA secret_access_key: - secure: S3MCw/gXyWBuq8cW+eFQjbfjccxrH1koYqQxsYDvCDkM7D2PLqd88yv8lND7dVt0 + secure: hyH54di5NyNdV+jjntM1dRN/NeUgDidwZmwcg4/UKpdJqGf1AAwYb2ulXYK67CXA bucket: rust-lang-cargo-dev set_public: true region: us-west-1 diff --git a/src/crates-io/Cargo.toml b/src/crates-io/Cargo.toml index 71393b8a55b..d4e4afe035d 100644 --- a/src/crates-io/Cargo.toml +++ b/src/crates-io/Cargo.toml @@ -13,6 +13,6 @@ name = "crates_io" path = "lib.rs" [dependencies] -curl = "0.3" +curl = "0.4" url = "1.0" rustc-serialize = "0.3" diff --git a/tests/build-auth.rs b/tests/build-auth.rs index 761d319412b..748937d8ffd 100644 --- a/tests/build-auth.rs +++ b/tests/build-auth.rs @@ -127,7 +127,10 @@ fn https_something_happens() { let a = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = a.local_addr().unwrap(); let t = thread::spawn(move|| { - drop(a.accept().unwrap()); + let mut s = a.accept().unwrap().0; + drop(s.write(b"1234")); + drop(s.shutdown(std::net::Shutdown::Write)); + drop(s.read(&mut [0; 16])); }); let p = project("foo") @@ -164,7 +167,7 @@ Caused by: // just not verify the error message here. "[..]" } else { - "[[..]] SSL error: [..]" + "[..] SSL error: [..]" }))); t.join().ok().unwrap(); diff --git a/tests/cargotest/Cargo.toml b/tests/cargotest/Cargo.toml index 1b59c708e62..d33514b1d6e 100644 --- a/tests/cargotest/Cargo.toml +++ b/tests/cargotest/Cargo.toml @@ -11,7 +11,7 @@ bufstream = "0.1" cargo = { path = "../.." } filetime = "0.1" flate2 = "0.2" -git2 = "0.5" +git2 = { version = "0.6", default-features = false } hamcrest = "0.1" kernel32-sys = "0.2" libc = "0.2" diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index ea63261892b..fc79837708c 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -366,24 +366,29 @@ impl Execs { let mut a = actual.lines(); let e = out.lines(); - let diffs = if partial { - let mut min = self.diff_lines(a.clone(), e.clone(), partial); + if partial { + let mut diffs = self.diff_lines(a.clone(), e.clone(), partial); while let Some(..) = a.next() { let a = self.diff_lines(a.clone(), e.clone(), partial); - if a.len() < min.len() { - min = a; + if a.len() < diffs.len() { + diffs = a; } } - min + ham::expect(diffs.is_empty(), + format!("expected to find:\n\ + {}\n\n\ + did not find in output:\n\ + {}", out, + actual)) } else { - self.diff_lines(a, e, partial) - }; - ham::expect(diffs.is_empty(), - format!("differences:\n\ - {}\n\n\ - other output:\n\ - `{}`", diffs.join("\n"), - String::from_utf8_lossy(extra))) + let diffs = self.diff_lines(a, e, partial); + ham::expect(diffs.is_empty(), + format!("differences:\n\ + {}\n\n\ + other output:\n\ + `{}`", diffs.join("\n"), + String::from_utf8_lossy(extra))) + } } diff --git a/tests/freshness.rs b/tests/freshness.rs index 03baf550ee5..e3e059eb7b0 100644 --- a/tests/freshness.rs +++ b/tests/freshness.rs @@ -199,15 +199,16 @@ fn rebuild_tests_if_lib_changes() { #[test] fn test() { foo::foo(); } "#); + p.build(); - assert_that(p.cargo_process("build"), + p.root().move_into_the_past(); + + assert_that(p.cargo("build"), execs().with_status(0)); assert_that(p.cargo("test"), execs().with_status(0)); File::create(&p.root().join("src/lib.rs")).unwrap(); - p.root().move_into_the_past(); - p.root().join("target").move_into_the_past(); assert_that(p.cargo("build"), execs().with_status(0)); diff --git a/tests/net-config.rs b/tests/net-config.rs index deb9ff940a9..be868c2c26f 100644 --- a/tests/net-config.rs +++ b/tests/net-config.rs @@ -26,7 +26,7 @@ fn net_retry_loads_from_config() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(101) .with_stderr_contains("[WARNING] spurious network error \ -(1 tries remaining): [2/-1] [..]")); +(1 tries remaining): [..]")); } #[test] @@ -50,7 +50,7 @@ fn net_retry_git_outputs_warning() { assert_that(p.cargo_process("build").arg("-v").arg("-j").arg("1"), execs().with_status(101) .with_stderr_contains("[WARNING] spurious network error \ -(2 tries remaining): [2/-1] [..]") +(2 tries remaining): [..]") .with_stderr_contains("\ -[WARNING] spurious network error (1 tries remaining): [2/-1] [..]")); +[WARNING] spurious network error (1 tries remaining): [..]")); } From 35300a323dfa004dd25d73af56e5dddfed0c18b2 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Tue, 15 Nov 2016 07:44:13 +0100 Subject: [PATCH 0836/3888] Changed rustversion to the last successful nightly --- src/rustversion.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rustversion.txt b/src/rustversion.txt index d4da2ff74c9..8918bbc071a 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-11-05 +2016-11-03 From 0b8ba8319107427d0c08844309d5c02c1a5a884d Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Tue, 15 Nov 2016 21:49:41 +0900 Subject: [PATCH 0837/3888] Remove unused type aliases --- src/cargo/core/resolver/mod.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 9cc723d69dc..fab8934bc6a 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -98,11 +98,6 @@ pub enum Method<'a> { }, } -// Err(..) == standard transient error (e.g. I/O error) -// Ok(Err(..)) == resolve error, but is human readable -// Ok(Ok(..)) == success in resolving -type ResolveResult<'a> = CargoResult>>>; - // Information about the dependencies for a crate, a tuple of: // // (dependency info, candidates, features activated) From 36f02c29b64457c097b8e05bd733205fd38eefbe Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Tue, 15 Nov 2016 09:51:12 -0800 Subject: [PATCH 0838/3888] Ignore the flaky lock test on older windows --- tests/concurrent.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/concurrent.rs b/tests/concurrent.rs index a2b827f565d..bd3963d09aa 100644 --- a/tests/concurrent.rs +++ b/tests/concurrent.rs @@ -343,7 +343,9 @@ fn same_project() { // Make sure that if Cargo dies while holding a lock that it's released and the // next Cargo to come in will take over cleanly. +// older win versions don't support job objects, so skip test there #[test] +#[cfg_attr(target_env = "msvc", ignore)] fn killing_cargo_releases_the_lock() { let p = project("foo") .file("Cargo.toml", r#" @@ -496,4 +498,4 @@ fn no_deadlock_with_git_dependencies() { assert_that(result, execs().with_status(0)) } -} \ No newline at end of file +} From 62b06c128f26cebb9b66b41dff4eee88114d9306 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 3 Nov 2016 17:00:13 -0700 Subject: [PATCH 0839/3888] Fix regression with path overrides If an override points to a path dependency then that's not locked, so we're missing information for that, but it's already warned about, so no need to worry. --- src/cargo/core/registry.rs | 10 +++-- tests/overrides.rs | 88 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 037b87a8b62..a798a49a504 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -291,9 +291,13 @@ impl<'cfg> PackageRegistry<'cfg> { override_summary: &Summary, real_summary: &Summary) -> CargoResult<()> { let real = real_summary.package_id(); - let map = self.locked.get(real.source_id()).chain_error(|| { - human(format!("failed to find lock source of {}", real)) - })?; + // If we don't have a locked variant then things are going quite wrong + // at this point, but we've already emitted a warning, so don't worry + // about it. + let map = match self.locked.get(real.source_id()) { + Some(map) => map, + None => return Ok(()), + }; let list = map.get(real.name()).chain_error(|| { human(format!("failed to find lock name of {}", real)) })?; diff --git a/tests/overrides.rs b/tests/overrides.rs index ba17e0f3253..2ba54fbc271 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -925,3 +925,91 @@ fn overriding_nonexistent_no_spurious() { [FINISHED] [..] ").with_stdout("")); } + +#[test] +fn override_to_path_dep() { + Package::new("foo", "0.1.0").dep("bar", "0.1").publish(); + Package::new("bar", "0.1.0").publish(); + + let p = project("local") + .file("Cargo.toml", r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "0.1.0" + "#) + .file("src/lib.rs", "") + .file("foo/Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + bar = { path = "bar" } + "#) + .file("foo/src/lib.rs", "") + .file("foo/bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.0.1" + authors = [] + "#) + .file("foo/bar/src/lib.rs", "") + .file(".cargo/config", r#" + paths = ["foo"] + "#); + + assert_that(p.cargo_process("build"), + execs().with_status(0)); +} + +#[test] +fn replace_to_path_dep() { + Package::new("foo", "0.1.0").dep("bar", "0.1").publish(); + Package::new("bar", "0.1.0").publish(); + + let p = project("local") + .file("Cargo.toml", r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + foo = "0.1.0" + + [replace] + "foo:0.1.0" = { path = "foo" } + "#) + .file("src/lib.rs", "extern crate foo;") + .file("foo/Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { path = "bar" } + "#) + .file("foo/src/lib.rs", " + extern crate bar; + + pub fn foo() { + bar::bar(); + } + ") + .file("foo/bar/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("foo/bar/src/lib.rs", "pub fn bar() {}"); + + assert_that(p.cargo_process("build"), + execs().with_status(0)); +} From 1a9e603ac1517ae07699104f114b7c358df3a7fc Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Tue, 15 Nov 2016 22:48:21 -0800 Subject: [PATCH 0840/3888] Ignore killing_cargo_releases_the_lock on windows --- tests/concurrent.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/concurrent.rs b/tests/concurrent.rs index bd3963d09aa..ba2300afa25 100644 --- a/tests/concurrent.rs +++ b/tests/concurrent.rs @@ -345,7 +345,7 @@ fn same_project() { // next Cargo to come in will take over cleanly. // older win versions don't support job objects, so skip test there #[test] -#[cfg_attr(target_env = "msvc", ignore)] +#[cfg_attr(target_env = "windows", ignore)] fn killing_cargo_releases_the_lock() { let p = project("foo") .file("Cargo.toml", r#" From 7df0c508a5d2cab34bceb9d71603bba92deb4c32 Mon Sep 17 00:00:00 2001 From: Nipunn Koorapati Date: Tue, 15 Nov 2016 23:46:57 -0800 Subject: [PATCH 0841/3888] Target_env -> Target_os --- tests/concurrent.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/concurrent.rs b/tests/concurrent.rs index ba2300afa25..a6eff1e7079 100644 --- a/tests/concurrent.rs +++ b/tests/concurrent.rs @@ -345,7 +345,7 @@ fn same_project() { // next Cargo to come in will take over cleanly. // older win versions don't support job objects, so skip test there #[test] -#[cfg_attr(target_env = "windows", ignore)] +#[cfg_attr(target_os = "windows", ignore)] fn killing_cargo_releases_the_lock() { let p = project("foo") .file("Cargo.toml", r#" From b8c4a88e6c2cb73a73f2a8a88d305b6a3ddc5f94 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Nov 2016 16:05:31 -0800 Subject: [PATCH 0842/3888] Bump to 0.16.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- Makefile.in | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9853a26f1ce..773a12cd2d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "cargo" -version = "0.15.0" +version = "0.16.0" dependencies = [ "advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -68,7 +68,7 @@ name = "cargotest" version = "0.1.0" dependencies = [ "bufstream 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cargo 0.15.0", + "cargo 0.16.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index fa10f385736..0fdeae1bf0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo" -version = "0.15.0" +version = "0.16.0" authors = ["Yehuda Katz ", "Carl Lerche ", "Alex Crichton "] diff --git a/Makefile.in b/Makefile.in index 2af0c33e3b4..d37262726c8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -CFG_RELEASE_NUM=0.15.0 +CFG_RELEASE_NUM=0.16.0 CFG_RELEASE_LABEL= OPENSSL_VERS=1.0.2j From 06a077adfe1dc3c4939fb9e639abaf499b3c2bcc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Nov 2016 12:21:13 -0800 Subject: [PATCH 0843/3888] Fix tests on nightly --- src/rustversion.txt | 2 +- tests/cargotest/support/mod.rs | 9 +++++++-- tests/proc-macro.rs | 15 ++++----------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/rustversion.txt b/src/rustversion.txt index 8918bbc071a..891320872cb 100644 --- a/src/rustversion.txt +++ b/src/rustversion.txt @@ -1 +1 @@ -2016-11-03 +2016-11-16 diff --git a/tests/cargotest/support/mod.rs b/tests/cargotest/support/mod.rs index 18f11244b06..429a0e65da3 100644 --- a/tests/cargotest/support/mod.rs +++ b/tests/cargotest/support/mod.rs @@ -235,8 +235,13 @@ impl ErrMsg for Result { // Path to cargo executables pub fn cargo_dir() -> PathBuf { env::var_os("CARGO_BIN_PATH").map(PathBuf::from).or_else(|| { - env::current_exe().ok().as_ref().and_then(|s| s.parent()) - .map(|s| s.to_path_buf()) + env::current_exe().ok().map(|mut path| { + path.pop(); + if path.ends_with("deps") { + path.pop(); + } + path + }) }).unwrap_or_else(|| { panic!("CARGO_BIN_PATH wasn't set. Cannot continue running test") }) diff --git a/tests/proc-macro.rs b/tests/proc-macro.rs index c1a2306e6aa..59dc96e21c7 100644 --- a/tests/proc-macro.rs +++ b/tests/proc-macro.rs @@ -49,8 +49,8 @@ fn noop() { use proc_macro::TokenStream; #[proc_macro_derive(Noop)] - pub fn noop(input: TokenStream) -> TokenStream { - input + pub fn noop(_input: TokenStream) -> TokenStream { + "".parse().unwrap() } "#); noop.build(); @@ -87,8 +87,8 @@ fn impl_and_derive() { fn impl_by_transmogrify(&self) -> bool; } - #[derive(Transmogrify)] - struct X; + #[derive(Transmogrify, Debug)] + struct X { success: bool } fn main() { let x = X::new(); @@ -115,8 +115,6 @@ fn impl_and_derive() { #[proc_macro_derive(Transmogrify)] #[doc(hidden)] pub fn transmogrify(input: TokenStream) -> TokenStream { - assert_eq!(input.to_string(), "struct X;\n"); - " impl X { fn new() -> Self { @@ -129,11 +127,6 @@ fn impl_and_derive() { true } } - - #[derive(Debug)] - struct X { - success: bool, - } ".parse().unwrap() } "#); From af9364420714b6c9671b73fd481da108576e847a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Nov 2016 12:36:30 -0800 Subject: [PATCH 0844/3888] Link OpenSSL statically on OSX Now that Cargo requires OpenSSL >= 1.0.1 transitively through the `openssl-sys` 0.9 release the dynamic libraries for OpenSSL are no longer located on OSX by default. This means that the support necessary for libssh2 needs to be statically linked rather than dynamically linked. Closes #3303 --- Makefile.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index d37262726c8..19c3e2952ec 100644 --- a/Makefile.in +++ b/Makefile.in @@ -232,6 +232,12 @@ OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32 OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32 define BUILD_OPENSSL + +ifdef CFG_ENABLE_NIGHTLY +cargo-$(1): export OPENSSL_STATIC := 1 +test-unit-$(1): export OPENSSL_STATIC := 1 +endif + ifdef OPENSSL_OS_$(1) ifdef CFG_ENABLE_NIGHTLY OPENSSL_INSTALL_$(1) := $$(CFG_BUILD_DIR)/target/openssl/$(1)-install @@ -250,9 +256,7 @@ target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \ touch $$@ # variables read by various build scripts to find openssl -cargo-$(1): export OPENSSL_STATIC := 1 cargo-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) -test-unit-$(1): export OPENSSL_STATIC := 1 test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) # build libz statically into the cargo we're producing From 5a4fe2beb9ca16c5a453995e8e1d9cc271d9dfad Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 22 Nov 2016 21:37:26 -0800 Subject: [PATCH 0845/3888] Really fix OSX nightlies After #3311 we're now correctly trying to link OpenSSL statically on OSX. Unfortunately though this is failing to complete on the builders. Turns out the way we install OpenSSL through Homebrew create "universal archives" which is essentially an archive with both i686 and x86_64 object files, but separated. The linker takes care of this just fine but rustc currently chokes on it, unable to include the library statically into the compiler. To work around this we prepare our own mini install of OpenSSL by copying relevant bits into a local directory (like we do on Linux). As part of this we use the `lipo` tool, which is used to manage these fat archives, to disassemble the archive and only extract the relevant architecture. This should make a pre-installation step which both extracts the information and configures Cargo to use it. This should also fix the errors we're seeing on Travis I believe. --- Makefile.in | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/Makefile.in b/Makefile.in index 19c3e2952ec..7d1a4db30b1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -231,17 +231,20 @@ SETARCH_i686-unknown-linux-gnu := setarch i386 OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32 OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32 +LIPO_FAMILY_i686-apple-darwin := i386 +LIPO_FAMILY_x86_64-apple-darwin := x86_64 + define BUILD_OPENSSL ifdef CFG_ENABLE_NIGHTLY + cargo-$(1): export OPENSSL_STATIC := 1 test-unit-$(1): export OPENSSL_STATIC := 1 -endif -ifdef OPENSSL_OS_$(1) -ifdef CFG_ENABLE_NIGHTLY OPENSSL_INSTALL_$(1) := $$(CFG_BUILD_DIR)/target/openssl/$(1)-install +ifdef OPENSSL_OS_$(1) + target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \ | target/openssl/ mkdir -p target/openssl/$(1) @@ -261,12 +264,39 @@ test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) # build libz statically into the cargo we're producing cargo-$(1): export LIBZ_SYS_STATIC := 1 -else + +else ifdef LIPO_FAMILY_$(1) + target/openssl/$(1).stamp: + @echo installing from `brew --prefix openssl` + @rm -rf $$(OPENSSL_INSTALL_$(1)) + mkdir -p $$(OPENSSL_INSTALL_$(1))/lib + cp -r `brew --prefix openssl`/include $$(OPENSSL_INSTALL_$(1))/include + cp -r `brew --prefix openssl`/lib/pkgconfig $$(OPENSSL_INSTALL_$(1))/lib/pkgconfig + lipo -output $$(OPENSSL_INSTALL_$(1))/lib/libssl.a \ + -extract_family $$(LIPO_FAMILY_$(1)) \ + `brew --prefix openssl`/lib/libssl.a || \ + cp `brew --prefix openssl`/lib/libssl.a \ + $$(OPENSSL_INSTALL_$(1))/lib/libssl.a + lipo -output $$(OPENSSL_INSTALL_$(1))/lib/libcrypto.a \ + -extract_family $$(LIPO_FAMILY_$(1)) \ + `brew --prefix openssl`/lib/libcrypto.a || \ + cp `brew --prefix openssl`/lib/libcrypto.a \ + $$(OPENSSL_INSTALL_$(1))/lib/libcrypto.a + touch $$@ + +cargo-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) +test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) + +else # !OPENSSL_OS_$(1) && !OSX +target/openssl/$(1).stamp: + endif -else + +else # !CFG_ENABLE_NIGHTLY target/openssl/$(1).stamp: endif + endef $(foreach target,$(CFG_TARGET),$(eval $(call BUILD_OPENSSL,$(target)))) From c7174aff47db6a1650df67b2ff853c1bfd0a2930 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 24 Nov 2016 09:58:46 -0800 Subject: [PATCH 0846/3888] Make a freshness test less flaky We can't rely on frobbing mtimes, need to actually just wait a whole second. --- tests/freshness.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/freshness.rs b/tests/freshness.rs index b5390a20379..e6e7633ff15 100644 --- a/tests/freshness.rs +++ b/tests/freshness.rs @@ -445,16 +445,15 @@ fn rebuild_tests_if_lib_changes() { "#); p.build(); - p.root().move_into_the_past(); - assert_that(p.cargo("build"), execs().with_status(0)); assert_that(p.cargo("test"), execs().with_status(0)); + sleep_ms(1000); File::create(&p.root().join("src/lib.rs")).unwrap(); - assert_that(p.cargo("build"), + assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); assert_that(p.cargo("test").arg("-v"), execs().with_status(101)); From b04238800fc340915c004f342ccb3c8df9dc2c54 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Fri, 25 Nov 2016 00:13:57 +0100 Subject: [PATCH 0847/3888] Bump git2 dependency to fix #3312 --- Cargo.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 773a12cd2d5..1a2f6cf7176 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,13 +13,13 @@ dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -71,7 +71,7 @@ dependencies = [ "cargo 0.16.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -199,12 +199,12 @@ dependencies = [ [[package]] name = "git2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -216,7 +216,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -266,7 +266,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -641,7 +641,7 @@ dependencies = [ "checksum fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "640001e1bd865c7c32806292822445af576a6866175b5225aa2087ca5e3de551" "checksum gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "553f11439bdefe755bf366b264820f1da70f3aaf3924e594b886beb9c831bcf5" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" -"checksum git2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae93eae026f17b013912629d243444e52ee5d6b1339e71d5212099d1d1b73fc2" +"checksum git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bb44465898fca9b1885213832c8f4210b04e27d4c4c5e6315671a8bbaae6a6" "checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" @@ -649,7 +649,7 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" "checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" -"checksum libgit2-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7ba5bccd2adaf5f251b478000c27532e050be86baa3ebf8c76bb6a7f3c82ef35" +"checksum libgit2-sys 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b37995539bb695289a95041039c4994bf45baa308a41b6233e70519cd3c49f0c" "checksum libssh2-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "538844618f14e5e919332beaf718cf22b63b18cb9b37370560cd1bc55b2734f8" "checksum libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "283c2d162f78c5090522e13fc809820c33181570ae40de1bea84f3864c8759f9" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" From 6d26a6ead793fe8e23306b69252187266e4e11bf Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 26 Nov 2016 09:11:08 -0800 Subject: [PATCH 0848/3888] Update git2 fixing initialization races This updates libgit2/libssh2 bindings to fix initialization races in OpenSSL. This should fix some of the spurious segfaults we've been seeing on Travis OSX. --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a2f6cf7176..7734f06859b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,13 +13,13 @@ dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -71,7 +71,7 @@ dependencies = [ "cargo 0.16.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -199,12 +199,12 @@ dependencies = [ [[package]] name = "git2" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -216,7 +216,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -266,14 +266,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libgit2-sys" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "curl-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libssh2-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -281,7 +281,7 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cmake 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -641,7 +641,7 @@ dependencies = [ "checksum fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "640001e1bd865c7c32806292822445af576a6866175b5225aa2087ca5e3de551" "checksum gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "553f11439bdefe755bf366b264820f1da70f3aaf3924e594b886beb9c831bcf5" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" -"checksum git2 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bb44465898fca9b1885213832c8f4210b04e27d4c4c5e6315671a8bbaae6a6" +"checksum git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "76a6b09c00bfcca72a1ad874f04048f756370724e6ee20e98039ff21e688ced3" "checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" @@ -649,8 +649,8 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" "checksum libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "044d1360593a78f5c8e5e710beccdc24ab71d1f01bc19a29bcacdba22e8475d8" -"checksum libgit2-sys 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b37995539bb695289a95041039c4994bf45baa308a41b6233e70519cd3c49f0c" -"checksum libssh2-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "538844618f14e5e919332beaf718cf22b63b18cb9b37370560cd1bc55b2734f8" +"checksum libgit2-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a72539122e79e54cc5c4d5a7a5b53f03b667f7c22c7a0440433e658cf0440f" +"checksum libssh2-sys 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ed089186abb468a78f7170177304751805e33c20e7aef4b8298884ce2080b5de" "checksum libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "283c2d162f78c5090522e13fc809820c33181570ae40de1bea84f3864c8759f9" "checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054" "checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" From ce154e181a92d0caf2052f31a30748f99371d9d1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 26 Nov 2016 14:37:27 -0800 Subject: [PATCH 0849/3888] Compile OpenSSL from source on OSX I'm seeing a bunch of weird illegal instructions on OSX nightlies for Cargo. My guess is that they're all related to OpenSSL linking. Right now we're linking from Homebrew but I have a sneaking suspicion that it compiles with `-march=native` rather than what we'd like as a portable binary. To work around this compile OpenSSL ourselves and link it that way. Note that I believe this won't bring in the certificate trust store of OpenSSL on OSX (or at least not the right one from the keychain). We shouldn't need that, however, as OpenSSL is just used as the cryptographic primitives in libssh2 and Cargo itself. So in that sense we shouldn't need it for actually SSL at all. --- .travis.yml | 1 - Makefile.in | 48 ++++++++++++++++++------------------------------ 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9046991de40..eb7b08655d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ matrix: MACOSX_DEPLOYMENT_TARGET=10.7 CFG_DISABLE_CROSS_TESTS=1 os: osx - install: brew uninstall openssl && brew install openssl --universal --without-test # stable musl target, tested - env: TARGET=x86_64-unknown-linux-musl diff --git a/Makefile.in b/Makefile.in index 7d1a4db30b1..fa9474e599c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -172,17 +172,19 @@ OPENSSL_OS_aarch64-unknown-linux-gnu := linux-aarch64 OPENSSL_OS_arm-unknown-linux-gnueabi := linux-armv4 OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4 OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4 +OPENSSL_OS_i686-apple-darwin := darwin-i386-cc OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf OPENSSL_OS_i686-unknown-linux-gnu := linux-elf OPENSSL_OS_i686-unknown-linux-musl := linux-elf OPENSSL_OS_mips-unknown-linux-gnu := linux-mips32 -OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32 OPENSSL_OS_mips64-unknown-linux-gnuabi64 := linux64-mips64 OPENSSL_OS_mips64el-unknown-linux-gnuabi64 := linux64-mips64 +OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32 OPENSSL_OS_powerpc-unknown-linux-gnu := linux-ppc OPENSSL_OS_powerpc64-unknown-linux-gnu := linux-ppc64 OPENSSL_OS_powerpc64le-unknown-linux-gnu := linux-ppc64le OPENSSL_OS_s390x-unknown-linux-gnu := linux64-s390x +OPENSSL_OS_x86_64-apple-darwin := darwin64-x86_64-cc OPENSSL_OS_x86_64-unknown-freebsd := BSD-x86_64 OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64 OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64 @@ -192,6 +194,7 @@ OPENSSL_AR_aarch64-unknown-linux-gnu := aarch64-linux-gnu-ar OPENSSL_AR_arm-unknown-linux-gnueabi := arm-linux-gnueabi-ar OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar +OPENSSL_AR_i686-apple-darwin := ar OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar OPENSSL_AR_i686-unknown-linux-gnu := ar OPENSSL_AR_i686-unknown-linux-musl := ar @@ -203,6 +206,7 @@ OPENSSL_AR_powerpc-unknown-linux-gnu := powerpc-linux-gnu-ar OPENSSL_AR_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-ar OPENSSL_AR_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-ar OPENSSL_AR_s390x-unknown-linux-gnu := s390x-linux-gnu-ar +OPENSSL_AR_x86_64-apple-darwin := ar OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar OPENSSL_AR_x86_64-unknown-linux-gnu := ar OPENSSL_AR_x86_64-unknown-linux-musl := ar @@ -211,6 +215,7 @@ OPENSSL_CC_aarch64-unknown-linux-gnu := aarch64-linux-gnu-gcc OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc +OPENSSL_CC_i686-apple-darwin := clang OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc OPENSSL_CC_i686-unknown-linux-gnu := gcc OPENSSL_CC_i686-unknown-linux-musl := musl-gcc @@ -222,18 +227,17 @@ OPENSSL_CC_powerpc-unknown-linux-gnu := powerpc-linux-gnu-gcc OPENSSL_CC_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-gcc-5 OPENSSL_CC_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-gcc OPENSSL_CC_s390x-unknown-linux-gnu := s390x-linux-gnu-gcc +OPENSSL_CC_x86_64-apple-darwin := clang OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc OPENSSL_CC_x86_64-unknown-linux-gnu := gcc OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc SETARCH_i686-unknown-linux-gnu := setarch i386 +OPENSSL_CFLAGS_i686-apple-darwin := -m32 OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32 OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32 -LIPO_FAMILY_i686-apple-darwin := i386 -LIPO_FAMILY_x86_64-apple-darwin := x86_64 - define BUILD_OPENSSL ifdef CFG_ENABLE_NIGHTLY @@ -265,30 +269,7 @@ test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) # build libz statically into the cargo we're producing cargo-$(1): export LIBZ_SYS_STATIC := 1 -else ifdef LIPO_FAMILY_$(1) - -target/openssl/$(1).stamp: - @echo installing from `brew --prefix openssl` - @rm -rf $$(OPENSSL_INSTALL_$(1)) - mkdir -p $$(OPENSSL_INSTALL_$(1))/lib - cp -r `brew --prefix openssl`/include $$(OPENSSL_INSTALL_$(1))/include - cp -r `brew --prefix openssl`/lib/pkgconfig $$(OPENSSL_INSTALL_$(1))/lib/pkgconfig - lipo -output $$(OPENSSL_INSTALL_$(1))/lib/libssl.a \ - -extract_family $$(LIPO_FAMILY_$(1)) \ - `brew --prefix openssl`/lib/libssl.a || \ - cp `brew --prefix openssl`/lib/libssl.a \ - $$(OPENSSL_INSTALL_$(1))/lib/libssl.a - lipo -output $$(OPENSSL_INSTALL_$(1))/lib/libcrypto.a \ - -extract_family $$(LIPO_FAMILY_$(1)) \ - `brew --prefix openssl`/lib/libcrypto.a || \ - cp `brew --prefix openssl`/lib/libcrypto.a \ - $$(OPENSSL_INSTALL_$(1))/lib/libcrypto.a - touch $$@ - -cargo-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) -test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1)) - -else # !OPENSSL_OS_$(1) && !OSX +else # !OPENSSL_OS_$(1) target/openssl/$(1).stamp: endif @@ -301,10 +282,17 @@ endef $(foreach target,$(CFG_TARGET),$(eval $(call BUILD_OPENSSL,$(target)))) +ifeq ($(shell uname),Darwin) +SHASUM := shasum -a 256 +else +SHASUM := sha256sum +endif + target/openssl/openssl-$(OPENSSL_VERS).tar.gz: | target/openssl/ - curl -o $(@) https://www.openssl.org/source/openssl-$(OPENSSL_VERS).tar.gz - sha256sum $(@) > $(@).sha256 + curl -o $(@).tmp https://www.openssl.org/source/openssl-$(OPENSSL_VERS).tar.gz + $(SHASUM) $(@).tmp > $(@).sha256 test $(OPENSSL_SHA256) = `cut -d ' ' -f 1 $(@).sha256` + mv $(@).tmp $(@) target/openssl/: mkdir -p $(@) From 023b853e463cfb1b4d4f7adb8f3d0f4545093ea4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 28 Nov 2016 08:51:36 -0800 Subject: [PATCH 0850/3888] Test for bad path overrides with summaries Bad path overrides are currently detected to issue warnings in cases where path overrides are not suitable and have exhibited buggy behavior in the past. Unfortunately though it looks like some false positives are being issued, causing unnecessary confusion about `paths` overrides. This commit fixes the detection of these "bad path overrides" by comparing `Summary` dependencies (what's written down in `Cargo.toml`) rather than comparing the `Cargo.toml` of the override with `Cargo.lock`. We're guaranteed that the package we're overridding has already been resolved into `Cargo.lock`, so we know that if the two `Cargo.toml` files are equivalent we'll continue with the same crate graph. I'm not actually entirely sure why I originally thought it'd be better to go through the `Cargo.lock` comparison route. Unfortunately that doesn't take into account optional deps which aren't in `Cargo.lock` but are in `Cargo.toml` of the override, causing the false positive. This method, however, simply ensures that the two dependency lists are the same. Closes #3313 --- src/cargo/core/dependency.rs | 2 +- src/cargo/core/registry.rs | 20 +------- tests/overrides.rs | 90 ++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 19 deletions(-) diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index 23cb71034b4..377f21dee06 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -11,7 +11,7 @@ use util::{CargoError, CargoResult, Cfg, CfgExpr, ChainError, human, Config}; /// Information about a dependency requested by a Cargo manifest. /// Cheap to copy. -#[derive(PartialEq, Clone ,Debug)] +#[derive(PartialEq, Clone, Debug)] pub struct Dependency { inner: Rc, } diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index a798a49a504..ec458f8fb9c 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -290,23 +290,7 @@ impl<'cfg> PackageRegistry<'cfg> { fn warn_bad_override(&self, override_summary: &Summary, real_summary: &Summary) -> CargoResult<()> { - let real = real_summary.package_id(); - // If we don't have a locked variant then things are going quite wrong - // at this point, but we've already emitted a warning, so don't worry - // about it. - let map = match self.locked.get(real.source_id()) { - Some(map) => map, - None => return Ok(()), - }; - let list = map.get(real.name()).chain_error(|| { - human(format!("failed to find lock name of {}", real)) - })?; - let &(_, ref real_deps) = list.iter().find(|&&(ref id, _)| { - real == id - }).chain_error(|| { - human(format!("failed to find lock version of {}", real)) - })?; - let mut real_deps = real_deps.clone(); + let mut real_deps = real_summary.dependencies().iter().collect::>(); let boilerplate = "\ This is currently allowed but is known to produce buggy behavior with spurious @@ -322,7 +306,7 @@ http://doc.crates.io/specifying-dependencies.html#overriding-dependencies "; for dep in override_summary.dependencies() { - if let Some(i) = real_deps.iter().position(|id| dep.matches_id(id)) { + if let Some(i) = real_deps.iter().position(|d| dep == *d) { real_deps.remove(i); continue } diff --git a/tests/overrides.rs b/tests/overrides.rs index 2ba54fbc271..d92f81791cc 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -1013,3 +1013,93 @@ fn replace_to_path_dep() { assert_that(p.cargo_process("build"), execs().with_status(0)); } + +#[test] +fn paths_ok_with_optional() { + Package::new("bar", "0.1.0").publish(); + + let p = project("local") + .file("Cargo.toml", r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + foo = { path = "foo" } + "#) + .file("src/lib.rs", "") + .file("foo/Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { version = "0.1", optional = true } + "#) + .file("foo/src/lib.rs", "") + .file("foo2/Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { version = "0.1", optional = true } + "#) + .file("foo2/src/lib.rs", "") + .file(".cargo/config", r#" + paths = ["foo2"] + "#); + + assert_that(p.cargo_process("build"), + execs().with_status(0).with_stderr("\ +[COMPILING] foo v0.1.0 ([..]foo2) +[COMPILING] local v0.0.1 ([..]) +[FINISHED] [..] +")); +} + +#[test] +fn paths_add_optional_bad() { + Package::new("bar", "0.1.0").publish(); + + let p = project("local") + .file("Cargo.toml", r#" + [package] + name = "local" + version = "0.0.1" + authors = [] + + [dependencies] + foo = { path = "foo" } + "#) + .file("src/lib.rs", "") + .file("foo/Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + "#) + .file("foo/src/lib.rs", "") + .file("foo2/Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dependencies] + bar = { version = "0.1", optional = true } + "#) + .file("foo2/src/lib.rs", "") + .file(".cargo/config", r#" + paths = ["foo2"] + "#); + + assert_that(p.cargo_process("build"), + execs().with_status(0).with_stderr_contains("\ +warning: path override for crate `foo` has altered the original list of +dependencies; the dependency on `bar` was either added or\ +")); +} From 50f33b69caf93823256fb109d54090dd2f51411e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 28 Nov 2016 09:48:14 -0800 Subject: [PATCH 0851/3888] Require `cargo install --vers` takes a semver version Historically Cargo accidentally took a semver version *requirement*, so let's start issuing warnings about how this is now legacy behavior. Closes #3321 --- src/cargo/ops/cargo_install.rs | 28 +++++++++++++++++++++++++--- tests/install.rs | 26 +++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index c2a348e2e99..f6715992fd3 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -7,6 +7,7 @@ use std::io::prelude::*; use std::io::SeekFrom; use std::path::{Path, PathBuf}; +use semver::Version; use tempdir::TempDir; use toml; @@ -57,7 +58,7 @@ pub fn install(root: Option<&str>, let map = SourceConfigMap::new(config)?; let (pkg, source) = if source_id.is_git() { select_pkg(GitSource::new(source_id, config), source_id, - krate, vers, &mut |git| git.read_packages())? + krate, vers, config, &mut |git| git.read_packages())? } else if source_id.is_path() { let path = source_id.url().to_file_path().ok() .expect("path sources must have a valid path"); @@ -68,11 +69,11 @@ pub fn install(root: Option<&str>, specify an alternate source", path.display())) })?; select_pkg(PathSource::new(&path, source_id, config), - source_id, krate, vers, + source_id, krate, vers, config, &mut |path| path.read_packages())? } else { select_pkg(map.load(source_id)?, - source_id, krate, vers, + source_id, krate, vers, config, &mut |_| Err(human("must specify a crate to install from \ crates.io, or use --path or --git to \ specify alternate source")))? @@ -251,6 +252,7 @@ fn select_pkg<'a, T>(mut source: T, source_id: &SourceId, name: Option<&str>, vers: Option<&str>, + config: &Config, list_all: &mut FnMut(&mut T) -> CargoResult>) -> CargoResult<(Package, Box)> where T: Source + 'a @@ -258,6 +260,26 @@ fn select_pkg<'a, T>(mut source: T, source.update()?; match name { Some(name) => { + let vers = match vers { + Some(v) => { + match v.parse::() { + Ok(v) => Some(format!("={}", v)), + Err(_) => { + let msg = format!("the `--vers` provided, `{}`, is \ + not a valid semver version\n\n\ + historically Cargo treated this \ + as a semver version requirement \ + accidentally\nand will continue \ + to do so, but this behavior \ + will be removed eventually", v); + config.shell().warn(&msg)?; + Some(v.to_string()) + } + } + } + None => None, + }; + let vers = vers.as_ref().map(|s| &**s); let dep = Dependency::parse_no_deprecated(name, vers, source_id)?; let deps = source.query(&dep)?; match deps.iter().map(|p| p.package_id()).max() { diff --git a/tests/install.rs b/tests/install.rs index 6d064703fe2..eb77c0a2e41 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -87,7 +87,7 @@ fn bad_version() { assert_that(cargo_process("install").arg("foo").arg("--vers=0.2.0"), execs().with_status(101).with_stderr("\ [UPDATING] registry [..] -[ERROR] could not find `foo` in `registry [..]` with version `0.2.0` +[ERROR] could not find `foo` in `registry [..]` with version `=0.2.0` ")); } @@ -826,3 +826,27 @@ fn use_path_workspace() { let lock2 = p.read_lockfile(); assert!(lock == lock2, "different lockfiles"); } + +#[test] +fn vers_precise() { + pkg("foo", "0.1.1"); + pkg("foo", "0.1.2"); + + assert_that(cargo_process("install").arg("foo").arg("--vers").arg("0.1.1"), + execs().with_status(0).with_stderr_contains("\ +[DOWNLOADING] foo v0.1.1 (registry [..]) +")); +} + +#[test] +fn legacy_version_requirement() { + pkg("foo", "0.1.1"); + + assert_that(cargo_process("install").arg("foo").arg("--vers").arg("0.1"), + execs().with_status(0).with_stderr_contains("\ +warning: the `--vers` provided, `0.1`, is not a valid semver version + +historically Cargo treated this as a semver version requirement accidentally +and will continue to do so, but this behavior will be removed eventually +")); +} From 80444aa11a244388ebd9ab3ba592c0b2bb7d5e74 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Nov 2016 10:05:55 -0800 Subject: [PATCH 0852/3888] Refactor metadata generation Remove generation all the way in manifest-parsing and defer it until we actually need it during compilation. Additionally remove lots of weird logic that's no longer necessary that we're hashing quite a few fields. --- src/cargo/core/manifest.rs | 27 ++----- src/cargo/core/mod.rs | 2 +- src/cargo/core/package.rs | 6 +- src/cargo/core/package_id.rs | 23 +----- src/cargo/ops/cargo_clean.rs | 5 +- src/cargo/ops/cargo_rustc/context.rs | 91 ++++++++++++------------ src/cargo/ops/cargo_rustc/fingerprint.rs | 4 +- src/cargo/ops/cargo_rustc/mod.rs | 17 +++-- src/cargo/util/toml.rs | 54 ++++---------- 9 files changed, 81 insertions(+), 148 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index f5f4217da81..93fac21fdf9 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -6,7 +6,6 @@ use rustc_serialize::{Encoder, Encodable}; use core::{Dependency, PackageId, Summary, SourceId, PackageIdSpec}; use core::WorkspaceConfig; -use core::package_id::Metadata; pub enum EitherManifest { Real(Manifest), @@ -159,7 +158,6 @@ pub struct Target { kind: TargetKind, name: String, src_path: PathBuf, - metadata: Option, tested: bool, benched: bool, doc: bool, @@ -279,7 +277,6 @@ impl Target { kind: TargetKind::Bin, name: String::new(), src_path: PathBuf::new(), - metadata: None, doc: false, doctest: false, harness: true, @@ -289,40 +286,35 @@ impl Target { } } - pub fn lib_target(name: &str, crate_targets: Vec, - src_path: &Path, - metadata: Metadata) -> Target { + pub fn lib_target(name: &str, + crate_targets: Vec, + src_path: &Path) -> Target { Target { kind: TargetKind::Lib(crate_targets), name: name.to_string(), src_path: src_path.to_path_buf(), - metadata: Some(metadata), doctest: true, doc: true, ..Target::blank() } } - pub fn bin_target(name: &str, src_path: &Path, - metadata: Option) -> Target { + pub fn bin_target(name: &str, src_path: &Path) -> Target { Target { kind: TargetKind::Bin, name: name.to_string(), src_path: src_path.to_path_buf(), - metadata: metadata, doc: true, ..Target::blank() } } /// Builds a `Target` corresponding to the `build = "build.rs"` entry. - pub fn custom_build_target(name: &str, src_path: &Path, - metadata: Option) -> Target { + pub fn custom_build_target(name: &str, src_path: &Path) -> Target { Target { kind: TargetKind::CustomBuild, name: name.to_string(), src_path: src_path.to_path_buf(), - metadata: metadata, for_host: true, benched: false, tested: false, @@ -340,25 +332,21 @@ impl Target { } } - pub fn test_target(name: &str, src_path: &Path, - metadata: Metadata) -> Target { + pub fn test_target(name: &str, src_path: &Path) -> Target { Target { kind: TargetKind::Test, name: name.to_string(), src_path: src_path.to_path_buf(), - metadata: Some(metadata), benched: false, ..Target::blank() } } - pub fn bench_target(name: &str, src_path: &Path, - metadata: Metadata) -> Target { + pub fn bench_target(name: &str, src_path: &Path) -> Target { Target { kind: TargetKind::Bench, name: name.to_string(), src_path: src_path.to_path_buf(), - metadata: Some(metadata), tested: false, ..Target::blank() } @@ -367,7 +355,6 @@ impl Target { pub fn name(&self) -> &str { &self.name } pub fn crate_name(&self) -> String { self.name.replace("-", "_") } pub fn src_path(&self) -> &Path { &self.src_path } - pub fn metadata(&self) -> Option<&Metadata> { self.metadata.as_ref() } pub fn kind(&self) -> &TargetKind { &self.kind } pub fn tested(&self) -> bool { self.tested } pub fn harness(&self) -> bool { self.harness } diff --git a/src/cargo/core/mod.rs b/src/cargo/core/mod.rs index 305b6ed7c74..e663dcdf270 100644 --- a/src/cargo/core/mod.rs +++ b/src/cargo/core/mod.rs @@ -2,7 +2,7 @@ pub use self::dependency::{Dependency, DependencyInner}; pub use self::manifest::{Manifest, Target, TargetKind, Profile, LibKind, Profiles}; pub use self::manifest::{EitherManifest, VirtualManifest}; pub use self::package::{Package, PackageSet}; -pub use self::package_id::{PackageId, Metadata}; +pub use self::package_id::PackageId; pub use self::package_id_spec::PackageIdSpec; pub use self::registry::Registry; pub use self::resolver::Resolve; diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 03ed7d88729..11e53cf2c9a 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use semver::Version; use core::{Dependency, Manifest, PackageId, SourceId, Target, TargetKind}; -use core::{Summary, Metadata, SourceMap}; +use core::{Summary, SourceMap}; use ops; use util::{CargoResult, Config, LazyCell, ChainError, internal, human, lev_distance}; use rustc_serialize::{Encoder,Encodable}; @@ -94,10 +94,6 @@ impl Package { self.targets().iter().any(|t| t.is_custom_build()) } - pub fn generate_metadata(&self) -> Metadata { - self.package_id().generate_metadata() - } - pub fn find_closest_target(&self, target: &str, kind: TargetKind) -> Option<&Target> { let targets = self.targets(); diff --git a/src/cargo/core/package_id.rs b/src/cargo/core/package_id.rs index 8f1992a733e..d9224bae180 100644 --- a/src/cargo/core/package_id.rs +++ b/src/cargo/core/package_id.rs @@ -9,7 +9,7 @@ use regex::Regex; use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; use semver; -use util::{CargoResult, CargoError, short_hash, ToSemver}; +use util::{CargoResult, CargoError, ToSemver}; use core::source::SourceId; /// Identifier for a specific version of a package in a specific source. @@ -118,12 +118,6 @@ impl From for Box { fn from(t: PackageIdError) -> Box { Box::new(t) } } -#[derive(PartialEq, Eq, Hash, Clone, RustcEncodable, Debug)] -pub struct Metadata { - pub metadata: String, - pub extra_filename: String -} - impl PackageId { pub fn new(name: &str, version: T, sid: &SourceId) -> CargoResult { @@ -141,13 +135,6 @@ impl PackageId { pub fn version(&self) -> &semver::Version { &self.inner.version } pub fn source_id(&self) -> &SourceId { &self.inner.source_id } - pub fn generate_metadata(&self) -> Metadata { - let metadata = short_hash(self); - let extra_filename = format!("-{}", metadata); - - Metadata { metadata: metadata, extra_filename: extra_filename } - } - pub fn with_precise(&self, precise: Option) -> PackageId { PackageId { inner: Arc::new(PackageIdInner { @@ -169,14 +156,6 @@ impl PackageId { } } -impl Metadata { - pub fn mix(&mut self, t: &T) { - let new_metadata = short_hash(&(&self.metadata, t)); - self.extra_filename = format!("-{}", new_metadata); - self.metadata = new_metadata; - } -} - impl fmt::Display for PackageId { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{} v{}", self.inner.name, self.inner.version)?; diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 99b45f7c20a..08f9b78c1d5 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -73,9 +73,8 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { cx.probe_target_info(&units)?; for unit in units.iter() { - let layout = cx.layout(unit); - rm_rf(&layout.proxy().fingerprint(&unit.pkg))?; - rm_rf(&layout.build(&unit.pkg))?; + rm_rf(&cx.layout(unit).proxy().fingerprint(&unit.pkg))?; + rm_rf(&cx.layout(unit).build(&unit.pkg))?; for (src, link_dst, _) in cx.target_filenames(&unit)? { rm_rf(&src)?; diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index d95b7ee75c6..0d4dc8aef03 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -1,12 +1,15 @@ +#![allow(deprecated)] + use std::collections::{HashSet, HashMap, BTreeSet}; use std::env; +use std::fmt; +use std::hash::{Hasher, Hash, SipHasher}; use std::path::{Path, PathBuf}; use std::str::{self, FromStr}; use std::sync::Arc; - use core::{Package, PackageId, PackageSet, Resolve, Target, Profile}; -use core::{TargetKind, Profiles, Metadata, Dependency, Workspace}; +use core::{TargetKind, Profiles, Dependency, Workspace}; use core::dependency::Kind as DepKind; use util::{CargoResult, ChainError, internal, Config, profile, Cfg, human}; @@ -53,6 +56,9 @@ struct TargetInfo { cfg: Option>, } +#[derive(Clone)] +pub struct Metadata(u64); + impl<'a, 'cfg> Context<'a, 'cfg> { pub fn new(ws: &Workspace<'cfg>, resolve: &'a Resolve, @@ -311,7 +317,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// We build to the path: "{filename}-{target_metadata}" /// We use a linking step to link/copy to a predictable filename /// like `target/debug/libfoo.{a,so,rlib}` and such. - pub fn target_metadata(&self, unit: &Unit) -> Option { + pub fn target_metadata(&mut self, unit: &Unit) -> Option { // No metadata for dylibs because of a couple issues // - OSX encodes the dylib name in the executable // - Windows rustc multiple files of which we can't easily link all of them @@ -336,56 +342,41 @@ impl<'a, 'cfg> Context<'a, 'cfg> { return None; } - let metadata = unit.target.metadata().cloned().map(|mut m| { - if let Some(features) = self.resolve.features(unit.pkg.package_id()) { - let mut feat_vec: Vec<&String> = features.iter().collect(); - feat_vec.sort(); - for feat in feat_vec { - m.mix(feat); - } - } - m.mix(unit.profile); - m - }); - let mut pkg_metadata = { - let mut m = unit.pkg.generate_metadata(); - if let Some(features) = self.resolve.features(unit.pkg.package_id()) { + let mut hasher = SipHasher::new_with_keys(0, 0); + + // Unique metadata per (name, source, version) triple. This'll allow us + // to pull crates from anywhere w/o worrying about conflicts + unit.pkg.package_id().hash(&mut hasher); + + // Also mix in enabled features to our metadata. This'll ensure that + // when changing feature sets each lib is separately cached. + match self.resolve.features(unit.pkg.package_id()) { + Some(features) => { let mut feat_vec: Vec<&String> = features.iter().collect(); feat_vec.sort(); - for feat in feat_vec { - m.mix(feat); - } + feat_vec.hash(&mut hasher); } - m.mix(unit.profile); - m - }; - - if unit.target.is_lib() && unit.profile.test { - // Libs and their tests are built in parallel, so we need to make - // sure that their metadata is different. - metadata.map(|mut m| { - m.mix(&"test"); - m - }) - } else if unit.target.is_bin() && unit.profile.test { - // Make sure that the name of this test executable doesn't - // conflict with a library that has the same name and is - // being tested - pkg_metadata.mix(&format!("bin-{}", unit.target.name())); - Some(pkg_metadata) - } else if unit.pkg.package_id().source_id().is_path() && - !unit.profile.test { - Some(pkg_metadata) - } else { - metadata + None => Vec::<&String>::new().hash(&mut hasher), } + + // Throw in the profile we're compiling with. This helps caching + // panic=abort and panic=unwind artifacts, additionally with various + // settings like debuginfo and whatnot. + unit.profile.hash(&mut hasher); + + // Finally throw in the target name/kind. This ensures that concurrent + // compiles of targets in the same crate don't collide. + unit.target.name().hash(&mut hasher); + unit.target.kind().hash(&mut hasher); + + Some(Metadata(hasher.finish())) } /// Returns the file stem for a given target/profile combo (with metadata) - pub fn file_stem(&self, unit: &Unit) -> String { + pub fn file_stem(&mut self, unit: &Unit) -> String { match self.target_metadata(unit) { - Some(ref metadata) => format!("{}{}", unit.target.crate_name(), - metadata.extra_filename), + Some(ref metadata) => format!("{}-{}", unit.target.crate_name(), + metadata), None => self.bin_stem(unit), } } @@ -407,7 +398,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Returns an Option because in some cases we don't want to link /// (eg a dependent lib) - pub fn link_stem(&self, unit: &Unit) -> Option<(PathBuf, String)> { + pub fn link_stem(&mut self, unit: &Unit) -> Option<(PathBuf, String)> { let src_dir = self.out_dir(unit); let bin_stem = self.bin_stem(unit); let file_stem = self.file_stem(unit); @@ -441,7 +432,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// filename: filename rustc compiles to. (Often has metadata suffix). /// link_dst: Optional file to link/copy the result to (without metadata suffix) /// linkable: Whether possible to link against file (eg it's a library) - pub fn target_filenames(&self, unit: &Unit) + pub fn target_filenames(&mut self, unit: &Unit) -> CargoResult, bool)>> { let out_dir = self.out_dir(unit); let stem = self.file_stem(unit); @@ -870,3 +861,9 @@ fn env_args(config: &Config, Ok(Vec::new()) } + +impl fmt::Display for Metadata { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:016x}", self.0) + } +} diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 6cc8f88c105..952ccac7830 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -531,7 +531,7 @@ pub fn dir(cx: &Context, unit: &Unit) -> PathBuf { } /// Returns the (old, new) location for the dep info file of a target. -pub fn dep_info_loc(cx: &Context, unit: &Unit) -> PathBuf { +pub fn dep_info_loc(cx: &mut Context, unit: &Unit) -> PathBuf { dir(cx, unit).join(&format!("dep-{}", filename(cx, unit))) } @@ -653,7 +653,7 @@ fn mtime_if_fresh(output: &Path, paths: I) -> Option } } -fn filename(cx: &Context, unit: &Unit) -> String { +fn filename(cx: &mut Context, unit: &Unit) -> String { // file_stem includes metadata hash. Thus we have a different // fingerprint for every metadata hash version. This works because // even if the package is fresh, we'll still link the fresh target diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 02e1088303b..73f3fed96a5 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -421,7 +421,7 @@ fn add_plugin_deps(rustc: &mut ProcessBuilder, Ok(()) } -fn prepare_rustc(cx: &Context, +fn prepare_rustc(cx: &mut Context, crate_types: Vec<&str>, unit: &Unit) -> CargoResult { let mut base = cx.compilation.rustc_process(unit.pkg)?; @@ -509,7 +509,7 @@ fn root_path(cx: &Context, unit: &Unit) -> PathBuf { } } -fn build_base_args(cx: &Context, +fn build_base_args(cx: &mut Context, cmd: &mut ProcessBuilder, unit: &Unit, crate_types: &[&str]) { @@ -610,8 +610,8 @@ fn build_base_args(cx: &Context, match cx.target_metadata(unit) { Some(m) => { - cmd.arg("-C").arg(&format!("metadata={}", m.metadata)); - cmd.arg("-C").arg(&format!("extra-filename={}", m.extra_filename)); + cmd.arg("-C").arg(&format!("metadata={}", m)); + cmd.arg("-C").arg(&format!("extra-filename=-{}", m)); } None => { cmd.arg("-C").arg(&format!("metadata={}", short_hash(unit.pkg))); @@ -645,17 +645,16 @@ fn build_plugin_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) { opt(cmd, "-C", "linker=", cx.linker(unit.kind).map(|s| s.as_ref())); } -fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) +fn build_deps_args(cmd: &mut ProcessBuilder, cx: &mut Context, unit: &Unit) -> CargoResult<()> { - let layout = cx.layout(unit); cmd.arg("-L").arg(&{ let mut deps = OsString::from("dependency="); - deps.push(layout.deps()); + deps.push(cx.layout(unit).deps()); deps }); if unit.pkg.has_custom_build() { - cmd.env("OUT_DIR", &layout.build_out(unit.pkg)); + cmd.env("OUT_DIR", &cx.layout(unit).build_out(unit.pkg)); } for unit in cx.dep_targets(unit)?.iter() { @@ -666,7 +665,7 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) return Ok(()); - fn link_to(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) + fn link_to(cmd: &mut ProcessBuilder, cx: &mut Context, unit: &Unit) -> CargoResult<()> { for (dst, _link_dst, linkable) in cx.target_filenames(unit)? { if !linkable { diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index c5d70b7098b..5e5dc93a669 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -14,7 +14,6 @@ use core::{Summary, Manifest, Target, Dependency, DependencyInner, PackageId}; use core::{EitherManifest, VirtualManifest}; use core::dependency::{Kind, Platform}; use core::manifest::{LibKind, Profile, ManifestMetadata}; -use core::package_id::Metadata; use sources::CRATES_IO; use util::{self, CargoResult, human, ToUrl, ToSemver, ChainError, Config}; @@ -437,7 +436,6 @@ impl TomlManifest { } let pkgid = project.to_package_id(source_id)?; - let metadata = pkgid.generate_metadata(); // If we have no lib at all, use the inferred lib if available // If we have a lib with a path, we're done @@ -550,8 +548,7 @@ impl TomlManifest { new_build, &examples, &tests, - &benches, - &metadata); + &benches); if targets.is_empty() { debug!("manifest has no build targets"); @@ -1064,8 +1061,7 @@ fn normalize(lib: &Option, custom_build: Option, examples: &[TomlExampleTarget], tests: &[TomlTestTarget], - benches: &[TomlBenchTarget], - metadata: &Metadata) -> Vec { + benches: &[TomlBenchTarget]) -> Vec { fn configure(toml: &TomlTarget, target: &mut Target) { let t2 = target.clone(); target.set_tested(toml.test.unwrap_or(t2.tested())) @@ -1080,9 +1076,7 @@ fn normalize(lib: &Option, }); } - fn lib_target(dst: &mut Vec, - l: &TomlLibTarget, - metadata: &Metadata) { + fn lib_target(dst: &mut Vec, l: &TomlLibTarget) { let path = l.path.clone().unwrap_or( PathValue::Path(Path::new("src").join(&format!("{}.rs", l.name()))) ); @@ -1095,14 +1089,8 @@ fn normalize(lib: &Option, } }; - // Binaries, examples, etc, may link to this library. Their crate names - // have a high likelihood to being the same as ours, however, so we need - // some extra metadata in our name to ensure symbols won't collide. - let mut metadata = metadata.clone(); - metadata.mix(&"lib"); let mut target = Target::lib_target(&l.name(), crate_types, - &path.to_path(), - metadata); + &path.to_path()); configure(l, &mut target); dst.push(target); } @@ -1113,8 +1101,7 @@ fn normalize(lib: &Option, let path = bin.path.clone().unwrap_or_else(|| { PathValue::Path(default(bin)) }); - let mut target = Target::bin_target(&bin.name(), &path.to_path(), - None); + let mut target = Target::bin_target(&bin.name(), &path.to_path()); configure(bin, &mut target); dst.push(target); } @@ -1124,7 +1111,7 @@ fn normalize(lib: &Option, let name = format!("build-script-{}", cmd.file_stem().and_then(|s| s.to_str()).unwrap_or("")); - dst.push(Target::custom_build_target(&name, cmd, None)); + dst.push(Target::custom_build_target(&name, cmd)); } fn example_targets(dst: &mut Vec, @@ -1141,40 +1128,29 @@ fn normalize(lib: &Option, } } - fn test_targets(dst: &mut Vec, tests: &[TomlTestTarget], - metadata: &Metadata, + fn test_targets(dst: &mut Vec, + tests: &[TomlTestTarget], default: &mut FnMut(&TomlTestTarget) -> PathBuf) { for test in tests.iter() { let path = test.path.clone().unwrap_or_else(|| { PathValue::Path(default(test)) }); - // make sure this metadata is different from any same-named libs. - let mut metadata = metadata.clone(); - metadata.mix(&format!("test-{}", test.name())); - - let mut target = Target::test_target(&test.name(), &path.to_path(), - metadata); + let mut target = Target::test_target(&test.name(), &path.to_path()); configure(test, &mut target); dst.push(target); } } - fn bench_targets(dst: &mut Vec, benches: &[TomlBenchTarget], - metadata: &Metadata, + fn bench_targets(dst: &mut Vec, + benches: &[TomlBenchTarget], default: &mut FnMut(&TomlBenchTarget) -> PathBuf) { for bench in benches.iter() { let path = bench.path.clone().unwrap_or_else(|| { PathValue::Path(default(bench)) }); - // make sure this metadata is different from any same-named libs. - let mut metadata = metadata.clone(); - metadata.mix(&format!("bench-{}", bench.name())); - - let mut target = Target::bench_target(&bench.name(), - &path.to_path(), - metadata); + let mut target = Target::bench_target(&bench.name(), &path.to_path()); configure(bench, &mut target); dst.push(target); } @@ -1183,7 +1159,7 @@ fn normalize(lib: &Option, let mut ret = Vec::new(); if let Some(ref lib) = *lib { - lib_target(&mut ret, lib, metadata); + lib_target(&mut ret, lib); bin_targets(&mut ret, bins, &mut |bin| Path::new("src").join("bin") .join(&format!("{}.rs", bin.name()))); @@ -1201,7 +1177,7 @@ fn normalize(lib: &Option, &mut |ex| Path::new("examples") .join(&format!("{}.rs", ex.name()))); - test_targets(&mut ret, tests, metadata, &mut |test| { + test_targets(&mut ret, tests, &mut |test| { if test.name() == "test" { Path::new("src").join("test.rs") } else { @@ -1209,7 +1185,7 @@ fn normalize(lib: &Option, } }); - bench_targets(&mut ret, benches, metadata, &mut |bench| { + bench_targets(&mut ret, benches, &mut |bench| { if bench.name() == "bench" { Path::new("src").join("bench.rs") } else { From 3ccbb1db9eda80b90661ca4b36519e61c02c7c47 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Nov 2016 12:32:10 -0800 Subject: [PATCH 0853/3888] Apply new fingerprinting to build dir outputs We now much more aggressively cache the output of the compiler based on feature sets and profile configuration. Unfortunately we forgot to extend this caching to build script output directories as well so this commit ensures that build script outputs are cached the same way with a directory per configuration of features and output settings. Closes #3302 --- src/cargo/ops/cargo_clean.rs | 13 +++-- src/cargo/ops/cargo_rustc/context.rs | 62 ++++++++++++++++----- src/cargo/ops/cargo_rustc/custom_build.rs | 22 ++++---- src/cargo/ops/cargo_rustc/fingerprint.rs | 15 ++---- src/cargo/ops/cargo_rustc/layout.rs | 65 ++--------------------- src/cargo/ops/cargo_rustc/mod.rs | 32 +++++------ src/cargo/ops/mod.rs | 4 +- tests/build-script.rs | 46 ++++++++++++++++ 8 files changed, 140 insertions(+), 119 deletions(-) diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index 08f9b78c1d5..fd270b79aba 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -73,10 +73,17 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { cx.probe_target_info(&units)?; for unit in units.iter() { - rm_rf(&cx.layout(unit).proxy().fingerprint(&unit.pkg))?; - rm_rf(&cx.layout(unit).build(&unit.pkg))?; + rm_rf(&cx.fingerprint_dir(unit))?; + if unit.target.is_custom_build() { + if unit.profile.run_custom_build { + rm_rf(&cx.build_script_out_dir(unit))?; + } else { + rm_rf(&cx.build_script_dir(unit))?; + } + continue + } - for (src, link_dst, _) in cx.target_filenames(&unit)? { + for (src, link_dst, _) in cx.target_filenames(unit)? { rm_rf(&src)?; if let Some(dst) = link_dst { rm_rf(&dst)?; diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 0d4dc8aef03..c0a92d643ec 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -11,12 +11,12 @@ use std::sync::Arc; use core::{Package, PackageId, PackageSet, Resolve, Target, Profile}; use core::{TargetKind, Profiles, Dependency, Workspace}; use core::dependency::Kind as DepKind; -use util::{CargoResult, ChainError, internal, Config, profile, Cfg, human}; +use util::{self, CargoResult, ChainError, internal, Config, profile, Cfg, human}; use super::TargetConfig; use super::custom_build::{BuildState, BuildScripts}; use super::fingerprint::Fingerprint; -use super::layout::{Layout, LayoutProxy}; +use super::layout::Layout; use super::links::Links; use super::{Kind, Compilation, BuildConfig}; @@ -278,23 +278,61 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } /// Returns the appropriate directory layout for either a plugin or not. - pub fn layout(&self, unit: &Unit) -> LayoutProxy { - let primary = unit.pkg.package_id() == &self.current_package; - match unit.kind { - Kind::Host => LayoutProxy::new(&self.host, primary), - Kind::Target => LayoutProxy::new(self.target.as_ref() - .unwrap_or(&self.host), - primary), + fn layout(&self, kind: Kind) -> &Layout { + match kind { + Kind::Host => &self.host, + Kind::Target => self.target.as_ref().unwrap_or(&self.host) } } + /// Returns the directories where Rust crate dependencies are found for the + /// specified unit. + pub fn deps_dir(&self, unit: &Unit) -> &Path { + self.layout(unit.kind).deps() + } + + /// Returns the directory for the specified unit where fingerprint + /// information is stored. + pub fn fingerprint_dir(&mut self, unit: &Unit) -> PathBuf { + let dir = self.pkg_dir(unit); + self.layout(unit.kind).fingerprint().join(dir) + } + + /// Returns the appropriate directory layout for either a plugin or not. + pub fn build_script_dir(&mut self, unit: &Unit) -> PathBuf { + assert!(unit.target.is_custom_build()); + assert!(!unit.profile.run_custom_build); + let dir = self.pkg_dir(unit); + self.layout(Kind::Host).build().join(dir) + } + + /// Returns the appropriate directory layout for either a plugin or not. + pub fn build_script_out_dir(&mut self, unit: &Unit) -> PathBuf { + assert!(unit.target.is_custom_build()); + assert!(unit.profile.run_custom_build); + let dir = self.pkg_dir(unit); + self.layout(unit.kind).build().join(dir).join("out") + } + /// Returns the appropriate output directory for the specified package and /// target. - pub fn out_dir(&self, unit: &Unit) -> PathBuf { + pub fn out_dir(&mut self, unit: &Unit) -> PathBuf { if unit.profile.doc { - self.layout(unit).doc_root() + self.layout(unit.kind).root().parent().unwrap().join("doc") + } else if unit.target.is_custom_build() { + self.build_script_dir(unit) + } else if unit.target.is_example() { + self.layout(unit.kind).examples().to_path_buf() } else { - self.layout(unit).out_dir(unit) + self.deps_dir(unit).to_path_buf() + } + } + + fn pkg_dir(&mut self, unit: &Unit) -> String { + let name = unit.pkg.package_id().name(); + match self.target_metadata(unit) { + Some(meta) => format!("{}-{}", name, meta), + None => format!("{}-{}", name, util::short_hash(unit.pkg)), } } diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index 375a6ea434c..eb62f38c522 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -82,11 +82,12 @@ pub fn prepare<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult<(Work, Work)> { - let host_unit = Unit { kind: Kind::Host, ..*unit }; - let (script_output, build_output) = { - (cx.layout(&host_unit).build(unit.pkg), - cx.layout(unit).build_out(unit.pkg)) - }; + let dependencies = cx.dep_run_custom_build(unit)?; + let build_script_unit = dependencies.iter().find(|d| { + !d.profile.run_custom_build && d.target.is_custom_build() + }).expect("running a script not depending on an actual script"); + let script_output = cx.build_script_dir(build_script_unit); + let build_output = cx.build_script_out_dir(unit); // Building the command to execute let to_exec = script_output.join(unit.target.name()); @@ -150,7 +151,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // This information will be used at build-time later on to figure out which // sorts of variables need to be discovered at that time. let lib_deps = { - cx.dep_run_custom_build(unit)?.iter().filter_map(|unit| { + dependencies.iter().filter_map(|unit| { if unit.profile.run_custom_build { Some((unit.pkg.manifest().links().unwrap().to_string(), unit.pkg.package_id().clone())) @@ -177,8 +178,8 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) }; cx.build_explicit_deps.insert(*unit, (output_file.clone(), rerun_if_changed)); - fs::create_dir_all(&cx.layout(&host_unit).build(unit.pkg))?; - fs::create_dir_all(&cx.layout(unit).build(unit.pkg))?; + fs::create_dir_all(&script_output)?; + fs::create_dir_all(&build_output)?; // Prepare the unit of "dirty work" which will actually run the custom build // command. @@ -336,9 +337,8 @@ impl BuildOutput { match key { "rustc-flags" => { - let (libs, links) = - BuildOutput::parse_rustc_flags(value, &whence) - ?; + let (libs, links) = + BuildOutput::parse_rustc_flags(value, &whence)?; library_links.extend(links.into_iter()); library_paths.extend(libs.into_iter()); } diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 952ccac7830..3d1f274498f 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -48,7 +48,7 @@ pub fn prepare_target<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult { let _p = profile::start(format!("fingerprint: {} / {}", unit.pkg.package_id(), unit.target.name())); - let new = dir(cx, unit); + let new = cx.fingerprint_dir(unit); let loc = new.join(&filename(cx, unit)); debug!("fingerprint at: {}", loc.display()); @@ -426,7 +426,7 @@ pub fn prepare_build_cmd<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult { let _p = profile::start(format!("fingerprint build cmd: {}", unit.pkg.package_id())); - let new = dir(cx, unit); + let new = cx.fingerprint_dir(unit); let loc = new.join("build"); debug!("fingerprint at: {}", loc.display()); @@ -507,13 +507,13 @@ fn write_fingerprint(loc: &Path, fingerprint: &Fingerprint) -> CargoResult<()> { debug!("write fingerprint: {}", loc.display()); paths::write(&loc, util::to_hex(hash).as_bytes())?; paths::write(&loc.with_extension("json"), - json::encode(&fingerprint).unwrap().as_bytes())?; + json::encode(&fingerprint).unwrap().as_bytes())?; Ok(()) } /// Prepare work for when a package starts to build pub fn prepare_init(cx: &mut Context, unit: &Unit) -> CargoResult<()> { - let new1 = dir(cx, unit); + let new1 = cx.fingerprint_dir(unit); let new2 = new1.clone(); if fs::metadata(&new1).is_err() { @@ -525,14 +525,9 @@ pub fn prepare_init(cx: &mut Context, unit: &Unit) -> CargoResult<()> { Ok(()) } -/// Return the (old, new) location for fingerprints for a package -pub fn dir(cx: &Context, unit: &Unit) -> PathBuf { - cx.layout(unit).proxy().fingerprint(unit.pkg) -} - /// Returns the (old, new) location for the dep info file of a target. pub fn dep_info_loc(cx: &mut Context, unit: &Unit) -> PathBuf { - dir(cx, unit).join(&format!("dep-{}", filename(cx, unit))) + cx.fingerprint_dir(unit).join(&format!("dep-{}", filename(cx, unit))) } fn compare_old_fingerprint(loc: &Path, new_fingerprint: &Fingerprint) diff --git a/src/cargo/ops/cargo_rustc/layout.rs b/src/cargo/ops/cargo_rustc/layout.rs index cf0cec2df02..2b5cd7514d8 100644 --- a/src/cargo/ops/cargo_rustc/layout.rs +++ b/src/cargo/ops/cargo_rustc/layout.rs @@ -49,10 +49,8 @@ use std::fs; use std::io; use std::path::{PathBuf, Path}; -use core::{Package, Workspace}; +use core::Workspace; use util::{Config, FileLock, CargoResult, Filesystem, human}; -use util::hex::short_hash; -use super::Unit; pub struct Layout { root: PathBuf, @@ -64,11 +62,6 @@ pub struct Layout { _lock: FileLock, } -pub struct LayoutProxy<'a> { - root: &'a Layout, - primary: bool, -} - impl Layout { pub fn new(ws: &Workspace, triple: Option<&str>, @@ -127,58 +120,6 @@ impl Layout { pub fn deps(&self) -> &Path { &self.deps } pub fn examples(&self) -> &Path { &self.examples } pub fn root(&self) -> &Path { &self.root } - - pub fn fingerprint(&self, package: &Package) -> PathBuf { - self.fingerprint.join(&self.pkg_dir(package)) - } - - pub fn build(&self, package: &Package) -> PathBuf { - self.build.join(&self.pkg_dir(package)) - } - - pub fn build_out(&self, package: &Package) -> PathBuf { - self.build(package).join("out") - } - - fn pkg_dir(&self, pkg: &Package) -> String { - format!("{}-{}", pkg.name(), short_hash(pkg)) - } -} - -impl<'a> LayoutProxy<'a> { - pub fn new(root: &'a Layout, primary: bool) -> LayoutProxy<'a> { - LayoutProxy { - root: root, - primary: primary, - } - } - - pub fn root(&self) -> &'a Path { - if self.primary {self.root.dest()} else {self.root.deps()} - } - pub fn deps(&self) -> &'a Path { self.root.deps() } - - pub fn examples(&self) -> &'a Path { self.root.examples() } - - pub fn build(&self, pkg: &Package) -> PathBuf { self.root.build(pkg) } - - pub fn build_out(&self, pkg: &Package) -> PathBuf { self.root.build_out(pkg) } - - pub fn proxy(&self) -> &'a Layout { self.root } - - pub fn out_dir(&self, unit: &Unit) -> PathBuf { - if unit.target.is_custom_build() { - self.build(unit.pkg) - } else if unit.target.is_example() { - self.examples().to_path_buf() - } else { - self.deps().to_path_buf() - } - } - - pub fn doc_root(&self) -> PathBuf { - // the "root" directory ends in 'debug' or 'release', and we want it to - // end in 'doc' instead - self.root.root().parent().unwrap().join("doc") - } + pub fn fingerprint(&self) -> &Path { &self.fingerprint } + pub fn build(&self) -> &Path { &self.build } } diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 73f3fed96a5..c9d3198d2af 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -18,7 +18,6 @@ use self::job_queue::JobQueue; pub use self::compilation::Compilation; pub use self::context::{Context, Unit}; -pub use self::layout::{Layout, LayoutProxy}; pub use self::custom_build::{BuildOutput, BuildMap, BuildScripts}; mod compilation; @@ -104,12 +103,6 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, queue.execute(&mut cx)?; for unit in units.iter() { - let out_dir = cx.layout(unit).build_out(unit.pkg) - .display().to_string(); - cx.compilation.extra_env.entry(unit.pkg.package_id().clone()) - .or_insert(Vec::new()) - .push(("OUT_DIR".to_string(), out_dir)); - for (dst, link_dst, _linkable) in cx.target_filenames(unit)? { let bindst = match link_dst { Some(link_dst) => link_dst, @@ -131,6 +124,13 @@ pub fn compile_targets<'a, 'cfg: 'a>(ws: &Workspace<'cfg>, // Include immediate lib deps as well for unit in cx.dep_targets(unit)?.iter() { + if unit.profile.run_custom_build { + let out_dir = cx.build_script_out_dir(unit).display().to_string(); + cx.compilation.extra_env.entry(unit.pkg.package_id().clone()) + .or_insert(Vec::new()) + .push(("OUT_DIR".to_string(), out_dir)); + } + let pkgid = unit.pkg.package_id(); if !unit.target.is_lib() { continue } if unit.profile.doc { continue } @@ -183,8 +183,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, let (dirty, fresh, freshness) = if unit.profile.run_custom_build { custom_build::prepare(cx, unit)? } else { - let (freshness, dirty, fresh) = fingerprint::prepare_target(cx, - unit)?; + let (freshness, dirty, fresh) = fingerprint::prepare_target(cx, unit)?; let work = if unit.profile.doc { rustdoc(cx, unit)? } else { @@ -465,10 +464,6 @@ fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { build_deps_args(&mut rustdoc, cx, unit)?; - if unit.pkg.has_custom_build() { - rustdoc.env("OUT_DIR", &cx.layout(unit).build_out(unit.pkg)); - } - rustdoc.args(&cx.rustdocflags_args(unit)?); let name = unit.pkg.name().to_string(); @@ -624,7 +619,7 @@ fn build_base_args(cx: &mut Context, } -fn build_plugin_args(cmd: &mut ProcessBuilder, cx: &Context, unit: &Unit) { +fn build_plugin_args(cmd: &mut ProcessBuilder, cx: &mut Context, unit: &Unit) { fn opt(cmd: &mut ProcessBuilder, key: &str, prefix: &str, val: Option<&OsStr>) { if let Some(val) = val { @@ -649,15 +644,14 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &mut Context, unit: &Unit) -> CargoResult<()> { cmd.arg("-L").arg(&{ let mut deps = OsString::from("dependency="); - deps.push(cx.layout(unit).deps()); + deps.push(cx.deps_dir(unit)); deps }); - if unit.pkg.has_custom_build() { - cmd.env("OUT_DIR", &cx.layout(unit).build_out(unit.pkg)); - } - for unit in cx.dep_targets(unit)?.iter() { + if unit.profile.run_custom_build { + cmd.env("OUT_DIR", &cx.build_script_out_dir(unit)); + } if unit.target.linkable() && !unit.profile.doc { link_to(cmd, cx, unit)?; } diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index ff4583c569a..902c72e3007 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -2,8 +2,8 @@ pub use self::cargo_clean::{clean, CleanOptions}; pub use self::cargo_compile::{compile, compile_ws, resolve_dependencies, CompileOptions}; pub use self::cargo_compile::{CompileFilter, CompileMode, MessageFormat}; pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages}; -pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind, Unit}; -pub use self::cargo_rustc::{Context, LayoutProxy}; +pub use self::cargo_rustc::{compile_targets, Compilation, Kind, Unit}; +pub use self::cargo_rustc::Context; pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig}; pub use self::cargo_run::run; pub use self::cargo_install::{install, install_list, uninstall}; diff --git a/tests/build-script.rs b/tests/build-script.rs index e6bcef0fbe9..dfccd32201f 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -2288,3 +2288,49 @@ fn cfg_env_vars_available() { assert_that(build.cargo_process("bench"), execs().with_status(0)); } + +#[test] +fn switch_features_rerun() { + let build = project("builder") + .file("Cargo.toml", r#" + [package] + name = "builder" + version = "0.0.1" + authors = [] + build = "build.rs" + + [features] + foo = [] + "#) + .file("src/main.rs", r#" + fn main() { + println!(include_str!(concat!(env!("OUT_DIR"), "/output"))); + } + "#) + .file("build.rs", r#" + use std::env; + use std::fs::File; + use std::io::Write; + use std::path::Path; + + fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let out_dir = Path::new(&out_dir).join("output"); + let mut f = File::create(&out_dir).unwrap(); + + if env::var_os("CARGO_FEATURE_FOO").is_some() { + f.write_all(b"foo").unwrap(); + } else { + f.write_all(b"bar").unwrap(); + } + } + "#); + build.build(); + + assert_that(build.cargo("run").arg("-v").arg("--features=foo"), + execs().with_status(0).with_stdout("foo\n")); + assert_that(build.cargo("run").arg("-v"), + execs().with_status(0).with_stdout("bar\n")); + assert_that(build.cargo("run").arg("-v").arg("--features=foo"), + execs().with_status(0).with_stdout("foo\n")); +} From df9ac82a548704fd8529f41278d2854ba68f3975 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 28 Nov 2016 21:41:21 +0100 Subject: [PATCH 0854/3888] Use short IDs in git dependencies checkout path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … in order to contribute less to the path length limit on Windows: https://github.com/servo/servo/pull/14397 --- src/cargo/sources/git/source.rs | 7 ++++++- src/cargo/sources/git/utils.rs | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index 321fe4dfcd0..0587d185f01 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -149,8 +149,13 @@ impl<'cfg> Source for GitSource<'cfg> { (self.remote.db_at(&db_path)?, actual_rev.unwrap()) }; + // Don’t use the full hash, + // to contribute less to reaching the path length limit on Windows: + // https://github.com/servo/servo/pull/14397 + let short_id = repo.to_short_id(actual_rev.clone()).unwrap(); + let checkout_path = lock.parent().join("checkouts") - .join(&self.ident).join(actual_rev.to_string()); + .join(&self.ident).join(short_id.as_str()); // Copy the database to the checkout location. After this we could drop // the lock on the database as we no longer needed it, but we leave it diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 7452c1dbbf8..3b3b005f3a0 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -19,6 +19,14 @@ impl fmt::Display for GitRevision { } } +pub struct GitShortID(git2::Buf); + +impl GitShortID { + pub fn as_str(&self) -> &str { + self.0.as_str().unwrap() + } +} + /// GitRemote represents a remote repository. It gets cloned into a local /// GitDatabase. #[derive(PartialEq,Clone,Debug)] @@ -215,6 +223,11 @@ impl GitDatabase { Ok(GitRevision(id)) } + pub fn to_short_id(&self, revision: GitRevision) -> CargoResult { + let obj = self.repo.find_object(revision.0, None)?; + Ok(GitShortID(obj.short_id()?)) + } + pub fn has_ref(&self, reference: &str) -> CargoResult<()> { self.repo.revparse_single(reference)?; Ok(()) From dfbee717bde758406f3c885ef3f082b0243990b3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 28 Nov 2016 15:48:10 -0800 Subject: [PATCH 0855/3888] Bump git2 dep to fix SSL paths This commit includes alexcrichton/git2-rs@a8f4a7faa which switches the order of initialization of libgit2. That commit ensures that the relevant env vars which a statically linked OpenSSL needs to function are set before libgit2 is initialized to ensure that libgit2 uses them. This was regressed accidentally in alexcrichton/git2-rs@071902aa when initialization was tweaked. Closes #3340 --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7734f06859b..991d59162ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,7 +13,7 @@ dependencies = [ "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -71,7 +71,7 @@ dependencies = [ "cargo 0.16.0", "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -199,7 +199,7 @@ dependencies = [ [[package]] name = "git2" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -216,7 +216,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "git2 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -641,7 +641,7 @@ dependencies = [ "checksum fs2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "640001e1bd865c7c32806292822445af576a6866175b5225aa2087ca5e3de551" "checksum gcc 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "553f11439bdefe755bf366b264820f1da70f3aaf3924e594b886beb9c831bcf5" "checksum gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0912515a8ff24ba900422ecda800b52f4016a56251922d397c576bf92c690518" -"checksum git2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "76a6b09c00bfcca72a1ad874f04048f756370724e6ee20e98039ff21e688ced3" +"checksum git2 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0534ca86640c6a3a0687cc6bee9ec4032509a0d112d97e8241fa6b7e075f6119" "checksum git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "68676bc784bf0bef83278898929bf64a251e87c0340723d0b93fa096c9c5bf8e" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf088f042a467089e9baa4972f57f9247e42a0cc549ba264c7a04fbb8ecb89d4" From 0ec6d72a9dcfbb167ca7b1bfd9c47d85baf6360e Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Wed, 30 Nov 2016 00:11:58 +0100 Subject: [PATCH 0856/3888] [WIP] Reordered rustc arguments. --- src/cargo/ops/cargo_rustc/mod.rs | 8 ++-- tests/bench.rs | 2 +- tests/build-lib.rs | 2 +- tests/build-script.rs | 66 ++++++++++++++++---------------- tests/build.rs | 20 +++++----- tests/cargo_alias_config.rs | 6 +-- tests/clean.rs | 4 +- tests/cross-compile.rs | 24 ++++++------ 8 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 02e1088303b..8155805c8ec 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -434,9 +434,9 @@ fn prepare_rustc(cx: &Context, fn rustdoc(cx: &mut Context, unit: &Unit) -> CargoResult { let mut rustdoc = cx.compilation.rustdoc_process(unit.pkg)?; - rustdoc.arg(&root_path(cx, unit)) + rustdoc.arg("--crate-name").arg(&unit.target.crate_name()) .cwd(cx.config.cwd()) - .arg("--crate-name").arg(&unit.target.crate_name()); + .arg(&root_path(cx, unit)); if unit.kind != Kind::Host { if let Some(target) = cx.requested_target() { @@ -523,6 +523,8 @@ fn build_base_args(cx: &Context, // Move to cwd so the root_path() passed below is actually correct cmd.cwd(cx.config.cwd()); + cmd.arg("--crate-name").arg(&unit.target.crate_name()); + cmd.arg(&root_path(cx, unit)); let color_config = cx.config.shell().color_config(); @@ -534,8 +536,6 @@ fn build_base_args(cx: &Context, cmd.arg("--error-format").arg("json"); } - cmd.arg("--crate-name").arg(&unit.target.crate_name()); - if !test { for crate_type in crate_types.iter() { cmd.arg("--crate-type").arg(crate_type); diff --git a/tests/bench.rs b/tests/bench.rs index fdaa7160a5f..cbd1ef96d9c 100644 --- a/tests/bench.rs +++ b/tests/bench.rs @@ -105,7 +105,7 @@ fn cargo_bench_verbose() { assert_that(p.cargo_process("bench").arg("-v").arg("hello"), execs().with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({url}) -[RUNNING] `rustc src[/]foo.rs [..]` +[RUNNING] `rustc [..] src[/]foo.rs [..]` [FINISHED] release [optimized] target(s) in [..] [RUNNING] `[..]target[/]release[/]deps[/]foo-[..][EXE] hello --bench`", url = p.url())) .with_stdout(" diff --git a/tests/build-lib.rs b/tests/build-lib.rs index 44c41b8f3d1..5fad077a0b9 100644 --- a/tests/build-lib.rs +++ b/tests/build-lib.rs @@ -7,7 +7,7 @@ use hamcrest::{assert_that}; fn verbose_output_for_lib(p: &ProjectBuilder) -> String { format!("\ [COMPILING] {name} v{version} ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name {name} --crate-type lib -g \ +[RUNNING] `rustc --crate-name {name} src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ diff --git a/tests/build-script.rs b/tests/build-script.rs index e6bcef0fbe9..2a49e9972f7 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -33,7 +33,7 @@ fn custom_build_script_failed() { execs().with_status(101) .with_stderr(&format!("\ [COMPILING] foo v0.5.0 ({url}) -[RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin [..]` +[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin [..]` [RUNNING] `[..][/]build-script-build` [ERROR] failed to run custom build command for `foo v0.5.0 ({url})` process didn't exit successfully: `[..][/]build-script-build` (exit code: 101)", @@ -184,7 +184,7 @@ fn custom_build_script_rustc_flags() { execs().with_status(101) .with_stderr(&format!("\ [COMPILING] bar v0.5.0 ({url}) -[RUNNING] `rustc {dir}{sep}src{sep}lib.rs --crate-name test --crate-type lib -g \ +[RUNNING] `rustc --crate-name test {dir}{sep}src{sep}lib.rs --crate-type lib -g \ -C metadata=[..] \ -C extra-filename=-[..] \ --out-dir {dir}{sep}target \ @@ -306,7 +306,7 @@ fn overrides_and_links() { [..] [..] [..] -[RUNNING] `rustc [..] --crate-name foo [..] -L foo -L bar[..]` +[RUNNING] `rustc --crate-name foo [..] -L foo -L bar[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -408,7 +408,7 @@ fn only_rerun_build_script() { .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc [..] --crate-name foo [..]` +[RUNNING] `rustc --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -496,8 +496,8 @@ fn testing_and_such() { .with_stderr("\ [COMPILING] foo v0.5.0 (file://[..]) [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc [..] --crate-name foo [..]` -[RUNNING] `rustc [..] --crate-name foo [..]` +[RUNNING] `rustc --crate-name foo [..]` +[RUNNING] `rustc --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..][/]foo-[..][EXE]` [DOCTEST] foo @@ -582,9 +582,9 @@ fn propagation_of_l_flags() { assert_that(p.cargo_process("build").arg("-v").arg("-j1"), execs().with_status(0) .with_stderr_contains("\ -[RUNNING] `rustc [..] --crate-name a [..]-L bar[..]-L foo[..]` +[RUNNING] `rustc --crate-name a [..] -L bar[..]-L foo[..]` [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `rustc [..] --crate-name foo [..] -L bar -L foo` +[RUNNING] `rustc --crate-name foo [..] -L bar -L foo` ")); } @@ -636,9 +636,9 @@ fn propagation_of_l_flags_new() { assert_that(p.cargo_process("build").arg("-v").arg("-j1"), execs().with_status(0) .with_stderr_contains("\ -[RUNNING] `rustc [..] --crate-name a [..]-L bar[..]-L foo[..]` +[RUNNING] `rustc --crate-name a [..] -L bar[..]-L foo[..]` [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `rustc [..] --crate-name foo [..] -L bar -L foo` +[RUNNING] `rustc --crate-name foo [..] -L bar -L foo` ")); } @@ -671,11 +671,11 @@ fn build_deps_simple() { execs().with_status(0) .with_stderr("\ [COMPILING] a v0.5.0 (file://[..]) -[RUNNING] `rustc [..] --crate-name a [..]` +[RUNNING] `rustc --crate-name a [..]` [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `rustc build.rs [..] --extern a=[..]` +[RUNNING] `rustc [..] build.rs [..] --extern a=[..]` [RUNNING] `[..][/]foo-[..][/]build-script-build` -[RUNNING] `rustc [..] --crate-name foo [..]` +[RUNNING] `rustc --crate-name foo [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -761,21 +761,21 @@ fn build_cmd_with_a_build_cmd() { execs().with_status(0) .with_stderr("\ [COMPILING] b v0.5.0 (file://[..]) -[RUNNING] `rustc [..] --crate-name b [..]` +[RUNNING] `rustc --crate-name b [..]` [COMPILING] a v0.5.0 (file://[..]) -[RUNNING] `rustc a[/]build.rs [..] --extern b=[..]` +[RUNNING] `rustc [..] a[/]build.rs [..] --extern b=[..]` [RUNNING] `[..][/]a-[..][/]build-script-build` -[RUNNING] `rustc [..]lib.rs --crate-name a --crate-type lib -g \ +[RUNNING] `rustc --crate-name a [..]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..]target[/]debug[/]deps --emit=dep-info,link \ -L [..]target[/]debug[/]deps` [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `rustc build.rs --crate-name build_script_build --crate-type bin \ +[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin \ -g -C metadata=[..] --out-dir [..] --emit=dep-info,link \ -L [..]target[/]debug[/]deps \ --extern a=[..]liba[..].rlib` [RUNNING] `[..][/]foo-[..][/]build-script-build` -[RUNNING] `rustc [..]lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc --crate-name foo [..]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] --emit=dep-info,link \ -L [..]target[/]debug[/]deps` @@ -853,9 +853,9 @@ fn output_separate_lines() { execs().with_status(101) .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `rustc build.rs [..]` +[RUNNING] `rustc [..] build.rs [..]` [RUNNING] `[..][/]foo-[..][/]build-script-build` -[RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` +[RUNNING] `rustc --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); } @@ -881,9 +881,9 @@ fn output_separate_lines_new() { execs().with_status(101) .with_stderr_contains("\ [COMPILING] foo v0.5.0 (file://[..]) -[RUNNING] `rustc build.rs [..]` +[RUNNING] `rustc [..] build.rs [..]` [RUNNING] `[..][/]foo-[..][/]build-script-build` -[RUNNING] `rustc [..] --crate-name foo [..] -L foo -l static=foo` +[RUNNING] `rustc --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ")); } @@ -1599,14 +1599,14 @@ fn flags_go_into_tests() { execs().with_status(0) .with_stderr("\ [COMPILING] a v0.5.0 ([..] -[RUNNING] `rustc a[/]build.rs [..]` +[RUNNING] `rustc [..] a[/]build.rs [..]` [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc a[/]src[/]lib.rs [..] -L test[..]` +[RUNNING] `rustc [..] a[/]src[/]lib.rs [..] -L test[..]` [COMPILING] b v0.5.0 ([..] -[RUNNING] `rustc b[/]src[/]lib.rs [..] -L test[..]` +[RUNNING] `rustc [..] b[/]src[/]lib.rs [..] -L test[..]` [COMPILING] foo v0.5.0 ([..] -[RUNNING] `rustc src[/]lib.rs [..] -L test[..]` -[RUNNING] `rustc tests[/]foo.rs [..] -L test[..]` +[RUNNING] `rustc [..] src[/]lib.rs [..] -L test[..]` +[RUNNING] `rustc [..] tests[/]foo.rs [..] -L test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..][/]foo-[..][EXE]`") .with_stdout(" @@ -1621,7 +1621,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured .with_stderr("\ [FRESH] a v0.5.0 ([..] [COMPILING] b v0.5.0 ([..] -[RUNNING] `rustc b[/]src[/]lib.rs [..] -L test[..]` +[RUNNING] `rustc [..] b[/]src[/]lib.rs [..] -L test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..][/]b-[..][EXE]`") .with_stdout(" @@ -1805,7 +1805,7 @@ fn rebuild_only_on_explicit_paths() { execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc src[/]lib.rs [..]` +[RUNNING] `rustc [..] src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1819,7 +1819,7 @@ fn rebuild_only_on_explicit_paths() { execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc src[/]lib.rs [..]` +[RUNNING] `rustc [..] src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1848,7 +1848,7 @@ fn rebuild_only_on_explicit_paths() { execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc src[/]lib.rs [..]` +[RUNNING] `rustc [..] src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); @@ -1859,7 +1859,7 @@ fn rebuild_only_on_explicit_paths() { execs().with_status(0).with_stderr("\ [COMPILING] a v0.5.0 ([..]) [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc src[/]lib.rs [..]` +[RUNNING] `rustc [..] src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -2235,7 +2235,7 @@ fn links_with_dots() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0) .with_stderr_contains("\ -[RUNNING] `rustc [..] --crate-name foo [..] -L foo[..]` +[RUNNING] `rustc --crate-name foo [..] [..] -L foo[..]` ")); } diff --git a/tests/build.rs b/tests/build.rs index 68a3562628c..02e14d18dd3 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -793,14 +793,14 @@ fn cargo_default_env_metadata_env_var() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] bar v0.0.1 ({url}/bar) -[RUNNING] `rustc bar[/]src[/]lib.rs --crate-name bar --crate-type dylib \ +[RUNNING] `rustc --crate-name bar bar[/]src[/]lib.rs --crate-type dylib \ -C prefer-dynamic -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps` [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ -C extra-filename=[..] \ --out-dir [..] \ @@ -821,14 +821,14 @@ suffix = env::consts::DLL_SUFFIX, assert_that(p.cargo_process("build").arg("-v").env("__CARGO_DEFAULT_LIB_METADATA", "1"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] bar v0.0.1 ({url}/bar) -[RUNNING] `rustc bar[/]src[/]lib.rs --crate-name bar --crate-type dylib \ +[RUNNING] `rustc --crate-name bar bar[/]src[/]lib.rs --crate-type dylib \ -C prefer-dynamic -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps` [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ -C extra-filename=[..] \ --out-dir [..] \ @@ -1141,7 +1141,7 @@ fn lto_build() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]main.rs --crate-name test --crate-type bin \ +[RUNNING] `rustc --crate-name test src[/]main.rs --crate-type bin \ -C opt-level=3 \ -C lto \ -C metadata=[..] \ @@ -1170,7 +1170,7 @@ fn verbose_build() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib -g \ +[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ @@ -1197,7 +1197,7 @@ fn verbose_release_build() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \ -C opt-level=3 \ -C metadata=[..] \ --out-dir [..] \ @@ -1240,7 +1240,7 @@ fn verbose_release_build_deps() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({url}/foo) -[RUNNING] `rustc foo[/]src[/]lib.rs --crate-name foo \ +[RUNNING] `rustc --crate-name foo foo[/]src[/]lib.rs \ --crate-type dylib --crate-type rlib -C prefer-dynamic \ -C opt-level=3 \ -C metadata=[..] \ @@ -1248,7 +1248,7 @@ fn verbose_release_build_deps() { --emit=dep-info,link \ -L dependency={dir}[/]target[/]release[/]deps` [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \ -C opt-level=3 \ -C metadata=[..] \ --out-dir [..] \ @@ -2357,7 +2357,7 @@ fn explicit_color_config_is_propagated_to_rustc() { assert_that(p.cargo_process("build").arg("-v").arg("--color").arg("always"), execs().with_status(0).with_stderr_contains( - "[..]rustc src[/]lib.rs --color always[..]")); + "[..]rustc [..] src[/]lib.rs --color always[..]")); assert_that(p.cargo_process("build").arg("-v").arg("--color").arg("never"), execs().with_status(0).with_stderr("\ diff --git a/tests/cargo_alias_config.rs b/tests/cargo_alias_config.rs index bc0dd35478b..5987f784e54 100644 --- a/tests/cargo_alias_config.rs +++ b/tests/cargo_alias_config.rs @@ -55,7 +55,7 @@ fn alias_config() { assert_that(p.cargo_process("b-cargo-test").arg("-v"), execs().with_status(0). with_stderr_contains("[COMPILING] foo v0.5.0 [..] -[RUNNING] `rustc [..] --crate-name foo [..]")); +[RUNNING] `rustc --crate-name foo [..]")); } #[test] @@ -73,7 +73,7 @@ fn alias_list_test() { assert_that(p.cargo_process("b-cargo-test").arg("-v"), execs().with_status(0). with_stderr_contains("[COMPILING] foo v0.5.0 [..]"). - with_stderr_contains("[RUNNING] `rustc [..] --crate-name [..]") + with_stderr_contains("[RUNNING] `rustc --crate-name [..]") ); } @@ -92,7 +92,7 @@ fn alias_with_flags_config() { assert_that(p.cargo_process("b-cargo-test").arg("-v"), execs().with_status(0). with_stderr_contains("[COMPILING] foo v0.5.0 [..]"). - with_stderr_contains("[RUNNING] `rustc [..] --crate-name foo [..]") + with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]") ); } diff --git a/tests/clean.rs b/tests/clean.rs index 39cc5287203..cdaa32b2ccb 100644 --- a/tests/clean.rs +++ b/tests/clean.rs @@ -171,9 +171,9 @@ fn build_script() { assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr("\ [COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc build.rs [..]` +[RUNNING] `rustc [..] build.rs [..]` [RUNNING] `[..]build-script-build` -[RUNNING] `rustc src[/]main.rs [..]` +[RUNNING] `rustc [..] src[/]main.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } diff --git a/tests/cross-compile.rs b/tests/cross-compile.rs index bbb534f8d3d..d865ffc6e0c 100644 --- a/tests/cross-compile.rs +++ b/tests/cross-compile.rs @@ -357,7 +357,7 @@ fn linker_and_ar() { execs().with_status(101) .with_stderr_contains(&format!("\ [COMPILING] foo v0.5.0 ({url}) -[RUNNING] `rustc src[/]foo.rs --crate-name foo --crate-type bin -g \ +[RUNNING] `rustc --crate-name foo src[/]foo.rs --crate-type bin -g \ -C metadata=[..] \ --out-dir {dir}[/]target[/]{target}[/]debug[/]deps \ --emit=dep-info,link \ @@ -604,9 +604,9 @@ fn cross_with_a_build_script() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] foo v0.0.0 (file://[..]) -[RUNNING] `rustc build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]foo-[..]` +[RUNNING] `rustc [..] build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]foo-[..]` [RUNNING] `{dir}[/]target[/]debug[/]build[/]foo-[..][/]build-script-build` -[RUNNING] `rustc src[/]main.rs [..] --target {target} [..]` +[RUNNING] `rustc [..] src[/]main.rs [..] --target {target} [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", target = target, dir = p.root().display()))); @@ -676,25 +676,25 @@ fn build_script_needed_for_host_and_target() { .with_stderr_contains(&format!("\ [COMPILING] d1 v0.0.0 ({url}/d1)", url = p.url())) .with_stderr_contains(&format!("\ -[RUNNING] `rustc d1[/]build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]d1-[..]`", +[RUNNING] `rustc [..] d1[/]build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]d1-[..]`", dir = p.root().display())) .with_stderr_contains(&format!("\ [RUNNING] `{dir}[/]target[/]debug[/]build[/]d1-[..][/]build-script-build`", dir = p.root().display())) .with_stderr_contains("\ -[RUNNING] `rustc d1[/]src[/]lib.rs [..]`") +[RUNNING] `rustc [..] d1[/]src[/]lib.rs [..]`") .with_stderr_contains(&format!("\ [COMPILING] d2 v0.0.0 ({url}/d2)", url = p.url())) .with_stderr_contains(&format!("\ -[RUNNING] `rustc d2[/]src[/]lib.rs [..] \ +[RUNNING] `rustc [..] d2[/]src[/]lib.rs [..] \ -L /path/to/{host}`", host = host)) .with_stderr_contains(&format!("\ [COMPILING] foo v0.0.0 ({url})", url = p.url())) .with_stderr_contains(&format!("\ -[RUNNING] `rustc build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]foo-[..] \ +[RUNNING] `rustc [..] build.rs [..] --out-dir {dir}[/]target[/]debug[/]build[/]foo-[..] \ -L /path/to/{host}`", dir = p.root().display(), host = host)) .with_stderr_contains(&format!("\ -[RUNNING] `rustc src[/]main.rs [..] --target {target} [..] \ +[RUNNING] `rustc [..] src[/]main.rs [..] --target {target} [..] \ -L /path/to/{target}`", target = target))); } @@ -852,13 +852,13 @@ fn build_script_with_platform_specific_dependencies() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] d2 v0.0.0 ([..]) -[RUNNING] `rustc d2[/]src[/]lib.rs [..]` +[RUNNING] `rustc [..] d2[/]src[/]lib.rs [..]` [COMPILING] d1 v0.0.0 ([..]) -[RUNNING] `rustc d1[/]src[/]lib.rs [..]` +[RUNNING] `rustc [..] d1[/]src[/]lib.rs [..]` [COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc build.rs [..]` +[RUNNING] `rustc [..] build.rs [..]` [RUNNING] `{dir}[/]target[/]debug[/]build[/]foo-[..][/]build-script-build` -[RUNNING] `rustc src[/]lib.rs [..] --target {target} [..]` +[RUNNING] `rustc [..] src[/]lib.rs [..] --target {target} [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", dir = p.root().display(), target = target))); } From 8f42189e0212a9be814ee654720502cc4766806b Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Wed, 30 Nov 2016 01:05:55 +0100 Subject: [PATCH 0857/3888] Updated one more test to fit new rustc argument order. --- tests/cross-compile.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cross-compile.rs b/tests/cross-compile.rs index d865ffc6e0c..6cffa301fb1 100644 --- a/tests/cross-compile.rs +++ b/tests/cross-compile.rs @@ -804,9 +804,9 @@ fn plugin_build_script_right_arch() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc build.rs [..]` +[RUNNING] `rustc [..] build.rs [..]` [RUNNING] `[..][/]build-script-build` -[RUNNING] `rustc src[/]lib.rs [..]` +[RUNNING] `rustc [..] src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } From 79d49b000c7e7a09470f26133d2dfa9160aafa10 Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Wed, 30 Nov 2016 08:49:00 +0100 Subject: [PATCH 0858/3888] Another test update for the argument order changetest update for the argument order change. Please enter the commit message for your changes. Lines starting --- tests/doc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/doc.rs b/tests/doc.rs index 457e53c25d1..44f2f4dff23 100644 --- a/tests/doc.rs +++ b/tests/doc.rs @@ -445,7 +445,7 @@ fn doc_release() { execs().with_status(0) .with_stderr("\ [DOCUMENTING] foo v0.0.1 ([..]) -[RUNNING] `rustdoc src[/]lib.rs [..]` +[RUNNING] `rustdoc [..] src[/]lib.rs [..]` ")); } From 35778b48e998616c7097f542e5dd0eae257caa61 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 29 Nov 2016 06:36:31 -0800 Subject: [PATCH 0859/3888] Add support for release branches in Cargo Follow the same strategy as the compiler for now in basically every respect: * Add new `--release-channel` configure option, defaulting to `dev` * Remove old `--enable-nightly` * Add `--enable-build-openssl` as an orthogonal option * Hook up Travis/AppVeyor to stable/beta/master branches to do the right channel builds. --- .travis.yml | 12 +++++---- Makefile.in | 23 ++++++++++------ appveyor.yml | 7 ++--- configure | 49 +++++++--------------------------- src/ci/docker/cross/Dockerfile | 16 +++++++++++ src/ci/docker/run.sh | 1 + src/ci/run.sh | 20 +++++++++++++- 7 files changed, 71 insertions(+), 57 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb7b08655d1..961c8488c99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,13 +57,13 @@ matrix: IMAGE=cross - env: TARGET=mips64-unknown-linux-gnuabi64 IMAGE=cross - rust: nightly + rust: beta - env: TARGET=mips64el-unknown-linux-gnuabi64 IMAGE=cross - rust: nightly + rust: beta - env: TARGET=s390x-unknown-linux-gnu IMAGE=cross - rust: nightly + rust: beta - env: TARGET=powerpc-unknown-linux-gnu IMAGE=cross rust: beta @@ -86,7 +86,7 @@ matrix: IMAGE=dist MAKE_TARGETS="test distcheck doc install uninstall" DEPLOY=0 - rust: nightly + rust: nightly-2016-11-26 exclude: - rust: stable @@ -125,10 +125,12 @@ branches: only: - master - auto-cargo + - beta + - stable before_deploy: - mkdir -p deploy/$TRAVIS_COMMIT - - cp target/$TARGET/release/dist/cargo-nightly-$TARGET.tar.gz + - cp target/$TARGET/release/dist/cargo-*-$TARGET.tar.gz deploy/$TRAVIS_COMMIT deploy: diff --git a/Makefile.in b/Makefile.in index fa9474e599c..79d9a52e094 100644 --- a/Makefile.in +++ b/Makefile.in @@ -8,13 +8,20 @@ include config.mk export PATH := $(dir $(CFG_RUSTC)):$(PATH) -ifdef CFG_ENABLE_NIGHTLY -CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL)-nightly -CFG_PACKAGE_VERS = nightly -else -CFG_RELEASE=$(CFG_RELEASE_NUM)$(CFG_RELEASE_LABEL) -CFG_PACKAGE_VERS=$(CFG_RELEASE) +ifeq ($(CFG_RELEASE_CHANNEL),stable) +CFG_RELEASE=$(CFG_RELEASE_NUM) +CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM) +else ifeq ($(CFG_RELEASE_CHANNEL),beta) +CFG_RELEASE=$(CFG_RELEASE_NUM)-beta$(CFG_PRERELEASE_VERSION) +CFG_PACKAGE_VERS=beta +else ifeq ($(CFG_RELEASE_CHANNEL),nightly) +CFG_RELEASE=$(CFG_RELEASE_NUM)-nightly +CFG_PACKAGE_VERS=nightly +else ifeq ($(CFG_RELEASE_CHANNEL),dev) +CFG_RELEASE=$(CFG_RELEASE_NUM)-dev +CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev endif + CFG_BUILD_DATE = $(shell date +%F) ifeq ($(wildcard .git),) @@ -240,7 +247,7 @@ OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32 define BUILD_OPENSSL -ifdef CFG_ENABLE_NIGHTLY +ifdef CFG_ENABLE_BUILD_OPENSSL cargo-$(1): export OPENSSL_STATIC := 1 test-unit-$(1): export OPENSSL_STATIC := 1 @@ -274,7 +281,7 @@ target/openssl/$(1).stamp: endif -else # !CFG_ENABLE_NIGHTLY +else # !CFG_ENABLE_BUILD_OPENSSL target/openssl/$(1).stamp: endif diff --git a/appveyor.yml b/appveyor.yml index 7187fc0d5eb..905b35b9c32 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,16 +49,17 @@ cache: after_test: - mkdir %APPVEYOR_REPO_COMMIT% - - copy target\%TARGET%\release\dist\cargo-nightly-%TARGET%.tar.gz - %APPVEYOR_REPO_COMMIT% + - ps: Get-ChildItem -Path target\${env:TARGET}\release\dist -Filter '*.tar.gz' | Move-Item -Destination ${env:APPVEYOR_REPO_COMMIT} branches: only: - master - auto-cargo + - beta + - stable artifacts: - - path: $(APPVEYOR_REPO_COMMIT)\cargo-nightly-$(TARGET).tar.gz + - path: $(APPVEYOR_REPO_COMMIT)\cargo-*-$(TARGET).tar.gz name: cargo deploy: diff --git a/configure b/configure index 1ead582545e..55e9bb0dbb5 100755 --- a/configure +++ b/configure @@ -300,10 +300,10 @@ VAL_OPTIONS="" opt debug 1 "build with extra debug fun" opt optimize 1 "build with optimizations" -opt nightly 0 "build nightly packages" opt verify-install 1 "verify installed binaries work" opt option-checking 1 "complain about unrecognized options in this configure script" opt cross-tests 1 "run cross-compilation tests" +opt build-openssl 0 "compile OpenSSL at build time to link to" valopt prefix "/usr/local" "set installation prefix" valopt local-rust-root "" "set prefix for local rust binary" @@ -336,6 +336,14 @@ valopt docdir "${CFG_PREFIX}/share/doc/cargo" "install extra docs" valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH" valopt libdir "${CFG_PREFIX}/lib" "install libraries" +if [ -e ${CFG_SRC_DIR}.git ] +then + valopt release-channel "dev" "the name of the release channel to build" +else + msg "git: no git directory. Changing default release channel to stable" + valopt release-channel "stable" "the name of the release channel to build" +fi + if [ $HELP -eq 1 ] then echo @@ -385,45 +393,6 @@ if [ "$CFG_SRC_DIR" != "$CFG_BUILD_DIR" ]; then putvar CFG_CUSTOM_BUILD_DIR fi -if [ ! -z "$CFG_ENABLE_NIGHTLY" ]; then - need_cmd curl - if [ ! -f .cargo/config ]; then - mkdir -p .cargo - cat > .cargo/config <<-EOF -[target.arm-unknown-linux-gnueabi] -linker = "arm-linux-gnueabi-gcc" -[target.arm-unknown-linux-gnueabihf] -linker = "arm-linux-gnueabihf-gcc" -[target.armv7-unknown-linux-gnueabihf] -linker = "armv7-linux-gnueabihf-gcc" -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" -[target.i686-unknown-freebsd] -linker = "i686-unknown-freebsd10-gcc" -[target.x86_64-unknown-freebsd] -linker = "x86_64-unknown-freebsd10-gcc" -[target.x86_64-unknown-netbsd] -linker = "x86_64-unknown-netbsd-gcc" -[target.powerpc-unknown-linux-gnu] -linker = "powerpc-linux-gnu-gcc" -[target.powerpc64-unknown-linux-gnu] -linker = "powerpc64-linux-gnu-gcc-5" -[target.powerpc64le-unknown-linux-gnu] -linker = "powerpc64le-linux-gnu-gcc" -[target.mips-unknown-linux-gnu] -linker = "mips-linux-gnu-gcc" -[target.mipsel-unknown-linux-gnu] -linker = "mipsel-linux-gnu-gcc" -[target.mips64el-unknown-linux-gnuabi64] -linker = "mips64el-linux-gnuabi64-gcc" -[target.mips64-unknown-linux-gnuabi64] -linker = "mips64-linux-gnuabi64-gcc" -[target.s390x-unknown-linux-gnu] -linker = "s390x-linux-gnu-gcc" -EOF - fi -fi - step_msg "writing configuration" putvar CFG_SRC_DIR diff --git a/src/ci/docker/cross/Dockerfile b/src/ci/docker/cross/Dockerfile index e0a9840e05c..eb4818fed95 100644 --- a/src/ci/docker/cross/Dockerfile +++ b/src/ci/docker/cross/Dockerfile @@ -1,2 +1,18 @@ FROM alexcrichton/rust-slave-linux-cross:2016-10-11c ENTRYPOINT [] + +ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc \ + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=armv7-linux-gnueabihf-gcc \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CARGO_TARGET_I686_UNKNOWN_FREEBSD_LINKER=i686-unknown-freebsd10-gcc \ + CARGO_TARGET_X86_64_UNKNOWN_FREEBSD_LINKER=x86_64-unknown-freebsd10-gcc \ + CARGO_TARGET_X86_64_UNKNOWN_NETBSD_LINKER=x86_64-unknown-netbsd-gcc \ + CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ + CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc \ + CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ + CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ + CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ + CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc-5 \ + CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ + CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index a8f71fab1e7..1a0bb0c21c7 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -36,6 +36,7 @@ exec docker run \ --env MAKE_TARGETS="$MAKE_TARGETS" \ --env SRC=/checkout \ --env CARGO_HOME=/cargo \ + --env TRAVIS_BRANCH=$TRAVIS_BRANCH \ --volume "$HOME/.cargo:/cargo" \ --volume `rustc --print sysroot`:/rust:ro \ --volume `pwd`/target:/tmp/target \ diff --git a/src/ci/run.sh b/src/ci/run.sh index 456c3f8b2b1..a532757d9f3 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -17,10 +17,28 @@ if [ -z "$SRC" ]; then SRC=. fi +BRANCH=$TRAVIS_BRANCH +if [ "$BRANCH" = "" ]; then + BRANCH=$APPVEYOR_BRANCH +fi + +if [ "$BRANCH" = "stable" ]; then + CHANNEL=stable +elif [ "$BRANCH" = "beta" ]; then + CHANNEL=beta +elif [ "$BRANCH" = "master" ]; then + CHANNEL=nightly +elif [ "$BRANCH" = "auto-cargo" ]; then + CHANNEL=nightly +else + CHANNEL=dev +fi + $SRC/configure \ --prefix=/tmp/obj/install \ --target=$TARGET \ - --enable-nightly + --release-channel=$CHANNEL \ + --enable-build-openssl make cargo-$TARGET make dist-$TARGET From 8904f3ef7818b91ef737ea83900085a4762c390b Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Wed, 30 Nov 2016 20:04:14 +0100 Subject: [PATCH 0860/3888] Changed another batch of tests to account for new rustc argument order. --- tests/profiles.rs | 10 +++++----- tests/run.rs | 14 +++++++------- tests/rustc.rs | 16 ++++++++-------- tests/test.rs | 12 ++++++------ 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/profiles.rs b/tests/profiles.rs index eb96e5a8017..cc3cf74039e 100644 --- a/tests/profiles.rs +++ b/tests/profiles.rs @@ -27,7 +27,7 @@ fn profile_overrides() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \ -C opt-level=1 \ -C debug-assertions=on \ -C metadata=[..] \ @@ -60,7 +60,7 @@ fn opt_level_override_0() { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \ -g \ -C metadata=[..] \ --out-dir [..] \ @@ -90,7 +90,7 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) { assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \ -C opt-level={level} \ -g \ -C debug-assertions=on \ @@ -159,7 +159,7 @@ fn top_level_overrides_deps() { assert_that(p.cargo_process("build").arg("-v").arg("--release"), execs().with_status(0).with_stderr(&format!("\ [COMPILING] foo v0.0.0 ({url}/foo) -[RUNNING] `rustc foo[/]src[/]lib.rs --crate-name foo \ +[RUNNING] `rustc --crate-name foo foo[/]src[/]lib.rs \ --crate-type dylib --crate-type rlib -C prefer-dynamic \ -C opt-level=1 \ -g \ @@ -168,7 +168,7 @@ fn top_level_overrides_deps() { --emit=dep-info,link \ -L dependency={dir}[/]target[/]release[/]deps` [COMPILING] test v0.0.0 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name test --crate-type lib \ +[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \ -C opt-level=1 \ -g \ -C metadata=[..] \ diff --git a/tests/run.rs b/tests/run.rs index ce007bef645..095f6dc9862 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -227,8 +227,8 @@ fn specify_name() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] foo v0.0.1 ({dir}) -[RUNNING] `rustc src[/]lib.rs [..]` -[RUNNING] `rustc src[/]bin[/]a.rs [..]` +[RUNNING] `rustc [..] src[/]lib.rs [..]` +[RUNNING] `rustc [..] src[/]bin[/]a.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[/]debug[/]a[EXE]`", dir = path2url(p.root()))) .with_stdout("\ @@ -239,7 +239,7 @@ hello a.rs execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc src[/]bin[/]b.rs [..]` +[RUNNING] `rustc [..] src[/]bin[/]b.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target[/]debug[/]b[EXE]`") .with_stdout("\ @@ -416,14 +416,14 @@ fn example_with_release_flag() { execs().with_status(0) .with_stderr(&format!("\ [COMPILING] bar v0.0.1 ({url}/bar) -[RUNNING] `rustc bar[/]src[/]bar.rs --crate-name bar --crate-type lib \ +[RUNNING] `rustc --crate-name bar bar[/]src[/]bar.rs --crate-type lib \ -C opt-level=3 \ -C metadata=[..] \ --out-dir {dir}[/]target[/]release[/]deps \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]release[/]deps` [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc examples[/]a.rs --crate-name a --crate-type bin \ +[RUNNING] `rustc --crate-name a examples[/]a.rs --crate-type bin \ -C opt-level=3 \ -C metadata=[..] \ --out-dir {dir}[/]target[/]release[/]examples \ @@ -444,14 +444,14 @@ fast2")); execs().with_status(0) .with_stderr(&format!("\ [COMPILING] bar v0.0.1 ({url}/bar) -[RUNNING] `rustc bar[/]src[/]bar.rs --crate-name bar --crate-type lib \ +[RUNNING] `rustc --crate-name bar bar[/]src[/]bar.rs --crate-type lib \ -g \ -C metadata=[..] \ --out-dir {dir}[/]target[/]debug[/]deps \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps` [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc examples[/]a.rs --crate-name a --crate-type bin \ +[RUNNING] `rustc --crate-name a examples[/]a.rs --crate-type bin \ -g \ -C metadata=[..] \ --out-dir {dir}[/]target[/]debug[/]examples \ diff --git a/tests/rustc.rs b/tests/rustc.rs index b8475e16f44..f2c99dd4631 100644 --- a/tests/rustc.rs +++ b/tests/rustc.rs @@ -27,7 +27,7 @@ fn build_lib_for_foo() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ @@ -56,7 +56,7 @@ fn lib() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib -g \ -C debug-assertions=off \ -C metadata=[..] \ --out-dir [..] \ @@ -86,12 +86,12 @@ fn build_main_and_allow_unstable_options() { .with_status(0) .with_stderr(&format!("\ [COMPILING] {name} v{version} ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name {name} --crate-type lib -g \ +[RUNNING] `rustc --crate-name {name} src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..] \ --emit=dep-info,link \ -L dependency={dir}[/]target[/]debug[/]deps` -[RUNNING] `rustc src[/]main.rs --crate-name {name} --crate-type bin -g \ +[RUNNING] `rustc --crate-name {name} src[/]main.rs --crate-type bin -g \ -C debug-assertions \ -C metadata=[..] \ --out-dir [..] \ @@ -151,10 +151,10 @@ fn build_with_args_to_one_of_multiple_binaries() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..]` -[RUNNING] `rustc src[/]bin[/]bar.rs --crate-name bar --crate-type bin -g \ +[RUNNING] `rustc --crate-name bar src[/]bin[/]bar.rs --crate-type bin -g \ -C debug-assertions [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", url = p.url()))); @@ -207,10 +207,10 @@ fn build_with_args_to_one_of_multiple_tests() { .with_status(0) .with_stderr(format!("\ [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc src[/]lib.rs --crate-name foo --crate-type lib -g \ +[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib -g \ -C metadata=[..] \ --out-dir [..]` -[RUNNING] `rustc tests[/]bar.rs --crate-name bar -g \ +[RUNNING] `rustc --crate-name bar tests[/]bar.rs -g \ -C debug-assertions [..]--test[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ", url = p.url()))); diff --git a/tests/test.rs b/tests/test.rs index 8d058dc55c9..6166a1ec651 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -128,7 +128,7 @@ fn cargo_test_verbose() { assert_that(p.cargo_process("test").arg("-v").arg("hello"), execs().with_stderr(format!("\ [COMPILING] foo v0.5.0 ({url}) -[RUNNING] `rustc src[/]foo.rs [..]` +[RUNNING] `rustc [..] src[/]foo.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target[/]debug[/]deps[/]foo-[..][EXE] hello`", url = p.url())) .with_stdout(" @@ -1587,7 +1587,7 @@ fn example_with_dev_dep() { [..] [..] [..] -[RUNNING] `rustc [..] --crate-name ex [..] --extern a=[..]` +[RUNNING] `rustc --crate-name ex [..] --extern a=[..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -2058,8 +2058,8 @@ fn bin_does_not_rebuild_tests() { execs().with_status(0) .with_stderr("\ [COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc src[/]main.rs [..]` -[RUNNING] `rustc src[/]main.rs [..]` +[RUNNING] `rustc [..] src[/]main.rs [..]` +[RUNNING] `rustc [..] src[/]main.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } @@ -2120,8 +2120,8 @@ fn selective_test_optional_dep() { .arg("--features").arg("a").arg("-p").arg("a"), execs().with_status(0).with_stderr("\ [COMPILING] a v0.0.1 ([..]) -[RUNNING] `rustc a[/]src[/]lib.rs [..]` -[RUNNING] `rustc a[/]src[/]lib.rs [..]` +[RUNNING] `rustc [..] a[/]src[/]lib.rs [..]` +[RUNNING] `rustc [..] a[/]src[/]lib.rs [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } From f261b72e3bf8aa43a55b8bc1424e8ab84f337a23 Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Wed, 30 Nov 2016 20:42:44 +0100 Subject: [PATCH 0861/3888] Fixed type breaking some tests. --- tests/run.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.rs b/tests/run.rs index 095f6dc9862..4e666086fad 100644 --- a/tests/run.rs +++ b/tests/run.rs @@ -423,7 +423,7 @@ fn example_with_release_flag() { --emit=dep-info,link \ -L dependency={dir}[/]target[/]release[/]deps` [COMPILING] foo v0.0.1 ({url}) -[RUNNING] `rustc --crate-name a examples[/]a.rs --crate-type bin \ +[RUNNING] `rustc --crate-name a examples[/]a.rs --crate-type bin \ -C opt-level=3 \ -C metadata=[..] \ --out-dir {dir}[/]target[/]release[/]examples \ From 62927ad2df12a76ab60d27ef737332c6d3b1efbb Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Wed, 30 Nov 2016 21:05:23 +0100 Subject: [PATCH 0862/3888] Fixed a few additional tests. --- tests/rustc.rs | 2 +- tests/rustdoc.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/rustc.rs b/tests/rustc.rs index f2c99dd4631..69e16a36a2f 100644 --- a/tests/rustc.rs +++ b/tests/rustc.rs @@ -294,7 +294,7 @@ fn build_only_bar_dependency() { .with_status(0) .with_stderr("\ [COMPILING] bar v0.1.0 ([..]) -[RUNNING] `[..]--crate-name bar --crate-type lib [..] -C debug-assertions [..]` +[RUNNING] `rustc --crate-name bar [..] --crate-type lib [..] -C debug-assertions [..]` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] ")); } diff --git a/tests/rustdoc.rs b/tests/rustdoc.rs index 71f7fc507cd..a70a2f0c931 100644 --- a/tests/rustdoc.rs +++ b/tests/rustdoc.rs @@ -20,7 +20,7 @@ fn rustdoc_simple() { .with_status(0) .with_stderr(format!("\ [DOCUMENTING] foo v0.0.1 ({url}) -[RUNNING] `rustdoc src[/]lib.rs --crate-name foo \ +[RUNNING] `rustdoc --crate-name foo src[/]lib.rs \ -o {dir}[/]target[/]doc \ -L dependency={dir}[/]target[/]debug[/]deps` [FINISHED] debug [unoptimized + debuginfo] target(s) in [..] @@ -43,7 +43,7 @@ fn rustdoc_args() { .with_status(0) .with_stderr(format!("\ [DOCUMENTING] foo v0.0.1 ({url}) -[RUNNING] `rustdoc src[/]lib.rs --crate-name foo \ +[RUNNING] `rustdoc --crate-name foo src[/]lib.rs \ -o {dir}[/]target[/]doc \ --no-defaults \ -L dependency={dir}[/]target[/]debug[/]deps` @@ -88,7 +88,7 @@ fn rustdoc_foo_with_bar_dependency() { [COMPILING] bar v0.0.1 ([..]) [RUNNING] `rustc [..]bar[/]src[/]lib.rs [..]` [DOCUMENTING] foo v0.0.1 ({url}) -[RUNNING] `rustdoc src[/]lib.rs --crate-name foo \ +[RUNNING] `rustdoc --crate-name foo src[/]lib.rs \ -o {dir}[/]target[/]doc \ --no-defaults \ -L dependency={dir}[/]target[/]debug[/]deps \ @@ -133,7 +133,7 @@ fn rustdoc_only_bar_dependency() { .with_status(0) .with_stderr(format!("\ [DOCUMENTING] bar v0.0.1 ([..]) -[RUNNING] `rustdoc [..]bar[/]src[/]lib.rs --crate-name bar \ +[RUNNING] `rustdoc --crate-name bar [..]bar[/]src[/]lib.rs \ -o {dir}[/]target[/]doc \ --no-defaults \ -L dependency={dir}[/]target[/]debug[/]deps` From 4b83d37bc40e2ed46c1cc236291e4aedbeeebaa4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 29 Nov 2016 16:52:20 -0800 Subject: [PATCH 0863/3888] Fix retrying crate downloads for network errors Previously the `with_retry` loop was a little too tight where stale state about the sha256 and data was kept out of the loop. Instead we need to reinitialize these on each iteration of the loop to ensure that we correctly retry by forgetting the data we previously downloaded for an aborted download attempt. --- src/cargo/sources/registry/remote.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cargo/sources/registry/remote.rs b/src/cargo/sources/registry/remote.rs index 480b7185950..2b9b1ca02dd 100644 --- a/src/cargo/sources/registry/remote.rs +++ b/src/cargo/sources/registry/remote.rs @@ -158,17 +158,17 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> { handle.follow_location(true)?; let mut state = Sha256::new(); let mut body = Vec::new(); - { + network::with_retry(self.config, || { + state = Sha256::new(); + body = Vec::new(); let mut handle = handle.transfer(); handle.write_function(|buf| { state.update(buf); body.extend_from_slice(buf); Ok(buf.len()) })?; - network::with_retry(self.config, || { - handle.perform() - })? - } + handle.perform() + })?; let code = handle.response_code()?; if code != 200 && code != 0 { bail!("failed to get 200 response from `{}`, got {}", url, code) From 3ff719d54b4382a52d8e5fa5621b29319a6d035b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 30 Nov 2016 11:12:49 -0800 Subject: [PATCH 0864/3888] Slight tweaks to CI * Pass `--quiet` to all tests to have some quieter output * Skip builds on branches other than `auto-cargo` as it's already checked * Check the right env var for repo branches on appveyor * Only run a few builds on PRs --- .travis.yml | 25 +++++++++++++------------ Makefile.in | 3 ++- appveyor.yml | 20 ++++++++------------ src/ci/docker/run.sh | 3 +++ src/ci/run.sh | 15 ++++++++++++++- 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 961c8488c99..51e50435f8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ os: linux services: - docker +git: + depth: 1 + matrix: include: # stable linux builds, tested @@ -13,6 +16,7 @@ matrix: ALT=i686-unknown-linux-gnu IMAGE=dist MAKE_TARGETS="test distcheck doc install uninstall" + ALLOW_PR=1 - env: TARGET=i686-unknown-linux-gnu IMAGE=dist MAKE_TARGETS=test-unit-i686-unknown-linux-gnu @@ -99,11 +103,15 @@ before_script: sh -s -- --add-target=$ALT --disable-sudo -y --prefix=`rustc --print sysroot`; fi script: - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - SRC=. src/ci/run.sh $TARGET; - else - src/ci/docker/run.sh $IMAGE $TARGET; - fi + - > + if [ "$ALLOW_PR" = "" ] && [ "$TRAVIS_BRANCH" != "auto-cargo" ]; then + echo skipping, not a full build; + elif [ "$TRAVIS_OS_NAME" = "osx" ]; then + SRC=. src/ci/run.sh $TARGET; + else + src/ci/docker/run.sh $IMAGE $TARGET; + fi + after_success: | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && @@ -121,13 +129,6 @@ notifications: email: on_success: never -branches: - only: - - master - - auto-cargo - - beta - - stable - before_deploy: - mkdir -p deploy/$TRAVIS_COMMIT - cp target/$TARGET/release/dist/cargo-*-$TARGET.tar.gz diff --git a/Makefile.in b/Makefile.in index 79d9a52e094..ef02d4547ba 100644 --- a/Makefile.in +++ b/Makefile.in @@ -103,7 +103,8 @@ test-unit-$(1): target/openssl/$(1).stamp cargo-$(1) @mkdir -p $$(CFG_BUILD_DIR)/target/$(1)/cit $$(CARGO) test --target $(1) \ --manifest-path $(S)Cargo.toml \ - $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) + $$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) -- \ + --quiet endef $(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target)))) diff --git a/appveyor.yml b/appveyor.yml index 905b35b9c32..cfc59f75d0b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,12 +1,10 @@ environment: matrix: - TARGET: x86_64-pc-windows-gnu - ARCH: amd64 BITS: 64 CFG_DISABLE_CROSS_TESTS: 1 MAKE_TARGETS: test-unit-x86_64-pc-windows-gnu - TARGET: i686-pc-windows-gnu - ARCH: x86 BITS: 32 MINGW_URL: https://s3.amazonaws.com/rust-lang-ci MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z @@ -15,13 +13,12 @@ environment: MAKE_TARGETS: test-unit-i686-pc-windows-gnu - TARGET: i686-pc-windows-msvc BITS: 32 - ARCH: x86 MAKE_TARGETS: test-unit-i686-pc-windows-msvc CFG_DISABLE_CROSS_TESTS: 1 + ALLOW_PR: 1 - TARGET: x86_64-pc-windows-msvc OTHER_TARGET: i686-pc-windows-msvc BITS: 64 - ARCH: amd64 MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc install: @@ -38,6 +35,8 @@ install: - cargo -V - git submodule update --init +clone_depth: 1 + build: false test_script: @@ -48,16 +47,13 @@ cache: - C:\Users\appveyor\.cargo\registry after_test: - - mkdir %APPVEYOR_REPO_COMMIT% + - ps: New-Item -Path "${env:APPVEYOR_REPO_COMMIT}" -ItemType "directory" + - ps: New-Item -Path "target" -ItemType "directory" -Force + - ps: New-Item -Path "target/${env:TARGET}" -ItemType "directory" -Force + - ps: New-Item -Path "target/${env:TARGET}/release" -ItemType "directory" -Force + - ps: New-Item -Path "target/${env:TARGET}/release/dist" -ItemType "directory" -Force - ps: Get-ChildItem -Path target\${env:TARGET}\release\dist -Filter '*.tar.gz' | Move-Item -Destination ${env:APPVEYOR_REPO_COMMIT} -branches: - only: - - master - - auto-cargo - - beta - - stable - artifacts: - path: $(APPVEYOR_REPO_COMMIT)\cargo-*-$(TARGET).tar.gz name: cargo diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index 1a0bb0c21c7..f0546972be6 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -37,6 +37,9 @@ exec docker run \ --env SRC=/checkout \ --env CARGO_HOME=/cargo \ --env TRAVIS_BRANCH=$TRAVIS_BRANCH \ + --env TRAVIS_PULL_REQUEST_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH \ + --env ALLOW_PR=$ALLOW_PR \ + --env CI=$CI \ --volume "$HOME/.cargo:/cargo" \ --volume `rustc --print sysroot`:/rust:ro \ --volume `pwd`/target:/tmp/target \ diff --git a/src/ci/run.sh b/src/ci/run.sh index a532757d9f3..1f20a7652d9 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -19,7 +19,7 @@ fi BRANCH=$TRAVIS_BRANCH if [ "$BRANCH" = "" ]; then - BRANCH=$APPVEYOR_BRANCH + BRANCH=$APPVEYOR_REPO_BRANCH fi if [ "$BRANCH" = "stable" ]; then @@ -34,6 +34,19 @@ else CHANNEL=dev fi +# We want to only run tests in a few situations: +# +# * All tests on the auto-cargo branch +# * One test on PRs +# * Any tests done locally +# +# This means that here if we're on CI, then we skip tests if it's not the right +# branch or if we're not configured to run a test on PRs +if [ -n "$CI" ] && [ "$BRANCH" != "auto-cargo" ] && [ "$ALLOW_PR" = "" ]; then + echo no build necessary, skipping + exit 0 +fi + $SRC/configure \ --prefix=/tmp/obj/install \ --target=$TARGET \ From a966246d859695e0013c325f0dc0273558ae523e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Dec 2016 09:18:47 -0800 Subject: [PATCH 0865/3888] Delete old snapshot infrastructure No longer used --- .travis.install.deps.sh | 5 - src/etc/dl-snapshot.py | 97 --------------- src/etc/download.py | 58 --------- src/etc/install-deps.py | 93 -------------- src/etc/print-new-snapshot.py | 31 ----- src/rustversion.txt | 1 - src/snapshots.txt | 220 ---------------------------------- 7 files changed, 505 deletions(-) delete mode 100755 .travis.install.deps.sh delete mode 100644 src/etc/dl-snapshot.py delete mode 100644 src/etc/download.py delete mode 100644 src/etc/install-deps.py delete mode 100644 src/etc/print-new-snapshot.py delete mode 100644 src/rustversion.txt delete mode 100644 src/snapshots.txt diff --git a/.travis.install.deps.sh b/.travis.install.deps.sh deleted file mode 100755 index 387cf1dd0cf..00000000000 --- a/.travis.install.deps.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -set -ex - -python src/etc/install-deps.py diff --git a/src/etc/dl-snapshot.py b/src/etc/dl-snapshot.py deleted file mode 100644 index c44ed312767..00000000000 --- a/src/etc/dl-snapshot.py +++ /dev/null @@ -1,97 +0,0 @@ -import download -import hashlib -import os -import re -import shutil -import sys - -datere = re.compile('^\d{4}-\d{2}-\d{2}') -cksumre = re.compile('^ ([^ ]+) ([^$]+)$') - -current = None -snaps = {} -d = os.path.dirname(os.path.dirname(__file__)) -with open(d + '/snapshots.txt') as f: - for line in iter(f): - line = line.rstrip() - m = datere.match(line) - if m: - current = m.group() - snaps[current] = {} - continue - - m = cksumre.match(line) - if m: - snaps[current][m.group(1)] = m.group(2) - continue - - # This script currently doesn't look at older snapshots, so there is - # no need to look past the first section. - break - -date = current -triple = sys.argv[1] - -ts = triple.split('-') -arch = ts[0] - -if (arch == 'i586') or (arch == 'i386'): - arch = 'i686' - -if len(ts) == 2: - vendor = 'unknown' - target_os = ts[1] -else: - vendor = ts[1] - target_os = ts[2] - -# NB: The platform format differs from the triple format, to support -# bootstrapping multiple triples from the same snapshot. -plat_arch = arch if (arch != 'i686') else 'i386' -plat_os = target_os -if (target_os == 'windows'): - plat_os = 'winnt' -elif (target_os == 'darwin'): - plat_os = 'macos' -platform = "%s-%s" % (plat_os, plat_arch) -if platform not in snaps[date]: - raise Exception("no snapshot for the triple '%s'" % triple) - -# Reconstitute triple with any applicable changes. For historical reasons -# this differs from the snapshots.txt platform name. -if target_os == 'linux': - target_os = 'linux-gnu' -elif target_os == 'darwin': - vendor = 'apple' -elif target_os == 'windows': - vendor = 'pc' - target_os = 'windows-gnu' -triple = "%s-%s-%s" % (arch, vendor, target_os) -hash = snaps[date][platform] - -tarball = 'cargo-nightly-' + triple + '.tar.gz' -url = 'https://static.rust-lang.org/cargo-dist/%s/%s' % \ - (date.strip(), tarball) -dl_path = "target/dl/" + tarball -dst = "target/snapshot" - -if not os.path.isdir('target/dl'): - os.makedirs('target/dl') - -if os.path.isdir(dst): - shutil.rmtree(dst) - -exists = False -if os.path.exists(dl_path): - h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest() - if h == hash: - print("file already present %s (%s)" % (dl_path, hash,)) - exists = True - -if not exists: - download.get(url, dl_path) - h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest() - if h != hash: - raise Exception("failed to verify the checksum of the snapshot") - -download.unpack(dl_path, dst, strip=2) diff --git a/src/etc/download.py b/src/etc/download.py deleted file mode 100644 index 5ef0df34e0b..00000000000 --- a/src/etc/download.py +++ /dev/null @@ -1,58 +0,0 @@ -import contextlib -import os -import subprocess -import sys -import tarfile - - -def get(url, path, quiet=False): - # see http://serverfault.com/questions/301128/how-to-download - if sys.platform == 'win32': - run(["PowerShell.exe", "/nologo", "-Command", - "(New-Object System.Net.WebClient).DownloadFile('" + url + - "', '" + path + "')"], quiet=quiet) - else: - run(["curl", "-o", path, url], quiet=quiet) - - -def unpack(tarball, dst, quiet=False, strip=0): - if quiet: - print("extracting " + tarball) - with contextlib.closing(tarfile.open(tarball)) as tar: - for p in tar.getmembers(): - if p.isdir(): - continue - path = [] - p2 = p.name - while p2 != "": - a, b = os.path.split(p2) - path.insert(0, b) - p2 = a - if len(path) <= strip: - continue - fp = os.path.join(dst, *path[strip:]) - if not quiet: - print("extracting " + p.name) - contents = tar.extractfile(p) - if not os.path.exists(os.path.dirname(fp)): - os.makedirs(os.path.dirname(fp)) - open(fp, 'wb').write(contents.read()) - os.chmod(fp, p.mode) - - -def run(args, quiet=False): - if not quiet: - print("running: " + ' '.join(args)) - sys.stdout.flush() - # Use Popen here instead of call() as it apparently allows powershell on - # Windows to not lock up waiting for input presumably. - ret = subprocess.Popen(args, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - out, err = ret.communicate() - code = ret.wait() - if code != 0: - print("stdout: \n\n" + out) - print("stderr: \n\n" + err) - raise Exception("failed to fetch url") diff --git a/src/etc/install-deps.py b/src/etc/install-deps.py deleted file mode 100644 index 5f4b650c9f2..00000000000 --- a/src/etc/install-deps.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python - -import download -import os -import shutil -import sys - -if os.environ.get('BITS') == '32': - host_bits = 'i686' - extra_bits = 'x86_64' -else: - host_bits = 'x86_64' - extra_bits = 'i686' - - -# Figure out our target triple -if sys.platform == 'linux' or sys.platform == 'linux2': - host = host_bits + '-unknown-linux-gnu' - targets = [ - 'aarch64-unknown-linux-gnu', - 'arm-unknown-linux-gnueabi', - 'arm-unknown-linux-gnueabihf', - 'armv7-unknown-linux-gnueabihf', - 'i686-unknown-freebsd', - 'i686-unknown-linux-gnu', - 'mips-unknown-linux-gnu', - 'mipsel-unknown-linux-gnu', - 'mips64-unknown-linux-gnuabi64', - 'mips64el-unknown-linux-gnuabi64', - 's390x-unknown-linux-gnu', - 'powerpc-unknown-linux-gnu', - 'powerpc64-unknown-linux-gnu', - 'powerpc64le-unknown-linux-gnu', - 'x86_64-unknown-freebsd', - 'x86_64-unknown-linux-gnu', - 'x86_64-unknown-linux-musl', - 'x86_64-unknown-netbsd', - ] -elif sys.platform == 'darwin': - host = host_bits + '-apple-darwin' - targets = ['i686-apple-darwin', 'x86_64-apple-darwin'] -elif sys.platform == 'win32': - if os.environ.get('MSVC') == '1': - host = host_bits + '-pc-windows-msvc' - targets = [ - 'i686-pc-windows-msvc', - 'x86_64-pc-windows-msvc', - ] - else: - host = host_bits + '-pc-windows-gnu' - targets = [host] -else: - exit_msg = "There is no official Cargo snapshot for {} platform, sorry." - sys.exit(exit_msg.format(sys.platform)) - -rust_date = open('src/rustversion.txt').read().strip() -url = 'https://static.rust-lang.org/dist/' + rust_date -cargo_url = 'https://static.rust-lang.org/cargo-dist/2016-03-21' - - -def install_via_tarballs(): - if os.path.isdir("rustc-install"): - shutil.rmtree("rustc-install") - - # Download cargo - host_fname = 'cargo-nightly-' + host + '.tar.gz' - download.get(cargo_url + '/' + host_fname, host_fname) - download.unpack(host_fname, "rustc-install", quiet=True, strip=2) - os.remove(host_fname) - - # Download the compiler - host_fname = 'rustc-nightly-' + host + '.tar.gz' - download.get(url + '/' + host_fname, host_fname) - download.unpack(host_fname, "rustc-install", quiet=True, strip=2) - os.remove(host_fname) - - # Download all target libraries needed - for target in targets: - fetch_std(target) - - if os.path.isdir("rustc"): - shutil.rmtree("rustc") - os.rename("rustc-install", "rustc") - - -def fetch_std(target): - fname = 'rust-std-nightly-' + target + '.tar.gz' - print("adding target libs for " + target) - download.get(url + '/' + fname, fname) - download.unpack(fname, "rustc-install", quiet=True, strip=2) - os.remove(fname) - -install_via_tarballs() diff --git a/src/etc/print-new-snapshot.py b/src/etc/print-new-snapshot.py deleted file mode 100644 index ecfbda0337c..00000000000 --- a/src/etc/print-new-snapshot.py +++ /dev/null @@ -1,31 +0,0 @@ -# When updating snapshots, run this file and pipe it into `src/snapshots.txt` -import os -import sys -import hashlib -import download - -date = sys.argv[1] - -print(date) - -if not os.path.isdir('target/dl'): - os.makedirs('target/dl') - -snaps = { - 'macos-i386': 'i686-apple-darwin', - 'macos-x86_64': 'x86_64-apple-darwin', - 'linux-i386': 'i686-unknown-linux-gnu', - 'linux-x86_64': 'x86_64-unknown-linux-gnu', - 'winnt-i386': 'i686-pc-windows-gnu', - 'winnt-x86_64': 'x86_64-pc-windows-gnu', - 'bitrig-x86_64': 'x86_64-unknown-bitrig', -} - -for platform in sorted(snaps): - triple = snaps[platform] - tarball = 'cargo-nightly-' + triple + '.tar.gz' - url = 'https://static.rust-lang.org/cargo-dist/' + date + '/' + tarball - dl_path = "target/dl/" + tarball - download.get(url, dl_path, quiet=True) - h = hashlib.sha1(open(dl_path, 'rb').read()).hexdigest() - print(' ' + platform + ' ' + h) diff --git a/src/rustversion.txt b/src/rustversion.txt deleted file mode 100644 index 891320872cb..00000000000 --- a/src/rustversion.txt +++ /dev/null @@ -1 +0,0 @@ -2016-11-16 diff --git a/src/snapshots.txt b/src/snapshots.txt deleted file mode 100644 index 30ec19c5805..00000000000 --- a/src/snapshots.txt +++ /dev/null @@ -1,220 +0,0 @@ -2016-03-21 - linux-i386 ac401c16ff53e0c51b88707579b4f95d7d4c4763 - linux-x86_64 84266cf626ca4fcdc290bca8f1a74e6ad9e8b3d9 - macos-i386 3550c653db2b8a41fdd7057339c923353081e7b0 - macos-x86_64 0372d52f6d06e3e18c8ffa6f016638b6d082770e - winnt-i386 4bacbd3e0219f424740ce35e74a005b007a552aa - winnt-x86_64 8fc67036c4c76fbfa1d8532d9b9ac923f9060001 - -2016-01-31 - linux-i386 7e2f9c82e1af5aa43ef3ee2692b985a5f2398f0a - linux-x86_64 4c03a3fd2474133c7ad6d8bb5f6af9915ca5292a - macos-i386 4d84d31449a5926f9e7ceb344540d6e5ea530b88 - macos-x86_64 f8baef5b0b3e6f9825be1f1709594695ac0f0abc - winnt-i386 8702f7e3c49ef4a4eb9ffed2f1ca94ac288e48ff - winnt-x86_64 a531f9a7399cdcc6aa14a0f070df4ff3851772fa - -2015-04-02 - dragonfly-x86_64 7d330a67ad82701ee65a08a47a51c3b0b26697bc - freebsd-x86_64 2e0ade0901864ea67200f990cb289343b08959e7 - bitrig-x86_64 1b39aba2b9e1a7c9b5ac890b864eb1cb8a18e4d0 - openbsd-x86_64 1e2a02520f9e8e300a3d7ef91c1ab03e6baeebe6 - linux-i386 ba6c162680d5509d89ba2363d7cae2047f40c034 - linux-x86_64 94f715c9a52809a639f2ce6f8b1d5215a0c272b5 - macos-i386 cf333f16f89bfd50e8ce461c6f81ca30d33f7f73 - macos-x86_64 1f7008a6ec860e2bc7580e71bdf320ac518ddeb8 - winnt-i386 8c0088ae9e47133b976f7ad155c50ca9abb2906c - winnt-x86_64 01ae9ea568211a20f048e7b00d902d6fe72d1627 - -2015-03-26 - linux-i386 d8b59fb0a0e8222b1753370f1d7c91dcb9697b37 - linux-x86_64 e2f8388d6bccad3b3f09bbbe4ea1bc9671224f4c - macos-i386 3baad9c920c4a68bfd8c10ba3afb80013559adf5 - macos-x86_64 394afa61b945717bca18412c3c93a428db7d6d5d - winnt-i386 4bc98dabc039c34c040942f0eadd99ddb37f06dc - winnt-x86_64 54d948ed95b86b9c63861246cf7cfd7161a48a20 - -2015-03-17 - linux-i386 96a64fa9b4b6cc0cddaa90ecde4e08254c9025d5 - linux-x86_64 354bb5b11b1f19e270ebc0553db1ddc560999bdb - macos-i386 d1b69ef765bc450a3758b8abdb0909df7893058b - macos-x86_64 a2328a82e073c230cd88dcfac96bdc784a999200 - winnt-i386 fb6e346d59bda47ed87e36800e8bfe210cf01297 - winnt-x86_64 4ef3d1ce315df8b27bd842fb66b8e2b03ce99a08 - -2015-02-26 - linux-i386 2a28b604d09b4a76a54a05d91f7f158692427b3a - linux-x86_64 7367f4aca86d38e209ef7236b00175df036c03e2 - macos-i386 e5cabb0a4a2b4e47f7b1ae9b802e2b5d0b14eac5 - macos-x86_64 3026c60ddd46d2bcf1cb178fc801095dbfba5286 - winnt-i386 2008eed3965ed9a989a38c22b9c55c02ae9db1f1 - winnt-x86_64 98a48d7a6dbffcd099ea2574a68f04883624d9a1 - -2015-01-24 - linux-i386 96213038f850569f1c4fa6a0d146c6155c0d566b - linux-x86_64 4d87486493c2881edced7b1d2f8beaac32aaa5b5 - macos-i386 17b9fc782e86bffe170abb83a01e0cb7c90a0daa - macos-x86_64 18887bdbd3e6d2a127aa34216fa06e9877b0fbc6 - winnt-i386 10b9b5fa3e9241ef0b6c3b77b0c072a45b585905 - winnt-x86_64 ba71627e46964535b64da56bd0679e5f86fae957 - -2014-12-30 - linux-i386 ab8bba0918d3d2ddbd7fd21f147e223dbf04cece - linux-x86_64 0efe0f7bcbcbeb5494affcc8a2207db448a08c45 - macos-i386 e5097005b0a27c186b8edee24982fd4c3ebba81e - macos-x86_64 6c0bb776e5645fb93b67341b111c715f39b25511 - winnt-i386 2088c5256445b5bb2da57a71f6a9671e5a280477 - winnt-x86_64 950e25bcedc5ba9d96891523c9967f81d5f6c74d - -2014-12-21 - linux-i386 4dea04e278192c5409f43794a98f20a8f59df2d9 - linux-x86_64 3e48c573d3c4d26591feb7bfe988174720f08374 - macos-i386 dc3d498c0567af4a0820e91756dcfff8fde0efac - macos-x86_64 f301bd8c3c93a5c88698c69190e464af1525ac96 - winnt-i386 5b6bc87e302d1ff6ac9b0576292eb7cbff2c3b83 - winnt-x86_64 a8bb8d3a7ed3fc8caf4a33d6b9d2e43544877409 - -2014-12-20 - linux-i386 1cccab5a6ac8e73472bf78cdce019cd1a60d4638 - linux-x86_64 53c176fcda0a40fb77b901303c443de3dce3e58d - macos-i386 bbc23c78ca4307efa6250552a097e6b2ccfe2cc3 - macos-x86_64 4f97a30408c99858ad2b7a7f6edfe3d5b8f0ff3f - winnt-i386 5d77cd604b011100398023e8dc3d98c173247874 - winnt-x86_64 1290dcc2a51e99027803d641c08299abe1265158 - -2014-12-18 - linux-i386 30eec547395093ab9c6a0587a3210666b9272815 - linux-x86_64 20d13252996838680f4356a7addd75403bb11aec - macos-i386 c179a345cb1fbb08f8173133701635ef3c0e03be - macos-x86_64 4f2a877828a2d8ca7d66906529bde01b26d8cef7 - winnt-i386 fa20b54e06badc5fb092981d442e4e831dd9c5f8 - winnt-x86_64 196cae1120f5070e7dd4796d19ed45b9dd01aba2 - -2014-12-08 - linux-i386 853d29bc167748f8a481d5d43fb20ab99e3e16ee - linux-x86_64 57c79c64459145321baa8fc45d51c588d18125ad - macos-i386 43b483c9a389243ce58ba5356c4f71a626dc5658 - macos-x86_64 3777768da6a820f49d789c3477b493b24de59a61 - winnt-i386 b831d1d673db189496f94d3596351d9545687947 - winnt-x86_64 846b677e6fec99690b00595b934fdb30b834c815 - -2014-11-22 - linux-i386 3204c8a38721199f69d2971db887d1dc71a63825 - linux-x86_64 39ca0d02eac184bc764ff9c1f645ca361715c5c2 - macos-i386 ebc1836424c4b3ba49f9adef271c50d2a8e134c0 - macos-x86_64 a2045e95984b65eab4a704152566f8ab9a3be518 - winnt-i386 5e0831b14d2e6ee91ef195dfbc4d9699499d5e99 - winnt-x86_64 d5fa1b58207346061898459955fa7f0b33d77474 - -2014-11-11 - linux-i386 5cbf3346309d303cb954c363097fc4abedf50610 - linux-x86_64 8c1594e227eca6f23ba02daa5f3cd6150ac88907 - macos-i386 f338835a58cc5357ed092a23ba0ddbf2624dfacd - macos-x86_64 b2d03a6a9422c42b7f5ba008c8851ddc89ae693c - winnt-i386 50b851d94181375f0c7a00aacb7d8d63960eddc7 - winnt-x86_64 aa12a1cb80a665f53066a15774360d686b3e5968 - -2014-11-07 - linux-i386 f65ae2b9d94477fec79e444ea489ff98a456e033 - linux-x86_64 1a7f663d8f4e2109240a20d8e63c958e0557d883 - macos-i386 9d82a00bd396c99cc27693864da2364d0394e843 - macos-x86_64 1dc297d8e149384a76dfb7efc7869b82fe663b92 - winnt-i386 d9f87d83c6cbabd7a4794498e4c3a4e94df0740a - winnt-x86_64 74284401082e1b5aff14a72e2152ed5cb55812cf - -2014-10-28 - linux-i386 15fb3dd24140911ba707d8b4b1dd6826732a3ad6 - linux-x86_64 a924d82f5dc987efda6303d3e2c1aeb8ade34faa - macos-i386 bfaddd7eacd1dec4749ab4918fad47f50fa64467 - macos-x86_64 43a91c484f665be2ec0959e2e884ab93cce06a6b - winnt-i386 299de1d99341fed17dc2726e5564dd0ab0ca1dfa - winnt-x86_64 1948ae424458c498f904ea97efb00350a7d8598f - -2014-10-16 - linux-i386 61417861716cd41d8f372be36bb0572e4f29dec8 - linux-x86_64 59be4ff9f547f1ba47ad133ab74151a48bc2659b - macos-i386 cb5267d2e7df8406c26bb0337b1c2e80b125e2cb - macos-x86_64 9283adb4dfd1b60c7bfe38ef755f9187fe7d5580 - winnt-i386 88deb2950fa2b73358bc15763e6373ade6325f53 - winnt-x86_64 0143d4b0e4b20e84dbb27a4440b4b55d369f4456 - -2014-09-19 - linux-i386 c92895421e6fa170dbd713e74334b8c3cf22b817 - linux-x86_64 66ee4126f9e4820cd82e78181931f8ea365904de - macos-i386 e2364b1f1ece338b9fc4c308c472fc2413bff04e - macos-x86_64 09f92f06ab4f048acf71d83dc0426ff1509779a9 - winnt-i386 0c9b75d5b9ca58a7e39290fbe9c54d91db65c42c - winnt-x86_64 180c547aa79ba3069852450a6e833b577c7d4c3d - -2014-09-11 - linux-i386 f18823de75413ab72df91deb9b3b341c02005b2e - linux-x86_64 58d9789472dd955be94903cafd406ce394915297 - macos-i386 07da45add611e7ecea8f9115ee551df1ff354f51 - macos-x86_64 0b82c9c58865fe8298273ee5fafc937db1b80528 - winnt-i386 4782a7014dd53213535f19b1f2a09f640cf00490 - -2014-09-03 - linux-i386 d357756680a60cd00464fa991b71170dcddb2b30 - linux-x86_64 35fd121fda3509cc020d42223017be03a1c19b87 - macos-i386 40aad83e9d97f5a344179f4573807f3ac04775f9 - macos-x86_64 5e64f637019f499585ab100e5072b8eeeba191ed - winnt-i386 fc25a2f6f9ce3a6f11348ffe17e1115ca81fc4db - -2014-08-19 - linux-i386 8d20fc36b8b7339fcd1ae6c118f1becd001c2b08 - linux-x86_64 46e05521f0dceeb831462caa8a54ca1caf21c078 - macos-i386 fd65cf0e9c6fa137db666da289aa4359dbc56ca1 - macos-x86_64 59ba26a9c92af40c08eed443dcfca518718a2ba1 - winnt-i386 cb0c4fa54abebb86d1a4bb28c2b1d084234c3b35 - -2014-08-16 - linux-i386 30ea09ef95aa230ff415319be699c950603a8fb4 - linux-x86_64 95badae811c711ae5d03f837a38f6ae12c8e473a - macos-i386 5b7afe93a4a79416bab0778e7e03a786cf2e9252 - macos-x86_64 e4141beae6e3dae44393d148492ec9ac1ac1ae5c - winnt-i386 580cb0e92ddb1e2f935386183543c3d0152f13b9 - -2014-08-12 - linux-i386 af5e80dba2d845e30039302e57bd516c96b347de - linux-x86_64 42a7786073802d6b47dbb6d2bb071a322964b28e - macos-i386 244595a91534ce3097877d96241ae21d150e670d - macos-x86_64 8c56578bd4610adcc1b608aa841c13f6f9b60d45 - winnt-i386 4708fba1f267c1c32460c7d8b4cd2ed8c32a1ecb - -2014-08-08 - linux-i386 44207002e96c4f1309af70673966ee1e67938f5e - linux-x86_64 5dc5e5aa575814af2d4e40e9dcdca2c55b594bd1 - macos-i386 5d1924057a0d56d033f32680f4b393cdd9c6805a - macos-x86_64 65462ea1e48cb4b4c57ff7e947cd2cc26a8f2723 - winnt-i386 a481b15d35ab2e1d1dcd2f181a2566e097604ffc - -2014-08-06 - linux-i386 eb7c2a87b30db077f6f1c4ea724ebd0e5cc07d1c - linux-x86_64 1672657adb9012df2912bbb2f43466f1c6817e55 - macos-i386 1224207bbfa9f46796940512ac8a7a9ab9f5665b - macos-x86_64 da4afea32d7336a0a91b8fe160d38896385d4ae2 - winnt-i386 2b6b2efe9ec77d3d456c943bb2e54f2281309ef1 - -2014-08-04 - linux-i386 49032ce8c5c2b94d73e298dcbdb09e0b2fbe573c - linux-x86_64 98c83ecc7cac3765d62f5e8b19bdc506e01f3cab - macos-i386 c450260a2edace970089b35fed644eb607b509ba - macos-x86_64 04763ba59b70240d16bdb57845e3511b3b243522 - winnt-i386 15a70b068beb3b85760279496cf62b7406e5e2b2 - -2014-07-30 - linux-i386 4d4e78426060b891cf729d5e3cca86d5aebdd31d - linux-x86_64 2a39bb838bc1c740d41a2ee8054a2c32f1efbec8 - macos-i386 16d1581dad71b1cf551646bc2dfdc920f4dda16c - macos-x86_64 05d836f2195e55f050e68e8bb209405a67fbefcb - winnt-i386 ade95f921ba73848d2ae67d1b8cd7c364e881e86 - -2014-07-29 - mac 53f8bc39132e987d25e022698c3234fee0916ecf - linux b7dbdc89126577fda2eef7d63c5f7fc1d8d28f99 - win 9551454e2ce649d146ad8d856cee3672ab0def02 - -2014-07-26 - mac 9a78815c7fcdb1cdabc93eb120f80444f209d968 - linux b38e7c45292d2cc6a1932fa9a1f349f9b92c0c1d - win 4e955f8b80684ea6c9ca2dd6e2c235ce2d9cf21f From 5cdbb4c15ac9de14ae69b55401bb213eda6f76ed Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 1 Dec 2016 10:23:48 -0800 Subject: [PATCH 0866/3888] Upload to a different bucket --- .travis.yml | 6 +++--- appveyor.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51e50435f8b..1b23028dec7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -136,12 +136,12 @@ before_deploy: deploy: - provider: s3 - bucket: rust-lang-cargo-dev + bucket: rust-lang-ci skip_cleanup: true local_dir: deploy - upload_dir: cargo-master + upload_dir: cargo-builds acl: public_read - region: us-west-1 + region: us-east-1 access_key_id: AKIAIWZDM2B2IJOWBGTA secret_access_key: secure: NB9b/MhIDiv8OtNiN/sHaFgA3xG2fa7MGuQQKJNj80ktvgByzDm5UPNyNeoYx9SmJ3jOWobgcPVaoUd2S+6XgO3bMBqm7sM/oMeE0KdqToh6+V2bKfyRF2U5fm697LEGepPIBYqMLDg4nr/dbknbKltzp6dAfJRyy22Nb721zPQ= diff --git a/appveyor.yml b/appveyor.yml index cfc59f75d0b..ee076135bc7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -64,10 +64,10 @@ deploy: access_key_id: AKIAIWZDM2B2IJOWBGTA secret_access_key: secure: hyH54di5NyNdV+jjntM1dRN/NeUgDidwZmwcg4/UKpdJqGf1AAwYb2ulXYK67CXA - bucket: rust-lang-cargo-dev + bucket: rust-lang-ci set_public: true - region: us-west-1 + region: us-east-1 artifact: cargo - folder: cargo-master + folder: cargo-builds on: branch: auto-cargo From 7957019f6f7059b1472a803584213009982a04ab Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Thu, 1 Dec 2016 19:57:05 +0100 Subject: [PATCH 0867/3888] Implemented string lookup for `build.rustflags` config key --- src/cargo/ops/cargo_rustc/context.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index d95b7ee75c6..6be2bef024d 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -866,6 +866,8 @@ fn env_args(config: &Config, if let Some(args) = config.get_list(&key)? { let args = args.val.into_iter().map(|a| a.0); return Ok(args.collect()); + } else if let Some(arg) = config.get_string(&key)? { + return Ok(arg.val.split(' ').map(str::to_string).collect()); } Ok(Vec::new()) From c30475da0c8461e90f98be24c45c298789e1fbaa Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 1 Dec 2016 21:59:03 +0200 Subject: [PATCH 0868/3888] doc: remove reference to non-existent function --- src/bin/cargo.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 05c88019b55..56a03a01011 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -291,8 +291,7 @@ fn execute_subcommand(config: &Config, } } -/// List all runnable commands. find_command should always succeed -/// if given one of returned command. +/// List all runnable commands fn list_commands(config: &Config) -> BTreeSet { let prefix = "cargo-"; let suffix = env::consts::EXE_SUFFIX; From bd5741525902a1da813388cf1183dc9a1d39b1b2 Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Fri, 2 Dec 2016 00:03:49 +0100 Subject: [PATCH 0869/3888] Improved error handling to reflect the actual situation, added tests * One of the tests still doesn't pass, this needs further investigation --- src/cargo/ops/cargo_rustc/context.rs | 24 +++++++- tests/rustflags.rs | 86 ++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 6be2bef024d..2ec275e71b3 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -856,19 +856,37 @@ fn env_args(config: &Config, // Then the target.*.rustflags value let target = build_config.requested_target.as_ref().unwrap_or(&build_config.host_triple); let key = format!("target.{}.{}", target, name); - if let Some(args) = config.get_list(&key)? { + let list = config.get_list(&key); + if let Ok(Some(args)) = list { let args = args.val.into_iter().map(|a| a.0); return Ok(args.collect()); } + let string = config.get_string(&key); + if let Ok(Some(arg)) = string { + return Ok(arg.val.split(' ').map(str::to_string).collect()); + } + if list.is_err() && string.is_err() { + if let Some(value) = config.values()?.get(&key) { + return config.expected("list or string", &key, value.clone()); + } + } // Then the build.rustflags value let key = format!("build.{}", name); - if let Some(args) = config.get_list(&key)? { + let list = config.get_list(&key); + if let Ok(Some(args)) = list { let args = args.val.into_iter().map(|a| a.0); return Ok(args.collect()); - } else if let Some(arg) = config.get_string(&key)? { + } + let string = config.get_string(&key); + if let Ok(Some(arg)) = string { return Ok(arg.val.split(' ').map(str::to_string).collect()); } + if list.is_err() && string.is_err() { + if let Some(value) = config.values()?.get(&key) { + return config.expected("list or string", &key, value.clone()); + } + } Ok(Vec::new()) } diff --git a/tests/rustflags.rs b/tests/rustflags.rs index cc9266ac281..1cf9e96cd14 100644 --- a/tests/rustflags.rs +++ b/tests/rustflags.rs @@ -949,3 +949,89 @@ fn target_rustflags_precedence() { assert_that(p.cargo("bench"), execs().with_status(101)); } + +#[test] +fn target_rustflags_string_and_array_form1() { + let p1 = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + "#) + .file("src/lib.rs", "") + .file(".cargo/config", r#" + [build] + rustflags = ["--cfg", "foo"] + "#); + p1.build(); + + assert_that(p1.cargo("build").arg("-v"), + execs().with_status(0).with_stderr("\ +[COMPILING] foo v0.0.1 ([..]) +[RUNNING] `rustc [..] --cfg foo[..]` +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + + let p2 = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + "#) + .file("src/lib.rs", "") + .file(".cargo/config", r#" + [build] + rustflags = "--cfg foo" + "#); + p2.build(); + + assert_that(p2.cargo("build").arg("-v"), + execs().with_status(0).with_stderr("\ +[COMPILING] foo v0.0.1 ([..]) +[RUNNING] `rustc [..] --cfg foo[..]` +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + +} + +#[test] +fn target_rustflags_string_and_array_form2() { + let p1 = project("foo") + .file("Cargo.toml", &format!(r#" + [package] + name = "foo" + version = "0.0.1" + + [target.{}] + rustflags = ["--cfg", "foo"] + "#, rustc_host())) + .file("src/lib.rs", ""); + p1.build(); + + assert_that(p1.cargo("build").arg("-v"), + execs().with_status(0).with_stderr("\ +[COMPILING] foo v0.0.1 ([..]) +[RUNNING] `rustc [..] --cfg foo[..]` +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + + let p2 = project("foo") + .file("Cargo.toml", &format!(r#" + [package] + name = "foo" + version = "0.0.1" + + [target.{}] + rustflags = "--cfg foo" + "#, rustc_host())) + .file("src/lib.rs", ""); + p2.build(); + + assert_that(p2.cargo("build").arg("-v"), + execs().with_status(0).with_stderr("\ +[COMPILING] foo v0.0.1 ([..]) +[RUNNING] `rustc [..] --cfg foo[..]` +[FINISHED] debug [unoptimized + debuginfo] target(s) in [..] +")); + +} From 01d03cef1e727782397034be5ff063bb1d96be94 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 1 Dec 2016 22:08:59 +0200 Subject: [PATCH 0870/3888] doc: fix code formatting --- src/cargo/util/network.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cargo/util/network.rs b/src/cargo/util/network.rs index 4bc12b7b4e6..e5f22a1c388 100644 --- a/src/cargo/util/network.rs +++ b/src/cargo/util/network.rs @@ -2,14 +2,17 @@ use util::{CargoResult, Config, errors}; /// Wrapper method for network call retry logic. /// -/// Retry counts provided by Config object 'net.retry'. Config shell outputs +/// Retry counts provided by Config object `net.retry`. Config shell outputs /// a warning on per retry. /// /// Closure must return a CargoResult. /// -/// Example: +/// # Examples +/// +/// ```ignore /// use util::network; /// cargo_result = network.with_retry(&config, || something.download()); +/// ``` pub fn with_retry(config: &Config, mut callback: F) -> CargoResult where F: FnMut() -> Result, E: errors::NetworkError From ee0eaf8ecfacd3eabd063a2eca604a45b7662865 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 28 Nov 2016 07:27:14 -0800 Subject: [PATCH 0871/3888] Add host dependency path via -L for cross compiles Now that proc-macro crates can reexport from their dependencies we need to be able to find the other crates, so ensure that we pass an appropriate -L flag. Closes #3334 --- src/cargo/ops/cargo_rustc/context.rs | 4 ++++ src/cargo/ops/cargo_rustc/mod.rs | 10 ++++++++++ tests/cross-compile.rs | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index c0a92d643ec..74ba9b60037 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -314,6 +314,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> { self.layout(unit.kind).build().join(dir).join("out") } + pub fn host_deps(&self) -> &Path { + self.host.deps() + } + /// Returns the appropriate output directory for the specified package and /// target. pub fn out_dir(&mut self, unit: &Unit) -> PathBuf { diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 561949b7123..e54f539f392 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -648,6 +648,16 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &mut Context, unit: &Unit) deps }); + // Be sure that the host path is also listed. This'll ensure that proc-macro + // dependencies are correctly found (for reexported macros). + if let Kind::Target = unit.kind { + cmd.arg("-L").arg(&{ + let mut deps = OsString::from("dependency="); + deps.push(cx.host_deps()); + deps + }); + } + for unit in cx.dep_targets(unit)?.iter() { if unit.profile.run_custom_build { cmd.env("OUT_DIR", &cx.build_script_out_dir(unit)); diff --git a/tests/cross-compile.rs b/tests/cross-compile.rs index 6cffa301fb1..c8cdc4aa757 100644 --- a/tests/cross-compile.rs +++ b/tests/cross-compile.rs @@ -363,7 +363,8 @@ fn linker_and_ar() { --emit=dep-info,link \ --target {target} \ -C ar=my-ar-tool -C linker=my-linker-tool \ - -L dependency={dir}[/]target[/]{target}[/]debug[/]deps` + -L dependency={dir}[/]target[/]{target}[/]debug[/]deps \ + -L dependency={dir}[/]target[/]debug[/]deps` ", dir = p.root().display(), url = p.url(), From fa7603adb78aba93ebed4a5a55153a3c10ff318c Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Fri, 2 Dec 2016 16:00:58 +0100 Subject: [PATCH 0872/3888] Fixed broken testcase for string-based form of rustflags config key. --- tests/rustflags.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/rustflags.rs b/tests/rustflags.rs index 1cf9e96cd14..f5117c31379 100644 --- a/tests/rustflags.rs +++ b/tests/rustflags.rs @@ -997,11 +997,12 @@ fn target_rustflags_string_and_array_form1() { #[test] fn target_rustflags_string_and_array_form2() { let p1 = project("foo") - .file("Cargo.toml", &format!(r#" + .file("Cargo.toml", r#" [package] name = "foo" version = "0.0.1" - + "#) + .file(".cargo/config", &format!(r#" [target.{}] rustflags = ["--cfg", "foo"] "#, rustc_host())) @@ -1016,11 +1017,12 @@ fn target_rustflags_string_and_array_form2() { ")); let p2 = project("foo") - .file("Cargo.toml", &format!(r#" + .file("Cargo.toml", r#" [package] name = "foo" version = "0.0.1" - + "#) + .file(".cargo/config", &format!(r#" [target.{}] rustflags = "--cfg foo" "#, rustc_host())) From e4b3701109afb96ab2ebf539c4be53d7c1c20ebd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 23 Nov 2016 08:29:36 -0800 Subject: [PATCH 0873/3888] Emit more info on --message-format=json This adds more output on Cargo's behalf to the output of `--message-format=json`. Cargo will now emit a message when a crate is finished compiling with a list of all files that were just generated along with a message when a build script finishes executing with linked libraries and linked library paths. Closes #3212 --- src/cargo/core/manifest.rs | 21 ++++++- src/cargo/ops/cargo_compile.rs | 4 +- src/cargo/ops/cargo_rustc/custom_build.rs | 15 +++++ src/cargo/ops/cargo_rustc/mod.rs | 37 +++++++++--- src/cargo/util/machine_message.rs | 74 ++++++++++++++++------- tests/build.rs | 28 +++++++++ 6 files changed, 144 insertions(+), 35 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 93fac21fdf9..da40c6a55a0 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -123,7 +123,7 @@ impl Encodable for TargetKind { } } -#[derive(RustcEncodable, RustcDecodable, Clone, PartialEq, Eq, Debug, Hash)] +#[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct Profile { pub opt_level: String, pub lto: bool, @@ -139,6 +139,25 @@ pub struct Profile { pub panic: Option, } +#[derive(RustcEncodable)] +struct SerializedProfile<'a> { + opt_level: &'a str, + debuginfo: bool, + debug_assertions: bool, + test: bool, +} + +impl Encodable for Profile { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { + SerializedProfile { + opt_level: &self.opt_level, + debuginfo: self.debuginfo, + debug_assertions: self.debug_assertions, + test: self.test, + }.encode(s) + } +} + #[derive(Default, Clone, Debug, PartialEq, Eq)] pub struct Profiles { pub release: Profile, diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 74b78769476..e2f62e2593b 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -251,7 +251,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let mut build_config = scrape_build_config(config, jobs, target)?; build_config.release = release; build_config.test = mode == CompileMode::Test || mode == CompileMode::Bench; - build_config.json_errors = message_format == MessageFormat::Json; + build_config.json_messages = message_format == MessageFormat::Json; if let CompileMode::Doc { deps } = mode { build_config.doc_all = deps; } @@ -512,7 +512,7 @@ fn scrape_target_config(config: &Config, triple: &str) let (flags, definition) = value.string(&k)?; let whence = format!("in `{}` (in {})", key, definition.display()); - let (paths, links) = + let (paths, links) = BuildOutput::parse_rustc_flags(&flags, &whence) ?; output.library_paths.extend(paths); diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index eb62f38c522..e412b846ed9 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -7,6 +7,7 @@ use std::sync::{Mutex, Arc}; use core::PackageId; use util::{CargoResult, Human, Freshness, Cfg}; use util::{internal, ChainError, profile, paths}; +use util::machine_message; use super::job::Work; use super::{fingerprint, Kind, Context, Unit}; @@ -168,6 +169,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) output_file.clone()); let build_scripts = super::load_build_deps(cx, unit); let kind = unit.kind; + let json_messages = cx.build_config.json_messages; // Check to see if the build script as already run, and if it has keep // track of whether it has told us about some explicit dependencies @@ -242,6 +244,19 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // state informing what variables were discovered via our script as // well. let parsed_output = BuildOutput::parse(&output.stdout, &pkg_name)?; + + if json_messages { + let library_paths = parsed_output.library_paths.iter().map(|l| { + l.display().to_string() + }).collect::>(); + machine_message::emit(machine_message::BuildScript { + package_id: &id, + linked_libs: &parsed_output.library_links, + linked_paths: &library_paths, + cfgs: &parsed_output.cfgs, + }); + } + build_state.insert(id, kind, parsed_output); Ok(()) }); diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index e54f539f392..186ce0d728c 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -42,7 +42,7 @@ pub struct BuildConfig { pub release: bool, pub test: bool, pub doc_all: bool, - pub json_errors: bool, + pub json_messages: bool, } #[derive(Clone, Default)] @@ -246,9 +246,15 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { let cwd = cx.config.cwd().to_path_buf(); rustc.args(&cx.rustflags_args(unit)?); - let json_errors = cx.build_config.json_errors; + let json_messages = cx.build_config.json_messages; let package_id = unit.pkg.package_id().clone(); let target = unit.target.clone(); + let profile = unit.profile.clone(); + let features = cx.resolve.features(unit.pkg.package_id()) + .into_iter() + .flat_map(|i| i) + .map(|s| s.to_string()) + .collect::>(); return Ok(Work::new(move |state| { // Only at runtime have we discovered what the extra -L and -l // arguments are for native libraries, so we process those here. We @@ -273,7 +279,7 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { } state.running(&rustc); - if json_errors { + if json_messages { rustc.exec_with_streaming( &mut |line| if !line.is_empty() { Err(internal(&format!("compiler stdout is not empty: `{}`", line))) @@ -285,12 +291,11 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { internal(&format!("compiler produced invalid json: `{}`", line)) })?; - machine_message::FromCompiler::new( - &package_id, - &target, - compiler_message - ).emit(); - + machine_message::emit(machine_message::FromCompiler { + package_id: &package_id, + target: &target, + message: compiler_message, + }); Ok(()) }, ).map(|_| ()) @@ -321,6 +326,18 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { fingerprint::append_current_dir(&dep_info_loc, &cwd)?; } + if json_messages { + machine_message::emit(machine_message::Artifact { + package_id: &package_id, + target: &target, + profile: &profile, + features: features, + filenames: filenames.iter().map(|&(ref src, _, _)| { + src.display().to_string() + }).collect(), + }); + } + Ok(()) })); @@ -527,7 +544,7 @@ fn build_base_args(cx: &mut Context, cmd.arg("--color").arg(&color_config.to_string()); } - if cx.build_config.json_errors { + if cx.build_config.json_messages { cmd.arg("--error-format").arg("json"); } diff --git a/src/cargo/util/machine_message.rs b/src/cargo/util/machine_message.rs index 7de1ead0e67..64e6c35f160 100644 --- a/src/cargo/util/machine_message.rs +++ b/src/cargo/util/machine_message.rs @@ -1,30 +1,60 @@ -use rustc_serialize::json; -use core::{PackageId, Target}; +use rustc_serialize::Encodable; +use rustc_serialize::json::{self, Json}; + +use core::{PackageId, Target, Profile}; + +pub trait Message: Encodable { + fn reason(&self) -> &str; +} + +pub fn emit(t: T) { + let json = json::encode(&t).unwrap(); + let mut map = match json.parse().unwrap() { + Json::Object(obj) => obj, + _ => panic!("not a json object"), + }; + map.insert("reason".to_string(), Json::String(t.reason().to_string())); + println!("{}", Json::Object(map)); +} #[derive(RustcEncodable)] pub struct FromCompiler<'a> { - reason: &'static str, - package_id: &'a PackageId, - target: &'a Target, - message: json::Json, -} - -impl<'a> FromCompiler<'a> { - pub fn new(package_id: &'a PackageId, - target: &'a Target, - message: json::Json) - -> FromCompiler<'a> { - FromCompiler { - reason: "compiler-message", - package_id: package_id, - target: target, - message: message, - } + pub package_id: &'a PackageId, + pub target: &'a Target, + pub message: json::Json, +} + +impl<'a> Message for FromCompiler<'a> { + fn reason(&self) -> &str { + "compiler-message" } +} - pub fn emit(self) { - let json = json::encode(&self).unwrap(); - println!("{}", json); +#[derive(RustcEncodable)] +pub struct Artifact<'a> { + pub package_id: &'a PackageId, + pub target: &'a Target, + pub profile: &'a Profile, + pub features: Vec, + pub filenames: Vec, +} + +impl<'a> Message for Artifact<'a> { + fn reason(&self) -> &str { + "compiler-artifact" } } +#[derive(RustcEncodable)] +pub struct BuildScript<'a> { + pub package_id: &'a PackageId, + pub linked_libs: &'a [String], + pub linked_paths: &'a [String], + pub cfgs: &'a [String], +} + +impl<'a> Message for BuildScript<'a> { + fn reason(&self) -> &str { + "build-script-executed" + } +} diff --git a/tests/build.rs b/tests/build.rs index 02e14d18dd3..e6ae434c5e7 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -2411,6 +2411,20 @@ fn compiler_json_error_format() { } } + { + "reason":"compiler-artifact", + "profile": { + "debug_assertions": true, + "debuginfo": true, + "opt_level": "0", + "test": false + }, + "features": [], + "package_id":"bar 0.5.0 ([..])", + "target":{"kind":["lib"],"name":"bar","src_path":"[..]lib.rs"}, + "filenames":["[..].rlib"] + } + { "reason":"compiler-message", "package_id":"foo 0.5.0 ([..])", @@ -2426,6 +2440,20 @@ fn compiler_json_error_format() { }] } } + + { + "reason":"compiler-artifact", + "package_id":"foo 0.5.0 ([..])", + "target":{"kind":["bin"],"name":"foo","src_path":"[..]main.rs"}, + "profile": { + "debug_assertions": true, + "debuginfo": true, + "opt_level": "0", + "test": false + }, + "features": [], + "filenames": ["[..]"] + } "#)); } From 30aa740c275b30ce93f99274f2c54740a1825bbe Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Fri, 2 Dec 2016 19:43:37 +0100 Subject: [PATCH 0874/3888] Refactored ugly rustflags lookup code into a separate function. --- src/cargo/ops/cargo_rustc/context.rs | 28 ++++---------------------- src/cargo/util/config.rs | 30 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 2ec275e71b3..9cb4af91082 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -856,37 +856,17 @@ fn env_args(config: &Config, // Then the target.*.rustflags value let target = build_config.requested_target.as_ref().unwrap_or(&build_config.host_triple); let key = format!("target.{}.{}", target, name); - let list = config.get_list(&key); - if let Ok(Some(args)) = list { - let args = args.val.into_iter().map(|a| a.0); + if let Some(args) = config.get_list_or_split_string(&key)? { + let args = args.val.into_iter(); return Ok(args.collect()); } - let string = config.get_string(&key); - if let Ok(Some(arg)) = string { - return Ok(arg.val.split(' ').map(str::to_string).collect()); - } - if list.is_err() && string.is_err() { - if let Some(value) = config.values()?.get(&key) { - return config.expected("list or string", &key, value.clone()); - } - } // Then the build.rustflags value let key = format!("build.{}", name); - let list = config.get_list(&key); - if let Ok(Some(args)) = list { - let args = args.val.into_iter().map(|a| a.0); + if let Some(args) = config.get_list_or_split_string(&key)? { + let args = args.val.into_iter(); return Ok(args.collect()); } - let string = config.get_string(&key); - if let Ok(Some(arg)) = string { - return Ok(arg.val.split(' ').map(str::to_string).collect()); - } - if list.is_err() && string.is_err() { - if let Some(value) = config.values()?.get(&key) { - return config.expected("list or string", &key, value.clone()); - } - } Ok(Vec::new()) } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index dc97acc0aac..598a6dcccbe 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -225,6 +225,36 @@ impl Config { } } + pub fn get_list_or_split_string(&self, key: &str) + -> CargoResult>>> { + match self.get_env::(key) { + Ok(Some(value)) => + return Ok(Some(Value { + val: value.val.split(' ').map(str::to_string).collect(), + definition: value.definition + })), + Err(err) => return Err(err), + Ok(None) => (), + } + + match self.get(key)? { + Some(CV::List(i, path)) => { + Ok(Some(Value { + val: i.into_iter().map(|(s, _)| s).collect(), + definition: Definition::Path(path), + })) + } + Some(CV::String(i, path)) => { + Ok(Some(Value { + val: i.split(' ').map(str::to_string).collect(), + definition: Definition::Path(path), + })) + } + Some(val) => self.expected("list or string", key, val), + None => Ok(None), + } + } + pub fn get_table(&self, key: &str) -> CargoResult>>> { match self.get(key)? { From 0afb91f74b904c0866a353ca8529fdba501e2487 Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Thu, 1 Dec 2016 22:42:45 -0500 Subject: [PATCH 0875/3888] Assume build = 'build.rs' by default This change makes cargo assume `build = "build.rs"` if there is a `build.rs` file in the same directory as `Cargo.toml`. However, you can set `build = false` to prevent this. --- src/cargo/util/toml.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 5e5dc93a669..1d4f8608ad0 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -286,12 +286,18 @@ pub struct TomlProfile { panic: Option, } +#[derive(RustcDecodable, Clone, Debug)] +pub enum StringOrBool { + String(String), + Bool(bool), +} + #[derive(RustcDecodable)] pub struct TomlProject { name: String, version: TomlVersion, authors: Vec, - build: Option, + build: Option, links: Option, exclude: Option>, include: Option>, @@ -540,7 +546,11 @@ impl TomlManifest { } // processing the custom build script - let new_build = project.build.as_ref().map(PathBuf::from); + let manifest_file = util::important_paths::find_root_manifest_for_wd(None, &layout.root) + .chain_error(|| human("Could not find root manifest location"))?; + let base_dir = manifest_file.parent() + .ok_or(human("Could not get parent directory of manifest"))?; + let new_build = self.maybe_custom_build(&project.build, &base_dir); // Get targets let targets = normalize(&lib, @@ -767,6 +777,23 @@ impl TomlManifest { } Ok(replace) } + + fn maybe_custom_build(&self, build: &Option, project_dir: &Path) + -> Option { + let build_rs = project_dir.join("build.rs"); + match *build { + Some(StringOrBool::Bool(false)) => None, // explicitly no build script + Some(StringOrBool::Bool(true)) => Some(build_rs.into()), + Some(StringOrBool::String(ref s)) => Some(PathBuf::from(s)), + None => { + match fs::metadata(&build_rs) { + Ok(ref e) if e.is_file() => Some(build_rs.into()), + Ok(_) => None, + Err(_) => None, + } + } + } + } } /// Will check a list of toml targets, and make sure the target names are unique within a vector. From 561b6421194483d43173f4afe3e738469159bc13 Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Thu, 1 Dec 2016 23:01:51 -0500 Subject: [PATCH 0876/3888] Tests for new `package.build` behavior --- tests/build-script.rs | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/build-script.rs b/tests/build-script.rs index 46d8e144063..8524eb95072 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -2334,3 +2334,74 @@ fn switch_features_rerun() { assert_that(build.cargo("run").arg("-v").arg("--features=foo"), execs().with_status(0).with_stdout("foo\n")); } + +#[test] +fn assume_build_script_when_build_rs_present() { + let p = project("builder") + .file("Cargo.toml", r#" + [package] + name = "builder" + version = "0.0.1" + authors = [] + "#) + .file("src/main.rs", r#" + fn main() { + println!(include_str!(concat!(env!("OUT_DIR"), "/output"))); + } + "#) + .file("build.rs", r#" + use std::env; + use std::fs::File; + use std::io::Write; + use std::path::Path; + + fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let out_dir = Path::new(&out_dir).join("output"); + let mut f = File::create(&out_dir).unwrap(); + f.write_all(b"foo").unwrap(); + } + "#); + p.build(); + + assert_that(p.cargo("run").arg("-v"), + execs().with_status(0).with_stdout("foo\n")); +} + +#[test] +fn if_build_set_to_false_dont_tread_build_rs_as_build_script() { + let p = project("builder") + .file("Cargo.toml", r#" + [package] + name = "builder" + version = "0.0.1" + authors = [] + build = false + "#) + .file("src/main.rs", r#" + use std::path::Path; + fn main() { + let f = env!("OUT_DIR"); + assert!( + ! Path::new(f).join("output").exists() + ) + } + "#) + .file("build.rs", r#" + use std::env; + use std::fs::File; + use std::io::Write; + use std::path::Path; + + fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let out_dir = Path::new(&out_dir).join("output"); + let mut f = File::create(&out_dir).unwrap(); + f.write_all(b"foo").unwrap(); + } + "#); + p.build(); + + assert_that(p.cargo("run").arg("-v"), + execs().with_status(0)); +} From df4da8b09b31b3a38eb447e0d3ef5451ddbae22a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Dec 2016 14:27:37 -0800 Subject: [PATCH 0877/3888] Use -j1 on recursive make for OpenSSL It looks like OpenSSL building on OSX has races... --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index ef02d4547ba..89e3f2a3156 100644 --- a/Makefile.in +++ b/Makefile.in @@ -266,7 +266,7 @@ target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \ AR=$$(OPENSSL_AR_$(1)) \ $$(SETARCH_$(1)) ./Configure --prefix=$$(OPENSSL_INSTALL_$(1)) \ no-dso $$(OPENSSL_OS_$(1)) -fPIC $$(OPENSSL_CFLAGS_$(1))&& \ - $(MAKE) -j10 && \ + $(MAKE) -j1 && \ $(MAKE) install) touch $$@ From d9e49da4215edaab55e8e35825946668397b835b Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Fri, 18 Nov 2016 16:49:55 -0500 Subject: [PATCH 0878/3888] Upload categories specified in the manifest --- src/cargo/core/manifest.rs | 1 + src/cargo/ops/registry.rs | 2 ++ src/cargo/util/toml.rs | 2 ++ src/crates-io/lib.rs | 1 + src/doc/manifest.md | 10 ++++++++-- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 93fac21fdf9..e9bc79609e0 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -47,6 +47,7 @@ pub struct VirtualManifest { pub struct ManifestMetadata { pub authors: Vec, pub keywords: Vec, + pub categories: Vec, pub license: Option, pub license_file: Option, pub description: Option, // not markdown diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index d937976f867..af80760b63b 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -112,6 +112,7 @@ fn transmit(config: &Config, let ManifestMetadata { ref authors, ref description, ref homepage, ref documentation, ref keywords, ref readme, ref repository, ref license, ref license_file, + ref categories, } = *manifest.metadata(); let readme = match *readme { Some(ref readme) => Some(paths::read(&pkg.root().join(readme))?), @@ -142,6 +143,7 @@ fn transmit(config: &Config, homepage: homepage.clone(), documentation: documentation.clone(), keywords: keywords.clone(), + categories: categories.clone(), readme: readme, repository: repository.clone(), license: license.clone(), diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 5e5dc93a669..bcac3d2da09 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -304,6 +304,7 @@ pub struct TomlProject { documentation: Option, readme: Option, keywords: Option>, + categories: Option>, license: Option, license_file: Option, repository: Option, @@ -640,6 +641,7 @@ impl TomlManifest { license_file: project.license_file.clone(), repository: project.repository.clone(), keywords: project.keywords.clone().unwrap_or(Vec::new()), + categories: project.categories.clone().unwrap_or(Vec::new()), }; let workspace_config = match (self.workspace.as_ref(), diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index 884460df290..4d8d889f3b4 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -78,6 +78,7 @@ pub struct NewCrate { pub homepage: Option, pub readme: Option, pub keywords: Vec, + pub categories: Vec, pub license: Option, pub license_file: Option, pub repository: Option, diff --git a/src/doc/manifest.md b/src/doc/manifest.md index 9aaab670738..326cd628cc4 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -118,10 +118,16 @@ repository = "..." # contents of this file are stored and indexed in the registry. readme = "..." -# This is a small list of keywords used to categorize and search for this -# package. +# This is a list of up to five keywords that describe this crate. Keywords +# are searchable on crates.io, and you may choose any words that would +# help someone find this crate. keywords = ["...", "..."] +# This is a list of up to five categories where this crate would fit. +# Categories are a fixed list available at crates.io/categories, and +# they must match exactly. +categories = ["...", "..."] + # This is a string description of the license for this package. Currently # crates.io will validate the license provided against a whitelist of known # license identifiers from http://spdx.org/licenses/. Multiple licenses can be From 8ca8fddc89b216cdcbe4d2ceb9ed744c567022a9 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 29 Nov 2016 13:19:07 -0500 Subject: [PATCH 0879/3888] Warn when crates.io sends back invalid category slugs --- src/cargo/ops/registry.rs | 21 +++++++++++++++++---- src/crates-io/lib.rs | 28 +++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index af80760b63b..2b444760959 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -133,7 +133,7 @@ fn transmit(config: &Config, return Ok(()); } - registry.publish(&NewCrate { + let publish = registry.publish(&NewCrate { name: pkg.name().to_string(), vers: pkg.version().to_string(), deps: deps, @@ -148,9 +148,22 @@ fn transmit(config: &Config, repository: repository.clone(), license: license.clone(), license_file: license_file.clone(), - }, tarball).map_err(|e| { - human(e.to_string()) - }) + }, tarball); + + match publish { + Ok(invalid_categories) => { + if !invalid_categories.is_empty() { + let msg = format!("\ + the following are not valid category slugs and were \ + ignored: {}. Please see https://crates.io/category_slugs \ + for the list of all category slugs. \ + ", invalid_categories.join(", ")); + config.shell().warn(&msg)?; + } + Ok(()) + }, + Err(e) => Err(human(e.to_string())), + } } pub fn registry_configuration(config: &Config) -> CargoResult { diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index 4d8d889f3b4..12c195edbc5 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -10,7 +10,7 @@ use std::io::{self, Cursor}; use std::result; use curl::easy::{Easy, List}; -use rustc_serialize::json; +use rustc_serialize::json::{self, Json}; use url::percent_encoding::{percent_encode, QUERY_ENCODE_SET}; @@ -39,6 +39,7 @@ pub enum Error { NotFound, JsonEncodeError(json::EncoderError), JsonDecodeError(json::DecoderError), + JsonParseError(json::ParserError), } impl From for Error { @@ -53,6 +54,12 @@ impl From for Error { } } +impl From for Error { + fn from(err: json::ParserError) -> Error { + Error::JsonParseError(err) + } +} + impl From for Error { fn from(err: curl::Error) -> Error { Error::Curl(err) @@ -111,7 +118,6 @@ pub struct User { #[derive(RustcDecodable)] struct Users { users: Vec } #[derive(RustcDecodable)] struct TotalCrates { total: u32 } #[derive(RustcDecodable)] struct Crates { crates: Vec, meta: TotalCrates } - impl Registry { pub fn new(host: String, token: Option) -> Registry { Registry::new_handle(host, token, Easy::new()) @@ -148,7 +154,8 @@ impl Registry { Ok(json::decode::(&body)?.users) } - pub fn publish(&mut self, krate: &NewCrate, tarball: &File) -> Result<()> { + pub fn publish(&mut self, krate: &NewCrate, tarball: &File) + -> Result> { let json = json::encode(krate)?; // Prepare the body. The format of the upload request is: // @@ -191,10 +198,20 @@ impl Registry { headers.append(&format!("Authorization: {}", token))?; self.handle.http_headers(headers)?; - let _body = handle(&mut self.handle, &mut |buf| { + let body = handle(&mut self.handle, &mut |buf| { body.read(buf).unwrap_or(0) })?; - Ok(()) + // Can't derive RustcDecodable because JSON has a key named "crate" :( + let response = Json::from_str(&body)?; + let invalid_categories: Vec = + response + .find_path(&["warnings", "invalid_categories"]) + .and_then(Json::as_array) + .map(|x| { + x.iter().flat_map(Json::as_string).map(Into::into).collect() + }) + .unwrap_or_else(Vec::new); + Ok(invalid_categories) } pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec, u32)> { @@ -329,6 +346,7 @@ impl fmt::Display for Error { Error::NotFound => write!(f, "cannot find crate"), Error::JsonEncodeError(ref e) => write!(f, "json encode error: {}", e), Error::JsonDecodeError(ref e) => write!(f, "json decode error: {}", e), + Error::JsonParseError(ref e) => write!(f, "json parse error: {}", e), } } } From e719371f601c5f8aaa9c534d1980dc721df4a304 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Tue, 29 Nov 2016 16:09:00 -0500 Subject: [PATCH 0880/3888] Have a fallback for an empty response This happens in tests. --- src/crates-io/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index 12c195edbc5..e35d8244033 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -202,7 +202,11 @@ impl Registry { body.read(buf).unwrap_or(0) })?; // Can't derive RustcDecodable because JSON has a key named "crate" :( - let response = Json::from_str(&body)?; + let response = if body.len() > 0 { + Json::from_str(&body)? + } else { + Json::from_str("{}")? + }; let invalid_categories: Vec = response .find_path(&["warnings", "invalid_categories"]) From 937cb7a752bfcca7f9ac9e8a1ac3870c91e525ac Mon Sep 17 00:00:00 2001 From: "Eric D. Reichert" Date: Mon, 5 Dec 2016 09:05:33 -0500 Subject: [PATCH 0881/3888] Added .idea to the list of git exlusions. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9695c8fe806..8a6bfeba36d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ src/registry/target src/registry/Cargo.lock rustc __pycache__ +.idea/ From 658ac2c981bf3d5aa84aede731436cee07c00d9d Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Mon, 5 Dec 2016 09:41:03 -0500 Subject: [PATCH 0882/3888] Using layout.root here should be sufficient --- src/cargo/util/toml.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 1d4f8608ad0..fd5a36ca1f9 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -546,11 +546,7 @@ impl TomlManifest { } // processing the custom build script - let manifest_file = util::important_paths::find_root_manifest_for_wd(None, &layout.root) - .chain_error(|| human("Could not find root manifest location"))?; - let base_dir = manifest_file.parent() - .ok_or(human("Could not get parent directory of manifest"))?; - let new_build = self.maybe_custom_build(&project.build, &base_dir); + let new_build = self.maybe_custom_build(&project.build, &layout.root); // Get targets let targets = normalize(&lib, From 054865248677c50ebf8ffafb61b1344926b90218 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 5 Dec 2016 12:36:44 -0500 Subject: [PATCH 0883/3888] Add more structure to the warnings returned from crates.io publish --- src/cargo/ops/registry.rs | 6 +++--- src/crates-io/lib.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 2b444760959..4c9bad817ac 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -151,13 +151,13 @@ fn transmit(config: &Config, }, tarball); match publish { - Ok(invalid_categories) => { - if !invalid_categories.is_empty() { + Ok(warnings) => { + if !warnings.invalid_categories.is_empty() { let msg = format!("\ the following are not valid category slugs and were \ ignored: {}. Please see https://crates.io/category_slugs \ for the list of all category slugs. \ - ", invalid_categories.join(", ")); + ", warnings.invalid_categories.join(", ")); config.shell().warn(&msg)?; } Ok(()) diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index e35d8244033..00637be3dc2 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -111,6 +111,10 @@ pub struct User { pub name: Option, } +pub struct Warnings { + pub invalid_categories: Vec, +} + #[derive(RustcDecodable)] struct R { ok: bool } #[derive(RustcDecodable)] struct ApiErrorList { errors: Vec } #[derive(RustcDecodable)] struct ApiError { detail: String } @@ -155,7 +159,7 @@ impl Registry { } pub fn publish(&mut self, krate: &NewCrate, tarball: &File) - -> Result> { + -> Result { let json = json::encode(krate)?; // Prepare the body. The format of the upload request is: // @@ -215,7 +219,7 @@ impl Registry { x.iter().flat_map(Json::as_string).map(Into::into).collect() }) .unwrap_or_else(Vec::new); - Ok(invalid_categories) + Ok(Warnings { invalid_categories: invalid_categories }) } pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec, u32)> { From 9a2548925542f728bd20959dc190962406724421 Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Mon, 5 Dec 2016 13:02:13 -0500 Subject: [PATCH 0884/3888] correct typo --- tests/build-script.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/build-script.rs b/tests/build-script.rs index 8524eb95072..021ea084245 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -2369,7 +2369,7 @@ fn assume_build_script_when_build_rs_present() { } #[test] -fn if_build_set_to_false_dont_tread_build_rs_as_build_script() { +fn if_build_set_to_false_dont_treat_build_rs_as_build_script() { let p = project("builder") .file("Cargo.toml", r#" [package] From 5c186b34c5c96e093b96dc7288044a56bd58ccbd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 5 Dec 2016 22:54:11 -0800 Subject: [PATCH 0885/3888] Upload sha256 sums of cargo artifacts --- .travis.yml | 6 ++++++ appveyor.yml | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1b23028dec7..db5a623335e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -133,6 +133,12 @@ before_deploy: - mkdir -p deploy/$TRAVIS_COMMIT - cp target/$TARGET/release/dist/cargo-*-$TARGET.tar.gz deploy/$TRAVIS_COMMIT + - > + if [ "$TRAVIS_OS_NAME" == "osx" ]; then + find "deploy/$TRAVIS_COMMIT" -maxdepth 1 -type f -exec sh -c 'shasum -a 256 -b "{}" > "{}.sha256"' \;; + else + find "deploy/$TRAVIS_COMMIT" -maxdepth 1 -type f -exec sh -c 'sha256sum -b "{}" > "{}.sha256"' \;; + fi deploy: - provider: s3 diff --git a/appveyor.yml b/appveyor.yml index ee076135bc7..488c2dee8ed 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -53,9 +53,10 @@ after_test: - ps: New-Item -Path "target/${env:TARGET}/release" -ItemType "directory" -Force - ps: New-Item -Path "target/${env:TARGET}/release/dist" -ItemType "directory" -Force - ps: Get-ChildItem -Path target\${env:TARGET}\release\dist -Filter '*.tar.gz' | Move-Item -Destination ${env:APPVEYOR_REPO_COMMIT} + - ps: Get-FileHash .\${env:APPVEYOR_REPO_COMMIT}\* | ForEach-Object {[io.file]::WriteAllText($_.Path + ".sha256", $_.Hash.ToLower() + "`n")} artifacts: - - path: $(APPVEYOR_REPO_COMMIT)\cargo-*-$(TARGET).tar.gz + - path: $(APPVEYOR_REPO_COMMIT)\cargo-* name: cargo deploy: From 7b9deb1cc61147b29ac483e8b3e4230c2a8a6a19 Mon Sep 17 00:00:00 2001 From: Paul Woolcock Date: Tue, 6 Dec 2016 10:07:52 -0500 Subject: [PATCH 0886/3888] change this to only emit a warning right now --- src/cargo/util/toml.rs | 17 ++++++++++++++--- tests/build-script.rs | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index fd5a36ca1f9..18b4d4c6cfc 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -546,7 +546,7 @@ impl TomlManifest { } // processing the custom build script - let new_build = self.maybe_custom_build(&project.build, &layout.root); + let new_build = self.maybe_custom_build(&project.build, &layout.root, &mut warnings); // Get targets let targets = normalize(&lib, @@ -774,7 +774,10 @@ impl TomlManifest { Ok(replace) } - fn maybe_custom_build(&self, build: &Option, project_dir: &Path) + fn maybe_custom_build(&self, + build: &Option, + project_dir: &Path, + warnings: &mut Vec) -> Option { let build_rs = project_dir.join("build.rs"); match *build { @@ -783,7 +786,15 @@ impl TomlManifest { Some(StringOrBool::String(ref s)) => Some(PathBuf::from(s)), None => { match fs::metadata(&build_rs) { - Ok(ref e) if e.is_file() => Some(build_rs.into()), + // Enable this after the warning has been visible for some time + // Ok(ref e) if e.is_file() => Some(build_rs.into()), + Ok(ref e) if e.is_file() => { + warnings.push("`build.rs` files in the same directory \ + as your `Cargo.toml` will soon be treated \ + as build scripts. Add `build = false` to \ + your `Cargo.toml` to prevent this".into()); + None + }, Ok(_) => None, Err(_) => None, } diff --git a/tests/build-script.rs b/tests/build-script.rs index 021ea084245..01ea55f9a51 100644 --- a/tests/build-script.rs +++ b/tests/build-script.rs @@ -2345,8 +2345,12 @@ fn assume_build_script_when_build_rs_present() { authors = [] "#) .file("src/main.rs", r#" + use std::path::Path; fn main() { - println!(include_str!(concat!(env!("OUT_DIR"), "/output"))); + let f = env!("OUT_DIR"); + assert!( + ! Path::new(f).join("output").exists() + ); } "#) .file("build.rs", r#" @@ -2365,7 +2369,14 @@ fn assume_build_script_when_build_rs_present() { p.build(); assert_that(p.cargo("run").arg("-v"), - execs().with_status(0).with_stdout("foo\n")); + execs().with_status(0).with_stderr("\ +warning: `build.rs` files in the same directory as your `Cargo.toml` will soon be treated \ +as build scripts. Add `build = false` to your `Cargo.toml` to prevent this + Compiling builder v0.0.1 ([..]) + Running [..] + Finished [..] + Running [..] +")); } #[test] From 0a952925c8e2c39ce18eedf66eb33f08b437f2d0 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Thu, 20 Oct 2016 23:57:51 -0400 Subject: [PATCH 0887/3888] avoid panic when virtual workspace has no members --- src/cargo/core/resolver/encode.rs | 18 +++++++++--------- tests/workspaces.rs | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index 47c20b89bea..6640e53e3aa 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -283,14 +283,15 @@ impl<'a, 'cfg> Encodable for WorkspaceResolve<'a, 'cfg> { let root = self.ws.members().max_by_key(|member| { member.name() - }).unwrap().package_id(); + }).map(Package::package_id); let encodable = ids.iter().filter_map(|&id| { - if self.use_root_key && root == id { - return None + match root { + Some(ref root) if !(self.use_root_key && *root == id) => { + Some(encodable_resolve_node(id, self.resolve)) + }, + _ => None, } - - Some(encodable_resolve_node(id, self.resolve)) }).collect::>(); let mut metadata = self.resolve.metadata.clone(); @@ -307,10 +308,9 @@ impl<'a, 'cfg> Encodable for WorkspaceResolve<'a, 'cfg> { let metadata = if metadata.len() == 0 {None} else {Some(metadata)}; - let root = if self.use_root_key { - Some(encodable_resolve_node(&root, self.resolve)) - } else { - None + let root = match root { + Some(root) if self.use_root_key => Some(encodable_resolve_node(&root, self.resolve)), + _ => None, }; EncodableResolve { package: Some(encodable), diff --git a/tests/workspaces.rs b/tests/workspaces.rs index 42ac608da46..00bb68bd43d 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -652,6 +652,29 @@ manifest located at: [..] #[test] fn virtual_build() { + let p = project("foo") + .file("Cargo.toml", r#" + [workspace] + members = ["bar"] + "#) + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + assert_that(p.cargo("build"), + execs().with_status(101) + .with_stderr("\ +error: manifest path `[..]` is a virtual manifest, but this command \ +requires running against an actual package in this workspace +")); +} + +#[test] +fn virtual_build_no_members() { let p = project("foo") .file("Cargo.toml", r#" [workspace] From 6b14bfe9af746ed8d62a7c9cd4a829c372a812bd Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Thu, 20 Oct 2016 16:14:54 -0400 Subject: [PATCH 0888/3888] add `--all` flag to `cargo-test` --- src/bin/bench.rs | 2 +- src/bin/build.rs | 2 +- src/bin/doc.rs | 4 +- src/bin/install.rs | 2 +- src/bin/run.rs | 4 +- src/bin/rustc.rs | 6 +- src/bin/rustdoc.rs | 6 +- src/bin/test.rs | 19 +++- src/cargo/ops/cargo_compile.rs | 37 ++++++-- src/cargo/ops/cargo_doc.rs | 17 +++- src/cargo/ops/cargo_package.rs | 2 +- src/cargo/ops/cargo_rustc/context.rs | 12 ++- src/cargo/ops/cargo_rustc/job_queue.rs | 4 +- src/cargo/ops/cargo_rustc/mod.rs | 4 +- src/cargo/ops/mod.rs | 2 +- tests/test.rs | 126 +++++++++++++++++++++++++ 16 files changed, 213 insertions(+), 36 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 774b3003cf7..bee11df314b 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -88,7 +88,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &options.flag_package, + spec: ops::Packages::Packages(&options.flag_package), release: true, mode: ops::CompileMode::Bench, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/build.rs b/src/bin/build.rs index 7e6688b410f..446c87ea8e0 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -84,7 +84,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &options.flag_package, + spec: ops::Packages::Packages(&options.flag_package), mode: ops::CompileMode::Build, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/doc.rs b/src/bin/doc.rs index f8b434247a9..c28533a89de 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops::{self, MessageFormat}; +use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -80,7 +80,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &options.flag_package, + spec: Packages::Packages(&options.flag_package), filter: ops::CompileFilter::new(options.flag_lib, &options.flag_bin, &empty, diff --git a/src/bin/install.rs b/src/bin/install.rs index c27db56ffaf..e2ac62241b4 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -108,7 +108,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &[], + spec: ops::Packages::Packages(&[]), mode: ops::CompileMode::Build, release: !options.flag_debug, filter: ops::CompileFilter::new(false, &options.flag_bin, &[], diff --git a/src/bin/run.rs b/src/bin/run.rs index 1e7089a7572..38fa657da9c 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops::{self, MessageFormat}; +use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, CliError, Config, Human}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -81,7 +81,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &[], + spec: Packages::Packages(&[]), release: options.flag_release, mode: ops::CompileMode::Build, filter: if examples.is_empty() && bins.is_empty() { diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index a73088bfd64..66369e2db93 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -1,7 +1,7 @@ use std::env; use cargo::core::Workspace; -use cargo::ops::{self, CompileOptions, CompileMode, MessageFormat}; +use cargo::ops::{self, CompileOptions, CompileMode, MessageFormat, Packages}; use cargo::util::important_paths::{find_root_manifest_for_wd}; use cargo::util::{CliResult, CliError, Config, human}; @@ -95,6 +95,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { } }; + let spec = options.flag_package.map_or_else(Vec::new, |s| vec![s]); + let opts = CompileOptions { config: config, jobs: options.flag_jobs, @@ -102,7 +104,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]), + spec: Packages::Packages(&spec), mode: mode, release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index 0d159f47a8e..41c29a4e810 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -1,5 +1,5 @@ use cargo::core::Workspace; -use cargo::ops::{self, MessageFormat}; +use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, Config}; use cargo::util::important_paths::{find_root_manifest_for_wd}; @@ -80,6 +80,8 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; + let spec = options.flag_package.map_or_else(Vec::new, |s| vec![s]); + let doc_opts = ops::DocOptions { open_result: options.flag_open, compile_opts: ops::CompileOptions { @@ -89,7 +91,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &options.flag_package.map_or(Vec::new(), |s| vec![s]), + spec: Packages::Packages(&spec), release: options.flag_release, filter: ops::CompileFilter::new(options.flag_lib, &options.flag_bin, diff --git a/src/bin/test.rs b/src/bin/test.rs index c28ff8fc431..8884e773d08 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -1,7 +1,7 @@ use cargo::core::Workspace; -use cargo::ops::{self, MessageFormat}; +use cargo::ops::{self, MessageFormat, Packages}; use cargo::util::{CliResult, CliError, Human, human, Config}; -use cargo::util::important_paths::{find_root_manifest_for_wd}; +use cargo::util::important_paths::find_root_manifest_for_wd; #[derive(RustcDecodable)] pub struct Options { @@ -28,6 +28,7 @@ pub struct Options { flag_no_fail_fast: bool, flag_frozen: bool, flag_locked: bool, + flag_all: bool, } pub const USAGE: &'static str = " @@ -46,6 +47,7 @@ Options: --bench NAME Test only the specified benchmark target --no-run Compile, but don't run tests -p SPEC, --package SPEC ... Package to run tests for + --all Test all packages in the workspace -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --release Build artifacts in release mode, with optimizations --features FEATURES Space-separated list of features to also build @@ -72,6 +74,9 @@ which indicates which package should be tested. If it is not given, then the current package is tested. For more information on SPEC and its format, see the `cargo help pkgid` command. +All packages in the workspace are tested if the `--all` flag is supplied. The +`--all` flag may be supplied in the presence of a virtual manifest. + The --jobs argument affects the building of the test executable but does not affect how many jobs are used when running the tests. @@ -111,6 +116,12 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_bench); } + let spec = if options.flag_all { + Packages::All + } else { + Packages::Packages(&options.flag_package) + }; + let ops = ops::TestOptions { no_run: options.flag_no_run, no_fail_fast: options.flag_no_fail_fast, @@ -122,7 +133,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { features: &options.flag_features, all_features: options.flag_all_features, no_default_features: options.flag_no_default_features, - spec: &options.flag_package, + spec: spec, release: options.flag_release, mode: mode, filter: filter, @@ -139,7 +150,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { Some(err) => { Err(match err.exit.as_ref().and_then(|e| e.code()) { Some(i) => CliError::new(human("test failed"), i), - None => CliError::new(Box::new(Human(err)), 101) + None => CliError::new(Box::new(Human(err)), 101), }) } } diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index e2f62e2593b..e1bcc2ef7d9 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -22,6 +22,7 @@ //! previously compiled dependency //! +use std::borrow::Cow; use std::collections::HashMap; use std::path::PathBuf; @@ -47,8 +48,8 @@ pub struct CompileOptions<'a> { pub all_features: bool, /// Flag if the default feature should be built for the root package pub no_default_features: bool, - /// Root package to build (if None it's the current one) - pub spec: &'a [String], + /// Root package to build (if empty it's the current one) + pub spec: Packages<'a>, /// Filter to apply to the root package to select which targets will be /// built. pub filter: CompileFilter<'a>, @@ -79,6 +80,12 @@ pub enum MessageFormat { Json } +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum Packages<'a> { + All, + Packages(&'a [String]), +} + pub enum CompileFilter<'a> { Everything, Only { @@ -92,8 +99,10 @@ pub enum CompileFilter<'a> { pub fn compile<'a>(ws: &Workspace<'a>, options: &CompileOptions<'a>) -> CargoResult> { - for key in ws.current()?.manifest().warnings().iter() { - options.config.shell().warn(key)? + if let Some(root_package) = ws.current_opt() { + for key in root_package.manifest().warnings().iter() { + options.config.shell().warn(key)? + } } compile_ws(ws, None, options) } @@ -112,8 +121,9 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, let mut registry = PackageRegistry::new(ws.config())?; if let Some(source) = source { - registry.add_preloaded(ws.current()?.package_id().source_id(), - source); + if let Some(root_package) = ws.current_opt() { + registry.add_preloaded(root_package.package_id().source_id(), source); + } } // First, resolve the root_package's *listed* dependencies, as well as @@ -152,7 +162,6 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, source: Option>, options: &CompileOptions<'a>) -> CargoResult> { - let root_package = ws.current()?; let CompileOptions { config, jobs, target, spec, features, all_features, no_default_features, release, mode, message_format, @@ -166,8 +175,19 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, bail!("jobs must be at least 1") } + let spec: Cow<'a, [String]> = match spec { + Packages::Packages(spec) => spec.into(), + Packages::All => ws.members() + .map(|package| { + let package_id = package.package_id(); + PackageIdSpec::from_package_id(package_id).to_string() + }) + .collect() + }; + let profiles = ws.profiles(); if spec.len() == 0 { + let root_package = ws.current()?; generate_targets(root_package, profiles, mode, filter, release)?; } @@ -184,10 +204,11 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let mut pkgids = Vec::new(); if spec.len() > 0 { - for p in spec { + for p in spec.iter() { pkgids.push(resolve_with_overrides.query(&p)?); } } else { + let root_package = ws.current()?; pkgids.push(root_package.package_id()); }; diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index 8c27335745e..eb1894fde0a 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -15,9 +15,18 @@ pub struct DocOptions<'a> { pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { let package = ws.current()?; + let spec = match options.compile_opts.spec { + ops::Packages::Packages(packages) => packages, + _ => { + // This should not happen, because the `doc` binary is hard-coded to pass + // the `Packages::Packages` variant. + bail!("`cargo doc` does not support the `--all` flag") + }, + }; + let mut lib_names = HashSet::new(); let mut bin_names = HashSet::new(); - if options.compile_opts.spec.is_empty() { + if spec.is_empty() { for target in package.targets().iter().filter(|t| t.documented()) { if target.is_lib() { assert!(lib_names.insert(target.crate_name())); @@ -37,10 +46,10 @@ pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> { ops::compile(ws, &options.compile_opts)?; if options.open_result { - let name = if options.compile_opts.spec.len() > 1 { + let name = if spec.len() > 1 { bail!("Passing multiple packages and `open` is not supported") - } else if options.compile_opts.spec.len() == 1 { - PackageIdSpec::parse(&options.compile_opts.spec[0])? + } else if spec.len() == 1 { + PackageIdSpec::parse(&spec[0])? .name() .replace("-", "_") } else { diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 26841796ec8..c837e0156db 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -291,7 +291,7 @@ fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> features: &[], no_default_features: false, all_features: false, - spec: &[], + spec: ops::Packages::Packages(&[]), filter: ops::CompileFilter::Everything, release: false, message_format: ops::MessageFormat::Human, diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 9e0cc26eb6a..de90ba89b26 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -31,7 +31,7 @@ pub struct Unit<'a> { pub struct Context<'a, 'cfg: 'a> { pub config: &'cfg Config, pub resolve: &'a Resolve, - pub current_package: PackageId, + pub current_package: Option, pub compilation: Compilation<'cfg>, pub packages: &'a PackageSet<'cfg>, pub build_state: Arc, @@ -76,7 +76,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { None => None, }; - let current_package = ws.current()?.package_id().clone(); + let current_package = ws.current_opt().map(Package::package_id).cloned(); Ok(Context { host: host_layout, target: target_layout, @@ -450,7 +450,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // we don't want to link it up. if src_dir.ends_with("deps") { // Don't lift up library dependencies - if unit.pkg.package_id() != &self.current_package && !unit.target.is_bin() { + if self.current_package.as_ref().map_or(false, |p| unit.pkg.package_id() != p) + && !unit.target.is_bin() { None } else { Some(( @@ -836,8 +837,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } pub fn show_warnings(&self, pkg: &PackageId) -> bool { - pkg == &self.current_package || pkg.source_id().is_path() || - self.config.extra_verbose() + self.current_package.as_ref().map_or(false, |p| *pkg == *p) + || pkg.source_id().is_path() + || self.config.extra_verbose() } } diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index e69bd33cd91..6ddd002f84f 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -198,7 +198,9 @@ impl<'a> JobQueue<'a> { } let build_type = if self.is_release { "release" } else { "debug" }; - let profile = cx.lib_profile(&cx.current_package); + let profile = cx.current_package.as_ref().map_or_else(Profile::default, |p| { + cx.lib_profile(p).to_owned() + }); let mut opt_type = String::from(if profile.opt_level == "0" { "unoptimized" } else { "optimized" }); if profile.debuginfo { diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 186ce0d728c..0abfe498655 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -557,7 +557,9 @@ fn build_base_args(cx: &mut Context, let prefer_dynamic = (unit.target.for_host() && !unit.target.is_custom_build()) || (crate_types.contains(&"dylib") && - unit.pkg.package_id() != &cx.current_package); + cx.current_package.as_ref().map_or(false, |p| { + *p != *unit.pkg.package_id() + })); if prefer_dynamic { cmd.arg("-C").arg("prefer-dynamic"); } diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 902c72e3007..2b46cc4d26a 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -1,6 +1,6 @@ pub use self::cargo_clean::{clean, CleanOptions}; pub use self::cargo_compile::{compile, compile_ws, resolve_dependencies, CompileOptions}; -pub use self::cargo_compile::{CompileFilter, CompileMode, MessageFormat}; +pub use self::cargo_compile::{CompileFilter, CompileMode, MessageFormat, Packages}; pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages}; pub use self::cargo_rustc::{compile_targets, Compilation, Kind, Unit}; pub use self::cargo_rustc::Context; diff --git a/tests/test.rs b/tests/test.rs index 6166a1ec651..1ed25b6f0b6 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -9,6 +9,7 @@ use std::str; use cargotest::{sleep_ms, is_nightly}; use cargotest::support::{project, execs, basic_bin_manifest, basic_lib_manifest}; use cargotest::support::paths::CargoPathExt; +use cargotest::support::registry::Package; use hamcrest::{assert_that, existing_file, is_not}; use cargo::util::process; @@ -2398,3 +2399,128 @@ fn test_many_with_features() { .arg("--features").arg("foo"), execs().with_status(0)); } + +#[test] +fn test_all_workspace() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = { path = "bar" } + + [workspace] + "#) + .file("src/main.rs", r#" + #[test] + fn foo_test() {} + "#) + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + "#) + .file("bar/src/lib.rs", r#" + #[test] + fn bar_test() {} + "#); + p.build(); + + assert_that(p.cargo_process("test") + .arg("--all"), + execs().with_stdout_contains("\ +running 1 test +test foo_test ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +") + .with_stdout_contains("\ +running 1 test +test bar_test ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +")); +} + +#[test] +fn test_all_virtual_manifest() { + let p = project("workspace") + .file("Cargo.toml", r#" + [workspace] + members = ["a", "b"] + "#) + .file("a/Cargo.toml", r#" + [project] + name = "a" + version = "0.1.0" + "#) + .file("a/src/lib.rs", r#" + #[test] + fn a() {} + "#) + .file("b/Cargo.toml", r#" + [project] + name = "b" + version = "0.1.0" + "#) + .file("b/src/lib.rs", r#" + #[test] + fn b() {} + "#); + p.build(); + + assert_that(p.cargo_process("test") + .arg("--all"), + execs().with_stdout_contains("\ +running 1 test +test b ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +") + .with_stdout_contains("\ +running 1 test +test b ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +")); +} + +#[test] +fn test_all_member_dependency_same_name() { + let p = project("workspace") + .file("Cargo.toml", r#" + [workspace] + members = ["a"] + "#) + .file("a/Cargo.toml", r#" + [project] + name = "a" + version = "0.1.0" + + [dependencies] + a = "0.1.0" + "#) + .file("a/src/lib.rs", r#" + #[test] + fn a() {} + "#); + p.build(); + + Package::new("a", "0.1.0").publish(); + + assert_that(p.cargo_process("test") + .arg("--all"), + execs().with_stdout_contains("\ +running 1 test +test a ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +")); +} From 605a7a868e3bcfe2e68a0d9c75611997c3d04038 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 16 Nov 2016 14:31:06 -0500 Subject: [PATCH 0889/3888] remove current_package from context --- src/cargo/ops/cargo_rustc/context.rs | 13 ++++++------- src/cargo/ops/cargo_rustc/job_queue.rs | 4 ++-- src/cargo/ops/cargo_rustc/mod.rs | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index de90ba89b26..c53ce604072 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -29,9 +29,9 @@ pub struct Unit<'a> { } pub struct Context<'a, 'cfg: 'a> { + pub ws: &'a Workspace<'cfg>, pub config: &'cfg Config, pub resolve: &'a Resolve, - pub current_package: Option, pub compilation: Compilation<'cfg>, pub packages: &'a PackageSet<'cfg>, pub build_state: Arc, @@ -60,7 +60,7 @@ struct TargetInfo { pub struct Metadata(u64); impl<'a, 'cfg> Context<'a, 'cfg> { - pub fn new(ws: &Workspace<'cfg>, + pub fn new(ws: &'a Workspace<'cfg>, resolve: &'a Resolve, packages: &'a PackageSet<'cfg>, config: &'cfg Config, @@ -76,12 +76,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { None => None, }; - let current_package = ws.current_opt().map(Package::package_id).cloned(); Ok(Context { + ws: ws, host: host_layout, target: target_layout, resolve: resolve, - current_package: current_package, packages: packages, config: config, target_info: TargetInfo::default(), @@ -450,8 +449,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // we don't want to link it up. if src_dir.ends_with("deps") { // Don't lift up library dependencies - if self.current_package.as_ref().map_or(false, |p| unit.pkg.package_id() != p) - && !unit.target.is_bin() { + if self.ws.current_opt().map_or(false, |p| unit.pkg.package_id() != p.package_id()) + && !unit.target.is_bin() { None } else { Some(( @@ -837,7 +836,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } pub fn show_warnings(&self, pkg: &PackageId) -> bool { - self.current_package.as_ref().map_or(false, |p| *pkg == *p) + self.ws.current_opt().map_or(false, |p| *pkg == *p.package_id()) || pkg.source_id().is_path() || self.config.extra_verbose() } diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 6ddd002f84f..5e35a7e1030 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -198,8 +198,8 @@ impl<'a> JobQueue<'a> { } let build_type = if self.is_release { "release" } else { "debug" }; - let profile = cx.current_package.as_ref().map_or_else(Profile::default, |p| { - cx.lib_profile(p).to_owned() + let profile = cx.ws.current_opt().map_or_else(Profile::default, |p| { + cx.lib_profile(p.package_id()).to_owned() }); let mut opt_type = String::from(if profile.opt_level == "0" { "unoptimized" } else { "optimized" }); diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 0abfe498655..dff80e493a7 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -557,8 +557,8 @@ fn build_base_args(cx: &mut Context, let prefer_dynamic = (unit.target.for_host() && !unit.target.is_custom_build()) || (crate_types.contains(&"dylib") && - cx.current_package.as_ref().map_or(false, |p| { - *p != *unit.pkg.package_id() + cx.ws.current_opt().map_or(false, |p| { + *p.package_id() != *unit.pkg.package_id() })); if prefer_dynamic { cmd.arg("-C").arg("prefer-dynamic"); From 541af9c972fa7e99c0c66efb5d5b0c1a6d76b961 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 16 Nov 2016 15:26:18 -0500 Subject: [PATCH 0890/3888] pass `Packages` into resolve dependencies --- src/cargo/ops/cargo_compile.rs | 47 ++++++++++++-------------- src/cargo/ops/cargo_output_metadata.rs | 11 +++--- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index e1bcc2ef7d9..e086315936a 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -22,7 +22,6 @@ //! previously compiled dependency //! -use std::borrow::Cow; use std::collections::HashMap; use std::path::PathBuf; @@ -112,8 +111,8 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, features: &[String], all_features: bool, no_default_features: bool, - specs: &[PackageIdSpec]) - -> CargoResult<(PackageSet<'a>, Resolve)> { + specs: &Packages<'a>) + -> CargoResult<(Vec, PackageSet<'a>, Resolve)> { let features = features.iter().flat_map(|s| { s.split_whitespace() }).map(|s| s.to_string()).collect::>(); @@ -147,15 +146,27 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, } }; + let specs = match *specs { + Packages::All => { + ws.members() + .map(Package::package_id) + .map(PackageIdSpec::from_package_id) + .collect() + }, + Packages::Packages(packages) => { + packages.iter().map(|p| PackageIdSpec::parse(&p)).collect::>>()? + } + }; + let resolved_with_overrides = ops::resolve_with_previous(&mut registry, ws, method, Some(&resolve), None, - specs)?; + &specs)?; let packages = ops::get_resolved_packages(&resolved_with_overrides, registry); - Ok((packages, resolved_with_overrides)) + Ok((specs, packages, resolved_with_overrides)) } pub fn compile_ws<'a>(ws: &Workspace<'a>, @@ -175,40 +186,24 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, bail!("jobs must be at least 1") } - let spec: Cow<'a, [String]> = match spec { - Packages::Packages(spec) => spec.into(), - Packages::All => ws.members() - .map(|package| { - let package_id = package.package_id(); - PackageIdSpec::from_package_id(package_id).to_string() - }) - .collect() - }; - let profiles = ws.profiles(); - if spec.len() == 0 { - let root_package = ws.current()?; - generate_targets(root_package, profiles, mode, filter, release)?; - } - let specs = spec.iter().map(|p| PackageIdSpec::parse(p)) - .collect::>>()?; - - let pair = resolve_dependencies(ws, + let resolve = resolve_dependencies(ws, source, features, all_features, no_default_features, - &specs)?; - let (packages, resolve_with_overrides) = pair; + &spec)?; + let (spec, packages, resolve_with_overrides) = resolve; let mut pkgids = Vec::new(); if spec.len() > 0 { for p in spec.iter() { - pkgids.push(resolve_with_overrides.query(&p)?); + pkgids.push(resolve_with_overrides.query(&p.to_string())?); } } else { let root_package = ws.current()?; + generate_targets(root_package, profiles, mode, filter, release)?; pkgids.push(root_package.package_id()); }; diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index bc1a04f0cfd..2856d1658c1 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -1,8 +1,8 @@ use rustc_serialize::{Encodable, Encoder}; use core::resolver::Resolve; -use core::{Package, PackageId, PackageIdSpec, Workspace}; -use ops; +use core::{Package, PackageId, Workspace}; +use ops::{self, Packages}; use util::CargoResult; const VERSION: u32 = 1; @@ -43,16 +43,13 @@ fn metadata_no_deps(ws: &Workspace, fn metadata_full(ws: &Workspace, opt: &OutputMetadataOptions) -> CargoResult { - let specs = ws.members().map(|pkg| { - PackageIdSpec::from_package_id(pkg.package_id()) - }).collect::>(); let deps = ops::resolve_dependencies(ws, None, &opt.features, opt.all_features, opt.no_default_features, - &specs)?; - let (packages, resolve) = deps; + &Packages::All)?; + let (_, packages, resolve) = deps; let packages = try!(packages.package_ids() .map(|i| packages.get(i).map(|p| p.clone())) From 453a509e5283212c98bc1f912ece26f4501b44ab Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 16 Nov 2016 16:04:31 -0500 Subject: [PATCH 0891/3888] show warnings for all members of the workspace --- src/cargo/ops/cargo_compile.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index e086315936a..a0e70e9ba3f 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -98,8 +98,8 @@ pub enum CompileFilter<'a> { pub fn compile<'a>(ws: &Workspace<'a>, options: &CompileOptions<'a>) -> CargoResult> { - if let Some(root_package) = ws.current_opt() { - for key in root_package.manifest().warnings().iter() { + for member in ws.members() { + for key in member.manifest().warnings().iter() { options.config.shell().warn(key)? } } From fbcc6422f869d896ab60ceff2fb7ac2d3d08e3ff Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Fri, 2 Dec 2016 14:30:16 -0500 Subject: [PATCH 0892/3888] remove unnecessary match --- src/cargo/core/resolver/encode.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/resolver/encode.rs b/src/cargo/core/resolver/encode.rs index 6640e53e3aa..b0c6e280a37 100644 --- a/src/cargo/core/resolver/encode.rs +++ b/src/cargo/core/resolver/encode.rs @@ -286,12 +286,11 @@ impl<'a, 'cfg> Encodable for WorkspaceResolve<'a, 'cfg> { }).map(Package::package_id); let encodable = ids.iter().filter_map(|&id| { - match root { - Some(ref root) if !(self.use_root_key && *root == id) => { - Some(encodable_resolve_node(id, self.resolve)) - }, - _ => None, + if self.use_root_key && root.unwrap() == id { + return None } + + Some(encodable_resolve_node(id, self.resolve)) }).collect::>(); let mut metadata = self.resolve.metadata.clone(); From cf683d692d8449b87ad52f1d673bacb8e88ec36b Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Fri, 2 Dec 2016 14:40:37 -0500 Subject: [PATCH 0893/3888] avoid round-tripping through string --- src/cargo/ops/cargo_compile.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index a0e70e9ba3f..8a5ed55c723 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -199,7 +199,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let mut pkgids = Vec::new(); if spec.len() > 0 { for p in spec.iter() { - pkgids.push(resolve_with_overrides.query(&p.to_string())?); + pkgids.push(p.query(resolve_with_overrides.iter())?); } } else { let root_package = ws.current()?; From 50102c3d213d02e942073a6bf38f02b848532460 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Fri, 2 Dec 2016 15:21:31 -0500 Subject: [PATCH 0894/3888] remove unnecessary usage of `current_opt` --- src/cargo/ops/cargo_rustc/context.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index c53ce604072..09977ca300d 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -836,9 +836,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } pub fn show_warnings(&self, pkg: &PackageId) -> bool { - self.ws.current_opt().map_or(false, |p| *pkg == *p.package_id()) - || pkg.source_id().is_path() - || self.config.extra_verbose() + pkg.source_id().is_path() || self.config.extra_verbose() } } From e092fd9466f200d36d713b8a11419872e5dd0212 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Fri, 2 Dec 2016 15:28:40 -0500 Subject: [PATCH 0895/3888] remove unused argument to `Context::lib_profile` --- src/cargo/ops/cargo_rustc/context.rs | 14 +++++++------- src/cargo/ops/cargo_rustc/custom_build.rs | 2 +- src/cargo/ops/cargo_rustc/job_queue.rs | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index 09977ca300d..b1690755f96 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -597,7 +597,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Ok(Unit { pkg: pkg, target: t, - profile: self.lib_profile(id), + profile: self.lib_profile(), kind: unit.kind.for_target(t), }) }) @@ -630,7 +630,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Unit { pkg: unit.pkg, target: t, - profile: self.lib_profile(id), + profile: self.lib_profile(), kind: unit.kind.for_target(t), } })); @@ -707,7 +707,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { ret.push(Unit { pkg: dep, target: lib, - profile: self.lib_profile(dep.package_id()), + profile: self.lib_profile(), kind: unit.kind.for_target(lib), }); if self.build_config.doc_all { @@ -753,7 +753,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { Unit { pkg: unit.pkg, target: t, - profile: self.lib_profile(unit.pkg.package_id()), + profile: self.lib_profile(), kind: unit.kind.for_target(t), } }) @@ -808,7 +808,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Number of jobs specified for this build pub fn jobs(&self) -> u32 { self.build_config.jobs } - pub fn lib_profile(&self, _pkg: &PackageId) -> &'a Profile { + pub fn lib_profile(&self) -> &'a Profile { let (normal, test) = if self.build_config.release { (&self.profiles.release, &self.profiles.bench_deps) } else { @@ -821,10 +821,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } - pub fn build_script_profile(&self, pkg: &PackageId) -> &'a Profile { + pub fn build_script_profile(&self, _pkg: &PackageId) -> &'a Profile { // TODO: should build scripts always be built with the same library // profile? How is this controlled at the CLI layer? - self.lib_profile(pkg) + self.lib_profile() } pub fn rustflags_args(&self, unit: &Unit) -> CargoResult> { diff --git a/src/cargo/ops/cargo_rustc/custom_build.rs b/src/cargo/ops/cargo_rustc/custom_build.rs index e412b846ed9..5c697e92836 100644 --- a/src/cargo/ops/cargo_rustc/custom_build.rs +++ b/src/cargo/ops/cargo_rustc/custom_build.rs @@ -97,7 +97,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) // environment variables. Note that the profile-related environment // variables are not set with this the build script's profile but rather the // package's library profile. - let profile = cx.lib_profile(unit.pkg.package_id()); + let profile = cx.lib_profile(); let to_exec = to_exec.into_os_string(); let mut cmd = cx.compilation.host_process(to_exec, unit.pkg)?; cmd.env("OUT_DIR", &build_output) diff --git a/src/cargo/ops/cargo_rustc/job_queue.rs b/src/cargo/ops/cargo_rustc/job_queue.rs index 5e35a7e1030..f06a0bbebb6 100644 --- a/src/cargo/ops/cargo_rustc/job_queue.rs +++ b/src/cargo/ops/cargo_rustc/job_queue.rs @@ -198,9 +198,7 @@ impl<'a> JobQueue<'a> { } let build_type = if self.is_release { "release" } else { "debug" }; - let profile = cx.ws.current_opt().map_or_else(Profile::default, |p| { - cx.lib_profile(p.package_id()).to_owned() - }); + let profile = cx.lib_profile(); let mut opt_type = String::from(if profile.opt_level == "0" { "unoptimized" } else { "optimized" }); if profile.debuginfo { From e5e9139bddcb2dbeb16144e5cbc713d8046f7d7f Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Fri, 2 Dec 2016 16:03:42 -0500 Subject: [PATCH 0896/3888] fix formatting issues --- src/cargo/ops/cargo_compile.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 8a5ed55c723..e3b22f9d8e3 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -152,7 +152,7 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, .map(Package::package_id) .map(PackageIdSpec::from_package_id) .collect() - }, + } Packages::Packages(packages) => { packages.iter().map(|p| PackageIdSpec::parse(&p)).collect::>>()? } @@ -189,11 +189,11 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let profiles = ws.profiles(); let resolve = resolve_dependencies(ws, - source, - features, - all_features, - no_default_features, - &spec)?; + source, + features, + all_features, + no_default_features, + &spec)?; let (spec, packages, resolve_with_overrides) = resolve; let mut pkgids = Vec::new(); From 483de8d7e8250ef05ecb6b9fd59d12f637accf4d Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Thu, 8 Dec 2016 17:32:33 -0500 Subject: [PATCH 0897/3888] replace `current_opt` with membership check --- src/cargo/ops/cargo_rustc/context.rs | 3 +-- src/cargo/ops/cargo_rustc/mod.rs | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index b1690755f96..e0759ad8104 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -449,8 +449,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // we don't want to link it up. if src_dir.ends_with("deps") { // Don't lift up library dependencies - if self.ws.current_opt().map_or(false, |p| unit.pkg.package_id() != p.package_id()) - && !unit.target.is_bin() { + if self.ws.members().find(|&p| p != unit.pkg).is_some() && !unit.target.is_bin() { None } else { Some(( diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index dff80e493a7..809437c644a 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -557,9 +557,7 @@ fn build_base_args(cx: &mut Context, let prefer_dynamic = (unit.target.for_host() && !unit.target.is_custom_build()) || (crate_types.contains(&"dylib") && - cx.ws.current_opt().map_or(false, |p| { - *p.package_id() != *unit.pkg.package_id() - })); + cx.ws.members().find(|&p| p != unit.pkg).is_some()); if prefer_dynamic { cmd.arg("-C").arg("prefer-dynamic"); } From 601b473b738ce04490b522987205d3a90ae10a12 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 16 Nov 2016 14:46:24 +1300 Subject: [PATCH 0898/3888] cargo check Adds a new mode - check - which only checks code, rather than generating machine code. It takes into account that proc macros and build scripts will still require generated code. Implemented by adding a check profile and setting this on each Unit, unless the unit is required to be built (i.e., is a proc macro, build script, or dep of one). --- src/bin/cargo.rs | 2 + src/bin/check.rs | 103 +++++++++++++++++++++ src/cargo/core/manifest.rs | 14 ++- src/cargo/core/workspace.rs | 1 + src/cargo/ops/cargo_clean.rs | 4 +- src/cargo/ops/cargo_compile.rs | 18 ++-- src/cargo/ops/cargo_rustc/context.rs | 68 +++++++++----- src/cargo/ops/cargo_rustc/mod.rs | 28 ++++-- src/cargo/util/toml.rs | 3 + src/etc/_cargo | 18 ++++ src/etc/cargo.bashcomp.sh | 1 + src/etc/man/cargo-check.1 | 132 +++++++++++++++++++++++++++ 12 files changed, 348 insertions(+), 44 deletions(-) create mode 100644 src/bin/check.rs create mode 100644 src/etc/man/cargo-check.1 diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 56a03a01011..05cf786dd9c 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -51,6 +51,7 @@ Options: Some common cargo commands are (see all commands with --list): build Compile the current project + check Analyze the current project and report errors, but don't build object files clean Remove the target directory doc Build this project's and its dependencies' documentation new Create a new cargo project @@ -75,6 +76,7 @@ macro_rules! each_subcommand{ ($mac:ident) => { $mac!(bench); $mac!(build); + $mac!(check); $mac!(clean); $mac!(doc); $mac!(fetch); diff --git a/src/bin/check.rs b/src/bin/check.rs new file mode 100644 index 00000000000..4e36b2999d8 --- /dev/null +++ b/src/bin/check.rs @@ -0,0 +1,103 @@ +use std::env; + +use cargo::core::Workspace; +use cargo::ops::{self, CompileOptions, MessageFormat}; +use cargo::util::important_paths::{find_root_manifest_for_wd}; +use cargo::util::{CliResult, Config}; + +#[derive(RustcDecodable)] +pub struct Options { + flag_package: Vec, + flag_jobs: Option, + flag_features: Vec, + flag_all_features: bool, + flag_no_default_features: bool, + flag_target: Option, + flag_manifest_path: Option, + flag_verbose: u32, + flag_quiet: Option, + flag_color: Option, + flag_message_format: MessageFormat, + flag_release: bool, + flag_lib: bool, + flag_bin: Vec, + flag_example: Vec, + flag_test: Vec, + flag_bench: Vec, + flag_locked: bool, + flag_frozen: bool, +} + +pub const USAGE: &'static str = " +Check a local package and all of its dependencies for errors + +Usage: + cargo check [options] + +Options: + -h, --help Print this message + -p SPEC, --package SPEC ... Package to check + -j N, --jobs N Number of parallel jobs, defaults to # of CPUs + --lib Check only this package's library + --bin NAME Check only the specified binary + --example NAME Check only the specified example + --test NAME Check only the specified test target + --bench NAME Check only the specified benchmark target + --release Check artifacts in release mode, with optimizations + --features FEATURES Space-separated list of features to also check + --all-features Check all available features + --no-default-features Do not check the `default` feature + --target TRIPLE Check for the target triple + --manifest-path PATH Path to the manifest to compile + -v, --verbose ... Use verbose output + -q, --quiet No output printed to stdout + --color WHEN Coloring: auto, always, never + --message-format FMT Error format: human, json [default: human] + --frozen Require Cargo.lock and cache are up to date + --locked Require Cargo.lock is up to date + +If the --package argument is given, then SPEC is a package id specification +which indicates which package should be built. If it is not given, then the +current package is built. For more information on SPEC and its format, see the +`cargo help pkgid` command. + +Compilation can be configured via the use of profiles which are configured in +the manifest. The default profile for this command is `dev`, but passing +the --release flag will use the `release` profile instead. +"; + +pub fn execute(options: Options, config: &Config) -> CliResult> { + debug!("executing; cmd=cargo-check; args={:?}", + env::args().collect::>()); + config.configure(options.flag_verbose, + options.flag_quiet, + &options.flag_color, + options.flag_frozen, + options.flag_locked)?; + + let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?; + + let opts = CompileOptions { + config: config, + jobs: options.flag_jobs, + target: options.flag_target.as_ref().map(|t| &t[..]), + features: &options.flag_features, + all_features: options.flag_all_features, + no_default_features: options.flag_no_default_features, + spec: &options.flag_package, + mode: ops::CompileMode::Check, + release: options.flag_release, + filter: ops::CompileFilter::new(options.flag_lib, + &options.flag_bin, + &options.flag_test, + &options.flag_example, + &options.flag_bench), + message_format: options.flag_message_format, + target_rustdoc_args: None, + target_rustc_args: None, + }; + + let ws = Workspace::new(&root, config)?; + ops::compile(&ws, &opts)?; + Ok(None) +} diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index da40c6a55a0..d5a2f25e0f5 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -71,7 +71,7 @@ impl LibKind { "lib" => LibKind::Lib, "rlib" => LibKind::Rlib, "dylib" => LibKind::Dylib, - "procc-macro" => LibKind::ProcMacro, + "proc-macro" => LibKind::ProcMacro, s => LibKind::Other(s.to_string()), } } @@ -136,6 +136,7 @@ pub struct Profile { pub test: bool, pub doc: bool, pub run_custom_build: bool, + pub check: bool, pub panic: Option, } @@ -168,6 +169,7 @@ pub struct Profiles { pub bench_deps: Profile, pub doc: Profile, pub custom_build: Profile, + pub check: Profile, } /// Information about a binary, a library, an example, etc. that is part of the @@ -531,6 +533,13 @@ impl Profile { ..Profile::default_dev() } } + + pub fn default_check() -> Profile { + Profile { + check: true, + ..Profile::default_dev() + } + } } impl Default for Profile { @@ -547,6 +556,7 @@ impl Default for Profile { test: false, doc: false, run_custom_build: false, + check: false, panic: None, } } @@ -560,6 +570,8 @@ impl fmt::Display for Profile { write!(f, "Profile(doc)") } else if self.run_custom_build { write!(f, "Profile(run)") + } else if self.check { + write!(f, "Profile(check)") } else { write!(f, "Profile(build)") } diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index f35432f6469..d0b0fdeec15 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -450,6 +450,7 @@ impl<'cfg> Workspace<'cfg> { bench_deps: Profile::default_release(), doc: Profile::default_doc(), custom_build: Profile::default_custom_build(), + check: Profile::default_check(), }; for pkg in self.members().filter(|p| p.manifest_path() != root_manifest) { diff --git a/src/cargo/ops/cargo_clean.rs b/src/cargo/ops/cargo_clean.rs index fd270b79aba..330d396dff5 100644 --- a/src/cargo/ops/cargo_clean.rs +++ b/src/cargo/ops/cargo_clean.rs @@ -54,10 +54,10 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> { for kind in [Kind::Host, Kind::Target].iter() { let Profiles { ref release, ref dev, ref test, ref bench, ref doc, - ref custom_build, ref test_deps, ref bench_deps, + ref custom_build, ref test_deps, ref bench_deps, ref check } = *profiles; let profiles = [release, dev, test, bench, doc, custom_build, - test_deps, bench_deps]; + test_deps, bench_deps, check]; for profile in profiles.iter() { units.push(Unit { pkg: &pkg, diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index e3b22f9d8e3..da6f538ce61 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -69,6 +69,7 @@ pub struct CompileOptions<'a> { pub enum CompileMode { Test, Build, + Check, Bench, Doc { deps: bool }, } @@ -188,13 +189,13 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>, let profiles = ws.profiles(); - let resolve = resolve_dependencies(ws, - source, - features, - all_features, - no_default_features, - &spec)?; - let (spec, packages, resolve_with_overrides) = resolve; + let pair = resolve_dependencies(ws, + source, + features, + all_features, + no_default_features, + &specs)?; + let (packages, resolve_with_overrides) = pair; let mut pkgids = Vec::new(); if spec.len() > 0 { @@ -335,6 +336,7 @@ fn generate_targets<'a>(pkg: &'a Package, CompileMode::Test => test, CompileMode::Bench => &profiles.bench, CompileMode::Build => build, + CompileMode::Check => &profiles.check, CompileMode::Doc { .. } => &profiles.doc, }; match *filter { @@ -366,7 +368,7 @@ fn generate_targets<'a>(pkg: &'a Package, } Ok(base) } - CompileMode::Build => { + CompileMode::Build | CompileMode::Check => { Ok(pkg.targets().iter().filter(|t| { t.is_bin() || t.is_lib() }).map(|t| (t, profile)).collect()) diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index e0759ad8104..bb8176a6f05 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -20,7 +20,7 @@ use super::layout::Layout; use super::links::Links; use super::{Kind, Compilation, BuildConfig}; -#[derive(Clone, Copy, Eq, PartialEq, Hash)] +#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)] pub struct Unit<'a> { pub pkg: &'a Package, pub target: &'a Target, @@ -70,9 +70,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let dest = if build_config.release { "release" } else { "debug" }; let host_layout = Layout::new(ws, None, &dest)?; let target_layout = match build_config.requested_target.as_ref() { - Some(target) => { - Some(Layout::new(ws, Some(&target), &dest)?) - } + Some(target) => Some(Layout::new(ws, Some(&target), dest)?), None => None, }; @@ -148,6 +146,9 @@ impl<'a, 'cfg> Context<'a, 'cfg> { unit: &Unit<'a>, crate_types: &mut BTreeSet) -> CargoResult<()> { + if unit.profile.check { + crate_types.insert("metadata".to_string()); + } for target in unit.pkg.manifest().targets() { crate_types.extend(target.rustc_crate_types().iter().map(|s| { if *s == "lib" { @@ -207,6 +208,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> { line.contains(crate_type) }); if not_supported { + if crate_type == "metadata" { + bail!("compiler does not support `--crate-type metadata`, \ + cannot run `cargo check`."); + } map.insert(crate_type.to_string(), None); continue } @@ -251,8 +256,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let mut visited = HashSet::new(); for unit in units { self.walk_used_in_plugin_map(unit, - unit.target.for_host(), - &mut visited)?; + unit.target.for_host(), + &mut visited)?; } Ok(()) } @@ -270,8 +275,8 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } for unit in self.dep_targets(unit)? { self.walk_used_in_plugin_map(&unit, - is_plugin || unit.target.for_host(), - visited)?; + is_plugin || unit.target.for_host(), + visited)?; } Ok(()) } @@ -509,20 +514,25 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } } }; - match *unit.target.kind() { - TargetKind::Example | - TargetKind::Bin | - TargetKind::CustomBuild | - TargetKind::Bench | - TargetKind::Test => { - add("bin", false)?; - } - TargetKind::Lib(..) if unit.profile.test => { - add("bin", false)?; - } - TargetKind::Lib(ref libs) => { - for lib in libs { - add(lib.crate_type(), lib.linkable())?; + + if unit.profile.check { + add("metadata", true)?; + } else { + match *unit.target.kind() { + TargetKind::Example | + TargetKind::Bin | + TargetKind::CustomBuild | + TargetKind::Bench | + TargetKind::Test => { + add("bin", false)?; + } + TargetKind::Lib(..) if unit.profile.test => { + add("bin", false)?; + } + TargetKind::Lib(ref libs) => { + for lib in libs { + add(lib.crate_type(), lib.linkable())?; + } } } } @@ -593,12 +603,20 @@ impl<'a, 'cfg> Context<'a, 'cfg> { match self.get_package(id) { Ok(pkg) => { pkg.targets().iter().find(|t| t.is_lib()).map(|t| { - Ok(Unit { + let profile = if unit.profile.check && + !t.is_custom_build() + && !t.for_host() { + &self.profiles.check + } else { + self.lib_profile() + }; + let unit = Unit { pkg: pkg, target: t, - profile: self.lib_profile(), + profile: profile, kind: unit.kind.for_target(t), - }) + }; + Ok(unit) }) } Err(e) => Some(Err(e)) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index 809437c644a..6c59910537c 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -52,7 +52,7 @@ pub struct TargetConfig { pub overrides: HashMap, } -pub type PackagesToBuild<'a> = [(&'a Package, Vec<(&'a Target,&'a Profile)>)]; +pub type PackagesToBuild<'a> = [(&'a Package, Vec<(&'a Target, &'a Profile)>)]; // Returns a mapping of the root package plus its immediate dependencies to // where the compiled libraries are all located. @@ -203,6 +203,7 @@ fn compile<'a, 'cfg: 'a>(cx: &mut Context<'a, 'cfg>, for unit in cx.dep_targets(unit)?.iter() { compile(cx, jobs, unit)?; } + Ok(()) } @@ -270,11 +271,20 @@ fn rustc(cx: &mut Context, unit: &Unit) -> CargoResult { // FIXME(rust-lang/rust#18913): we probably shouldn't have to do // this manually - for &(ref dst, ref _link_dst, _linkable) in filenames.iter() { - if fs::metadata(&dst).is_ok() { - fs::remove_file(&dst).chain_error(|| { - human(format!("Could not remove file: {}.", dst.display())) - })?; + for &(ref filename, ref _link_dst, _linkable) in filenames.iter() { + let mut dsts = vec![root.join(filename)]; + // If there is both an rmeta and rlib, rustc will prefer to use the + // rlib, even if it is older. Therefore, we must delete the rlib to + // force using the new rmeta. + if dsts[0].extension() == Some(&OsStr::new("rmeta")) { + dsts.push(root.join(filename).with_extension("rlib")); + } + for dst in &dsts { + if fs::metadata(dst).is_ok() { + fs::remove_file(dst).chain_error(|| { + human(format!("Could not remove file: {}.", dst.display())) + })?; + } } } @@ -528,7 +538,7 @@ fn build_base_args(cx: &mut Context, let Profile { ref opt_level, lto, codegen_units, ref rustc_args, debuginfo, debug_assertions, rpath, test, doc: _doc, run_custom_build, - ref panic, rustdoc_args: _, + ref panic, rustdoc_args: _, check, } = *unit.profile; assert!(!run_custom_build); @@ -548,7 +558,9 @@ fn build_base_args(cx: &mut Context, cmd.arg("--error-format").arg("json"); } - if !test { + if check { + cmd.arg("--crate-type").arg("metadata"); + } else if !test { for crate_type in crate_types.iter() { cmd.arg("--crate-type").arg(crate_type); } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 18b4d4c6cfc..7d47bcf928e 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -1248,6 +1248,8 @@ fn build_profiles(profiles: &Option) -> Profiles { doc: merge(Profile::default_doc(), profiles.and_then(|p| p.doc.as_ref())), custom_build: Profile::default_custom_build(), + check: merge(Profile::default_check(), + profiles.and_then(|p| p.dev.as_ref())), }; // The test/bench targets cannot have panic=abort because they'll all get // compiled with --test which requires the unwind runtime currently @@ -1277,6 +1279,7 @@ fn build_profiles(profiles: &Option) -> Profiles { test: profile.test, doc: profile.doc, run_custom_build: profile.run_custom_build, + check: profile.check, panic: panic.clone().or(profile.panic), } } diff --git a/src/etc/_cargo b/src/etc/_cargo index 17585920252..4a23bf35280 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -51,6 +51,23 @@ case $state in '--color=:colorization option:(auto always never)' \ ;; + check) + _arguments \ + '--features=[space separated feature list]' \ + '--all-features[enable all available features]' \ + '(-h, --help)'{-h,--help}'[show help message]' \ + '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ + "${command_scope_spec[@]}" \ + '--manifest-path=[path to manifest]: :_files -/' \ + '--no-default-features[do not check the default features]' \ + '(-p,--package)'{-p=,--package=}'[package to check]:packages:_get_package_names' \ + '--release=[check in release mode]' \ + '--target=[target triple]' \ + '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ + '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ + '--color=:colorization option:(auto always never)' \ + ;; + clean) _arguments \ '(-h, --help)'{-h,--help}'[show help message]' \ @@ -384,6 +401,7 @@ _cargo_cmds(){ local -a commands;commands=( 'bench:execute all benchmarks of a local package' 'build:compile the current project' +'check:check the current project without compiling' 'clean:remove generated artifacts' 'doc:build package documentation' 'fetch:fetch package dependencies' diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh index 5c6675e9069..44b8998839e 100644 --- a/src/etc/cargo.bashcomp.sh +++ b/src/etc/cargo.bashcomp.sh @@ -24,6 +24,7 @@ _cargo() local opt___nocmd="$opt_common -V --version --list" local opt__bench="$opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --no-run" local opt__build="$opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --test --bench --example --release" + local opt__check="$opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --lib --bin --example" local opt__clean="$opt_common $opt_pkg $opt_mani --target --release" local opt__doc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_jobs --target --open --no-deps --release" local opt__fetch="$opt_common $opt_mani" diff --git a/src/etc/man/cargo-check.1 b/src/etc/man/cargo-check.1 new file mode 100644 index 00000000000..0931bf0e976 --- /dev/null +++ b/src/etc/man/cargo-check.1 @@ -0,0 +1,132 @@ +.TH "CARGO\-CHECK" "1" "May 2016" "The Rust package manager" "Cargo Manual" +.hy +.SH NAME +.PP +cargo\-check \- Check the current project +.SH SYNOPSIS +.PP +\f[I]cargo check\f[] [OPTIONS] +.SH DESCRIPTION +.PP +Check a local package and all of its dependencies. +.PP +If the \f[B]\-\-package\f[] argument is given, then \f[I]SPEC\f[] is a +package id specification which indicates which package should be checked. +If it is not given, then the current package is checked. +For more information on \f[I]SPEC\f[] and its format, see the "cargo +help pkgid" command. +.PP +Compilation can be configured via the use of profiles which are +configured in the manifest. +The default profile for this command is \f[I]dev\f[], but passing the +\f[B]\-\-release\f[] flag will use the \f[I]release\f[] profile instead. +.SH OPTIONS +.TP +.B \-h, \-\-help +Print this message. +.RS +.RE +.TP +.B \-p \f[I]SPEC\f[], \-\-package \f[I]SPEC ...\f[] +Package to check. +.RS +.RE +.TP +.B \-j \f[I]IN\f[], \-\-jobs \f[I]IN\f[] +Number of parallel jobs, defaults to # of CPUs. +.RS +.RE +.TP +.B \-\-lib +Check only this package\[aq]s library. +.RS +.RE +.TP +.B \-\-bin \f[I]NAME\f[] +Check only the specified binary. +.RS +.RE +.TP +.B \-\-example \f[I]NAME\f[] +Check only the specified example. +.RS +.RE +.TP +.B \-\-test \f[I]NAME\f[] +Check only the specified test target. +.RS +.RE +.TP +.B \-\-bench \f[I]NAME\f[] +Check only the specified benchmark target. +.RS +.RE +.TP +.B \-\-release +Check artifacts in release mode. +.RS +.RE +.TP +.B \-\-all\-features +Check with all available features. +.RS +.RE +.TP +.B \-\-features \f[I]FEATURES\f[] +Space\-separated list of features to also check. +.RS +.RE +.TP +.B \-\-no\-default\-features +Do not check the \f[C]default\f[] feature. +.RS +.RE +.TP +.B \-\-target \f[I]TRIPLE\f[] +Check for the target triple. +.RS +.RE +.TP +.B \-\-manifest\-path \f[I]PATH\f[] +Path to the manifest to compile. +.RS +.RE +.TP +.B \-v, \-\-verbose +Use verbose output. +.RS +.RE +.TP +.B \-q, \-\-quiet +No output printed to stdout. +.RS +.RE +.TP +.B \-\-color \f[I]WHEN\f[] +Coloring: auto, always, never. +.RS +.RE +.SH EXAMPLES +.PP +Check a local package and all of its dependencies +.IP +.nf +\f[C] +$\ cargo\ check +\f[] +.fi +.PP +Check a package with optimizations +.IP +.nf +\f[C] +$\ cargo\ check\ \-\-release +\f[] +.fi +.SH SEE ALSO +.PP +cargo(1) +.SH COPYRIGHT +.PP +This work is dual\-licensed under Apache 2.0 and MIT terms. +See \f[I]COPYRIGHT\f[] file in the cargo source distribution. From 6bdc040d770dd720d431c1f846e50ff0b384b16f Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 29 Nov 2016 16:10:00 +1300 Subject: [PATCH 0899/3888] tests --- tests/check.rs | 214 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 tests/check.rs diff --git a/tests/check.rs b/tests/check.rs new file mode 100644 index 00000000000..88cfdf92c07 --- /dev/null +++ b/tests/check.rs @@ -0,0 +1,214 @@ +extern crate cargotest; +extern crate hamcrest; + +use cargotest::is_nightly; +use cargotest::support::{execs, project}; +use hamcrest::assert_that; + +#[test] +fn check_success() { + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + "#) + .file("src/main.rs", r#" + extern crate bar; + fn main() { + ::bar::baz(); + } + "#); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", r#" + pub fn baz() {} + "#); + bar.build(); + + let expected = if is_nightly() { 0 } else { 101 }; + assert_that(foo.cargo_process("check"), + execs().with_status(expected)); +} + +#[test] +fn check_fail() { + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + "#) + .file("src/main.rs", r#" + extern crate bar; + fn main() { + ::bar::baz(42); + } + "#); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", r#" + pub fn baz() {} + "#); + bar.build(); + + assert_that(foo.cargo_process("check"), + execs().with_status(101)); +} + +#[test] +fn custom_derive() { + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + "#) + .file("src/main.rs", r#" +#![feature(proc_macro)] + +#[macro_use] +extern crate bar; + +trait B { + fn b(&self); +} + +#[derive(B)] +struct A; + +fn main() { + let a = A; + a.b(); +} +"#); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + [lib] + proc-macro = true + "#) + .file("src/lib.rs", r#" +#![feature(proc_macro, proc_macro_lib)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(B)] +pub fn derive(_input: TokenStream) -> TokenStream { + format!("impl B for A {{ fn b(&self) {{}} }}").parse().unwrap() +} +"#); + bar.build(); + + let expected = if is_nightly() { 0 } else { 101 }; + assert_that(foo.cargo_process("check"), + execs().with_status(expected)); +} + +#[test] +fn check_build() { + if !is_nightly() { + return; + } + + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + "#) + .file("src/main.rs", r#" + extern crate bar; + fn main() { + ::bar::baz(); + } + "#); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", r#" + pub fn baz() {} + "#); + bar.build(); + + assert_that(foo.cargo_process("check"), + execs().with_status(0)); + assert_that(foo.cargo_process("build"), + execs().with_status(0)); +} + +#[test] +fn build_check() { + if !is_nightly() { + return; + } + + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies.bar] + path = "../bar" + "#) + .file("src/main.rs", r#" + extern crate bar; + fn main() { + ::bar::baz(); + } + "#); + let bar = project("bar") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("src/lib.rs", r#" + pub fn baz() {} + "#); + bar.build(); + + assert_that(foo.cargo_process("build"), + execs().with_status(0)); + assert_that(foo.cargo_process("check"), + execs().with_status(0)); +} From 9a34895572158a85e92395a264d8ed5c7a7ecad3 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 2 Dec 2016 11:25:55 +1300 Subject: [PATCH 0900/3888] Be a bit more careful not to crash if the compiler doesn't support --crate-type metadata --- src/cargo/ops/cargo_compile.rs | 2 +- src/cargo/ops/cargo_rustc/context.rs | 34 ++++++++++++++++++---------- src/cargo/util/toml.rs | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index da6f538ce61..b44b3e025fd 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -65,7 +65,7 @@ pub struct CompileOptions<'a> { pub target_rustc_args: Option<&'a [String]>, } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Debug)] pub enum CompileMode { Test, Build, diff --git a/src/cargo/ops/cargo_rustc/context.rs b/src/cargo/ops/cargo_rustc/context.rs index bb8176a6f05..f01c0b141ed 100644 --- a/src/cargo/ops/cargo_rustc/context.rs +++ b/src/cargo/ops/cargo_rustc/context.rs @@ -174,13 +174,17 @@ impl<'a, 'cfg> Context<'a, 'cfg> { "RUSTFLAGS")?; let mut process = self.config.rustc()?.process(); process.arg("-") - .arg("--crate-name").arg("_") + .arg("--crate-name").arg("___") .arg("--print=file-names") .args(&rustflags) .env_remove("RUST_LOG"); for crate_type in crate_types { - process.arg("--crate-type").arg(crate_type); + // Here and below we'll skip the metadata crate-type because it is + // not supported by older compilers. We'll do this one manually. + if crate_type != "metadata" { + process.arg("--crate-type").arg(crate_type); + } } if kind == Kind::Target { process.arg("--target").arg(&self.target_triple()); @@ -204,31 +208,37 @@ impl<'a, 'cfg> Context<'a, 'cfg> { let mut map = HashMap::new(); for crate_type in crate_types { let not_supported = error.lines().any(|line| { - line.contains("unsupported crate type") && - line.contains(crate_type) + (line.contains("unsupported crate type") || + line.contains("unknown crate type")) && + line.contains(crate_type) }); if not_supported { - if crate_type == "metadata" { - bail!("compiler does not support `--crate-type metadata`, \ - cannot run `cargo check`."); - } map.insert(crate_type.to_string(), None); - continue + continue; + } + if crate_type == "metadata" { + continue; } let line = match lines.next() { Some(line) => line, None => bail!("malformed output when learning about \ target-specific information from rustc"), }; - let mut parts = line.trim().split('_'); + let mut parts = line.trim().split("___"); let prefix = parts.next().unwrap(); let suffix = match parts.next() { Some(part) => part, None => bail!("output of --print=file-names has changed in \ the compiler, cannot parse"), }; - map.insert(crate_type.to_string(), - Some((prefix.to_string(), suffix.to_string()))); + + map.insert(crate_type.to_string(), Some((prefix.to_string(), suffix.to_string()))); + } + + // Manually handle the metadata case. If it is not supported by the + // compiler we'll error out elsewhere. + if crate_types.contains("metadata") { + map.insert("metadata".to_string(), Some(("lib".to_owned(), ".rmeta".to_owned()))); } let cfg = if has_cfg { diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 7d47bcf928e..e670715d4ea 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -1249,7 +1249,7 @@ fn build_profiles(profiles: &Option) -> Profiles { profiles.and_then(|p| p.doc.as_ref())), custom_build: Profile::default_custom_build(), check: merge(Profile::default_check(), - profiles.and_then(|p| p.dev.as_ref())), + profiles.and_then(|p| p.dev.as_ref())), }; // The test/bench targets cannot have panic=abort because they'll all get // compiled with --test which requires the unwind runtime currently From 523c93305a13ef5459d78183aee05a133d48f389 Mon Sep 17 00:00:00 2001 From: "Eric D. Reichert" Date: Mon, 5 Dec 2016 09:09:41 -0500 Subject: [PATCH 0901/3888] Added -vv to the list of options printed by cargo and its sub commands. --- src/bin/bench.rs | 2 +- src/bin/build.rs | 2 +- src/bin/cargo.rs | 2 +- src/bin/clean.rs | 2 +- src/bin/doc.rs | 2 +- src/bin/fetch.rs | 2 +- src/bin/generate_lockfile.rs | 2 +- src/bin/git_checkout.rs | 2 +- src/bin/init.rs | 2 +- src/bin/install.rs | 2 +- src/bin/login.rs | 2 +- src/bin/metadata.rs | 2 +- src/bin/new.rs | 2 +- src/bin/owner.rs | 2 +- src/bin/package.rs | 2 +- src/bin/pkgid.rs | 2 +- src/bin/publish.rs | 2 +- src/bin/read_manifest.rs | 2 +- src/bin/run.rs | 2 +- src/bin/rustc.rs | 2 +- src/bin/rustdoc.rs | 2 +- src/bin/search.rs | 2 +- src/bin/test.rs | 2 +- src/bin/uninstall.rs | 2 +- src/bin/update.rs | 2 +- src/bin/verify_project.rs | 2 +- src/bin/version.rs | 2 +- src/bin/yank.rs | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index 774b3003cf7..f1dc5e54b97 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -48,7 +48,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to build benchmarks for - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] diff --git a/src/bin/build.rs b/src/bin/build.rs index 7e6688b410f..0544b6383ad 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -49,7 +49,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to compile - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 56a03a01011..30101544678 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -43,7 +43,7 @@ Options: -V, --version Print version info and exit --list List installed commands --explain CODE Run `rustc --explain CODE` - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/clean.rs b/src/bin/clean.rs index 35146c687af..482e891978c 100644 --- a/src/bin/clean.rs +++ b/src/bin/clean.rs @@ -30,7 +30,7 @@ Options: --manifest-path PATH Path to the manifest to the package to clean --target TRIPLE Target triple to clean output for (default all) --release Whether or not to clean release artifacts - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/doc.rs b/src/bin/doc.rs index f8b434247a9..35e7601bf06 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -45,7 +45,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to document - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] diff --git a/src/bin/fetch.rs b/src/bin/fetch.rs index 877d53869a6..01bca5f5154 100644 --- a/src/bin/fetch.rs +++ b/src/bin/fetch.rs @@ -22,7 +22,7 @@ Usage: Options: -h, --help Print this message --manifest-path PATH Path to the manifest to fetch dependencies for - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/generate_lockfile.rs b/src/bin/generate_lockfile.rs index 40717435f04..70365505fe4 100644 --- a/src/bin/generate_lockfile.rs +++ b/src/bin/generate_lockfile.rs @@ -24,7 +24,7 @@ Usage: Options: -h, --help Print this message --manifest-path PATH Path to the manifest to generate a lockfile for - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/git_checkout.rs b/src/bin/git_checkout.rs index 268776c7b74..f2e9f609159 100644 --- a/src/bin/git_checkout.rs +++ b/src/bin/git_checkout.rs @@ -22,7 +22,7 @@ Usage: Options: -h, --help Print this message - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/init.rs b/src/bin/init.rs index 1b69a2204de..d585ce03dfa 100644 --- a/src/bin/init.rs +++ b/src/bin/init.rs @@ -32,7 +32,7 @@ Options: --bin Use a binary (application) template --lib Use a library template --name NAME Set the resulting package name - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/install.rs b/src/bin/install.rs index c27db56ffaf..448e17419be 100644 --- a/src/bin/install.rs +++ b/src/bin/install.rs @@ -57,7 +57,7 @@ Build and install options: --bin NAME Only install the binary NAME --example EXAMPLE Install the example EXAMPLE instead of binaries --root DIR Directory to install packages into - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet Less output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/login.rs b/src/bin/login.rs index 6bb3618da1f..1202c82aaa8 100644 --- a/src/bin/login.rs +++ b/src/bin/login.rs @@ -26,7 +26,7 @@ Usage: Options: -h, --help Print this message --host HOST Host to set the token for - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/metadata.rs b/src/bin/metadata.rs index 7971d0707b7..f7be16c575f 100644 --- a/src/bin/metadata.rs +++ b/src/bin/metadata.rs @@ -35,7 +35,7 @@ Options: --manifest-path PATH Path to the manifest --format-version VERSION Format version [default: 1] Valid values: 1 - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/new.rs b/src/bin/new.rs index 7b7ab664ba1..d0bd8103973 100644 --- a/src/bin/new.rs +++ b/src/bin/new.rs @@ -32,7 +32,7 @@ Options: --bin Use a binary (application) template --lib Use a library template --name NAME Set the resulting package name - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/owner.rs b/src/bin/owner.rs index 4c6976aa7d1..10fd84f8c2e 100644 --- a/src/bin/owner.rs +++ b/src/bin/owner.rs @@ -29,7 +29,7 @@ Options: -l, --list List owners of a crate --index INDEX Registry index to modify owners for --token TOKEN API token to use when authenticating - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/package.rs b/src/bin/package.rs index f3f95a99c64..0292bb7ba99 100644 --- a/src/bin/package.rs +++ b/src/bin/package.rs @@ -32,7 +32,7 @@ Options: --allow-dirty Allow dirty working directories to be packaged --manifest-path PATH Path to the manifest to compile -j N, --jobs N Number of parallel jobs, defaults to # of CPUs - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/pkgid.rs b/src/bin/pkgid.rs index e18a505bf58..536cfa19906 100644 --- a/src/bin/pkgid.rs +++ b/src/bin/pkgid.rs @@ -25,7 +25,7 @@ Options: -h, --help Print this message -p SPEC, --package SPEC Argument to get the package id specifier for --manifest-path PATH Path to the manifest to the package to clean - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/publish.rs b/src/bin/publish.rs index 56db84d1766..1228b294e14 100644 --- a/src/bin/publish.rs +++ b/src/bin/publish.rs @@ -34,7 +34,7 @@ Options: --manifest-path PATH Path to the manifest of the package to publish -j N, --jobs N Number of parallel jobs, defaults to # of CPUs --dry-run Perform all checks without uploading - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/read_manifest.rs b/src/bin/read_manifest.rs index dfff8a78e1b..a663cda4a7a 100644 --- a/src/bin/read_manifest.rs +++ b/src/bin/read_manifest.rs @@ -20,7 +20,7 @@ Usage: Options: -h, --help Print this message - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) --manifest-path PATH Path to the manifest --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/run.rs b/src/bin/run.rs index 1e7089a7572..45f1cd9404b 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -40,7 +40,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to execute - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index a73088bfd64..9de83c46ee2 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -52,7 +52,7 @@ Options: --no-default-features Do not compile default features for the package --target TRIPLE Target triple which compiles will be for --manifest-path PATH Path to the manifest to fetch dependencies for - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] diff --git a/src/bin/rustdoc.rs b/src/bin/rustdoc.rs index 0d159f47a8e..8591ecee495 100644 --- a/src/bin/rustdoc.rs +++ b/src/bin/rustdoc.rs @@ -50,7 +50,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to document - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] diff --git a/src/bin/search.rs b/src/bin/search.rs index eebe34988fb..5bc518f659f 100644 --- a/src/bin/search.rs +++ b/src/bin/search.rs @@ -25,7 +25,7 @@ Usage: Options: -h, --help Print this message --host HOST Host of a registry to search in - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --limit LIMIT Limit the number of results (default: 10, max: 100) diff --git a/src/bin/test.rs b/src/bin/test.rs index c28ff8fc431..4401dc1d99a 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -53,7 +53,7 @@ Options: --no-default-features Do not build the `default` feature --target TRIPLE Build for the target triple --manifest-path PATH Path to the manifest to build tests for - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --message-format FMT Error format: human, json [default: human] diff --git a/src/bin/uninstall.rs b/src/bin/uninstall.rs index b5c827e7a4f..9f3c33af121 100644 --- a/src/bin/uninstall.rs +++ b/src/bin/uninstall.rs @@ -25,7 +25,7 @@ Options: -h, --help Print this message --root DIR Directory to uninstall packages from --bin NAME Only uninstall the binary NAME - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet Less output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/update.rs b/src/bin/update.rs index 6cf1e79864c..ede94bb0f79 100644 --- a/src/bin/update.rs +++ b/src/bin/update.rs @@ -30,7 +30,7 @@ Options: --aggressive Force updating all dependencies of as well --precise PRECISE Update a single dependency to exactly PRECISE --manifest-path PATH Path to the crate's manifest - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/verify_project.rs b/src/bin/verify_project.rs index 726e1ab358b..be498942a1b 100644 --- a/src/bin/verify_project.rs +++ b/src/bin/verify_project.rs @@ -30,7 +30,7 @@ Usage: Options: -h, --help Print this message --manifest-path PATH Path to the manifest to verify - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date diff --git a/src/bin/version.rs b/src/bin/version.rs index 24ef5aea3cb..d809d1ddd94 100644 --- a/src/bin/version.rs +++ b/src/bin/version.rs @@ -14,7 +14,7 @@ Usage: Options: -h, --help Print this message - -v, --verbose Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) --color WHEN Coloring: auto, always, never "; diff --git a/src/bin/yank.rs b/src/bin/yank.rs index 760e8cb80b0..d7fdf775297 100644 --- a/src/bin/yank.rs +++ b/src/bin/yank.rs @@ -27,7 +27,7 @@ Options: --undo Undo a yank, putting a version back into the index --index INDEX Registry index to yank from --token TOKEN API token to use when authenticating - -v, --verbose ... Use verbose output + -v, --verbose ... Use verbose output (-vv very verbose/build.rs output) -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never --frozen Require Cargo.lock and cache are up to date From 21b0906a215e9155bf3c5e5eaf95b01921c9621d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 12 Dec 2016 15:57:19 +0300 Subject: [PATCH 0902/3888] Add test for --package and virtual manifest closes #3194 --- tests/workspaces.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/workspaces.rs b/tests/workspaces.rs index 00bb68bd43d..579dfa0dbfe 100644 --- a/tests/workspaces.rs +++ b/tests/workspaces.rs @@ -624,6 +624,28 @@ fn virtual_works() { assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); } +#[test] +fn explicit_package_argument_works_with_virtual_manifest() { + let p = project("foo") + .file("Cargo.toml", r#" + [workspace] + members = ["bar"] + "#) + .file("bar/Cargo.toml", r#" + [project] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("bar/src/main.rs", "fn main() {}"); + p.build(); + assert_that(p.cargo("build").cwd(p.root()).args(&["--package", "bar"]), + execs().with_status(0)); + assert_that(&p.root().join("Cargo.lock"), existing_file()); + assert_that(&p.bin("bar"), existing_file()); + assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); +} + #[test] fn virtual_misconfigure() { let p = project("foo") From 2cf4bfbd60e6e482e0d0dfbdf05909ba47419102 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 12 Dec 2016 17:33:12 +0300 Subject: [PATCH 0903/3888] Warn if replace is not actually used closes #3324 --- src/cargo/ops/cargo_compile.rs | 8 ++++++++ tests/overrides.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index e3b22f9d8e3..a4c3f1c6d45 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -163,6 +163,14 @@ pub fn resolve_dependencies<'a>(ws: &Workspace<'a>, method, Some(&resolve), None, &specs)?; + for &(ref replace_spec, _) in ws.root_replace() { + if !resolved_with_overrides.replacements().keys().any(|r| replace_spec.matches(r)) { + ws.config().shell().warn( + format!("package replacement is not used: {}", replace_spec) + )? + } + } + let packages = ops::get_resolved_packages(&resolved_with_overrides, registry); diff --git a/tests/overrides.rs b/tests/overrides.rs index d92f81791cc..720a03cce25 100644 --- a/tests/overrides.rs +++ b/tests/overrides.rs @@ -922,6 +922,7 @@ fn overriding_nonexistent_no_spurious() { execs().with_status(0)); assert_that(p.cargo("build"), execs().with_status(0).with_stderr("\ +[WARNING] package replacement is not used: [..]bar:0.1.0 [FINISHED] [..] ").with_stdout("")); } From 04f40e8025dedfc2c609619c0c0f92f443b1ba13 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 12 Dec 2016 21:28:25 +0300 Subject: [PATCH 0904/3888] Add explanatory comment to header.html See #3387 --- src/doc/header.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/header.html b/src/doc/header.html index 83e76173c95..8d12def3165 100644 --- a/src/doc/header.html +++ b/src/doc/header.html @@ -27,6 +27,7 @@

    CARGO

    Docs +