|
1 | 1 | use cargo::ops;
|
2 |
| -use cargo::core::manifest::TargetKind; |
3 |
| -use cargo::util::{CliResult, CliError, human, Config}; |
| 2 | +use cargo::util::{CliResult, CliError, Config}; |
4 | 3 | use cargo::util::important_paths::{find_root_manifest_for_cwd};
|
5 | 4 |
|
6 | 5 | #[derive(RustcDecodable)]
|
@@ -47,36 +46,35 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
|
47 | 46 | config.shell().set_verbose(options.flag_verbose);
|
48 | 47 | let root = try!(find_root_manifest_for_cwd(options.flag_manifest_path));
|
49 | 48 |
|
50 |
| - let env = match (options.flag_release, options.flag_example.is_some()) { |
51 |
| - (true, _) => "release", |
52 |
| - (false, true) => "test", |
53 |
| - (false, false) => "compile" |
54 |
| - }; |
| 49 | + let (mut examples, mut bins) = (Vec::new(), Vec::new()); |
| 50 | + if let Some(s) = options.flag_bin { |
| 51 | + bins.push(s); |
| 52 | + } |
| 53 | + if let Some(s) = options.flag_example { |
| 54 | + examples.push(s); |
| 55 | + } |
55 | 56 |
|
56 | 57 | let compile_opts = ops::CompileOptions {
|
57 |
| - env: env, |
58 | 58 | config: config,
|
59 | 59 | jobs: options.flag_jobs,
|
60 | 60 | target: options.flag_target.as_ref().map(|t| &t[..]),
|
61 |
| - dev_deps: true, |
62 | 61 | features: &options.flag_features,
|
63 | 62 | no_default_features: options.flag_no_default_features,
|
64 | 63 | spec: None,
|
65 |
| - lib_only: false, |
66 | 64 | exec_engine: None,
|
67 |
| - }; |
68 |
| - |
69 |
| - let (target_kind, name) = match (options.flag_bin, options.flag_example) { |
70 |
| - (Some(bin), None) => (TargetKind::Bin, Some(bin)), |
71 |
| - (None, Some(example)) => (TargetKind::Example, Some(example)), |
72 |
| - (None, None) => (TargetKind::Bin, None), |
73 |
| - (Some(_), Some(_)) => return Err(CliError::from_boxed( |
74 |
| - human("specify either `--bin` or `--example`, not both"), 1)), |
| 65 | + release: options.flag_release, |
| 66 | + mode: ops::CompileMode::Build, |
| 67 | + filter: if examples.is_empty() && bins.is_empty() { |
| 68 | + ops::CompileFilter::Everything |
| 69 | + } else { |
| 70 | + ops::CompileFilter::Only { |
| 71 | + lib: false, tests: &[], benches: &[], |
| 72 | + bins: &bins, examples: &examples, |
| 73 | + } |
| 74 | + }, |
75 | 75 | };
|
76 | 76 |
|
77 | 77 | let err = try!(ops::run(&root,
|
78 |
| - target_kind, |
79 |
| - name, |
80 | 78 | &compile_opts,
|
81 | 79 | &options.arg_args).map_err(|err| {
|
82 | 80 | CliError::from_boxed(err, 101)
|
|
0 commit comments