Skip to content

Commit b8eb498

Browse files
committed
Squashed 'cargo/' changes from b4665f7..fb9916f
fb9916f Merge branch 'master' of https://github.com/rust-lang/cargo 59238e8 Auto merge of #2575 - alexcrichton:bump, r=alexcrichton 1f889f7 Bump to 0.11.0 81debdd Auto merge of #2574 - alexcrichton:crates-io-bump, r=alexcrichton 5d87c4f Bump the crates-io crate to 0.2 88e3081 Auto merge of #2562 - smaximov:doc-add-env-vars, r=alexcrichton 2ef6fcb Add reference to env vars introduced in PR #2523 to the docs 4e1ffb1 Auto merge of #2561 - alexcrichton:update-tar, r=alexcrichton 11a0a31 Update dependency on tar 10ddd7d Auto merge of #2554 - alexcrichton:robust-test, r=alexcrichton bc8e332 Make a test a bit more robust to the environment 34a7a06 Auto merge of #2465 - TheNeikos:add-version_env, r=alexcrichton dd26ce3 Add a new CARGO_PKG_AUTHORS environment variable 31214eb Auto merge of #2385 - alexcrichton:top-level-overrides, r=wycats f20ca62 Auto merge of #2547 - alexcrichton:more-locking, r=brson 6f6d7c8 Protect against concurrent access to Cargo.lock a9fd1c2 Change `Config::target_dir` to return Filesystem 12f76a5 Auto merge of #2541 - alexcrichton:aarch64, r=alexcrichton 0f317c5 Download the aarch64 standard library on the bots db60a09 Auto merge of #2534 - alexcrichton:lock-with-git-repos, r=brson 72690ba Auto merge of #2538 - alexcrichton:aarch64, r=alexcrichton 0a146ef Prepare for aarch64 nightlies and CI fa7805a Auto merge of #2505 - srinivasreddy:improve_msg, r=alexcrichton c63bbc6 remote unnecessary expression fae9c53 Auto merge of #2491 - JIghtuse:master, r=alexcrichton 01cc9e1 Generate the lock file when there is no lock file 18e5930 Replace existing sources before updating 1a6a32e Auto merge of #2532 - japaric:musl, r=alexcrichton d38f03b Auto merge of #2531 - alexcrichton:fix-stdin, r=alexcrichton 99c517b Update Rust to pick up rust-lang/rust#32257 d382d6a install-deps.py: add x86_64-unknown-linux-musl target abdc756 Auto merge of #2523 - srinivasreddy:issue-2504, r=alexcrichton 3a654e4 implemented cargo package name as CARGO_PKG_NAME; And package description and home page are exposed as CARGO_PKG_DESCRIPTION and CARGO_PKG_HOMEPAGE respectively. And add a test case - for CARGO_PKG_NAME, CARGO_PKR_DESCRIPTION, CARGO_HOMEPAGE. 54d738b Implement top-level overrides 12dbfa3 Reject manifest with duplicate dependencies in different targets git-subtree-dir: cargo git-subtree-split: fb9916f50201af8011180f9273c4a107952459a0
1 parent e51e69c commit b8eb498

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1293
-319
lines changed

Cargo.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cargo"
3-
version = "0.10.0"
3+
version = "0.11.0"
44
authors = ["Yehuda Katz <wycats@gmail.com>",
55
"Carl Lerche <me@carllerche.com>",
66
"Alex Crichton <alex@alexcrichton.com>"]
@@ -18,7 +18,7 @@ path = "src/cargo/lib.rs"
1818

1919
[dependencies]
2020
advapi32-sys = "0.1"
21-
crates-io = { path = "src/crates-io", version = "0.1" }
21+
crates-io = { path = "src/crates-io", version = "0.2" }
2222
crossbeam = "0.2"
2323
curl = "0.2"
2424
docopt = "0.6"

Makefile.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CFG_RELEASE_NUM=0.10.0
1+
CFG_RELEASE_NUM=0.11.0
22
CFG_RELEASE_LABEL=
33

