Skip to content

Commit

Permalink
Proper building virtual manifest with -p flag
Browse files Browse the repository at this point in the history
  • Loading branch information
debris committed Jul 27, 2017
1 parent 15791c7 commit 33431d7
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 272 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ src/registry/Cargo.lock
rustc
__pycache__
.idea/
*.iml
*.iml
*.swp
11 changes: 4 additions & 7 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;

let spec = if options.flag_all || ws.is_virtual() {
Packages::All
} else {
Packages::from_flags(options.flag_all,
&options.flag_exclude,
&options.flag_package)?
};
let spec = Packages::from_flags(ws.is_virtual(),
options.flag_all,
&options.flag_exclude,
&options.flag_package)?;

let ops = ops::TestOptions {
no_run: options.flag_no_run,
Expand Down
11 changes: 4 additions & 7 deletions src/bin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;

let spec = if options.flag_all || ws.is_virtual() {
Packages::All
} else {
Packages::from_flags(options.flag_all,
&options.flag_exclude,
&options.flag_package)?
};
let spec = Packages::from_flags(ws.is_virtual(),
options.flag_all,
&options.flag_exclude,
&options.flag_package)?;

let opts = CompileOptions {
config: config,
Expand Down
11 changes: 4 additions & 7 deletions src/bin/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;

let spec = if options.flag_all || ws.is_virtual() {
Packages::All
} else {
Packages::from_flags(options.flag_all,
&options.flag_exclude,
&options.flag_package)?
};
let spec = Packages::from_flags(ws.is_virtual(),
options.flag_all,
&options.flag_exclude,
&options.flag_package)?;

let opts = CompileOptions {
config: config,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
let root = find_root_manifest_for_wd(options.flag_manifest_path, config.cwd())?;
let ws = Workspace::new(&root, config)?;

let spec = if options.flag_all || ws.is_virtual() {
let spec = if options.flag_all || (ws.is_virtual() && options.flag_package.is_empty()) {
Packages::All
} else {
Packages::Packages(&options.flag_package)
Expand Down
11 changes: 4 additions & 7 deletions src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,10 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
&options.flag_bench, options.flag_benches);
}

let spec = if options.flag_all || ws.is_virtual() {
Packages::All
} else {
Packages::from_flags(options.flag_all,
&options.flag_exclude,
&options.flag_package)?
};
let spec = Packages::from_flags(ws.is_virtual(),
options.flag_all,
&options.flag_exclude,
&options.flag_package)?;

let ops = ops::TestOptions {
no_run: options.flag_no_run,
Expand Down
4 changes: 3 additions & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ pub enum Packages<'a> {
}

impl<'a> Packages<'a> {
pub fn from_flags(all: bool, exclude: &'a Vec<String>, package: &'a Vec<String>)
pub fn from_flags(virtual_ws: bool, all: bool, exclude: &'a Vec<String>, package: &'a Vec<String>)
-> CargoResult<Self>
{
let all = all || (virtual_ws && package.is_empty());

let packages = match (all, &exclude) {
(true, exclude) if exclude.is_empty() => Packages::All,
(true, exclude) => Packages::OptOut(exclude),
Expand Down
Loading

0 comments on commit 33431d7

Please sign in to comment.