File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -292,6 +292,32 @@ if foo_bar_condition {
292292}
293293```
294294
295+ ##### Example of local-only ` build.rs ` /build script
296+
297+ Build scripts can impose costs on downstream users, and crate authors who wish to avoid
298+ this can use "local-only" build scripts, which are active locally but not packaged in the
299+ distributed package. Completly removing the cost from downstream users.
300+
301+ The way to achieved this, is by excluding the ` build.rs ` in the ` Cargo.toml ` with the
302+ ` exclude ` key:
303+
304+ ``` diff
305+ [package]
306+ name = "foo"
307+ version = "0.1.0"
308+ + exclude = ["build.rs"]
309+ ```
310+
311+ * ` build.rs ` :*
312+ ``` rust
313+ fn main () {
314+ // Warning: build.rs is not published to crates.io.
315+
316+ println! (" cargo::rerun-if-changed=build.rs" );
317+ println! (" cargo::rustc-check-cfg=cfg(foo)" );
318+ }
319+ ```
320+
295321For a more complete example see in the [ build script examples] [ build-script-examples ] page
296322the [ conditional compilation] [ conditional-compilation-example ] example.
297323
You can’t perform that action at this time.
0 commit comments