Skip to content

Commit dd546ea

Browse files
committed
Add some warnings/disclaimers about build-dependencies.
Also add `autocfg` to the list.
1 parent da36b81 commit dd546ea

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/doc/src/reference/build-script-examples.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ The following sections illustrate some examples of writing build scripts.
55
Some common build script functionality can be found via crates on [crates.io].
66
Check out the [`build-dependencies`
77
keyword](https://crates.io/keywords/build-dependencies) to see what is
8-
available. Some popular crates are:
8+
available. The following is a sample of some popular crates[^]:
99

1010
* [`bindgen`](https://crates.io/crates/bindgen) — Automatically generate Rust
1111
FFI bindings to C libraries.
1212
* [`cc`](https://crates.io/crates/cc) — Compiles C/C++/assembly.
1313
* [`pkg-config`](https://crates.io/crates/pkg-config) — Detect system
1414
libraries using the `pkg-config` utility.
1515
* [`cmake`](https://crates.io/crates/cmake) — Runs the `cmake` build tool to build a native library.
16-
* [`rustc_version`](https://crates.io/crates/rustc_version),
16+
* [`autocfg`](https://crates.io/crates/autocfg),
17+
[`rustc_version`](https://crates.io/crates/rustc_version),
1718
[`version_check`](https://crates.io/crates/version_check) — These crates
1819
provide ways to implement conditional compilation based on the current
19-
version of `rustc`.
20+
`rustc` such as the version of the compiler.
21+
22+
[^]: This list is not an endorsement. Evaluate your dependencies to see which
23+
is right for your project.
2024

2125
### Code generation
2226

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ The build script **does not** have access to the dependencies listed in the
230230
build dependencies are not available to the package itself unless also
231231
explicitly added in the `[dependencies]` table.
232232

233+
It is recommended to carefully consider each dependency you add, weighing
234+
against the impact on compile time, licensing, maintenance, etc. Cargo will
235+
attempt to reuse a dependency if it is shared between build dependencies and
236+
normal dependencies. However, this is not always possible, for example when
237+
cross-compiling, so keep that in consideration of the impact on compile time.
238+
233239
### Change Detection
234240

235241
When rebuilding a package, Cargo does not necessarily know if the build script

0 commit comments

Comments
 (0)