File tree 1 file changed +26
-0
lines changed 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 {
292
292
}
293
293
```
294
294
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
+
295
321
For a more complete example see in the [ build script examples] [ build-script-examples ] page
296
322
the [ conditional compilation] [ conditional-compilation-example ] example.
297
323
You can’t perform that action at this time.
0 commit comments