Skip to content

Commit fbbc176

Browse files
authored
Clarify how cargo::metadata env var is selected (#14842)
### What does this PR try to resolve? At least for me, the explanation of how to use `cargo::metadata` is confusing. It seems to imply that the `X` in `DEP_X_KEY` is derived from the crate name, but it is actually derived from the `links` value in the package. This PR tries to rephrase the explanation to make this less confusing.
2 parents 66221ab + 17ba198 commit fbbc176

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/doc/src/reference/build-scripts.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,12 @@ key-value pairs. This metadata is set with the `cargo::metadata=KEY=VALUE`
432432
instruction.
433433

434434
The metadata is passed to the build scripts of **dependent** packages. For
435-
example, if the package `bar` depends on `foo`, then if `foo` generates
436-
`key=value` as part of its build script metadata, then the build script of
437-
`bar` will have the environment variables `DEP_FOO_KEY=value`. See the ["Using
438-
another `sys` crate"][using-another-sys] for an example of how this can be
439-
used.
435+
example, if the package `foo` depends on `bar`, which links `baz`, then if
436+
`bar` generates `key=value` as part of its build script metadata, then the
437+
build script of `foo` will have the environment variables `DEP_BAZ_KEY=value`
438+
(note that the value of the `links` key is used).
439+
See the ["Using another `sys` crate"][using-another-sys] for an example of
440+
how this can be used.
440441

441442
Note that metadata is only passed to immediate dependents, not transitive
442443
dependents.

0 commit comments

Comments
 (0)