Matthew Maurer | bd39854 | 2019-09-05 16:25:08 -0700 | [diff] [blame] | 1 | '\" t |
| 2 | .\" Title: cargo-build |
| 3 | .\" Author: [see the "AUTHOR(S)" section] |
| 4 | .\" Generator: Asciidoctor 1.5.8 |
| 5 | .\" Date: 2019-05-08 |
| 6 | .\" Manual: \ \& |
| 7 | .\" Source: \ \& |
| 8 | .\" Language: English |
| 9 | .\" |
| 10 | .TH "CARGO\-BUILD" "1" "2019-05-08" "\ \&" "\ \&" |
| 11 | .ie \n(.g .ds Aq \(aq |
| 12 | .el .ds Aq ' |
| 13 | .ss \n[.ss] 0 |
| 14 | .nh |
| 15 | .ad l |
| 16 | .de URL |
| 17 | \fI\\$2\fP <\\$1>\\$3 |
| 18 | .. |
| 19 | .als MTO URL |
| 20 | .if \n[.g] \{\ |
| 21 | . mso www.tmac |
| 22 | . am URL |
| 23 | . ad l |
| 24 | . . |
| 25 | . am MTO |
| 26 | . ad l |
| 27 | . . |
| 28 | . LINKSTYLE blue R < > |
| 29 | .\} |
| 30 | .SH "NAME" |
| 31 | cargo\-build \- Compile the current package |
| 32 | .SH "SYNOPSIS" |
| 33 | .sp |
| 34 | \fBcargo build [\fIOPTIONS\fP]\fP |
| 35 | .SH "DESCRIPTION" |
| 36 | .sp |
| 37 | Compile local packages and all of their dependencies. |
| 38 | .SH "OPTIONS" |
| 39 | .SS "Package Selection" |
| 40 | .sp |
| 41 | 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. |
| 47 | .sp |
| 48 | \fB\-p\fP \fISPEC\fP..., \fB\-\-package\fP \fISPEC\fP... |
| 49 | .RS 4 |
| 50 | Build only the specified packages. See \fBcargo\-pkgid\fP(1) for the |
| 51 | SPEC format. This flag may be specified multiple times. |
| 52 | .RE |
| 53 | .sp |
| 54 | \fB\-\-all\fP |
| 55 | .RS 4 |
| 56 | Build all members in the workspace. |
| 57 | .RE |
| 58 | .sp |
| 59 | \fB\-\-exclude\fP \fISPEC\fP... |
| 60 | .RS 4 |
| 61 | Exclude the specified packages. Must be used in conjunction with the |
| 62 | \fB\-\-all\fP flag. This flag may be specified multiple times. |
| 63 | .RE |
| 64 | .SS "Target Selection" |
| 65 | .sp |
| 66 | When no target selection options are given, \fBcargo build\fP will build all |
| 67 | binary and library targets of the selected packages. Binaries are skipped if |
| 68 | they have \fBrequired\-features\fP that are missing. |
| 69 | .sp |
| 70 | Passing target selection flags will build only the |
| 71 | specified targets. |
| 72 | .sp |
| 73 | \fB\-\-lib\fP |
| 74 | .RS 4 |
| 75 | Build the package\(cqs library. |
| 76 | .RE |
| 77 | .sp |
| 78 | \fB\-\-bin\fP \fINAME\fP... |
| 79 | .RS 4 |
| 80 | Build the specified binary. This flag may be specified multiple times. |
| 81 | .RE |
| 82 | .sp |
| 83 | \fB\-\-bins\fP |
| 84 | .RS 4 |
| 85 | Build all binary targets. |
| 86 | .RE |
| 87 | .sp |
| 88 | \fB\-\-example\fP \fINAME\fP... |
| 89 | .RS 4 |
| 90 | Build the specified example. This flag may be specified multiple times. |
| 91 | .RE |
| 92 | .sp |
| 93 | \fB\-\-examples\fP |
| 94 | .RS 4 |
| 95 | Build all example targets. |
| 96 | .RE |
| 97 | .sp |
| 98 | \fB\-\-test\fP \fINAME\fP... |
| 99 | .RS 4 |
| 100 | Build the specified integration test. This flag may be specified multiple |
| 101 | times. |
| 102 | .RE |
| 103 | .sp |
| 104 | \fB\-\-tests\fP |
| 105 | .RS 4 |
| 106 | Build all targets in test mode that have the \fBtest = true\fP manifest |
| 107 | flag set. By default this includes the library and binaries built as |
| 108 | unittests, and integration tests. Be aware that this will also build any |
| 109 | required dependencies, so the lib target may be built twice (once as a |
| 110 | unittest, and once as a dependency for binaries, integration tests, etc.). |
| 111 | Targets may be enabled or disabled by setting the \fBtest\fP flag in the |
| 112 | manifest settings for the target. |
| 113 | .RE |
| 114 | .sp |
| 115 | \fB\-\-bench\fP \fINAME\fP... |
| 116 | .RS 4 |
| 117 | Build the specified benchmark. This flag may be specified multiple times. |
| 118 | .RE |
| 119 | .sp |
| 120 | \fB\-\-benches\fP |
| 121 | .RS 4 |
| 122 | Build all targets in benchmark mode that have the \fBbench = true\fP |
| 123 | manifest flag set. By default this includes the library and binaries built |
| 124 | as benchmarks, and bench targets. Be aware that this will also build any |
| 125 | required dependencies, so the lib target may be built twice (once as a |
| 126 | benchmark, and once as a dependency for binaries, benchmarks, etc.). |
| 127 | Targets may be enabled or disabled by setting the \fBbench\fP flag in the |
| 128 | manifest settings for the target. |
| 129 | .RE |
| 130 | .sp |
| 131 | \fB\-\-all\-targets\fP |
| 132 | .RS 4 |
| 133 | Build all targets. This is equivalent to specifying \fB\-\-lib \-\-bins |
| 134 | \-\-tests \-\-benches \-\-examples\fP. |
| 135 | .RE |
| 136 | .SS "Feature Selection" |
| 137 | .sp |
| 138 | When no feature options are given, the \fBdefault\fP feature is activated for |
| 139 | every selected package. |
| 140 | .sp |
| 141 | \fB\-\-features\fP \fIFEATURES\fP |
| 142 | .RS 4 |
| 143 | Space or comma separated list of features to activate. These features only |
| 144 | apply to the current directory\(cqs package. Features of direct dependencies |
| 145 | may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. |
| 146 | .RE |
| 147 | .sp |
| 148 | \fB\-\-all\-features\fP |
| 149 | .RS 4 |
| 150 | Activate all available features of all selected packages. |
| 151 | .RE |
| 152 | .sp |
| 153 | \fB\-\-no\-default\-features\fP |
| 154 | .RS 4 |
| 155 | Do not activate the \fBdefault\fP feature of the current directory\(cqs |
| 156 | package. |
| 157 | .RE |
| 158 | .SS "Compilation Options" |
| 159 | .sp |
| 160 | \fB\-\-target\fP \fITRIPLE\fP |
| 161 | .RS 4 |
| 162 | Build for the given architecture. The default is the host |
| 163 | architecture. The general format of the triple is |
| 164 | \fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a |
| 165 | list of supported targets. |
| 166 | .sp |
| 167 | This may also be specified with the \fBbuild.target\fP |
| 168 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 169 | .RE |
| 170 | .sp |
| 171 | \fB\-\-release\fP |
| 172 | .RS 4 |
| 173 | Build optimized artifacts with the \fBrelease\fP profile. See the |
| 174 | PROFILES section for details on how this affects profile selection. |
| 175 | .RE |
| 176 | .SS "Output Options" |
| 177 | .sp |
| 178 | \fB\-\-target\-dir\fP \fIDIRECTORY\fP |
| 179 | .RS 4 |
| 180 | Directory for all generated artifacts and intermediate files. May also be |
| 181 | specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the |
| 182 | \fBbuild.target\-dir\fP \c |
| 183 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 184 | Defaults |
| 185 | to \fBtarget\fP in the root of the workspace. |
| 186 | .RE |
| 187 | .sp |
| 188 | \fB\-\-out\-dir\fP \fIDIRECTORY\fP |
| 189 | .RS 4 |
| 190 | Copy final artifacts to this directory. |
| 191 | .sp |
| 192 | This option is unstable and available only on the |
| 193 | \c |
| 194 | .URL "https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html" "nightly channel" |
| 195 | and requires the \fB\-Z unstable\-options\fP flag to enable. |
| 196 | See \c |
| 197 | .URL "https://github.com/rust\-lang/cargo/issues/6790" "" " " |
| 198 | for more information. |
| 199 | .RE |
| 200 | .SS "Display Options" |
| 201 | .sp |
| 202 | \fB\-v\fP, \fB\-\-verbose\fP |
| 203 | .RS 4 |
| 204 | Use verbose output. May be specified twice for "very verbose" output which |
| 205 | includes extra output such as dependency warnings and build script output. |
| 206 | May also be specified with the \fBterm.verbose\fP |
| 207 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 208 | .RE |
| 209 | .sp |
| 210 | \fB\-q\fP, \fB\-\-quiet\fP |
| 211 | .RS 4 |
| 212 | No output printed to stdout. |
| 213 | .RE |
| 214 | .sp |
| 215 | \fB\-\-color\fP \fIWHEN\fP |
| 216 | .RS 4 |
| 217 | Control when colored output is used. Valid values: |
| 218 | .sp |
| 219 | .RS 4 |
| 220 | .ie n \{\ |
| 221 | \h'-04'\(bu\h'+03'\c |
| 222 | .\} |
| 223 | .el \{\ |
| 224 | . sp -1 |
| 225 | . IP \(bu 2.3 |
| 226 | .\} |
| 227 | \fBauto\fP (default): Automatically detect if color support is available on the |
| 228 | terminal. |
| 229 | .RE |
| 230 | .sp |
| 231 | .RS 4 |
| 232 | .ie n \{\ |
| 233 | \h'-04'\(bu\h'+03'\c |
| 234 | .\} |
| 235 | .el \{\ |
| 236 | . sp -1 |
| 237 | . IP \(bu 2.3 |
| 238 | .\} |
| 239 | \fBalways\fP: Always display colors. |
| 240 | .RE |
| 241 | .sp |
| 242 | .RS 4 |
| 243 | .ie n \{\ |
| 244 | \h'-04'\(bu\h'+03'\c |
| 245 | .\} |
| 246 | .el \{\ |
| 247 | . sp -1 |
| 248 | . IP \(bu 2.3 |
| 249 | .\} |
| 250 | \fBnever\fP: Never display colors. |
| 251 | .RE |
| 252 | .sp |
| 253 | May also be specified with the \fBterm.color\fP |
| 254 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 255 | .RE |
| 256 | .sp |
| 257 | \fB\-\-message\-format\fP \fIFMT\fP |
| 258 | .RS 4 |
| 259 | The output format for diagnostic messages. Valid values: |
| 260 | .sp |
| 261 | .RS 4 |
| 262 | .ie n \{\ |
| 263 | \h'-04'\(bu\h'+03'\c |
| 264 | .\} |
| 265 | .el \{\ |
| 266 | . sp -1 |
| 267 | . IP \(bu 2.3 |
| 268 | .\} |
| 269 | \fBhuman\fP (default): Display in a human\-readable text format. |
| 270 | .RE |
| 271 | .sp |
| 272 | .RS 4 |
| 273 | .ie n \{\ |
| 274 | \h'-04'\(bu\h'+03'\c |
| 275 | .\} |
| 276 | .el \{\ |
| 277 | . sp -1 |
| 278 | . IP \(bu 2.3 |
| 279 | .\} |
| 280 | \fBjson\fP: Emit JSON messages to stdout. |
| 281 | .RE |
| 282 | .sp |
| 283 | .RS 4 |
| 284 | .ie n \{\ |
| 285 | \h'-04'\(bu\h'+03'\c |
| 286 | .\} |
| 287 | .el \{\ |
| 288 | . sp -1 |
| 289 | . IP \(bu 2.3 |
| 290 | .\} |
| 291 | \fBshort\fP: Emit shorter, human\-readable text messages. |
| 292 | .RE |
| 293 | .RE |
| 294 | .sp |
| 295 | \fB\-\-build\-plan\fP |
| 296 | .RS 4 |
| 297 | Outputs a series of JSON messages to stdout that indicate the commands to |
| 298 | run the build. |
| 299 | .sp |
| 300 | This option is unstable and available only on the |
| 301 | \c |
| 302 | .URL "https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html" "nightly channel" |
| 303 | and requires the \fB\-Z unstable\-options\fP flag to enable. |
| 304 | See \c |
| 305 | .URL "https://github.com/rust\-lang/cargo/issues/5579" "" " " |
| 306 | for more information. |
| 307 | .RE |
| 308 | .SS "Manifest Options" |
| 309 | .sp |
| 310 | \fB\-\-manifest\-path\fP \fIPATH\fP |
| 311 | .RS 4 |
| 312 | Path to the \fBCargo.toml\fP file. By default, Cargo searches in the current |
| 313 | directory or any parent directory for the \fBCargo.toml\fP file. |
| 314 | .RE |
| 315 | .sp |
| 316 | \fB\-\-frozen\fP, \fB\-\-locked\fP |
| 317 | .RS 4 |
| 318 | Either of these flags requires that the \fBCargo.lock\fP file is |
| 319 | up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will |
| 320 | exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from |
| 321 | attempting to access the network to determine if it is out\-of\-date. |
| 322 | .sp |
| 323 | These may be used in environments where you want to assert that the |
| 324 | \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network |
| 325 | access. |
| 326 | .RE |
| 327 | .sp |
| 328 | \fB\-\-offline\fP |
| 329 | .RS 4 |
| 330 | Prevents Cargo from accessing the network for any reason. Without this |
| 331 | flag, Cargo will stop with an error if it needs to access the network and |
| 332 | the network is not available. With this flag, Cargo will attempt to |
| 333 | proceed without the network if possible. |
| 334 | .sp |
| 335 | Beware that this may result in different dependency resolution than online |
| 336 | mode. Cargo will restrict itself to crates that are downloaded locally, even |
| 337 | if there might be a newer version as indicated in the local copy of the index. |
| 338 | See the \fBcargo\-fetch\fP(1) command to download dependencies before going |
| 339 | offline. |
| 340 | .sp |
| 341 | May also be specified with the \fBnet.offline\fP \c |
| 342 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 343 | .RE |
| 344 | .SS "Common Options" |
| 345 | .sp |
| 346 | \fB\-h\fP, \fB\-\-help\fP |
| 347 | .RS 4 |
| 348 | Prints help information. |
| 349 | .RE |
| 350 | .sp |
| 351 | \fB\-Z\fP \fIFLAG\fP... |
| 352 | .RS 4 |
| 353 | Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for |
| 354 | details. |
| 355 | .RE |
| 356 | .SS "Miscellaneous Options" |
| 357 | .sp |
| 358 | \fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP |
| 359 | .RS 4 |
| 360 | Number of parallel jobs to run. May also be specified with the |
| 361 | \fBbuild.jobs\fP \c |
| 362 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 363 | Defaults to |
| 364 | the number of CPUs. |
| 365 | .RE |
| 366 | .SH "PROFILES" |
| 367 | .sp |
| 368 | Profiles may be used to configure compiler options such as optimization levels |
| 369 | and debug settings. See |
| 370 | \c |
| 371 | .URL "https://doc.rust\-lang.org/cargo/reference/manifest.html#the\-profile\-sections" "the reference" |
| 372 | for more details. |
| 373 | .sp |
| 374 | Profile selection depends on the target and crate being built. By default the |
| 375 | \fBdev\fP or \fBtest\fP profiles are used. If the \fB\-\-release\fP flag is given, then the |
| 376 | \fBrelease\fP or \fBbench\fP profiles are used. |
| 377 | .TS |
| 378 | allbox tab(:); |
| 379 | lt lt lt. |
| 380 | T{ |
| 381 | .sp |
| 382 | Target |
| 383 | T}:T{ |
| 384 | .sp |
| 385 | Default Profile |
| 386 | T}:T{ |
| 387 | .sp |
| 388 | \fB\-\-release\fP Profile |
| 389 | T} |
| 390 | T{ |
| 391 | .sp |
| 392 | lib, bin, example |
| 393 | T}:T{ |
| 394 | .sp |
| 395 | \fBdev\fP |
| 396 | T}:T{ |
| 397 | .sp |
| 398 | \fBrelease\fP |
| 399 | T} |
| 400 | T{ |
| 401 | .sp |
| 402 | test, bench, or any target |
| 403 | .br |
| 404 | in "test" or "bench" mode |
| 405 | T}:T{ |
| 406 | .sp |
| 407 | \fBtest\fP |
| 408 | T}:T{ |
| 409 | .sp |
| 410 | \fBbench\fP |
| 411 | T} |
| 412 | .TE |
| 413 | .sp |
| 414 | .sp |
| 415 | Dependencies use the \fBdev\fP/\fBrelease\fP profiles. |
| 416 | .SH "ENVIRONMENT" |
| 417 | .sp |
| 418 | See \c |
| 419 | .URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " " |
| 420 | for |
| 421 | details on environment variables that Cargo reads. |
| 422 | .SH "EXIT STATUS" |
| 423 | .sp |
| 424 | 0 |
| 425 | .RS 4 |
| 426 | Cargo succeeded. |
| 427 | .RE |
| 428 | .sp |
| 429 | 101 |
| 430 | .RS 4 |
| 431 | Cargo failed to complete. |
| 432 | .RE |
| 433 | .SH "EXAMPLES" |
| 434 | .sp |
| 435 | .RS 4 |
| 436 | .ie n \{\ |
| 437 | \h'-04' 1.\h'+01'\c |
| 438 | .\} |
| 439 | .el \{\ |
| 440 | . sp -1 |
| 441 | . IP " 1." 4.2 |
| 442 | .\} |
| 443 | Build the local package and all of its dependencies: |
| 444 | .sp |
| 445 | .if n .RS 4 |
| 446 | .nf |
| 447 | cargo build |
| 448 | .fi |
| 449 | .if n .RE |
| 450 | .RE |
| 451 | .sp |
| 452 | .RS 4 |
| 453 | .ie n \{\ |
| 454 | \h'-04' 2.\h'+01'\c |
| 455 | .\} |
| 456 | .el \{\ |
| 457 | . sp -1 |
| 458 | . IP " 2." 4.2 |
| 459 | .\} |
| 460 | Build with optimizations: |
| 461 | .sp |
| 462 | .if n .RS 4 |
| 463 | .nf |
| 464 | cargo build \-\-release |
| 465 | .fi |
| 466 | .if n .RE |
| 467 | .RE |
| 468 | .SH "SEE ALSO" |
| 469 | .sp |
| 470 | \fBcargo\fP(1), \fBcargo\-rustc\fP(1) |