Skip to content

Commit a474391

Browse files
committed
Update doc for --crate-type flag
1 parent 3066142 commit a474391

File tree

5 files changed

+79
-17
lines changed

5 files changed

+79
-17
lines changed

src/doc/man/cargo-rustc.md

+17
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ See the [the reference](../reference/profiles.html) for more details on profiles
7070

7171
{{> options-timings }}
7272

73+
{{#option "`--crate-type` _crate-type_"}}
74+
Build for the given crate type. This flag accepts a comma-separated list of
75+
1 or more crate types, of which the allowed values are the same as `crate-type`
76+
field in the manifest for configurating a Cargo target. See
77+
[`crate-type` field](../reference/cargo-targets.html#the-crate-type-field)
78+
for possible values.
79+
80+
If the manifest contains a list, and `--crate-type` is provided,
81+
the command-line argument value will override what is in the manifest.
82+
83+
This flag only works when building a `lib` or `example` library target.
84+
{{/option}}
85+
7386
{{/options}}
7487

7588
### Output Options
@@ -123,5 +136,9 @@ See the [the reference](../reference/profiles.html) for more details on profiles
123136

124137
cargo rustc --lib -- -Z print-type-sizes
125138

139+
3. Override `crate-type` field in Cargo.toml with command-line option:
140+
141+
cargo rustc --lib --crate-type lib,cdylib
142+
126143
## SEE ALSO
127144
{{man "cargo" 1}}, {{man "cargo-build" 1}}, {{man "rustc" 1}}

src/doc/man/generated_txt/cargo-rustc.txt

+17
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@ OPTIONS
191191
o json (unstable, requires -Zunstable-options): Emit
192192
machine-readable JSON information about timing information.
193193

194+
--crate-type crate-type
195+
Build for the given crate type. This flag accepts a comma-separated
196+
list of 1 or more crate types, of which the allowed values are the
197+
same as crate-type field in the manifest for configurating a Cargo
198+
target. See crate-type field
199+
<https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-crate-type-field>
200+
for possible values.
201+
202+
If the manifest contains a list, and --crate-type is provided, the
203+
command-line argument value will override what is in the manifest.
204+
205+
This flag only works when building a lib or example library target.
206+
194207
Output Options
195208
--target-dir directory
196209
Directory for all generated artifacts and intermediate files. May
@@ -339,6 +352,10 @@ EXAMPLES
339352

340353
cargo rustc --lib -- -Z print-type-sizes
341354

355+
3. Override crate-type field in Cargo.toml with command-line option:
356+
357+
cargo rustc --lib --crate-type lib,cdylib
358+
342359
SEE ALSO
343360
cargo(1), cargo-build(1), rustc(1)
344361

src/doc/src/commands/cargo-rustc.md

+15
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,17 @@ information about timing information.</li>
226226

227227

228228

229+
<dt class="option-term" id="option-cargo-rustc---crate-type"><a class="option-anchor" href="#option-cargo-rustc---crate-type"></a><code>--crate-type</code> <em>crate-type</em></dt>
230+
<dd class="option-desc">Build for the given crate type. This flag accepts a comma-separated list of
231+
1 or more crate types, of which the allowed values are the same as <code>crate-type</code>
232+
field in the manifest for configurating a Cargo target. See
233+
<a href="../reference/cargo-targets.html#the-crate-type-field"><code>crate-type</code> field</a>
234+
for possible values.</p>
235+
<p>If the manifest contains a list, and <code>--crate-type</code> is provided,
236+
the command-line argument value will override what is in the manifest.</p>
237+
<p>This flag only works when building a <code>lib</code> or <code>example</code> library target.</dd>
238+
239+
229240
</dl>
230241

231242
### Output Options
@@ -410,5 +421,9 @@ details on environment variables that Cargo reads.
410421

411422
cargo rustc --lib -- -Z print-type-sizes
412423

424+
3. Override `crate-type` field in Cargo.toml with command-line option:
425+
426+
cargo rustc --lib --crate-type lib,cdylib
427+
413428
## SEE ALSO
414429
[cargo(1)](cargo.html), [cargo-build(1)](cargo-build.html), [rustc(1)](https://doc.rust-lang.org/rustc/index.html)

src/doc/src/reference/unstable.md

+6-17
Original file line numberDiff line numberDiff line change
@@ -437,23 +437,6 @@ like to stabilize it somehow!
437437

438438
[rust-lang/rust#64158]: https://github.com/rust-lang/rust/pull/64158
439439

440-
### crate-type
441-
* Tracking Issue: [#10083](https://github.com/rust-lang/cargo/issues/10083)
442-
* RFC: [#3180](https://github.com/rust-lang/rfcs/pull/3180)
443-
* Original Pull Request: [#10093](https://github.com/rust-lang/cargo/pull/10093)
444-
445-
`cargo rustc --crate-type=lib,cdylib` forwards the `--crate-type` flag to `rustc`.
446-
This runs `rustc` with the corresponding
447-
[`--crate-type`](https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit)
448-
flag, and compiling.
449-
450-
When using it, it requires the `-Z unstable-options`
451-
command-line option:
452-
453-
```console
454-
cargo rustc --crate-type lib,cdylib -Z unstable-options
455-
```
456-
457440
### keep-going
458441
* Tracking Issue: [#0](https://github.com/rust-lang/cargo/issues/10496)
459442

@@ -1569,3 +1552,9 @@ unstable and require `-Zunstable-options`.)
15691552
The `--config` CLI option has been stabilized in the 1.63 release. See
15701553
the [config documentation](config.html#command-line-overrides) for more
15711554
information.
1555+
1556+
### crate-type
1557+
1558+
The `--crate-type` flag for `cargo rustc` has been stabilized in the 1.64
1559+
release. See the [`cargo rustc` documentation](../commands/cargo-rustc.md)
1560+
for more information.

src/etc/man/cargo-rustc.1

+24
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,20 @@ and does not provide machine\-readable timing data.
224224
information about timing information.
225225
.RE
226226
.RE
227+
.sp
228+
\fB\-\-crate\-type\fR \fIcrate\-type\fR
229+
.RS 4
230+
Build for the given crate type. This flag accepts a comma\-separated list of
231+
1 or more crate types, of which the allowed values are the same as \fBcrate\-type\fR
232+
field in the manifest for configurating a Cargo target. See
233+
\fI\f(BIcrate\-type\fI field\fR <https://doc.rust\-lang.org/cargo/reference/cargo\-targets.html#the\-crate\-type\-field>
234+
for possible values.
235+
.sp
236+
If the manifest contains a list, and \fB\-\-crate\-type\fR is provided,
237+
the command\-line argument value will override what is in the manifest.
238+
.sp
239+
This flag only works when building a \fBlib\fR or \fBexample\fR library target.
240+
.RE
227241
.SS "Output Options"
228242
.sp
229243
\fB\-\-target\-dir\fR \fIdirectory\fR
@@ -432,5 +446,15 @@ cargo rustc \-\-lib \-\- \-Z print\-type\-sizes
432446
.fi
433447
.RE
434448
.RE
449+
.sp
450+
.RS 4
451+
\h'-04' 3.\h'+01'Override \fBcrate\-type\fR field in Cargo.toml with command\-line option:
452+
.sp
453+
.RS 4
454+
.nf
455+
cargo rustc \-\-lib \-\-crate\-type lib,cdylib
456+
.fi
457+
.RE
458+
.RE
435459
.SH "SEE ALSO"
436460
\fBcargo\fR(1), \fBcargo\-build\fR(1), \fBrustc\fR(1)

0 commit comments

Comments
 (0)