Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into links
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Feb 21, 2018
2 parents 70dada8 + 847f1f7 commit 68a40ad
Show file tree
Hide file tree
Showing 98 changed files with 474 additions and 481 deletions.
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ and [merges][mergequeue] it into Cargo's `master` branch.

To contribute to the documentation, all you need to do is change the markdown
files in the `src/doc` directory. To view the rendered version of changes you
have made locally, run:
have made locally, make sure you have `mdbook` installed and run:

```sh
sh src/ci/dox.sh
open target/doc/index.html
cd src/doc
mdbook build
open book/index.html
```

To install `mdbook` run `cargo install mdbook`.


## Issue Triage

Expand Down
13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ git2-curl = "0.7"
glob = "0.2"
hex = "0.3"
home = "0.3"
ignore = "0.3"
ignore = "0.4"
jobserver = "0.1.9"
lazycell = "0.6"
libc = "0.2"
libgit2-sys = "0.6"
log = "0.4"
Expand All @@ -54,10 +55,10 @@ toml = "0.4"
url = "1.1"

[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = { version = "0.4.4", features = ["mac_os_10_7_support"] }
core-foundation = { version = "0.5.1", features = ["mac_os_10_7_support"] }

[target.'cfg(windows)'.dependencies]
miow = "0.2"
miow = "0.3"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
Expand All @@ -79,11 +80,15 @@ features = [

[dev-dependencies]
bufstream = "0.1"
cargotest = { path = "tests/cargotest", version = "0.1" }
cargotest = { path = "tests/testsuite/cargotest", version = "0.1" }
filetime = "0.1"
hamcrest = "=0.1.1"

[[bin]]
name = "cargo"
test = false
doc = false

[[test]]
name = "testsuite"
path = "tests/testsuite/lib.rs"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Learn more at https://doc.rust-lang.org/cargo/
[![Build Status](https://travis-ci.org/rust-lang/cargo.svg?branch=master)](https://travis-ci.org/rust-lang/cargo)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-lang/cargo?branch=master&svg=true)](https://ci.appveyor.com/project/rust-lang-libs/cargo)

Code documentation: https://docs.rs/cargo/

## Installing Cargo

Cargo is distributed by default with Rust, so if you've got `rustc` installed
Expand Down
21 changes: 16 additions & 5 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,15 @@ fn execute(flags: Flags, config: &mut Config) -> CliResult {
if flags.flag_list {
println!("Installed Commands:");
for command in list_commands(config) {
println!(" {}", command);
let (command, path) = command;
if flags.flag_verbose > 0 {
match path {
Some(p) => println!(" {:<20} {}", command, p),
None => println!(" {:<20}", command),
}
} else {
println!(" {}", command);
}
}
return Ok(());
}
Expand Down Expand Up @@ -301,7 +309,7 @@ fn find_closest(config: &Config, cmd: &str) -> Option<String> {
// Only consider candidates with a lev_distance of 3 or less so we don't
// suggest out-of-the-blue options.
let mut filtered = cmds.iter()
.map(|c| (lev_distance(c, cmd), c))
.map(|&(ref c, _)| (lev_distance(c, cmd), c))
.filter(|&(d, _)| d < 4)
.collect::<Vec<_>>();
filtered.sort_by(|a, b| a.0.cmp(&b.0));
Expand Down Expand Up @@ -347,7 +355,7 @@ fn execute_external_subcommand(config: &Config, cmd: &str, args: &[String]) -> C
}

/// List all runnable commands
fn list_commands(config: &Config) -> BTreeSet<String> {
fn list_commands(config: &Config) -> BTreeSet<(String, Option<String>)> {
let prefix = "cargo-";
let suffix = env::consts::EXE_SUFFIX;
let mut commands = BTreeSet::new();
Expand All @@ -367,13 +375,16 @@ fn list_commands(config: &Config) -> BTreeSet<String> {
}
if is_executable(entry.path()) {
let end = filename.len() - suffix.len();
commands.insert(filename[prefix.len()..end].to_string());
commands.insert(
(filename[prefix.len()..end].to_string(),
Some(path.display().to_string()))
);
}
}
}

macro_rules! add_cmd {
($cmd:ident) => ({ commands.insert(stringify!($cmd).replace("_", "-")); })
($cmd:ident) => ({ commands.insert((stringify!($cmd).replace("_", "-"), None)); })
}
each_subcommand!(add_cmd);
commands
Expand Down
17 changes: 7 additions & 10 deletions src/bin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Options:
control system (git, hg, pijul, or fossil) or do not
initialize any version control at all (none), overriding
a global configuration.
--bin Use a binary (application) template
--lib Use a library template [default]
--bin Use a binary (application) template [default]
--lib Use a library template
--name NAME Set the resulting package name
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet No output printed to stdout
Expand All @@ -56,17 +56,14 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult {

let path = &arg_path.unwrap_or_else(|| String::from("."));
let opts = ops::NewOptions::new(flag_vcs,
flag_bin,
flag_lib,
path,
flag_name.as_ref().map(|s| s.as_ref()));
flag_bin,
flag_lib,
path,
flag_name.as_ref().map(|s| s.as_ref()))?;

let opts_lib = opts.lib;
ops::init(&opts, config)?;

config.shell().status("Created", format!("{} project",
if opts_lib { "library" }
else {"binary (application)"}))?;
config.shell().status("Created", format!("{} project", opts.kind))?;

Ok(())
}
Expand Down
12 changes: 4 additions & 8 deletions src/bin/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Options:
control system (git, hg, pijul, or fossil) or do not
initialize any version control at all (none), overriding
a global configuration.
--bin Use a binary (application) template
--lib Use a library template [default]
--bin Use a binary (application) template [default]
--lib Use a library template
--name NAME Set the resulting package name, defaults to the value of <path>
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet No output printed to stdout
Expand All @@ -58,15 +58,11 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult {
flag_bin,
flag_lib,
&arg_path,
flag_name.as_ref().map(|s| s.as_ref()));
flag_name.as_ref().map(|s| s.as_ref()))?;

let opts_lib = opts.lib;
ops::new(&opts, config)?;

config.shell().status("Created", format!("{} `{}` project",
if opts_lib { "library" }
else {"binary (application)"},
arg_path))?;
config.shell().status("Created", format!("{} `{}` project", opts.kind, arg_path))?;

Ok(())
}
Expand Down
13 changes: 13 additions & 0 deletions src/cargo/core/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct Inner {
specified_req: bool,
kind: Kind,
only_match_name: bool,
rename: Option<String>,

optional: bool,
default_features: bool,
Expand All @@ -49,6 +50,7 @@ struct SerializedDependency<'a> {
source: &'a SourceId,
req: String,
kind: Kind,
rename: Option<&'a str>,

optional: bool,
uses_default_features: bool,
Expand All @@ -69,6 +71,7 @@ impl ser::Serialize for Dependency {
uses_default_features: self.uses_default_features(),
features: self.features(),
target: self.platform(),
rename: self.rename(),
}.serialize(s)
}
}
Expand Down Expand Up @@ -182,6 +185,7 @@ impl Dependency {
default_features: true,
specified_req: false,
platform: None,
rename: None,
}),
}
}
Expand Down Expand Up @@ -221,6 +225,10 @@ impl Dependency {
self.inner.platform.as_ref()
}

