};
let is_clapified = ::std::env::args().any(|arg| match arg.as_ref() {
- "build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" | "git-checkout" |
- "init" | "install" | "locate-project" | "login" | "metadata" | "new" |
- "owner" | "package" | "pkgid" | "publish" | "read-manifest" | "run" => true,
+ "build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" |
+ "git-checkout" | "init" | "install" | "locate-project" | "login" | "metadata" |
+ "new" | "owner" | "package" | "pkgid" | "publish" | "read-manifest" | "run" |
+ "rustc" => true,
_ => false
});
// $mac!(publish);
// $mac!(read_manifest);
// $mac!(run);
- $mac!(rustc);
+// $mac!(rustc);
$mac!(rustdoc);
$mac!(search);
$mac!(test);
)?;
let message_format = match args.value_of("message-format") {
- Some("json") => MessageFormat::Json,
- Some("human") | None => MessageFormat::Human,
- Some(f) => panic!("Impossible message format: {:?}", f),
+ None => MessageFormat::Human,
+ Some(f) => {
+ if f.eq_ignore_ascii_case("json") {
+ MessageFormat::Json
+ } else if f.eq_ignore_ascii_case("human") {
+ MessageFormat::Human
+ } else {
+ panic!("Impossible message format: {:?}", f)
+ }
+ }
};
let opts = CompileOptions {
}
}
}
+ ("rustc", Some(args)) => {
+ let ws = workspace_from_args(config, args)?;
+ let mode = match args.value_of("profile") {
+ Some("dev") | None => CompileMode::Build,
+ Some("test") => CompileMode::Test,
+ Some("bench") => CompileMode::Bench,
+ Some("check") => CompileMode::Check {test: false},
+ Some(mode) => {
+ let err = format_err!("unknown profile: `{}`, use dev,
+ test, or bench", mode);
+ return Err(CliError::new(err, 101))
+ }
+ };
+ let mut compile_opts = compile_options_from_args(config, args, mode)?;
+ let packages = values(args, "package");
+ compile_opts.spec = Packages::Packages(&packages);
+ compile_opts.target_rustc_args = Some(&values(args, "args"));
+ ops::compile(&ws, &compile_opts)?;
+ return Ok(());
+ }
_ => return Ok(())
}
}
publish::cli(),
read_manifest::cli(),
run::cli(),
+ rustc::cli(),
])
;
app
mod publish;
mod read_manifest;
mod run;
+mod rustc;
mod utils {
use clap::{self, SubCommand, AppSettings};
fn arg_message_format(self) -> Self {
self._arg(
opt("message-format", "Error format")
- .value_name("FMT").possible_values(&["human", "json"]).default_value("human")
+ .value_name("FMT")
+ .case_insensitive(true)
+ .possible_values(&["human", "json"]).default_value("human")
)
}
-extern crate clap;
+use clap::AppSettings;
use super::utils::*;
-use clap::AppSettings;
pub fn cli() -> App {
subcommand("run")
--- /dev/null
+use clap::AppSettings;
+
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("rustc")
+ .setting(AppSettings::TrailingVarArg)
+ .about("Compile a package and all of its dependencies")
+ .arg(Arg::with_name("args").multiple(true))
+ .arg(
+ opt("package", "Package to build")
+ .short("p").value_name("SPEC")
+ )
+ .arg_jobs()
+ .arg_targets_all(
+ "Build only this package's library",
+ "Build only the specified binary",
+ "Build all binaries",
+ "Build only the specified example",
+ "Build all examples",
+ "Build only the specified test target",
+ "Build all tests",
+ "Build only the specified bench target",
+ "Build all benches",
+ "Build all targets (lib and bin targets by default)",
+ )
+ .arg_release("Build artifacts in release mode, with optimizations")
+ .arg(
+ opt("profile", "Profile to build the selected target for")
+ .value_name("PROFILE")
+ )
+ .arg_features()
+ .arg_target_triple("Target triple which compiles will be for")
+ .arg_manifest_path()
+ .arg_message_format()
+ .after_help("\
+The specified target for the current package (or package specified by SPEC if
+provided) will be compiled along with all of its dependencies. The specified
+<args>... will all be passed to the final compiler invocation, not any of the
+dependencies. Note that the compiler will still unconditionally receive
+arguments such as -L, --extern, and --crate-type, and the specified <args>...
+will simply be added to the compiler invocation.
+
+This command requires that only one target is being compiled. If more than one
+target is available for the current package the filters of --lib, --bin, etc,
+must be used to select which target is compiled. To pass flags to all compiler
+processes spawned by Cargo, use the $RUSTFLAGS environment variable or the
+`build.rustflags` configuration option.
+")
+}
}
#[test]
+#[ignore]
fn fail_with_multiple_packages() {
let foo = project("foo")
.file("Cargo.toml", r#"