Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ ifeq ($(wildcard rustc/bin),)
export RUSTC := rustc
else
export RUSTC := $(CURDIR)/rustc/bin/rustc
export LD_LIBRARY_PATH := $(CURDIR)/rustc/lib:$(LD_LIBRARY_PATH)
export DYLD_LIBRARY_PATH := $(CURDIR)/rustc/lib:$(DYLD_LIBRARY_PATH)
endif

export PATH := $(PATH):$(CURDIR)/rustc/bin
export PATH := $(CURDIR)/rustc/bin:$(PATH)

# Link flags to pull in dependencies
BINS = cargo \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ $ ./cargo-nightly/bin/cargo build

The current nightlies available are:

* `cargo-nightly-linux`
* `cargo-nightly-win`
* `cargo-nightly-mac`
* [`cargo-nightly-linux`](http://static.rust-lang.org/cargo-dist/cargo-nightly-linux.tar.gz)
* [`cargo-nightly-win`](http://static.rust-lang.org/cargo-dist/cargo-nightly-win.tar.gz)
* [`cargo-nightly-mac`](http://static.rust-lang.org/cargo-dist/cargo-nightly-mac.tar.gz)

## Compiling cargo

Expand Down
2 changes: 1 addition & 1 deletion libs/hamcrest-rust
2 changes: 1 addition & 1 deletion libs/hammer.rs
Submodule hammer.rs updated 3 files
+1 −1 Makefile
+14 −14 src/hammer.rs
+5 −5 src/usage.rs
2 changes: 1 addition & 1 deletion libs/toml-rs
7 changes: 4 additions & 3 deletions src/bin/cargo-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ use cargo::util::important_paths::find_project_manifest;
struct Options {
manifest_path: Option<String>,
jobs: Option<uint>,
update: bool,
rest: Vec<String>,
}

hammer_config!(Options "Run the package's test suite", |c| {
c.short("jobs", 'j')
c.short("jobs", 'j').short("update", 'u')
})

fn main() {
Expand All @@ -45,7 +46,7 @@ fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
};

let compile_opts = ops::CompileOptions {
update: false,
update: options.update,
env: "test",
shell: shell,
jobs: options.jobs
Expand All @@ -64,7 +65,7 @@ fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
for file in walk {
// TODO: The proper fix is to have target knows its expected
// output and only run expected executables.
if file.display().to_str().as_slice().contains("dSYM") { continue; }
if file.display().to_string().as_slice().contains("dSYM") { continue; }
if !is_executable(&file) { continue; }

try!(util::process(file).exec().map_err(|e| {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo-verify-project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() {
}
};
let file = Path::new(manifest);
let contents = match File::open(&file).read_to_str() {
let contents = match File::open(&file).read_to_string() {
Ok(s) => s,
Err(e) => return fail("invalid", format!("error reading file: {}",
e).as_slice())
Expand Down
4 changes: 2 additions & 2 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn execute() {

fn process(args: Vec<String>) -> (String, Vec<String>) {
let mut args = Vec::from_slice(args.tail());
let head = args.shift().unwrap_or("--help".to_str());
let head = args.shift().unwrap_or("--help".to_string());

(head, args)
}
Expand Down Expand Up @@ -156,5 +156,5 @@ fn locate_project(_: NoFlags, _: &mut MultiShell) -> CliResult<Option<ProjectLoc
not representable in Unicode"))
.map_err(|e| CliError::from_boxed(e, 1)));

Ok(Some(ProjectLocation { root: string.to_str() }))
Ok(Some(ProjectLocation { root: string.to_string() }))
}
6 changes: 3 additions & 3 deletions src/cargo/core/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Dependency {
};

Ok(Dependency {
name: name.to_str(),
name: name.to_string(),
namespace: namespace.clone(),
req: version,
transitive: true
Expand Down Expand Up @@ -67,8 +67,8 @@ pub struct SerializedDependency {
impl SerializedDependency {
pub fn from_dependency(dep: &Dependency) -> SerializedDependency {
SerializedDependency {
name: dep.get_name().to_str(),
req: dep.get_version_req().to_str()
name: dep.get_name().to_string(),
req: dep.get_version_req().to_string()
}
}
}
6 changes: 3 additions & 3 deletions src/cargo/core/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub struct CLIError {
impl CLIError {
pub fn new<T: Show, U: Show>(msg: T, detail: Option<U>,
exit_code: uint) -> CLIError {
let detail = detail.map(|d| d.to_str());
CLIError { msg: msg.to_str(), detail: detail, exit_code: exit_code }
let detail = detail.map(|d| d.to_string());
CLIError { msg: msg.to_string(), detail: detail, exit_code: exit_code }
}
}

Expand Down Expand Up @@ -84,7 +84,7 @@ impl CargoError {
}

pub fn described<T: Show>(description: T) -> CargoError {
CargoInternalError(Described(description.to_str()))
CargoInternalError(Described(description.to_string()))
}

pub fn other() -> CargoError {
Expand Down
54 changes: 38 additions & 16 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ pub struct SerializedManifest {
impl<E, S: Encoder<E>> Encodable<S, E> for Manifest {
fn encode(&self, s: &mut S) -> Result<(), E> {
SerializedManifest {
name: self.summary.get_name().to_str(),
version: self.summary.get_version().to_str(),
name: self.summary.get_name().to_string(),
version: self.summary.get_version().to_string(),
dependencies: self.summary.get_dependencies().iter().map(|d| {
SerializedDependency::from_dependency(d)
}).collect(),
authors: self.authors.clone(),
targets: self.targets.clone(),
target_dir: self.target_dir.display().to_str(),
target_dir: self.target_dir.display().to_string(),
build: if self.build.len() == 0 { None } else { Some(self.build.clone()) },
}.encode(s)
}
Expand Down Expand Up @@ -100,7 +100,7 @@ pub enum TargetKind {
BinTarget
}

#[deriving(Encodable, Decodable, Clone, Hash, PartialEq)]
#[deriving(Encodable, Decodable, Clone, Hash, PartialEq, Show)]
pub struct Profile {
env: String, // compile, test, dev, bench, etc.
opt_level: uint,
Expand All @@ -112,7 +112,7 @@ pub struct Profile {
impl Profile {
pub fn default_dev() -> Profile {
Profile {
env: "compile".to_str(), // run in the default environment only
env: "compile".to_string(), // run in the default environment only
opt_level: 0,
debug: true,
test: false, // whether or not to pass --test
Expand All @@ -122,31 +122,31 @@ impl Profile {

pub fn default_test() -> Profile {
Profile {
env: "test".to_str(), // run in the default environment only
env: "test".to_string(), // run in the default environment only
opt_level: 0,
debug: true,
test: true, // whether or not to pass --test
dest: Some("test".to_str())
dest: Some("test".to_string())
}
}

pub fn default_bench() -> Profile {
Profile {
env: "bench".to_str(), // run in the default environment only
env: "bench".to_string(), // run in the default environment only
opt_level: 3,
debug: false,
test: true, // whether or not to pass --test
dest: Some("bench".to_str())
dest: Some("bench".to_string())
}
}

pub fn default_release() -> Profile {
Profile {
env: "release".to_str(), // run in the default environment only
env: "release".to_string(), // run in the default environment only
opt_level: 3,
debug: false,
test: false, // whether or not to pass --test
dest: Some("release".to_str())
dest: Some("release".to_string())
}
}

Expand Down Expand Up @@ -218,7 +218,7 @@ impl<E, S: Encoder<E>> Encodable<S, E> for Target {
SerializedTarget {
kind: kind,
name: self.name.clone(),
src_path: self.src_path.display().to_str(),
src_path: self.src_path.display().to_string(),
profile: self.profile.clone(),
metadata: self.metadata.clone()
}.encode(s)
Expand All @@ -227,8 +227,8 @@ impl<E, S: Encoder<E>> Encodable<S, E> for Target {

impl Show for Target {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}(name={}, path={})", self.kind, self.name,
self.src_path.display())
write!(f, "{}(name={}, path={}, profile={})", self.kind, self.name,
self.src_path.display(), self.profile)
}
}

Expand Down Expand Up @@ -298,14 +298,21 @@ impl Manifest {
}

impl Target {
pub fn file_stem(&self) -> String {
match self.metadata {
Some(ref metadata) => format!("{}{}", self.name, metadata.extra_filename),
None => self.name.clone()
}
}

pub fn lib_target(name: &str, crate_targets: Vec<LibKind>,
src_path: &Path, profile: &Profile,
metadata: &Metadata)
-> Target
{
Target {
kind: LibTarget(crate_targets),
name: name.to_str(),
name: name.to_string(),
src_path: src_path.clone(),
profile: profile.clone(),
metadata: Some(metadata.clone())
Expand All @@ -315,7 +322,7 @@ impl Target {
pub fn bin_target(name: &str, src_path: &Path, profile: &Profile) -> Target {
Target {
kind: BinTarget,
name: name.to_str(),
name: name.to_string(),
src_path: src_path.clone(),
profile: profile.clone(),
metadata: None
Expand All @@ -337,6 +344,21 @@ impl Target {
}
}

pub fn is_dylib(&self) -> bool {
match self.kind {
LibTarget(ref kinds) => kinds.iter().any(|&k| k == Dylib),
_ => false
}
}

pub fn is_rlib(&self) -> bool {
match self.kind {
LibTarget(ref kinds) =>
kinds.iter().any(|&k| k == Rlib || k == Lib),
_ => false
}
}

pub fn is_bin(&self) -> bool {
match self.kind {
BinTarget => true,
Expand Down
1 change: 1 addition & 0 deletions src/cargo/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub use self::dependency::{
};

pub use self::version_req::VersionReq;
pub use self::resolver::Resolve;

pub mod errors;
pub mod source;
Expand Down
8 changes: 4 additions & 4 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ impl<E, S: Encoder<E>> Encodable<S, E> for Package {
let package_id = summary.get_package_id();

SerializedPackage {
name: package_id.get_name().to_str(),
version: package_id.get_version().to_str(),
name: package_id.get_name().to_string(),
version: package_id.get_version().to_string(),
dependencies: summary.get_dependencies().iter().map(|d| {
SerializedDependency::from_dependency(d)
}).collect(),
authors: Vec::from_slice(manifest.get_authors()),
targets: Vec::from_slice(manifest.get_targets()),
manifest_path: self.manifest_path.display().to_str()
manifest_path: self.manifest_path.display().to_string()
}.encode(s)
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ impl Package {
// Sort the sources just to make sure we have a consistent fingerprint.
sources.sort_by(|a, b| {
cmp::lexical_ordering(a.kind.cmp(&b.kind),
a.location.to_str().cmp(&b.location.to_str()))
a.location.to_string().cmp(&b.location.to_string()))
});
let sources = sources.iter().map(|source_id| {
source_id.load(config)
Expand Down
22 changes: 17 additions & 5 deletions src/cargo/core/package_id.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use semver;
use url::Url;
use std::hash::Hash;
use std::fmt;
use std::fmt::{Show,Formatter};
use collections::hash;
use serialize::{
Encodable,
Encoder,
Expand Down Expand Up @@ -60,6 +62,16 @@ pub struct PackageId {
source_id: SourceId,
}

impl<S: hash::Writer> Hash<S> for PackageId {
fn hash(&self, state: &mut S) {
self.name.hash(state);
self.version.to_string().hash(state);
self.source_id.hash(state);
}
}

impl Eq for PackageId {}

#[deriving(Clone, Show, PartialEq)]
pub enum PackageIdError {
InvalidVersion(String),
Expand Down Expand Up @@ -87,7 +99,7 @@ impl PackageId {
sid: &SourceId) -> CargoResult<PackageId> {
let v = try!(version.to_version().map_err(InvalidVersion));
Ok(PackageId {
name: name.to_str(),
name: name.to_string(),
version: v,
source_id: sid.clone()
})
Expand All @@ -108,9 +120,9 @@ impl PackageId {
pub fn generate_metadata(&self) -> Metadata {
let metadata = format!("{}:-:{}:-:{}", self.name, self.version, self.source_id);
let extra_filename = short_hash(
&(self.name.as_slice(), self.version.to_str(), &self.source_id));
&(self.name.as_slice(), self.version.to_string(), &self.source_id));

Metadata { metadata: metadata, extra_filename: extra_filename }
Metadata { metadata: metadata, extra_filename: format!("-{}", extra_filename) }
}
}

Expand All @@ -120,7 +132,7 @@ impl Show for PackageId {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
try!(write!(f, "{} v{}", self.name, self.version));

if self.source_id.to_str().as_slice() != central_repo {
if self.source_id.to_string().as_slice() != central_repo {
try!(write!(f, " ({})", self.source_id));
}

Expand All @@ -141,7 +153,7 @@ impl<D: Decoder<Box<CargoError + Send>>>

impl<E, S: Encoder<E>> Encodable<S,E> for PackageId {
fn encode(&self, e: &mut S) -> Result<(), E> {
(self.name.clone(), self.version.to_str(), self.source_id.clone()).encode(e)
(self.name.clone(), self.version.to_string(), self.source_id.clone()).encode(e)
}
}

Expand Down
Loading