pub fn rename(&self) -> Option<&str> {
self.inner.rename.as_ref().map(|s| &**s)
}

pub fn set_kind(&mut self, kind: Kind) -> &mut Dependency {
Rc::make_mut(&mut self.inner).kind = kind;
self
Expand Down Expand Up @@ -261,6 +269,11 @@ impl Dependency {
self
}

pub fn set_rename(&mut self, rename: &str) -> &mut Dependency {
Rc::make_mut(&mut self.inner).rename = Some(rename.to_string());
self
}

/// Lock this dependency to depending on the specified package id
pub fn lock_to(&mut self, id: &PackageId) -> &mut Dependency {
assert_eq!(self.inner.source_id, *id.source_id());
Expand Down
3 changes: 3 additions & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ features! {

// Using epochs
[unstable] epoch: bool,

// Renaming a package in the manifest via the `package` key
[unstable] rename_dependency: bool,
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use std::path::{Path, PathBuf};
use semver::Version;
use serde::ser;
use toml;
use lazycell::LazyCell;

use core::{Dependency, Manifest, PackageId, SourceId, Target};
use core::{Summary, SourceMap};
use ops;
use util::{Config, LazyCell, internal, lev_distance};
use util::{Config, internal, lev_distance};
use util::errors::{CargoResult, CargoResultExt};

/// Information about a package that is available somewhere in the file system.
Expand Down
5 changes: 3 additions & 2 deletions src/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern crate hex;
extern crate home;
extern crate ignore;
extern crate jobserver;
extern crate lazycell;
extern crate libc;
extern crate libgit2_sys;
extern crate num_cpus;
Expand All @@ -39,7 +40,7 @@ extern crate core_foundation;

use std::fmt;

use serde::Deserialize;
use serde::de::DeserializeOwned;
use serde::ser;
use docopt::Docopt;
use failure::Error;
Expand Down Expand Up @@ -102,7 +103,7 @@ impl fmt::Display for VersionInfo {
}
}

pub fn call_main_without_stdin<'de, Flags: Deserialize<'de>>(
pub fn call_main_without_stdin<Flags: DeserializeOwned>(
exec: fn(Flags, &mut Config) -> CliResult,
config: &mut Config,
usage: &str,
Expand Down
Loading

0 comments on commit 68a40ad

Please sign in to comment.