Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation and CLI-support for --all-$KIND flags #3901

Merged
merged 7 commits into from
Apr 24, 2017
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
16 changes: 12 additions & 4 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ pub struct Options {
flag_message_format: MessageFormat,
flag_lib: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_example: Vec<String>,
flag_examples: bool,
flag_test: Vec<String>,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
flag_frozen: bool,
flag_locked: bool,
arg_args: Vec<String>,
Expand All @@ -37,9 +41,13 @@ Options:
-h, --help Print this message
--lib Benchmark only this package's library
--bin NAME Benchmark only the specified binary
--bins Benchmark all binaries
--example NAME Benchmark only the specified example
--examples Benchmark all examples
--test NAME Benchmark only the specified test target
--tests Benchmark all tests
--bench NAME Benchmark only the specified bench target
--benches Benchmark all benches
--no-run Compile, but don't run benchmarks
-p SPEC, --package SPEC ... Package to run benchmarks for
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
Expand Down Expand Up @@ -92,10 +100,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
release: true,
mode: ops::CompileMode::Bench,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&options.flag_test,
&options.flag_example,
&options.flag_bench),
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
&options.flag_bench, options.flag_benches,),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
Expand Down
18 changes: 13 additions & 5 deletions src/bin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ pub struct Options {
flag_release: bool,
flag_lib: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_example: Vec<String>,
flag_examples: bool,
flag_test: Vec<String>,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
flag_locked: bool,
flag_frozen: bool,
flag_all: bool,
Expand All @@ -42,9 +46,13 @@ Options:
-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
--bins Build all binaries
--example NAME Build only the specified example
--examples Build all examples
--test NAME Build only the specified test target
--bench NAME Build only the specified benchmark target
--tests Build all tests
--bench NAME Build only the specified bench target
--benches Build all benches
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--all-features Build all available features
Expand Down Expand Up @@ -99,10 +107,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
mode: ops::CompileMode::Build,
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&options.flag_test,
&options.flag_example,
&options.flag_bench),
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
&options.flag_bench, options.flag_benches,),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
Expand Down
18 changes: 13 additions & 5 deletions src/bin/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ Options:
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
--lib Check only this package's library
--bin NAME Check only the specified binary
--bins Check all binaries
--example NAME Check only the specified example
--examples Check all examples
--test NAME Check only the specified test target
--bench NAME Check only the specified benchmark target
--tests Check all tests
--bench NAME Check only the specified bench target
--benches Check all benches
--release Check artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also check
--all-features Check all available features
Expand Down Expand Up @@ -60,9 +64,13 @@ pub struct Options {
flag_release: bool,
flag_lib: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_example: Vec<String>,
flag_examples: bool,
flag_test: Vec<String>,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
flag_locked: bool,
flag_frozen: bool,
flag_all: bool,
Expand Down Expand Up @@ -98,10 +106,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
mode: ops::CompileMode::Check,
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&options.flag_test,
&options.flag_example,
&options.flag_bench),
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
&options.flag_bench, options.flag_benches,),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: None,
Expand Down
10 changes: 6 additions & 4 deletions src/bin/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct Options {
flag_package: Vec<String>,
flag_lib: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_frozen: bool,
flag_locked: bool,
flag_all: bool,
Expand All @@ -41,6 +42,7 @@ Options:
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
--lib Document only this package's library
--bin NAME Document only the specified binary
--bins Document all binaries
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--all-features Build all available features
Expand Down Expand Up @@ -93,10 +95,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
no_default_features: options.flag_no_default_features,
spec: spec,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&empty,
&empty,
&empty),
&options.flag_bin, options.flag_bins,
&empty, false,
&empty, false,
&empty, false),
message_format: options.flag_message_format,
release: options.flag_release,
mode: ops::CompileMode::Doc {
Expand Down
15 changes: 11 additions & 4 deletions src/bin/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ pub struct Options {
flag_no_default_features: bool,
flag_debug: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_example: Vec<String>,
flag_examples: bool,
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
Expand Down Expand Up @@ -54,8 +56,10 @@ Build and install options:
--all-features Build all available features
--no-default-features Do not build the `default` feature
--debug Build in debug mode instead of release mode
--bin NAME Only install the binary NAME
--example EXAMPLE Install the example EXAMPLE instead of binaries
--bin NAME Install only the specified binary
--bins Install all binaries
--example NAME Install only the specified example
--examples Install all examples
--root DIR Directory to install packages into
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet Less output printed to stdout
Expand Down Expand Up @@ -111,8 +115,11 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
spec: ops::Packages::Packages(&[]),
mode: ops::CompileMode::Build,
release: !options.flag_debug,
filter: ops::CompileFilter::new(false, &options.flag_bin, &[],
&options.flag_example, &[]),
filter: ops::CompileFilter::new(false,
&options.flag_bin, options.flag_bins,
&[], false,
&options.flag_example, options.flag_examples,
&[], false),
message_format: ops::MessageFormat::Human,
target_rustc_args: None,
target_rustdoc_args: None,
Expand Down
9 changes: 5 additions & 4 deletions src/bin/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
filter: if examples.is_empty() && bins.is_empty() {
ops::CompileFilter::Everything { required_features_filterable: false, }
} else {
ops::CompileFilter::Only {
lib: false, tests: &[], benches: &[],
bins: &bins, examples: &examples,
}
ops::CompileFilter::new(false,
&bins, false,
&[], false,
&examples, false,
&[], false)
},
message_format: options.flag_message_format,
target_rustdoc_args: None,
Expand Down
18 changes: 13 additions & 5 deletions src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ pub struct Options {
flag_release: bool,
flag_lib: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_example: Vec<String>,
flag_examples: bool,
flag_test: Vec<String>,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
flag_profile: Option<String>,
flag_frozen: bool,
flag_locked: bool,
Expand All @@ -42,9 +46,13 @@ Options:
-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
--bins Build all binaries
--example NAME Build only the specified example
--examples Build all examples
--test NAME Build only the specified test target
--bench NAME Build only the specified benchmark target
--tests Build all tests
--bench NAME Build only the specified bench target
--benches Build all benches
--release Build artifacts in release mode, with optimizations
--profile PROFILE Profile to build the selected target for
--features FEATURES Features to compile for the package
Expand Down Expand Up @@ -109,10 +117,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
mode: mode,
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&options.flag_test,
&options.flag_example,
&options.flag_bench),
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
&options.flag_bench, options.flag_benches,),
message_format: options.flag_message_format,
target_rustdoc_args: None,
target_rustc_args: options.arg_opts.as_ref().map(|a| &a[..]),
Expand Down
18 changes: 13 additions & 5 deletions src/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ pub struct Options {
flag_package: Option<String>,
flag_lib: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_example: Vec<String>,
flag_examples: bool,
flag_test: Vec<String>,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
flag_frozen: bool,
flag_locked: bool,
}
Expand All @@ -41,9 +45,13 @@ Options:
-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
--bins Build all binaries
--example NAME Build only the specified example
--examples Build all examples
--test NAME Build only the specified test target
--bench NAME Build only the specified benchmark target
--tests Build all tests
--bench NAME Build only the specified bench target
--benches Build all benches
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--all-features Build all available features
Expand Down Expand Up @@ -94,10 +102,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
spec: Packages::Packages(&spec),
release: options.flag_release,
filter: ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&options.flag_test,
&options.flag_example,
&options.flag_bench),
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
&options.flag_bench, options.flag_benches,),
message_format: options.flag_message_format,
mode: ops::CompileMode::Doc { deps: false },
target_rustdoc_args: Some(&options.arg_opts),
Expand Down
25 changes: 17 additions & 8 deletions src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ pub struct Options {
flag_lib: bool,
flag_doc: bool,
flag_bin: Vec<String>,
flag_bins: bool,
flag_example: Vec<String>,
flag_examples: bool,
flag_test: Vec<String>,
flag_tests: bool,
flag_bench: Vec<String>,
flag_benches: bool,
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
Expand All @@ -41,10 +45,14 @@ Options:
-h, --help Print this message
--lib Test only this package's library
--doc Test only this library's documentation
--bin NAME ... Test only the specified binaries
--bin NAME ... Test only the specified binary
--bins Test all binaries
--example NAME ... Check that the specified examples compile
--test NAME ... Test only the specified integration test targets
--bench NAME ... Test only the specified benchmark targets
--examples Check that all examples compile
--test NAME ... Test only the specified test target
--tests Test all tests
--bench NAME ... Test only the specified bench target
--benches Test all benches
--no-run Compile, but don't run tests
-p SPEC, --package SPEC ... Package to run tests for
--all Test all packages in the workspace
Expand Down Expand Up @@ -106,14 +114,15 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
let (mode, filter);
if options.flag_doc {
mode = ops::CompileMode::Doctest;
filter = ops::CompileFilter::new(true, &empty, &empty, &empty, &empty);
filter = ops::CompileFilter::new(true, &empty, false, &empty, false,
&empty, false, &empty, false);
} else {
mode = ops::CompileMode::Test;
filter = ops::CompileFilter::new(options.flag_lib,
&options.flag_bin,
&options.flag_test,
&options.flag_example,
&options.flag_bench);
&options.flag_bin, options.flag_bins,
&options.flag_test, options.flag_tests,
&options.flag_example, options.flag_examples,
&options.flag_bench, options.flag_benches);
}

let spec = if options.flag_all {
Expand Down
8 changes: 8 additions & 0 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,14 @@ impl Target {
}
}

pub fn is_bin_example(&self) -> bool {
// Needed for --all-examples in contexts where only runnable examples make sense
match self.kind {
TargetKind::ExampleBin => true,
_ => false
}
}

pub fn is_test(&self) -> bool { self.kind == TargetKind::Test }
pub fn is_bench(&self) -> bool { self.kind == TargetKind::Bench }
pub fn is_custom_build(&self) -> bool { self.kind == TargetKind::CustomBuild }
Expand Down
Loading