Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/doc/src/reference/build-script-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ There’s a couple of points of note here:
such crate as a dependency, because there's an *implicit* invariant that
sources in `.cargo/registry` should be immutable. `cargo` won't allow such
scripts when packaging.
* Sometimes, projects want to check in a generated file, and treat it as
source code. However, in this case, the file shouldn't be generated from
`build.rs`. Instead, have a test or similar which checks that the file
precisely matches the generated version *and fails if the result doesn't
match*, and run that test as part of your CI. (The test can generate a
temporary file to compare to, and if you want to update the generated file,
you can replace the checked-in file with that temporary file.)
Comment on lines +89 to +95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: should we point people to libraries like expect-test ad snapbox for doing this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to point people to snapbox and insta and expect-test, yes.

* This script is relatively simple as it just writes out a small generated file.
One could imagine that other more complex operations could take place such as
generating a Rust module from a C header file or another language definition,
Expand Down