-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add a workspace.default-members config that overrides implied --all #4743
Changes from all commits
ba7911d
8d5e73c
499a678
1240f42
82d563b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,26 +106,23 @@ pub enum MessageFormat { | |
|
||
#[derive(Clone, Copy, PartialEq, Eq, Debug)] | ||
pub enum Packages<'a> { | ||
Default, | ||
All, | ||
OptOut(&'a [String]), | ||
Packages(&'a [String]), | ||
} | ||
|
||
impl<'a> Packages<'a> { | ||
pub fn from_flags(virtual_ws: bool, all: bool, exclude: &'a [String], package: &'a [String]) | ||
pub fn from_flags(all: bool, exclude: &'a [String], package: &'a [String]) | ||
-> CargoResult<Self> | ||
{ | ||
let all = all || (virtual_ws && package.is_empty()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bikeshedding: this could be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did that at first and found it confusing when it came to writing all the patterns. Both because of boolean overload, and because |
||
|
||
let packages = match (all, &exclude) { | ||
(true, exclude) if exclude.is_empty() => Packages::All, | ||
(true, exclude) => Packages::OptOut(exclude), | ||
(false, exclude) if !exclude.is_empty() => bail!("--exclude can only be used together \ | ||
with --all"), | ||
_ => Packages::Packages(package), | ||
}; | ||
|
||
Ok(packages) | ||
Ok(match (all, exclude.len(), package.len()) { | ||
(false, 0, 0) => Packages::Default, | ||
(false, 0, _) => Packages::Packages(package), | ||
(false, _, _) => bail!("--exclude can only be used together with --all"), | ||
(true, 0, _) => Packages::All, | ||
(true, _, _) => Packages::OptOut(exclude), | ||
}) | ||
} | ||
|
||
pub fn into_package_id_specs(self, ws: &Workspace) -> CargoResult<Vec<PackageIdSpec>> { | ||
|
@@ -152,6 +149,12 @@ impl<'a> Packages<'a> { | |
Packages::Packages(packages) => { | ||
packages.iter().map(|p| PackageIdSpec::parse(p)).collect::<CargoResult<Vec<_>>>()? | ||
} | ||
Packages::Default => { | ||
ws.default_members() | ||
.map(Package::package_id) | ||
.map(PackageIdSpec::from_package_id) | ||
.collect() | ||
} | ||
}; | ||
Ok(specs) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -520,9 +520,19 @@ crate will be treated as a normal package, as well as a workspace. If the | |
manifest*. | ||
|
||
When working with *virtual manifests*, package-related cargo commands, like | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems wrong - an earlier commit makes default-members work for non-virtual manifests too, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, I forgot about that when writing the docs. Submitted #4784, thanks. |
||
`cargo build`, won't be available anymore. But, most of such commands support | ||
the `--all` option, will execute the command for all the non-virtual manifest in | ||
the workspace. | ||
`cargo build`, default to the set of packages specified by the `default-members` | ||
configuration: | ||
|
||
```toml | ||
[workspace] | ||
members = ["path/to/member1", "path/to/member2", "path/to/member3/*"] | ||
|
||
# The members that commands like `cargo build` apply to by deault. | ||
# This must expand to a subset of `members`. | ||
# Optional key, defaults to the same as `members` | ||
# (as if `--all` were used on the command line). | ||
default-members = ["path/to/member2", "path/to/member3/*"] | ||
``` | ||
|
||
# The project layout | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