Skip to content

Commit c2e1110

Browse files
committed
Auto merge of #7270 - ehuss:default-members-root-only, r=ehuss
Only apply default-members when building root manifest This is a reopening of #6755 rebased on master. Closes #5932
2 parents 93660b0 + 6ea762c commit c2e1110

File tree

15 files changed

+211
-86
lines changed

15 files changed

+211
-86
lines changed

src/cargo/core/workspace.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,15 @@ impl<'cfg> Workspace<'cfg> {
452452
WorkspaceConfig::Root(ref root_config) => {
453453
members_paths = root_config
454454
.members_paths(root_config.members.as_ref().unwrap_or(&vec![]))?;
455-
default_members_paths = if let Some(ref default) = root_config.default_members {
456-
Some(root_config.members_paths(default)?)
455+
default_members_paths = if root_manifest_path == self.current_manifest {
456+
if let Some(ref default) = root_config.default_members {
457+
Some(root_config.members_paths(default)?)
458+
} else {
459+
None
460+
}
457461
} else {
458462
None
459-
}
463+
};
460464
}
461465
_ => failure::bail!(
462466
"root of a workspace inferred but wasn't a root: {}",

src/doc/man/generated/cargo-bench.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,16 @@ <h3 id="cargo_bench_benchmark_options">Benchmark Options</h3>
6969
<h3 id="cargo_bench_package_selection">Package Selection</h3>
7070
<div class="paragraph">
7171
<p>By default, when no package selection options are given, the packages selected
72-
depend on the current working directory. In the root of a virtual workspace,
73-
all workspace members are selected (<code>--all</code> is implied). Otherwise, only the
74-
package in the current directory will be selected. The default packages may be
75-
overridden with the <code>workspace.default-members</code> key in the root <code>Cargo.toml</code>
76-
manifest.</p>
72+
depend on the selected manifest file (based on the current working directory if
73+
<code>--manifest-path</code> is not given). If the manifest is the root of a workspace then
74+
the workspaces default members are selected, otherwise only the package defined
75+
by the manifest will be selected.</p>
76+
</div>
77+
<div class="paragraph">
78+
<p>The default members of a workspace can be set explicitly with the
79+
<code>workspace.default-members</code> key in the root manifest. If this is not set, a
80+
virtual workspace will include all workspace members (equivalent to passing
81+
<code>--all</code>), and a non-virtual workspace will include only the root crate itself.</p>
7782
</div>
7883
<div class="dlist">
7984
<dl>

src/doc/man/generated/cargo-build.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ <h2 id="cargo_build_options">OPTIONS</h2>
2525
<h3 id="cargo_build_package_selection">Package Selection</h3>
2626
<div class="paragraph">
2727
<p>By default, when no package selection options are given, the packages selected
28-
depend on the current working directory. In the root of a virtual workspace,
29-
all workspace members are selected (<code>--all</code> is implied). Otherwise, only the
30-
package in the current directory will be selected. The default packages may be
31-
overridden with the <code>workspace.default-members</code> key in the root <code>Cargo.toml</code>
32-
manifest.</p>
28+
depend on the selected manifest file (based on the current working directory if
29+
<code>--manifest-path</code> is not given). If the manifest is the root of a workspace then
30+
the workspaces default members are selected, otherwise only the package defined
31+
by the manifest will be selected.</p>
32+
</div>
33+
<div class="paragraph">
34+
<p>The default members of a workspace can be set explicitly with the
35+
<code>workspace.default-members</code> key in the root manifest. If this is not set, a
36+
virtual workspace will include all workspace members (equivalent to passing
37+
<code>--all</code>), and a non-virtual workspace will include only the root crate itself.</p>
3338
</div>
3439
<div class="dlist">
3540
<dl>

src/doc/man/generated/cargo-check.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ <h2 id="cargo_check_options">OPTIONS</h2>
2929
<h3 id="cargo_check_package_selection">Package Selection</h3>
3030
<div class="paragraph">
3131
<p>By default, when no package selection options are given, the packages selected
32-
depend on the current working directory. In the root of a virtual workspace,
33-
all workspace members are selected (<code>--all</code> is implied). Otherwise, only the
34-
package in the current directory will be selected. The default packages may be
35-
overridden with the <code>workspace.default-members</code> key in the root <code>Cargo.toml</code>
36-
manifest.</p>
32+
depend on the selected manifest file (based on the current working directory if
33+
<code>--manifest-path</code> is not given). If the manifest is the root of a workspace then
34+
the workspaces default members are selected, otherwise only the package defined
35+
by the manifest will be selected.</p>
36+
</div>
37+
<div class="paragraph">
38+
<p>The default members of a workspace can be set explicitly with the
39+
<code>workspace.default-members</code> key in the root manifest. If this is not set, a
40+
virtual workspace will include all workspace members (equivalent to passing
41+
<code>--all</code>), and a non-virtual workspace will include only the root crate itself.</p>
3742
</div>
3843
<div class="dlist">
3944
<dl>

src/doc/man/generated/cargo-doc.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ <h3 id="cargo_doc_documentation_options">Documentation Options</h3>
4545
<h3 id="cargo_doc_package_selection">Package Selection</h3>
4646
<div class="paragraph">
4747
<p>By default, when no package selection options are given, the packages selected
48-
depend on the current working directory. In the root of a virtual workspace,
49-
all workspace members are selected (<code>--all</code> is implied). Otherwise, only the
50-
package in the current directory will be selected. The default packages may be
51-
overridden with the <code>workspace.default-members</code> key in the root <code>Cargo.toml</code>
52-
manifest.</p>
48+
depend on the selected manifest file (based on the current working directory if
49+
<code>--manifest-path</code> is not given). If the manifest is the root of a workspace then
50+
the workspaces default members are selected, otherwise only the package defined
51+
by the manifest will be selected.</p>
52+
</div>
53+
<div class="paragraph">
54+
<p>The default members of a workspace can be set explicitly with the
55+
<code>workspace.default-members</code> key in the root manifest. If this is not set, a
56+
virtual workspace will include all workspace members (equivalent to passing
57+
<code>--all</code>), and a non-virtual workspace will include only the root crate itself.</p>
5358
</div>
5459
<div class="dlist">
5560
<dl>

src/doc/man/generated/cargo-fix.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,16 @@ <h3 id="cargo_fix_fix_options">Fix options</h3>
100100
<h3 id="cargo_fix_package_selection">Package Selection</h3>
101101
<div class="paragraph">
102102
<p>By default, when no package selection options are given, the packages selected
103-
depend on the current working directory. In the root of a virtual workspace,
104-
all workspace members are selected (<code>--all</code> is implied). Otherwise, only the
105-
package in the current directory will be selected. The default packages may be
106-
overridden with the <code>workspace.default-members</code> key in the root <code>Cargo.toml</code>
107-
manifest.</p>
103+
depend on the selected manifest file (based on the current working directory if
104+
<code>--manifest-path</code> is not given). If the manifest is the root of a workspace then
105+
the workspaces default members are selected, otherwise only the package defined
106+
by the manifest will be selected.</p>
107+
</div>
108+
<div class="paragraph">
109+
<p>The default members of a workspace can be set explicitly with the
110+
<code>workspace.default-members</code> key in the root manifest. If this is not set, a
111+
virtual workspace will include all workspace members (equivalent to passing
112+
<code>--all</code>), and a non-virtual workspace will include only the root crate itself.</p>
108113
</div>
109114
<div class="dlist">
110115
<dl>

src/doc/man/generated/cargo-test.html

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,16 @@ <h3 id="cargo_test_test_options">Test Options</h3>
7575
<h3 id="cargo_test_package_selection">Package Selection</h3>
7676
<div class="paragraph">
7777
<p>By default, when no package selection options are given, the packages selected
78-
depend on the current working directory. In the root of a virtual workspace,
79-
all workspace members are selected (<code>--all</code> is implied). Otherwise, only the
80-
package in the current directory will be selected. The default packages may be
81-
overridden with the <code>workspace.default-members</code> key in the root <code>Cargo.toml</code>
82-
manifest.</p>
78+
depend on the selected manifest file (based on the current working directory if
79+
<code>--manifest-path</code> is not given). If the manifest is the root of a workspace then
80+
the workspaces default members are selected, otherwise only the package defined
81+
by the manifest will be selected.</p>
82+
</div>
83+
<div class="paragraph">
84+
<p>The default members of a workspace can be set explicitly with the
85+
<code>workspace.default-members</code> key in the root manifest. If this is not set, a
86+
virtual workspace will include all workspace members (equivalent to passing
87+
<code>--all</code>), and a non-virtual workspace will include only the root crate itself.</p>
8388
</div>
8489
<div class="dlist">
8590
<dl>

src/doc/man/options-packages.adoc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
By default, when no package selection options are given, the packages selected
2-
depend on the current working directory. In the root of a virtual workspace,
3-
all workspace members are selected (`--all` is implied). Otherwise, only the
4-
package in the current directory will be selected. The default packages may be
5-
overridden with the `workspace.default-members` key in the root `Cargo.toml`
6-
manifest.
2+
depend on the selected manifest file (based on the current working directory if
3+
`--manifest-path` is not given). If the manifest is the root of a workspace then
4+
the workspaces default members are selected, otherwise only the package defined
5+
by the manifest will be selected.
6+
7+
The default members of a workspace can be set explicitly with the
8+
`workspace.default-members` key in the root manifest. If this is not set, a
9+
virtual workspace will include all workspace members (equivalent to passing
10+
`--all`), and a non-virtual workspace will include only the root crate itself.
711

812
*-p* _SPEC_...::
913
*--package* _SPEC_...::

src/etc/man/cargo-bench.1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'\" t
22
.\" Title: cargo-bench
33
.\" Author: [see the "AUTHOR(S)" section]
4-
.\" Generator: Asciidoctor 2.0.8
5-
.\" Date: 2019-06-07
4+
.\" Generator: Asciidoctor 2.0.10
5+
.\" Date: 2019-08-19
66
.\" Manual: \ \&
77
.\" Source: \ \&
88
.\" Language: English
99
.\"
10-
.TH "CARGO\-BENCH" "1" "2019-06-07" "\ \&" "\ \&"
10+
.TH "CARGO\-BENCH" "1" "2019-08-19" "\ \&" "\ \&"
1111
.ie \n(.g .ds Aq \(aq
1212
.el .ds Aq '
1313
.ss \n[.ss] 0
@@ -77,11 +77,15 @@ the executable as a whole.
7777
.SS "Package Selection"
7878
.sp
7979
By default, when no package selection options are given, the packages selected
80-
depend on the current working directory. In the root of a virtual workspace,
81-
all workspace members are selected (\fB\-\-all\fP is implied). Otherwise, only the
82-
package in the current directory will be selected. The default packages may be
83-
overridden with the \fBworkspace.default\-members\fP key in the root \fBCargo.toml\fP
84-
manifest.
80+
depend on the selected manifest file (based on the current working directory if
81+
\fB\-\-manifest\-path\fP is not given). If the manifest is the root of a workspace then
82+
the workspaces default members are selected, otherwise only the package defined
83+
by the manifest will be selected.
84+
.sp
85+
The default members of a workspace can be set explicitly with the
86+
\fBworkspace.default\-members\fP key in the root manifest. If this is not set, a
87+
virtual workspace will include all workspace members (equivalent to passing
88+
\fB\-\-all\fP), and a non\-virtual workspace will include only the root crate itself.
8589
.sp
8690
\fB\-p\fP \fISPEC\fP..., \fB\-\-package\fP \fISPEC\fP...
8791
.RS 4

src/etc/man/cargo-build.1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'\" t
22
.\" Title: cargo-build
33
.\" Author: [see the "AUTHOR(S)" section]
4-
.\" Generator: Asciidoctor 2.0.8
5-
.\" Date: 2019-06-07
4+
.\" Generator: Asciidoctor 2.0.10
5+
.\" Date: 2019-08-19
66
.\" Manual: \ \&
77
.\" Source: \ \&
88
.\" Language: English
99
.\"
10-
.TH "CARGO\-BUILD" "1" "2019-06-07" "\ \&" "\ \&"
10+
.TH "CARGO\-BUILD" "1" "2019-08-19" "\ \&" "\ \&"
1111
.ie \n(.g .ds Aq \(aq
1212
.el .ds Aq '
1313
.ss \n[.ss] 0
@@ -39,11 +39,15 @@ Compile local packages and all of their dependencies.
3939
.SS "Package Selection"
4040
.sp
4141
By default, when no package selection options are given, the packages selected
42-
depend on the current working directory. In the root of a virtual workspace,
43-
all workspace members are selected (\fB\-\-all\fP is implied). Otherwise, only the
44-
package in the current directory will be selected. The default packages may be
45-
overridden with the \fBworkspace.default\-members\fP key in the root \fBCargo.toml\fP
46-
manifest.
42+
depend on the selected manifest file (based on the current working directory if
43+
\fB\-\-manifest\-path\fP is not given). If the manifest is the root of a workspace then
44+
the workspaces default members are selected, otherwise only the package defined
45+
by the manifest will be selected.
46+
.sp
47+
The default members of a workspace can be set explicitly with the
48+
\fBworkspace.default\-members\fP key in the root manifest. If this is not set, a
49+
virtual workspace will include all workspace members (equivalent to passing
50+
\fB\-\-all\fP), and a non\-virtual workspace will include only the root crate itself.
4751
.sp
4852
\fB\-p\fP \fISPEC\fP..., \fB\-\-package\fP \fISPEC\fP...
4953
.RS 4

0 commit comments

Comments
 (0)