Skip to content

Commit 50041a0

Browse files
committed
Merge branch 'master' of https://github.com/rust-lang/cargo
2 parents 2fac34a + 4f9bf54 commit 50041a0

20 files changed

+104
-84
lines changed

src/cargo/core/manifest.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub struct Profile {
118118
test: bool,
119119
doctest: bool,
120120
doc: bool,
121-
dest: Option<String>,
121+
dest: String,
122122
for_host: bool,
123123
harness: bool, // whether to use the test harness (--test)
124124
custom_build: bool,
@@ -135,7 +135,7 @@ impl Profile {
135135
rpath: false,
136136
test: false,
137137
doc: false,
138-
dest: None,
138+
dest: "debug".to_string(),
139139
for_host: false,
140140
doctest: false,
141141
custom_build: false,
@@ -157,7 +157,6 @@ impl Profile {
157157
env: "test".to_string(),
158158
debug: true,
159159
test: true,
160-
dest: None,
161160
.. Profile::default()
162161
}
163162
}
@@ -172,26 +171,23 @@ impl Profile {
172171
pub fn default_bench() -> Profile {
173172
Profile {
174173
env: "bench".to_string(),
175-
opt_level: 3,
176174
test: true,
177-
dest: Some("release".to_string()),
178-
.. Profile::default()
175+
.. Profile::default_release()
179176
}
180177
}
181178

182179
pub fn default_release() -> Profile {
183180
Profile {
184181
env: "release".to_string(),
185182
opt_level: 3,
186-
dest: Some("release".to_string()),
183+
dest: "release".to_string(),
187184
.. Profile::default()
188185
}
189186
}
190187

191188
pub fn default_doc() -> Profile {
192189
Profile {
193190
env: "doc".to_string(),
194-
dest: None,
195191
doc: true,
196192
.. Profile::default()
197193
}
@@ -210,10 +206,7 @@ impl Profile {
210206
pub fn opt_level(&self) -> u32 { self.opt_level }
211207
pub fn rpath(&self) -> bool { self.rpath }
212208
pub fn uses_test_harness(&self) -> bool { self.harness }
213-
214-
pub fn dest(&self) -> Option<&str> {
215-
self.dest.as_ref().map(|d| d.as_slice())
216-
}
209+
pub fn dest(&self) -> &str { &self.dest }
217210

218211
pub fn set_opt_level(mut self, level: u32) -> Profile {
219212
self.opt_level = level;

src/cargo/ops/cargo_package.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use tar::Archive;
66
use flate2::{GzBuilder, Compression};
77
use flate2::read::GzDecoder;
88

9-
use core::source::{Source, SourceId};
10-
use core::Package;
9+
use core::{Source, SourceId, Package, PackageId};
1110
use sources::PathSource;
1211
use util::{self, CargoResult, human, internal, ChainError, Config};
1312
use ops;
@@ -160,16 +159,23 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path)
160159
// When packages are uploaded to the registry, all path dependencies are
161160
// implicitly converted to registry-based dependencies, so we rewrite those
162161
// dependencies here.
162+
//
163+
// We also be sure to point all paths at `dst` instead of the previous
164+
// location that the package was original read from. In locking the
165+
// `SourceId` we're telling it that the corresponding `PathSource` will be
166+
// considered updated and won't actually read any packages.
163167
let registry = try!(SourceId::for_central(config));
168+
let precise = Some("locked".to_string());
169+
let new_src = try!(SourceId::for_path(&dst)).with_precise(precise);
170+
let new_pkgid = try!(PackageId::new(pkg.name(), pkg.version(), &new_src));
164171
let new_summary = pkg.summary().clone().map_dependencies(|d| {
165172
if !d.source_id().is_path() { return d }
166173
d.set_source_id(registry.clone())
167174
});
168175
let mut new_manifest = pkg.manifest().clone();
169-
new_manifest.set_summary(new_summary);
176+
new_manifest.set_summary(new_summary.override_id(new_pkgid));
170177
new_manifest.set_target_dir(dst.join("target"));
171-
let new_pkg = Package::new(new_manifest, &manifest_path,
172-
pkg.package_id().source_id());
178+
let new_pkg = Package::new(new_manifest, &manifest_path, &new_src);
173179

174180
// Now that we've rewritten all our path dependencies, compile it!
175181
try!(ops::compile_pkg(&new_pkg, &ops::CompileOptions {

src/cargo/ops/cargo_run.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ pub fn run(manifest_path: &Path,
5353
None => dst,
5454
};
5555
let exe = match (bin.profile().dest(), bin.is_example()) {
56-
(Some(s), true) => dst.join(s).join("examples").join(bin.name()),
57-
(Some(s), false) => dst.join(s).join(bin.name()),
58-
(None, true) => dst.join("examples").join(bin.name()),
59-
(None, false) => dst.join(bin.name()),
56+
(s, true) => dst.join(s).join("examples").join(bin.name()),
57+
(s, false) => dst.join(s).join(bin.name()),
6058
};
6159
let exe = match exe.relative_from(config.cwd()) {
6260
Some(path) => path,

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ impl<'a, 'b: 'a> Context<'a, 'b> {
9696
.arg("--crate-name").arg("_")
9797
.arg("--crate-type").arg("dylib")
9898
.arg("--crate-type").arg("bin")
99-
.arg("--print=file-names");
99+
.arg("--print=file-names")
100+
.env_remove("RUST_LOG");
100101
if let Some(s) = target {
101102
process.arg("--target").arg(s);
102103
};

src/cargo/ops/cargo_rustc/layout.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,13 @@ pub struct LayoutProxy<'a> {
6868
}
6969

7070
impl Layout {
71-
pub fn new(pkg: &Package, triple: Option<&str>, dest: Option<&str>) -> Layout {
71+
pub fn new(pkg: &Package, triple: Option<&str>, dest: &str) -> Layout {
7272
let mut path = pkg.absolute_target_dir();
7373
match triple {
7474
Some(s) => path.push(s),
7575
None => {}
7676
}
77-
match dest {
78-
Some(s) => path.push(s),
79-
None => {}
80-
}
77+
path.push(dest);
8178
Layout::at(path)
8279
}
8380

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ pub fn rustc_version() -> CargoResult<(String, String)> {
7575
// This is a temporary assert that ensures the consistency of the arguments
7676
// given the current limitations of Cargo. The long term fix is to have each
7777
// Target know the absolute path to the build location.
78-
fn uniq_target_dest<'a>(targets: &[&'a Target]) -> Option<&'a str> {
79-
let mut curr: Option<Option<&str>> = None;
78+
fn uniq_target_dest<'a>(targets: &[&'a Target]) -> &'a str {
79+
let mut curr: Option<&str> = None;
8080

8181
for t in targets.iter().filter(|t| !t.profile().is_custom_build()) {
8282
let dest = t.profile().dest();
8383

8484
match curr {
85-
Some(curr) => assert!(curr == dest),
85+
Some(curr) => assert_eq!(curr, dest),
8686
None => curr = Some(dest)
8787
}
8888
}
@@ -483,7 +483,8 @@ fn prepare_rustc(package: &Package, target: &Target, crate_types: Vec<&str>,
483483
fn rustdoc(package: &Package, target: &Target,
484484
cx: &mut Context) -> CargoResult<Work> {
485485
let kind = Kind::Target;
486-
let cx_root = cx.layout(package, kind).proxy().dest().join("doc");
486+
let cx_root = cx.get_package(cx.resolve.root()).absolute_target_dir()
487+
.join("doc");
487488
let mut rustdoc = try!(process(CommandType::Rustdoc, package, target, cx));
488489
rustdoc.arg(&root_path(cx, package, target))
489490
.cwd(cx.config.cwd())

src/cargo/sources/path.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,19 @@ impl<'a, 'b> PathSource<'a, 'b> {
5858
}
5959

6060
pub fn read_packages(&self) -> CargoResult<Vec<Package>> {
61+
6162
if self.updated {
6263
Ok(self.packages.clone())
64+
} else if self.id.is_path() && self.id.precise().is_some() {
65+
// If our source id is a path and it's listed with a precise
66+
// version, then it means that we're not allowed to have nested
67+
// dependencies (they've been rewritten to crates.io dependencies)
68+
// In this case we specifically read just one package, not a list of
69+
// packages.
70+
let path = self.path.join("Cargo.toml");
71+
let (pkg, _) = try!(ops::read_package(&path, &self.id,
72+
self.config));
73+
Ok(vec![pkg])
6374
} else {
6475
ops::read_packages(&self.path, &self.id, self.config)
6576
}
@@ -203,7 +214,7 @@ impl<'a, 'b> PathSource<'a, 'b> {
203214
{
204215
let mut ret = Vec::new();
205216
for pkg in self.packages.iter().filter(|p| *p == pkg) {
206-
let loc = pkg.manifest_path().parent().unwrap();
217+
let loc = pkg.root();
207218
try!(walk(loc, &mut ret, true, &mut filter));
208219
}
209220
return Ok(ret);

src/cargo/util/to_semver.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ impl<'a> ToSemver for &'a String {
2222
(**self).to_semver()
2323
}
2424
}
25+
26+
impl<'a> ToSemver for &'a Version {
27+
fn to_semver(self) -> Result<Version, String> {
28+
Ok(self.clone())
29+
}
30+
}

src/doc/config.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ with a configuration file in your home directory.
2323

2424
# Configuration Format
2525

26-
All configuration is currently in the TOML format (like the manifest), with
27-
simple key-value pairs inside of sections (tables) which all get merged
26+
All configuration is currently in the [TOML format][toml] (like the manifest),
27+
with simple key-value pairs inside of sections (tables) which all get merged
2828
together.
2929

30+
[toml]: https://github.com/toml-lang/toml
31+
3032
# Configuration keys
3133

3234
All of the following keys are optional, and their defaults are listed as their

src/doc/crates-io.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ Be sure to check out the [metadata you can
174174
specify](manifest.html#package-metadata) to ensure your crate can be discovered
175175
more easily!
176176

177-
## Limitations
177+
## Restrictions
178178

179-
There are a few limitations when publish a crate in the registry:
179+
There are a few restrictions when publishing a crate in the registry:
180180

181181
* Once a version is uploaded, it can never be overwritten. To upload a new copy
182182
of a crate you must upload a new version.
@@ -192,19 +192,19 @@ to manage a crate.
192192

193193
## `cargo owner`
194194

195-
A crate is often not developed by only one person, or perhaps the main developer
196-
changes over time! The owners of a crate is the only person allowed to publish
197-
new versions of the crate, but owners may also add other owners! This subcommand
198-
allows you to allow others to publish new versions as well as add new owners
199-
themselves:
195+
A crate is often developed by more than one person, or the primary maintainer
196+
may change over time! The owner of a crate is the only person allowed to publish
197+
new versions of the crate, but an owner may designate additional owners. Using
198+
this subcommand, an owner allows others to publish new versions, as well as to
199+
manage the list of owners themselves:
200200

201201
```notrust
202202
$ cargo owner --add my-buddy
203203
$ cargo owner --remove my-buddy
204204
```
205205

206-
The logins specified are the GitHub logins used by the user in question. The
207-
owner being added must also already have logged into crates.io previously.
206+
The owner IDs given to these commands must be GitHub user names. In order to be
207+
added, an owner must have also logged into crates.io previously.
208208

209209
## `cargo yank`
210210

0 commit comments

Comments
 (0)