fork/cargo
git clone https://git.julia.blue/fork/cargo
ebd20d245
master
1CARGO-METADATA(1) 2 3NAME 4 cargo-metadata — Machine-readable metadata about the current package 5 6SYNOPSIS 7 cargo metadata [options] 8 9DESCRIPTION 10 Output JSON to stdout containing information about the workspace members 11 and resolved dependencies of the current package. 12 13 The output format is subject to change in future versions of Cargo. It 14 is recommended to include the --format-version flag to future-proof your 15 code and ensure the output is in the format you are expecting. For more 16 on the expectations, see “Compatibility”. 17 18 See the cargo_metadata crate <https://crates.io/crates/cargo_metadata> 19 for a Rust API for reading the metadata. 20 21OUTPUT FORMAT 22 Compatibility 23 Within the same output format version, the compatibility is maintained, 24 except some scenarios. The following is a non-exhaustive list of changes 25 that are not considered as incompatible: 26 27 o Adding new fields — New fields will be added when needed. Reserving 28 this helps Cargo evolve without bumping the format version too often. 29 30 o Adding new values for enum-like fields — Same as adding new fields. 31 It keeps metadata evolving without stagnation. 32 33 o Changing opaque representations — The inner representations of some 34 fields are implementation details. For example, fields related to 35 “Source ID” are treated as opaque identifiers to differentiate 36 packages or sources. Consumers shouldn’t rely on those 37 representations unless specified. 38 39 JSON format 40 The JSON output has the following format: 41 42 { 43 /* Array of all packages in the workspace. 44 It also includes all feature-enabled dependencies unless --no-deps is used. 45 */ 46 "packages": [ 47 { 48 /* The name of the package. */ 49 "name": "my-package", 50 /* The version of the package. */ 51 "version": "0.1.0", 52 /* The Package ID for referring to the 53 package within the document and as the `--package` argument to many commands 54 */ 55 "id": "file:///path/to/my-package#0.1.0", 56 /* The license value from the manifest, or null. */ 57 "license": "MIT/Apache-2.0", 58 /* The license-file value from the manifest, or null. */ 59 "license_file": "LICENSE", 60 /* The description value from the manifest, or null. */ 61 "description": "Package description.", 62 /* The source ID of the package, an "opaque" identifier representing 63 where a package is retrieved from. See "Compatibility" above for 64 the stability guarantee. 65 66 This is null for path dependencies and workspace members. 67 68 For other dependencies, it is a string with the format: 69 - "registry+URL" for registry-based dependencies. 70 Example: "registry+https://github.com/rust-lang/crates.io-index" 71 - "git+URL" for git-based dependencies. 72 Example: "git+https://github.com/rust-lang/cargo?rev=5e85ba14aaa20f8133863373404cb0af69eeef2c#5e85ba14aaa20f8133863373404cb0af69eeef2c" 73 - "sparse+URL" for dependencies from a sparse registry 74 Example: "sparse+https://my-sparse-registry.org" 75 76 The value after the `+` is not explicitly defined, and may change 77 between versions of Cargo and may not directly correlate to other 78 things, such as registry definitions in a config file. New source 79 kinds may be added in the future which will have different `+` 80 prefixed identifiers. 81 */ 82 "source": null, 83 /* Array of dependencies declared in the package's manifest. */ 84 "dependencies": [ 85 { 86 /* The name of the dependency. */ 87 "name": "bitflags", 88 /* The source ID of the dependency. May be null, see 89 description for the package source. 90 */ 91 "source": "registry+https://github.com/rust-lang/crates.io-index", 92 /* The version requirement for the dependency. 93 Dependencies without a version requirement have a value of "*". 94 */ 95 "req": "^1.0", 96 /* The dependency kind. 97 "dev", "build", or null for a normal dependency. 98 */ 99 "kind": null, 100 /* If the dependency is renamed, this is the new name for 101 the dependency as a string. null if it is not renamed. 102 */ 103 "rename": null, 104 /* Boolean of whether or not this is an optional dependency. */ 105 "optional": false, 106 /* Boolean of whether or not default features are enabled. */ 107 "uses_default_features": true, 108 /* Array of features enabled. */ 109 "features": [], 110 /* The target platform for the dependency. 111 null if not a target dependency. 112 */ 113 "target": "cfg(windows)", 114 /* The file system path for a local path dependency. 115 not present if not a path dependency. 116 */ 117 "path": "/path/to/dep", 118 /* A string of the URL of the registry this dependency is from. 119 If not specified or null, the dependency is from the default 120 registry (crates.io). 121 */ 122 "registry": null, 123 /* (unstable) Boolean flag of whether or not this is a pulbic 124 dependency. This field is only present when 125 `-Zpublic-dependency` is enabled. 126 */ 127 "public": false 128 } 129 ], 130 /* Array of Cargo targets. */ 131 "targets": [ 132 { 133 /* Array of target kinds. 134 - lib targets list the `crate-type` values from the 135 manifest such as "lib", "rlib", "dylib", 136 "proc-macro", etc. (default ["lib"]) 137 - binary is ["bin"] 138 - example is ["example"] 139 - integration test is ["test"] 140 - benchmark is ["bench"] 141 - build script is ["custom-build"] 142 */ 143 "kind": [ 144 "bin" 145 ], 146 /* Array of crate types. 147 - lib and example libraries list the `crate-type` values 148 from the manifest such as "lib", "rlib", "dylib", 149 "proc-macro", etc. (default ["lib"]) 150 - all other target kinds are ["bin"] 151 */ 152 "crate_types": [ 153 "bin" 154 ], 155 /* The name of the target. 156 For lib targets, dashes will be replaced with underscores. 157 */ 158 "name": "my-package", 159 /* Absolute path to the root source file of the target. */ 160 "src_path": "/path/to/my-package/src/main.rs", 161 /* The Rust edition of the target. 162 Defaults to the package edition. 163 */ 164 "edition": "2018", 165 /* Array of required features. 166 This property is not included if no required features are set. 167 */ 168 "required-features": ["feat1"], 169 /* Whether the target should be documented by `cargo doc`. */ 170 "doc": true, 171 /* Whether or not this target has doc tests enabled, and 172 the target is compatible with doc testing. 173 */ 174 "doctest": false, 175 /* Whether or not this target should be built and run with `--test` 176 */ 177 "test": true 178 } 179 ], 180 /* Set of features defined for the package. 181 Each feature maps to an array of features or dependencies it 182 enables. 183 */ 184 "features": { 185 "default": [ 186 "feat1" 187 ], 188 "feat1": [], 189 "feat2": [] 190 }, 191 /* Absolute path to this package's manifest. */ 192 "manifest_path": "/path/to/my-package/Cargo.toml", 193 /* Package metadata. 194 This is null if no metadata is specified. 195 */ 196 "metadata": { 197 "docs": { 198 "rs": { 199 "all-features": true 200 } 201 } 202 }, 203 /* List of registries to which this package may be published. 204 Publishing is unrestricted if null, and forbidden if an empty array. */ 205 "publish": [ 206 "crates-io" 207 ], 208 /* Array of authors from the manifest. 209 Empty array if no authors specified. 210 */ 211 "authors": [ 212 "Jane Doe <user@example.com>" 213 ], 214 /* Array of categories from the manifest. */ 215 "categories": [ 216 "command-line-utilities" 217 ], 218 /* Optional string that is the default binary picked by cargo run. */ 219 "default_run": null, 220 /* Optional string that is the minimum supported rust version */ 221 "rust_version": "1.56", 222 /* Array of keywords from the manifest. */ 223 "keywords": [ 224 "cli" 225 ], 226 /* The readme value from the manifest or null if not specified. */ 227 "readme": "README.md", 228 /* The repository value from the manifest or null if not specified. */ 229 "repository": "https://github.com/rust-lang/cargo", 230 /* The homepage value from the manifest or null if not specified. */ 231 "homepage": "https://rust-lang.org", 232 /* The documentation value from the manifest or null if not specified. */ 233 "documentation": "https://doc.rust-lang.org/stable/std", 234 /* The default edition of the package. 235 Note that individual targets may have different editions. 236 */ 237 "edition": "2018", 238 /* Optional string that is the name of a native library the package 239 is linking to. 240 */ 241 "links": null, 242 } 243 ], 244 /* Array of members of the workspace. 245 Each entry is the Package ID for the package. 246 */ 247 "workspace_members": [ 248 "file:///path/to/my-package#0.1.0", 249 ], 250 /* Array of default members of the workspace. 251 Each entry is the Package ID for the package. 252 */ 253 "workspace_default_members": [ 254 "file:///path/to/my-package#0.1.0", 255 ], 256 // The resolved dependency graph for the entire workspace. The enabled 257 // features are based on the enabled features for the "current" package. 258 // Inactivated optional dependencies are not listed. 259 // 260 // This is null if --no-deps is specified. 261 // 262 // By default, this includes all dependencies for all target platforms. 263 // The `--filter-platform` flag may be used to narrow to a specific 264 // target triple. 265 "resolve": { 266 /* Array of nodes within the dependency graph. 267 Each node is a package. 268 */ 269 "nodes": [ 270 { 271 /* The Package ID of this node. */ 272 "id": "file:///path/to/my-package#0.1.0", 273 /* The dependencies of this package, an array of Package IDs. */ 274 "dependencies": [ 275 "https://github.com/rust-lang/crates.io-index#bitflags@1.0.4" 276 ], 277 /* The dependencies of this package. This is an alternative to 278 "dependencies" which contains additional information. In 279 particular, this handles renamed dependencies. 280 */ 281 "deps": [ 282 { 283 /* The name of the dependency's library target. 284 If this is a renamed dependency, this is the new 285 name. 286 */ 287 "name": "bitflags", 288 /* The Package ID of the dependency. */ 289 "pkg": "https://github.com/rust-lang/crates.io-index#bitflags@1.0.4" 290 /* Array of dependency kinds. Added in Cargo 1.40. */ 291 "dep_kinds": [ 292 { 293 /* The dependency kind. 294 "dev", "build", or null for a normal dependency. 295 */ 296 "kind": null, 297 /* The target platform for the dependency. 298 null if not a target dependency. 299 */ 300 "target": "cfg(windows)" 301 } 302 ] 303 } 304 ], 305 /* Array of features enabled on this package. */ 306 "features": [ 307 "default" 308 ] 309 } 310 ], 311 /* The package in the current working directory (if --manifest-path is not given). 312 This is null if there is a virtual workspace. Otherwise it is 313 the Package ID of the package. 314 */ 315 "root": "file:///path/to/my-package#0.1.0", 316 }, 317 /* The absolute path to the target directory where Cargo places its output. */ 318 "target_directory": "/path/to/my-package/target", 319 /* The absolute path to the build directory where Cargo places intermediate build artifacts. (unstable) */ 320 "build_directory": "/path/to/my-package/build-dir", 321 /* The version of the schema for this metadata structure. 322 This will be changed if incompatible changes are ever made. 323 */ 324 "version": 1, 325 /* The absolute path to the root of the workspace. */ 326 "workspace_root": "/path/to/my-package" 327 /* Workspace metadata. 328 This is null if no metadata is specified. */ 329 "metadata": { 330 "docs": { 331 "rs": { 332 "all-features": true 333 } 334 } 335 } 336 } 337 338 Notes: 339 340 o For "id" field syntax, see Package ID Specifications 341 <https://doc.rust-lang.org/cargo/reference/pkgid-spec.html> in the 342 reference. 343 344OPTIONS 345 Output Options 346 --no-deps 347 Output information only about the workspace members and don’t 348 fetch dependencies. 349 350 --format-version version 351 Specify the version of the output format to use. Currently 1 is the 352 only possible value. 353 354 --filter-platform triple 355 This filters the resolve output to only include dependencies for the 356 given target triple 357 <https://doc.rust-lang.org/cargo/appendix/glossary.html#target>. A 358 literal "host-tuple" can be used, which will internally be 359 substituted by the host’s target. Without this flag, the resolve 360 includes all targets. 361 362 Note that the dependencies listed in the “packages” array still 363 includes all dependencies. Each package definition is intended to be 364 an unaltered reproduction of the information within Cargo.toml. 365 366 Feature Selection 367 The feature flags allow you to control which features are enabled. When 368 no feature options are given, the default feature is activated for every 369 selected package. 370 371 See the features documentation 372 <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options> 373 for more details. 374 375 -F features, --features features 376 Space or comma separated list of features to activate. Features of 377 workspace members may be enabled with package-name/feature-name 378 syntax. This flag may be specified multiple times, which enables all 379 specified features. 380 381 --all-features 382 Activate all available features of all selected packages. 383 384 --no-default-features 385 Do not activate the default feature of the selected packages. 386 387 Display Options 388 -v, --verbose 389 Use verbose output. May be specified twice for “very verbose” 390 output which includes extra output such as dependency warnings and 391 build script output. May also be specified with the term.verbose 392 config value 393 <https://doc.rust-lang.org/cargo/reference/config.html>. 394 395 -q, --quiet 396 Do not print cargo log messages. May also be specified with the 397 term.quiet config value 398 <https://doc.rust-lang.org/cargo/reference/config.html>. 399 400 --color when 401 Control when colored output is used. Valid values: 402 403 o auto (default): Automatically detect if color support is 404 available on the terminal. 405 406 o always: Always display colors. 407 408 o never: Never display colors. 409 410 May also be specified with the term.color config value 411 <https://doc.rust-lang.org/cargo/reference/config.html>. 412 413 Manifest Options 414 --manifest-path path 415 Path to the Cargo.toml file. By default, Cargo searches for the 416 Cargo.toml file in the current directory or any parent directory. 417 418 --locked 419 Asserts that the exact same dependencies and versions are used as 420 when the existing Cargo.lock file was originally generated. Cargo 421 will exit with an error when either of the following scenarios 422 arises: 423 424 o The lock file is missing. 425 426 o Cargo attempted to change the lock file due to a different 427 dependency resolution. 428 429 It may be used in environments where deterministic builds are 430 desired, such as in CI pipelines. 431 432 --offline 433 Prevents Cargo from accessing the network for any reason. Without 434 this flag, Cargo will stop with an error if it needs to access the 435 network and the network is not available. With this flag, Cargo will 436 attempt to proceed without the network if possible. 437 438 Beware that this may result in different dependency resolution than 439 online mode. Cargo will restrict itself to crates that are 440 downloaded locally, even if there might be a newer version as 441 indicated in the local copy of the index. See the cargo-fetch(1) 442 command to download dependencies before going offline. 443 444 May also be specified with the net.offline config value 445 <https://doc.rust-lang.org/cargo/reference/config.html>. 446 447 --frozen 448 Equivalent to specifying both --locked and --offline. 449 450 --lockfile-path PATH 451 Changes the path of the lockfile from the default 452 (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock 453 (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that 454 providing --lockfile-path will ignore existing lockfile at the 455 default path, and instead will either use the lockfile from PATH, or 456 write a new lockfile into the provided PATH if it doesn’t exist. 457 This flag can be used to run most commands in read-only directories, 458 writing lockfile into the provided PATH. 459 460 This option is only available on the nightly channel 461 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and 462 requires the -Z unstable-options flag to enable (see #14421 463 <https://github.com/rust-lang/cargo/issues/14421>). 464 465 Common Options 466 +toolchain 467 If Cargo has been installed with rustup, and the first argument to 468 cargo begins with +, it will be interpreted as a rustup toolchain 469 name (such as +stable or +nightly). See the rustup documentation 470 <https://rust-lang.github.io/rustup/overrides.html> for more 471 information about how toolchain overrides work. 472 473 --config KEY=VALUE or PATH 474 Overrides a Cargo configuration value. The argument should be in 475 TOML syntax of KEY=VALUE, or provided as a path to an extra 476 configuration file. This flag may be specified multiple times. See 477 the command-line overrides section 478 <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> 479 for more information. 480 481 -C PATH 482 Changes the current working directory before executing any specified 483 operations. This affects things like where cargo looks by default 484 for the project manifest (Cargo.toml), as well as the directories 485 searched for discovering .cargo/config.toml, for example. This 486 option must appear before the command name, for example cargo -C 487 path/to/my-project build. 488 489 This option is only available on the nightly channel 490 <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and 491 requires the -Z unstable-options flag to enable (see #10098 492 <https://github.com/rust-lang/cargo/issues/10098>). 493 494 -h, --help 495 Prints help information. 496 497 -Z flag 498 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for 499 details. 500 501ENVIRONMENT 502 See the reference 503 <https://doc.rust-lang.org/cargo/reference/environment-variables.html> 504 for details on environment variables that Cargo reads. 505 506EXIT STATUS 507 o 0: Cargo succeeded. 508 509 o 101: Cargo failed to complete. 510 511EXAMPLES 512 1. Output JSON about the current package: 513 514 cargo metadata --format-version=1 515 516SEE ALSO 517 cargo(1), cargo-pkgid(1), Package ID Specifications 518 <https://doc.rust-lang.org/cargo/reference/pkgid-spec.html>, JSON 519 messages 520 <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages> 521