44
OPENSSL_VERS=1.0.2g
@@ -172,6 +172,7 @@ OPENSSL_OS_i686-unknown-linux-gnu := linux-elf
172172
OPENSSL_OS_arm-unknown-linux-gnueabi := linux-armv4
173173
OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4
174174
OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4
175+
OPENSSL_OS_aarch64-unknown-linux-gnu := linux-aarch64
175176
OPENSSL_OS_x86_64-unknown-freebsd := BSD-x86_64
176177
OPENSSL_OS_x86_64-unknown-netbsd := BSD-x86_64
177178

@@ -181,6 +182,7 @@ OPENSSL_CC_i686-unknown-linux-gnu := gcc
181182
OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc
182183
OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc
183184
OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc
185+
OPENSSL_CC_aarch64-unknown-linux-gnu := aarch64-linux-gnu-gcc
184186
OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc
185187
OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc
186188
OPENSSL_AR_x86_64-unknown-linux-gnu := ar
@@ -189,6 +191,7 @@ OPENSSL_AR_i686-unknown-linux-gnu := ar
189191
OPENSSL_AR_arm-unknown-linux-gnueabi := arm-linux-gnueabi-ar
190192
OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar
191193
OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar
194+
OPENSSL_AR_aarch64-unknown-linux-gnu := aarch64-linux-gnu-ar
192195
OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar
193196
OPENSSL_AR_x86_64-unknown-netbsd := x86_64-unknown-netbsd-ar
194197

configure

+2
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ linker = "arm-linux-gnueabi-gcc"
380380
linker = "arm-linux-gnueabihf-gcc"
381381
[target.armv7-unknown-linux-gnueabihf]
382382
linker = "armv7-linux-gnueabihf-gcc"
383+
[target.aarch64-unknown-linux-gnu]
384+
linker = "aarch64-linux-gnu-gcc"
383385
[target.x86_64-unknown-freebsd]
384386
linker = "x86_64-unknown-freebsd10-gcc"
385387
[target.x86_64-unknown-netbsd]

src/cargo/core/manifest.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use std::default::Default;
21
use std::fmt;
32
use std::path::{PathBuf, Path};
43

54
use semver::Version;
65
use rustc_serialize::{Encoder, Encodable};
76

8-
use core::{Dependency, PackageId, Summary};
7+
use core::{Dependency, PackageId, PackageIdSpec, Summary};
98
use core::package_id::Metadata;
109
use util::{CargoResult, human};
1110

@@ -20,7 +19,8 @@ pub struct Manifest {
2019
include: Vec<String>,
2120
metadata: ManifestMetadata,
2221
profiles: Profiles,
23-
publish: bool
22+
publish: bool,
23+
replace: Vec<(PackageIdSpec, Dependency)>,
2424
}
2525

