| Crates.io | rerun_except |
| lib.rs | rerun_except |
| version | 1.0.0 |
| created_at | 2019-05-26 19:26:13.520662+00 |
| updated_at | 2021-03-01 11:38:48.560004+00 |
| description | Rerun a cargo build except when specified files are changed |
| homepage | |
| repository | https://github.com/softdevteam/rerun_except/ |
| max_upload_size | |
| id | 137185 |
| size | 10,489 |
Specify which files should not trigger a cargo rebuild.
In normal operation, cargo rebuilds a project when any potentially relevant
file changes. One can use the
rerun-if-changed
instruction to tell cargo to only rebuild if certain files are changed.
However, it is easy to forget to add new files when using rerun-if-changed,
causing cargo not to rebuild a project when it should.
rerun_except inverts this logic, causing cargo to rebuild a project when a
file changes unless you explicitly ignored that file. This is safer than
rerun-if-changed because if you forget to explicitly ignore files, then
cargo will still rebuild your project.
rerun_except uses the ignore library to
specify which files to ignore in gitignore format. Note that explicit ignore
files in your project (e.g. .gitignore) are implicitly added to the list of
ignored files.
For example if you have the following file layout:
proj/
.gitignore
Cargo.toml
src/
lib.rs
lang_tests/
run.rs
test1.lang
test2.lang
target/
...
and you do not want the two .lang files to trigger a rebuild then you would
tell rerun_except to exclude lang_tests/*.lang. Assuming, as is common, that your
.gitignore file also the target/ directory, then rerun_except will
also ignore the target directory.
Adding a new file such as lang_tests/test3.lang will not trigger a rebuild
(since it is covered by the ignore glob lang_tests/*.lang), but adding a new
file such as build.rs will trigger a rebuild (since it is not covered by an
ignore glob).
To use rerun_except in this manner you simply need to call
rerun_except::rerun_except with an array of ignore globs in gitignore
format as part of your build.rs file:
use rerun_except::rerun_except;
fn main() {
rerun_except(&["lang_tests/*.lang"]).unwrap();
}