fork/cargo

git clone https://git.julia.blue/fork/cargo

Weihang Lofix: Remove build-plan (#16212)4aac07d01

master
17.6 KiB407 linesraw
1CARGO-BUILD(1)
2
3NAME
4       cargo-build — Compile the current package
5
6SYNOPSIS
7       cargo build [options]
8
9DESCRIPTION
10       Compile local packages and all of their dependencies.
11
12OPTIONS
13   Package Selection
14       By default, when no package selection options are given, the packages
15       selected depend on the selected manifest file (based on the current
16       working directory if --manifest-path is not given). If the manifest is
17       the root of a workspace then the workspaces default members are
18       selected, otherwise only the package defined by the manifest will be
19       selected.
20
21       The default members of a workspace can be set explicitly with the
22       workspace.default-members key in the root manifest. If this is not set,
23       a virtual workspace will include all workspace members (equivalent to
24       passing --workspace), and a non-virtual workspace will include only the
25       root crate itself.
26
27       -p spec…, --package spec…
28           Build only the specified packages. See cargo-pkgid(1) for the SPEC
29           format. This flag may be specified multiple times and supports
30           common Unix glob patterns like *, ? and []. However, to avoid your
31           shell accidentally expanding glob patterns before Cargo handles
32           them, you must use single quotes or double quotes around each
33           pattern.
34
35       --workspace
36           Build all members in the workspace.
37
38       --all
39           Deprecated alias for --workspace.
40
41       --exclude SPEC…
42           Exclude the specified packages. Must be used in conjunction with the
43           --workspace flag. This flag may be specified multiple times and
44           supports common Unix glob patterns like *, ? and []. However, to
45           avoid your shell accidentally expanding glob patterns before Cargo
46           handles them, you must use single quotes or double quotes around
47           each pattern.
48
49   Target Selection
50       When no target selection options are given, cargo build will build all
51       binary and library targets of the selected packages. Binaries are
52       skipped if they have required-features that are missing.
53
54       Binary targets are automatically built if there is an integration test
55       or benchmark being selected to build. This allows an integration test to
56       execute the binary to exercise and test its behavior. The
57       CARGO_BIN_EXE_<name> environment variable
58       <https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates>
59       is set when the integration test is built so that it can use the env
60       macro <https://doc.rust-lang.org/std/macro.env.html> to locate the
61       executable.
62
63       Passing target selection flags will build only the specified targets.
64
65       Note that --bin, --example, --test and --bench flags also support common
66       Unix glob patterns like *, ? and []. However, to avoid your shell
67       accidentally expanding glob patterns before Cargo handles them, you must
68       use single quotes or double quotes around each glob pattern.
69
70       --lib
71           Build the package’s library.
72
73       --bin name…
74           Build the specified binary. This flag may be specified multiple
75           times and supports common Unix glob patterns.
76
77       --bins
78           Build all binary targets.
79
80       --example name…
81           Build the specified example. This flag may be specified multiple
82           times and supports common Unix glob patterns.
83
84       --examples
85           Build all example targets.
86
87       --test name…
88           Build the specified integration test. This flag may be specified
89           multiple times and supports common Unix glob patterns.
90
91       --tests
92           Build all targets that have the test = true manifest flag set. By
93           default this includes the library and binaries built as unittests,
94           and integration tests. Be aware that this will also build any
95           required dependencies, so the lib target may be built twice (once as
96           a unittest, and once as a dependency for binaries, integration
97           tests, etc.). Targets may be enabled or disabled by setting the test
98           flag in the manifest settings for the target.
99
100       --bench name…
101           Build the specified benchmark. This flag may be specified multiple
102           times and supports common Unix glob patterns.
103
104       --benches
105           Build all targets that have the bench = true manifest flag set. By
106           default this includes the library and binaries built as benchmarks,
107           and bench targets. Be aware that this will also build any required
108           dependencies, so the lib target may be built twice (once as a
109           benchmark, and once as a dependency for binaries, benchmarks, etc.).
110           Targets may be enabled or disabled by setting the bench flag in the
111           manifest settings for the target.
112
113       --all-targets
114           Build all targets. This is equivalent to specifying --lib --bins
115           --tests --benches --examples.
116
117   Feature Selection
118       The feature flags allow you to control which features are enabled. When
119       no feature options are given, the default feature is activated for every
120       selected package.
121
122       See the features documentation
123       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
124       for more details.
125
126       -F features, --features features
127           Space or comma separated list of features to activate. Features of
128           workspace members may be enabled with package-name/feature-name
129           syntax. This flag may be specified multiple times, which enables all
130           specified features.
131
132       --all-features
133           Activate all available features of all selected packages.
134
135       --no-default-features
136           Do not activate the default feature of the selected packages.
137
138   Compilation Options
139       --target triple
140           Build for the specified target architecture. Flag may be specified
141           multiple times. The default is the host architecture. The general
142           format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.
143
144           Possible values:
145
146           o  Any supported target in rustc --print target-list.
147
148           o  "host-tuple", which will internally be substituted by the
149              host’s target. This can be particularly useful if you’re
150              cross-compiling some crates, and don’t want to specify your
151              host’s machine as a target (for instance, an xtask in a shared
152              project that may be worked on by many hosts).
153
154           o  A path to a custom target specification. See Custom Target Lookup
155              Path
156              <https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
157              for more information.
158
159           This may also be specified with the build.target config value
160           <https://doc.rust-lang.org/cargo/reference/config.html>.
161
162           Note that specifying this flag makes Cargo run in a different mode
163           where the target artifacts are placed in a separate directory. See
164           the build cache
165           <https://doc.rust-lang.org/cargo/reference/build-cache.html>
166           documentation for more details.
167
168       -r, --release
169           Build optimized artifacts with the release profile. See also the
170           --profile option for choosing a specific profile by name.
171
172       --profile name
173           Build with the given profile. See the reference
174           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
175           details on profiles.
176
177       --timings=fmts
178           Output information how long each compilation takes, and track
179           concurrency information over time. Accepts an optional
180           comma-separated list of output formats; --timings without an
181           argument will default to --timings=html. Specifying an output format
182           (rather than the default) is unstable and requires
183           -Zunstable-options. Valid output formats:
184
185           o  html (unstable, requires -Zunstable-options): Write a
186              human-readable file cargo-timing.html to the target/cargo-timings
187              directory with a report of the compilation. Also write a report
188              to the same directory with a timestamp in the filename if you
189              want to look at older runs. HTML output is suitable for human
190              consumption only, and does not provide machine-readable timing
191              data.
192
193           o  json (unstable, requires -Zunstable-options): Emit
194              machine-readable JSON information about timing information.
195
196   Output Options
197       --target-dir directory
198           Directory for all generated artifacts and intermediate files. May
199           also be specified with the CARGO_TARGET_DIR environment variable, or
200           the build.target-dir config value
201           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
202           target in the root of the workspace.
203
204       --artifact-dir directory
205           Copy final artifacts to this directory.
206
207           This option is unstable and available only on the nightly channel
208           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
209           requires the -Z unstable-options flag to enable. See
210           <https://github.com/rust-lang/cargo/issues/6790> for more
211           information.
212
213   Display Options
214       -v, --verbose
215           Use verbose output. May be specified twice for “very verbose”
216           output which includes extra output such as dependency warnings and
217           build script output. May also be specified with the term.verbose
218           config value
219           <https://doc.rust-lang.org/cargo/reference/config.html>.
220
221       -q, --quiet
222           Do not print cargo log messages. May also be specified with the
223           term.quiet config value
224           <https://doc.rust-lang.org/cargo/reference/config.html>.
225
226       --color when
227           Control when colored output is used. Valid values:
228
229           o  auto (default): Automatically detect if color support is
230              available on the terminal.
231
232           o  always: Always display colors.
233
234           o  never: Never display colors.
235
236           May also be specified with the term.color config value
237           <https://doc.rust-lang.org/cargo/reference/config.html>.
238
239       --message-format fmt
240           The output format for diagnostic messages. Can be specified multiple
241           times and consists of comma-separated values. Valid values:
242
243           o  human (default): Display in a human-readable text format.
244              Conflicts with short and json.
245
246           o  short: Emit shorter, human-readable text messages. Conflicts with
247              human and json.
248
249           o  json: Emit JSON messages to stdout. See the reference
250              <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
251              for more details. Conflicts with human and short.
252
253           o  json-diagnostic-short: Ensure the rendered field of JSON messages
254              contains the “short” rendering from rustc. Cannot be used
255              with human or short.
256
257           o  json-diagnostic-rendered-ansi: Ensure the rendered field of JSON
258              messages contains embedded ANSI color codes for respecting
259              rustc’s default color scheme. Cannot be used with human or
260              short.
261
262           o  json-render-diagnostics: Instruct Cargo to not include rustc
263              diagnostics in JSON messages printed, but instead Cargo itself
264              should render the JSON diagnostics coming from rustc. Cargo’s
265              own JSON diagnostics and others coming from rustc are still
266              emitted. Cannot be used with human or short.
267
268   Manifest Options
269       --manifest-path path
270           Path to the Cargo.toml file. By default, Cargo searches for the
271           Cargo.toml file in the current directory or any parent directory.
272
273       --ignore-rust-version
274           Ignore rust-version specification in packages.
275
276       --locked
277           Asserts that the exact same dependencies and versions are used as
278           when the existing Cargo.lock file was originally generated. Cargo
279           will exit with an error when either of the following scenarios
280           arises:
281
282           o  The lock file is missing.
283
284           o  Cargo attempted to change the lock file due to a different
285              dependency resolution.
286
287           It may be used in environments where deterministic builds are
288           desired, such as in CI pipelines.
289
290       --offline
291           Prevents Cargo from accessing the network for any reason. Without
292           this flag, Cargo will stop with an error if it needs to access the
293           network and the network is not available. With this flag, Cargo will
294           attempt to proceed without the network if possible.
295
296           Beware that this may result in different dependency resolution than
297           online mode. Cargo will restrict itself to crates that are
298           downloaded locally, even if there might be a newer version as
299           indicated in the local copy of the index. See the cargo-fetch(1)
300           command to download dependencies before going offline.
301
302           May also be specified with the net.offline config value
303           <https://doc.rust-lang.org/cargo/reference/config.html>.
304
305       --frozen
306           Equivalent to specifying both --locked and --offline.
307
308       --lockfile-path PATH
309           Changes the path of the lockfile from the default
310           (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock
311           (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that
312           providing --lockfile-path will ignore existing lockfile at the
313           default path, and instead will either use the lockfile from PATH, or
314           write a new lockfile into the provided PATH if it doesn’t exist.
315           This flag can be used to run most commands in read-only directories,
316           writing lockfile into the provided PATH.
317
318           This option is only available on the nightly channel
319           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
320           requires the -Z unstable-options flag to enable (see #14421
321           <https://github.com/rust-lang/cargo/issues/14421>).
322
323   Common Options
324       +toolchain
325           If Cargo has been installed with rustup, and the first argument to
326           cargo begins with +, it will be interpreted as a rustup toolchain
327           name (such as +stable or +nightly). See the rustup documentation
328           <https://rust-lang.github.io/rustup/overrides.html> for more
329           information about how toolchain overrides work.
330
331       --config KEY=VALUE or PATH
332           Overrides a Cargo configuration value. The argument should be in
333           TOML syntax of KEY=VALUE, or provided as a path to an extra
334           configuration file. This flag may be specified multiple times. See
335           the command-line overrides section
336           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
337           for more information.
338
339       -C PATH
340           Changes the current working directory before executing any specified
341           operations. This affects things like where cargo looks by default
342           for the project manifest (Cargo.toml), as well as the directories
343           searched for discovering .cargo/config.toml, for example. This
344           option must appear before the command name, for example cargo -C
345           path/to/my-project build.
346
347           This option is only available on the nightly channel
348           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
349           requires the -Z unstable-options flag to enable (see #10098
350           <https://github.com/rust-lang/cargo/issues/10098>).
351
352       -h, --help
353           Prints help information.
354
355       -Z flag
356           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
357           details.
358
359   Miscellaneous Options
360       -j N, --jobs N
361           Number of parallel jobs to run. May also be specified with the
362           build.jobs config value
363           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
364           the number of logical CPUs. If negative, it sets the maximum number
365           of parallel jobs to the number of logical CPUs plus provided value.
366           If a string default is provided, it sets the value back to defaults.
367           Should not be 0.
368
369       --keep-going
370           Build as many crates in the dependency graph as possible, rather
371           than aborting the build on the first one that fails to build.
372
373           For example if the current package depends on dependencies fails and
374           works, one of which fails to build, cargo build -j1 may or may not
375           build the one that succeeds (depending on which one of the two
376           builds Cargo picked to run first), whereas cargo build -j1
377           --keep-going would definitely run both builds, even if the one run
378           first fails.
379
380       --future-incompat-report
381           Displays a future-incompat report for any future-incompatible
382           warnings produced during execution of this command
383
384           See cargo-report(1)
385
386ENVIRONMENT
387       See the reference
388       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
389       for details on environment variables that Cargo reads.
390
391EXIT STATUS
392       o  0: Cargo succeeded.
393
394       o  101: Cargo failed to complete.
395
396EXAMPLES
397       1. Build the local package and all of its dependencies:
398
399              cargo build
400
401       2. Build with optimizations:
402
403              cargo build --release
404
405SEE ALSO
406       cargo(1), cargo-rustc(1)
407