Skip to content
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
1 change: 1 addition & 0 deletions src/doc/man/cargo-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ possible value.
{{#option "`--filter-platform` _triple_" }}
This filters the `resolve` output to only include dependencies for the
given [target triple](../appendix/glossary.html#target).
A literal `"host-tuple"` can be used, which will internally be substituted by the host's target.
Without this flag, the resolve includes all targets.

Note that the dependencies listed in the "packages" array still includes all
Expand Down
6 changes: 4 additions & 2 deletions src/doc/man/generated_txt/cargo-metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,10 @@ OPTIONS
--filter-platform triple
This filters the resolve output to only include dependencies for the
given target triple
<https://doc.rust-lang.org/cargo/appendix/glossary.html#target>.
Without this flag, the resolve includes all targets.
<https://doc.rust-lang.org/cargo/appendix/glossary.html#target>. A
literal "host-tuple" can be used, which will internally be
substituted by the host’s target. Without this flag, the resolve
includes all targets.

Note that the dependencies listed in the “packages” array still
includes all dependencies. Each package definition is intended to be
Expand Down
1 change: 1 addition & 0 deletions src/doc/src/commands/cargo-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ possible value.</p>
<dt class="option-term" id="option-cargo-metadata---filter-platform"><a class="option-anchor" href="#option-cargo-metadata---filter-platform"><code>--filter-platform</code> <em>triple</em></a></dt>
<dd class="option-desc"><p>This filters the <code>resolve</code> output to only include dependencies for the
given <a href="../appendix/glossary.html#target">target triple</a>.
A literal <code>"host-tuple"</code> can be used, which will internally be substituted by the host’s target.
Without this flag, the resolve includes all targets.</p>
<p>Note that the dependencies listed in the “packages” array still includes all
dependencies. Each package definition is intended to be an unaltered
Expand Down
1 change: 1 addition & 0 deletions src/etc/man/cargo-metadata.1
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ possible value.
.RS 4
This filters the \fBresolve\fR output to only include dependencies for the
given \fItarget triple\fR <https://doc.rust\-lang.org/cargo/appendix/glossary.html#target>\&.
A literal \fB"host\-tuple"\fR can be used, which will internally be substituted by the host\[cq]s target.
Without this flag, the resolve includes all targets.
.sp
Note that the dependencies listed in the \[lq]packages\[rq] array still includes all
Expand Down
33 changes: 19 additions & 14 deletions tests/testsuite/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3842,21 +3842,15 @@ fn filter_platform() {
.run();
clear();

// Filter on host, removes alt and cfg.
p.cargo("metadata --filter-platform")
.arg(&host_target)
.with_stderr_data(
str![[r#"
let host_filtered_stderr = str![[r#"
[WARNING] please specify `--format-version` flag explicitly to avoid compatibility problems
[DOWNLOADING] crates ...
[DOWNLOADED] normal-dep v0.0.1 (registry `dummy-registry`)
[DOWNLOADED] host-dep v0.0.1 (registry `dummy-registry`)

"#]]
.unordered(),
)
.with_stdout_data(
str![[r#"
"#]];

let host_filtered_stdout = str![[r#"
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This output could probably be a variable shared with both explicit triple and host-tuple.

"packages": [
{
Expand Down Expand Up @@ -3945,10 +3939,21 @@ fn filter_platform() {
},
"...": "{...}"
}
"#]]
.is_json()
.unordered(),
)
"#]];

// Filter on host, removes alt and cfg.
p.cargo("metadata --filter-platform")
.arg(&host_target)
.with_stderr_data(host_filtered_stderr.clone().unordered())
.with_stdout_data(host_filtered_stdout.clone().is_json().unordered())
.run();
clear();

// Filter on host-tuple, should produce same result as explicit host target.
p.cargo("metadata --filter-platform")
.arg("host-tuple")
.with_stderr_data(host_filtered_stderr.unordered())
.with_stdout_data(host_filtered_stdout.is_json().unordered())
.run();
clear();

Expand Down