Rename cargo-compile to cargo-build

This commit is contained in:
Yehuda Katz 2014-06-23 19:09:12 -07:00
parent 5919fa0dfc
commit eb6b0d6281
7 changed files with 45 additions and 51 deletions

View file

@ -4,7 +4,7 @@ DESTDIR ?= /usr/local
# Link flags to pull in dependencies
BINS = cargo \
cargo-compile \
cargo-build \
cargo-read-manifest \
cargo-rustc \
cargo-verify-project \

View file

@ -1,4 +1,4 @@
#![crate_id="cargo-compile"]
#![crate_id="cargo-build"]
#![feature(phase)]
extern crate cargo;
@ -24,7 +24,7 @@ pub struct Options {
update_remotes: bool
}
hammer_config!(Options "Compile the current project", |c| {
hammer_config!(Options "Build the current project", |c| {
c.short("update_remotes", 'u')
})

View file

@ -32,10 +32,7 @@ struct ProjectLocation {
fn execute() {
debug!("executing; cmd=cargo; args={}", os::args());
let (cmd, args) = match process(os::args()) {
Ok((cmd, args)) => (cmd, args),
Err(err) => return handle_error(err, &mut shell(false))
};
let (cmd, args) = process(os::args());
match cmd.as_slice() {
"config-for-key" => {
@ -52,7 +49,7 @@ fn execute() {
},
"--help" | "-h" | "help" | "-?" => {
println!("Commands:");
println!(" compile # compile the current project\n");
println!(" build # compile the current project\n");
let (_, options) = hammer::usage::<GlobalFlags>(false);
println!("Options (for all commands):\n\n{}", options);
@ -76,14 +73,11 @@ fn execute() {
}
}
fn process(args: Vec<String>) -> CliResult<(String, Vec<String>)> {
let args: Vec<String> = Vec::from_slice(args.tail());
let head = try!(args.iter().nth(0).require(|| {
human("No subcommand found")
}).map_err(|err| CliError::from_boxed(err, 1))).to_str();
let tail = Vec::from_slice(args.tail());
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());
Ok((head, tail))
(head, args)
}
#[deriving(Encodable)]

View file

@ -3,7 +3,7 @@ use std::io;
use std::io::{File, IoError};
use std::str;
use core::{MultiShell, Package, PackageSet, Target};
use core::{Package, PackageSet, Target};
use util;
use util::{CargoResult, ChainError, ProcessBuilder, internal, human, CargoError};
use util::{Config};

View file

@ -30,7 +30,7 @@ test!(cargo_compile_simple {
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice());
assert_that(p.cargo_process("cargo-compile"), execs());
assert_that(p.cargo_process("cargo-build"), execs());
assert_that(&p.root().join("target/foo"), existing_file());
let target = p.root().join("target");
@ -44,7 +44,7 @@ test!(cargo_compile_with_invalid_manifest {
let p = project("foo")
.file("Cargo.toml", "");
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs()
.with_status(101)
.with_stderr("Cargo.toml is not a valid manifest\n\n\
@ -58,7 +58,7 @@ test!(cargo_compile_with_invalid_manifest2 {
foo = bar
");
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs()
.with_status(101)
.with_stderr("could not parse input TOML\n\
@ -68,7 +68,7 @@ test!(cargo_compile_with_invalid_manifest2 {
test!(cargo_compile_without_manifest {
let p = project("foo");
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs()
.with_status(102)
.with_stderr("Could not find Cargo.toml in this directory or any \
@ -82,7 +82,7 @@ test!(cargo_compile_with_invalid_code {
let target = realpath(&p.root().join("target")).assert();
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs()
.with_status(101)
.with_stderr(format!("\
@ -101,7 +101,7 @@ test!(cargo_compile_with_warnings_in_the_root_package {
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
.file("src/foo.rs", "fn main() {} fn dead() {}");
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs()
.with_stderr("\
src/foo.rs:1:14: 1:26 warning: code is never used: `dead`, #[warn(dead_code)] \
@ -158,7 +158,7 @@ test!(cargo_compile_with_warnings_in_a_dep_package {
let bar = realpath(&p.root().join("bar")).assert();
let main = realpath(&p.root()).assert();
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs()
.with_stdout(format!("{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
@ -238,7 +238,7 @@ test!(cargo_compile_with_nested_deps_shorthand {
}
"#);
p.cargo_process("cargo-compile")
p.cargo_process("cargo-build")
.exec_with_output()
.assert();
@ -314,7 +314,7 @@ test!(cargo_compile_with_nested_deps_longhand {
}
"#);
assert_that(p.cargo_process("cargo-compile"), execs());
assert_that(p.cargo_process("cargo-build"), execs());
assert_that(&p.root().join("target/foo"), existing_file());
@ -340,7 +340,7 @@ test!(custom_build {
.file("src/foo.rs", r#"
fn main() { println!("Hello!"); }
"#);
assert_that(build.cargo_process("cargo-compile"),
assert_that(build.cargo_process("cargo-build"),
execs().with_status(0));
@ -359,7 +359,7 @@ test!(custom_build {
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_status(0)
.with_stdout(format!(" Compiling foo v0.5.0 (file:{})\n",
p.root().display()))
@ -381,7 +381,7 @@ test!(custom_build_failure {
.file("src/foo.rs", r#"
fn main() { fail!("nope") }
"#);
assert_that(build.cargo_process("cargo-compile"), execs().with_status(0));
assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
let mut p = project("foo");
@ -399,7 +399,7 @@ test!(custom_build_failure {
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_status(101).with_stderr(format!("\
Could not execute process `{}` (status=101)
--- stderr
@ -430,7 +430,7 @@ test!(custom_build_env_vars {
"#,
p.root().join("target").display(),
p.root().join("target/deps").display()));
assert_that(build.cargo_process("cargo-compile"), execs().with_status(0));
assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
p = p
@ -447,7 +447,7 @@ test!(custom_build_env_vars {
.file("src/foo.rs", r#"
fn main() {}
"#);
assert_that(p.cargo_process("cargo-compile"), execs().with_status(0));
assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
})
test!(custom_build_in_dependency {
@ -473,7 +473,7 @@ test!(custom_build_in_dependency {
"#,
p.root().join("target/deps").display(),
p.root().join("target/deps").display()));
assert_that(build.cargo_process("cargo-compile"), execs().with_status(0));
assert_that(build.cargo_process("cargo-build"), execs().with_status(0));
p = p
@ -507,7 +507,7 @@ test!(custom_build_in_dependency {
.file("bar/src/bar.rs", r#"
pub fn bar() {}
"#);
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_status(0));
})
@ -529,7 +529,7 @@ test!(many_crate_types {
.file("src/foo.rs", r#"
pub fn foo() {}
"#);
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_status(0));
let files = fs::readdir(&p.root().join("target")).assert();

View file

@ -84,7 +84,7 @@ test!(cargo_compile_simple_git_dep {
let root = project.root();
let git_root = git_project.root();
assert_that(project.cargo_process("cargo-compile"),
assert_that(project.cargo_process("cargo-build"),
execs()
.with_stdout(format!("{} git repository `file:{}`\n\
{} dep1 v0.5.0 (file:{})\n\
@ -165,7 +165,7 @@ test!(cargo_compile_with_nested_paths {
.file("src/parent.rs",
main_file(r#""{}", dep1::hello()"#, ["dep1"]).as_slice());
p.cargo_process("cargo-compile")
p.cargo_process("cargo-build")
.exec_with_output()
.assert();
@ -215,7 +215,7 @@ test!(recompilation {
main_file(r#""{}", bar::bar()"#, ["bar"]).as_slice());
// First time around we should compile both foo and bar
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_stdout(format!("{} git repository `file:{}`\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
@ -224,7 +224,7 @@ test!(recompilation {
COMPILING, p.root().display())));
// Don't recompile the second time
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
FRESH, git_project.root().display(),
@ -235,13 +235,13 @@ test!(recompilation {
pub fn bar() { println!("hello!"); }
"#).assert();
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
FRESH, git_project.root().display(),
FRESH, p.root().display())));
assert_that(p.process("cargo-compile").arg("-u"),
assert_that(p.process("cargo-build").arg("-u"),
execs().with_stdout(format!("{} git repository `file:{}`\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
@ -257,7 +257,7 @@ test!(recompilation {
git_project.process("git").args(["commit", "-m", "test"]).exec_with_output()
.assert();
assert_that(p.process("cargo-compile").arg("-u"),
assert_that(p.process("cargo-build").arg("-u"),
execs().with_stdout(format!("{} git repository `file:{}`\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",

View file

@ -72,7 +72,7 @@ test!(cargo_compile_with_nested_deps_shorthand {
}
"#);
p.cargo_process("cargo-compile")
p.cargo_process("cargo-build")
.exec_with_output()
.assert();
@ -117,20 +117,20 @@ test!(no_rebuild_dependency {
pub fn bar() {}
"#);
// First time around we should compile both foo and bar
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
COMPILING, bar.display(),
COMPILING, p.root().display())));
// This time we shouldn't compile bar
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
FRESH, bar.display(),
FRESH, p.root().display())));
p.build(); // rebuild the files (rewriting them in the process)
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
COMPILING, bar.display(),
@ -190,14 +190,14 @@ test!(deep_dependencies_trigger_rebuild {
.file("baz/src/baz.rs", r#"
pub fn baz() {}
"#);
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_stdout(format!("{} baz v0.5.0 (file:{})\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
COMPILING, baz.display(),
COMPILING, bar.display(),
COMPILING, p.root().display())));
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} baz v0.5.0 (file:{})\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
@ -213,7 +213,7 @@ test!(deep_dependencies_trigger_rebuild {
File::create(&p.root().join("baz/src/baz.rs")).write_str(r#"
pub fn baz() { println!("hello!"); }
"#).assert();
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} baz v0.5.0 (file:{})\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
@ -226,7 +226,7 @@ test!(deep_dependencies_trigger_rebuild {
extern crate baz;
pub fn bar() { println!("hello!"); baz::baz(); }
"#).assert();
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} baz v0.5.0 (file:{})\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
@ -289,14 +289,14 @@ test!(no_rebuild_two_deps {
.file("baz/src/baz.rs", r#"
pub fn baz() {}
"#);
assert_that(p.cargo_process("cargo-compile"),
assert_that(p.cargo_process("cargo-build"),
execs().with_stdout(format!("{} baz v0.5.0 (file:{})\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",
COMPILING, baz.display(),
COMPILING, bar.display(),
COMPILING, p.root().display())));
assert_that(p.process("cargo-compile"),
assert_that(p.process("cargo-build"),
execs().with_stdout(format!("{} baz v0.5.0 (file:{})\n\
{} bar v0.5.0 (file:{})\n\
{} foo v0.5.0 (file:{})\n",