2626
/// General metadata about a package which is just blindly uploaded to the
@@ -165,7 +165,8 @@ impl Manifest {
165165
links: Option<String>,
166166
metadata: ManifestMetadata,
167167
profiles: Profiles,
168-
publish: bool) -> Manifest {
168+
publish: bool,
169+
replace: Vec<(PackageIdSpec, Dependency)>) -> Manifest {
169170
Manifest {
170171
summary: summary,
171172
targets: targets,
@@ -176,6 +177,7 @@ impl Manifest {
176177
metadata: metadata,
177178
profiles: profiles,
178179
publish: publish,
180+
replace: replace,
179181
}
180182
}
181183

@@ -191,6 +193,7 @@ impl Manifest {
191193
pub fn warnings(&self) -> &[String] { &self.warnings }
192194
pub fn profiles(&self) -> &Profiles { &self.profiles }
193195
pub fn publish(&self) -> bool { self.publish }
196+
pub fn replace(&self) -> &[(PackageIdSpec, Dependency)] { &self.replace }
194197
pub fn links(&self) -> Option<&str> {
195198
self.links.as_ref().map(|s| &s[..])
196199
}

src/cargo/core/package.rs

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ impl Package {
8080
pub fn summary(&self) -> &Summary { self.manifest.summary() }
8181
pub fn targets(&self) -> &[Target] { self.manifest().targets() }
8282
pub fn version(&self) -> &Version { self.package_id().version() }
83+
pub fn authors(&self) -> &Vec<String> { &self.manifest.metadata().authors }
8384
pub fn publish(&self) -> bool { self.manifest.publish() }
8485

8586
pub fn has_custom_build(&self) -> bool {

src/cargo/core/registry.rs

+11-18
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'cfg> PackageRegistry<'cfg> {
7979
PackageRegistry {
8080
sources: SourceMap::new(),
8181
source_ids: HashMap::new(),
82-
overrides: vec![],
82+
overrides: Vec::new(),
8383
config: config,
8484
locked: HashMap::new(),
8585
}
@@ -158,21 +158,16 @@ impl<'cfg> PackageRegistry<'cfg> {
158158

159159
fn load(&mut self, source_id: &SourceId, kind: Kind) -> CargoResult<()> {
160160
(|| {
161-
let mut source = source_id.load(self.config);
162-
163-
// Ensure the source has fetched all necessary remote data.
164-
let p = profile::start(format!("updating: {}", source_id));
165-
try!(source.update());
166-
drop(p);
167-
161+
// Save off the source
162+
let source = source_id.load(self.config);
168163
if kind == Kind::Override {
169164
self.overrides.push(source_id.clone());
170165
}
171-
172-
// Save off the source
173166
self.add_source(source_id, source, kind);
174167

175-
Ok(())
168+
// Ensure the source has fetched all necessary remote data.
169+
let _p = profile::start(format!("updating: {}", source_id));
170+
self.sources.get_mut(source_id).unwrap().update()
176171
}).chain_error(|| human(format!("Unable to update {}", source_id)))
177172
}
178173

@@ -270,18 +265,16 @@ impl<'cfg> PackageRegistry<'cfg> {
270265

271266
impl<'cfg> Registry for PackageRegistry<'cfg> {
272267
fn query(&mut self, dep: &Dependency) -> CargoResult<Vec<Summary>> {
273-
let overrides = try!(self.query_overrides(dep));
268+
let overrides = try!(self.query_overrides(&dep));
274269

275270
let ret = if overrides.is_empty() {
276271
// Ensure the requested source_id is loaded
277272
try!(self.ensure_loaded(dep.source_id(), Kind::Normal));
278-
let mut ret = Vec::new();
279-
for (id, src) in self.sources.sources_mut() {
280-
if id == dep.source_id() {
281-
ret.extend(try!(src.query(dep)).into_iter());
282-
}
273+
274+
match self.sources.get_mut(dep.source_id()) {
275+
Some(src) => try!(src.query(&dep)),
276+
None => Vec::new(),
283277
}
284-
ret
285278
} else {
286279
overrides
287280
};

src/cargo/core/resolver/encode.rs

+43-21
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,23 @@ impl EncodableResolve {
2626

2727
let mut g = Graph::new();
2828
let mut tmp = HashMap::new();
29+
let mut replacements = HashMap::new();
2930

3031
let packages = Vec::new();
3132
let packages = self.package.as_ref().unwrap_or(&packages);
3233

33-
let root = try!(to_package_id(&self.root.name,
34-
&self.root.version,
35-
self.root.source.as_ref(),
36-
default, &path_deps));
37-
let ids = try!(packages.iter().map(|p| {
38-
to_package_id(&p.name, &p.version, p.source.as_ref(),
34+
let id2pkgid = |id: &EncodablePackageId| {
35+
to_package_id(&id.name, &id.version, id.source.as_ref(),
3936
default, &path_deps)
40-
}).collect::<CargoResult<Vec<_>>>());
37+
};
38+
let dep2pkgid = |dep: &EncodableDependency| {
39+
to_package_id(&dep.name, &dep.version, dep.source.as_ref(),
40+
default, &path_deps)
41+
};
42+
43+
let root = try!(dep2pkgid(&self.root));
44+
let ids = try!(packages.iter().map(&dep2pkgid)
45+
.collect::<CargoResult<Vec<_>>>());
4146

4247
{
4348
let mut register_pkg = |pkgid: &PackageId| {
@@ -57,16 +62,22 @@ impl EncodableResolve {
5762
{
5863
let mut add_dependencies = |id: &PackageId, pkg: &EncodableDependency|
5964
-> CargoResult<()> {
65+
if let Some(ref replace) = pkg.replace {
66+
let replace = try!(id2pkgid(replace));
67+
let replace_precise = tmp.get(&replace).map(|p| {
68+
replace.with_precise(p.clone())
69+
}).unwrap_or(replace);
70+
replacements.insert(id.clone(), replace_precise);
71+
assert!(pkg.dependencies.is_none());
72+
return Ok(())
73+
}
74+
6075
let deps = match pkg.dependencies {
6176
Some(ref deps) => deps,
6277
None => return Ok(()),
6378
};
6479
for edge in deps.iter() {
65-
let to_depend_on = try!(to_package_id(&edge.name,
66-
&edge.version,
67-
edge.source.as_ref(),
68-
default,
69-
&path_deps));
80+
let to_depend_on = try!(id2pkgid(edge));
7081
let precise_pkgid =
7182
tmp.get(&to_depend_on)
7283
.map(|p| to_depend_on.with_precise(p.clone()))
@@ -87,6 +98,7 @@ impl EncodableResolve {
8798
root: root,
8899
features: HashMap::new(),
89100
metadata: self.metadata.clone(),
101+
replacements: replacements,
90102
})
91103
}
92104
}
@@ -136,7 +148,8 @@ pub struct EncodableDependency {
136148
name: String,
137149
version: String,
138150
source: Option<SourceId>,
139-
dependencies: Option<Vec<EncodablePackageId>>
151+
dependencies: Option<Vec<EncodablePackageId>>,
152+
replace: Option<EncodablePackageId>,
140153
}
141154

142155
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq)]
@@ -186,24 +199,32 @@ impl Encodable for Resolve {
186199
let encodable = ids.iter().filter_map(|&id| {
187200
if self.root == *id { return None; }
188201

189-
Some(encodable_resolve_node(id, &self.graph))
202+
Some(encodable_resolve_node(id, self))
190203
}).collect::<Vec<EncodableDependency>>();
191204

192205
EncodableResolve {
193206
package: Some(encodable),
194-
root: encodable_resolve_node(&self.root, &self.graph),
207+
root: encodable_resolve_node(&self.root, self),
195208
metadata: self.metadata.clone(),
196209
}.encode(s)
197210
}
198211
}
199212

200-
fn encodable_resolve_node(id: &PackageId, graph: &Graph<PackageId>)
213+
fn encodable_resolve_node(id: &PackageId, resolve: &Resolve)
201214
-> EncodableDependency {
202-
let deps = graph.edges(id).map(|edge| {
203-
let mut deps = edge.map(encodable_package_id).collect::<Vec<_>>();
204-
deps.sort();
205-
deps
206-
});
215+
let (replace, deps) = match resolve.replacement(id) {
216+
Some(id) => {
217+
(Some(encodable_package_id(id)), None)
218+
}
219+
None => {
220+
let mut deps = resolve.graph.edges(id)
221+
.into_iter().flat_map(|a| a)
222+
.map(encodable_package_id)
223+
.collect::<Vec<_>>();
224+
deps.sort();
225+
(None, Some(deps))
226+
}
227+
};
207228

208229
let source = if id.source_id().is_path() {
209230
None
@@ -216,6 +237,7 @@ fn encodable_resolve_node(id: &PackageId, graph: &Graph<PackageId>)
216237
version: id.version().to_string(),
217238
source: source,
218239
dependencies: deps,
240+
replace: replace,
219241
}
220242
}
221243

0 commit comments

Comments
 (0)