]> git.proxmox.com Git - cargo.git/commitdiff
Add support for building all members of the workspace with "build --all"
authorSebastian Dröge <sebastian@centricular.com>
Fri, 6 Jan 2017 19:52:57 +0000 (21:52 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Fri, 6 Jan 2017 19:52:57 +0000 (21:52 +0200)
https://github.com/rust-lang/cargo/issues/3491

src/bin/build.rs

index 379f49ace9b7aae5b61ce402b1fb2e9769b1ccef..9b7ffc7c0bb7b584ee346e255c9282b8d0c004f2 100644 (file)
@@ -1,7 +1,7 @@
 use std::env;
 
 use cargo::core::Workspace;
-use cargo::ops::{self, CompileOptions, MessageFormat};
+use cargo::ops::{self, CompileOptions, MessageFormat, Packages};
 use cargo::util::important_paths::{find_root_manifest_for_wd};
 use cargo::util::{CliResult, Config};
 
@@ -26,6 +26,7 @@ pub struct Options {
     flag_bench: Vec<String>,
     flag_locked: bool,
     flag_frozen: bool,
+    flag_all: bool,
 }
 
 pub const USAGE: &'static str = "
@@ -37,6 +38,7 @@ Usage:
 Options:
     -h, --help                   Print this message
     -p SPEC, --package SPEC ...  Package to build
+    --all                        Build all packages in the workspace
     -j N, --jobs N               Number of parallel jobs, defaults to # of CPUs
     --lib                        Build only this package's library
     --bin NAME                   Build only the specified binary
@@ -61,6 +63,9 @@ which indicates which package should be built. If it is not given, then the
 current package is built. For more information on SPEC and its format, see the
 `cargo help pkgid` command.
 
+All packages in the workspace are built if the `--all` flag is supplied. The
+`--all` flag may be supplied in the presence of a virtual manifest.
+
 Compilation can be configured via the use of profiles which are configured in
 the manifest. The default profile for this command is `dev`, but passing
 the --release flag will use the `release` profile instead.
@@ -77,6 +82,12 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
 
     let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
 
+    let spec = if options.flag_all {
+        Packages::All
+    } else {
+        Packages::Packages(&options.flag_package)
+    };
+
     let opts = CompileOptions {
         config: config,
         jobs: options.flag_jobs,
@@ -84,7 +95,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
         features: &options.flag_features,
         all_features: options.flag_all_features,
         no_default_features: options.flag_no_default_features,
-        spec: ops::Packages::Packages(&options.flag_package),
+        spec: spec,
         mode: ops::CompileMode::Build,
         release: options.flag_release,
         filter: ops::CompileFilter::new(options.flag_lib,