change-detection

Crates.iochange-detection
lib.rschange-detection
version1.2.0
sourcesrc
created_at2020-12-05 21:25:15.300677
updated_at2021-04-17 21:12:14.570189
descriptionA library to generate change detection instructions during build time.
homepagehttps://github.com/rust-utility/change-detection
repositoryhttps://github.com/rust-utility/change-detection
max_upload_size
id319940
size24,044
Alexander Korolev (kilork)

documentation

README

A library to generate change detection instructions during build time

Legal

Dual-licensed under MIT or the UNLICENSE.

Features

Automates task of generating change detection instructions for your static files.

https://doc.rust-lang.org/cargo/reference/build-scripts.html#change-detection

Usage

Add dependency to Cargo.toml:

[dependencies]
change-detection = "1.2"

Add a call to build.rs:

use change_detection::ChangeDetection;

fn main() {
    ChangeDetection::path("src/hello.c").generate();
}

This is basically the same, as just write:

fn main() {
    println!("cargo:rerun-if-changed=src/hello.c");
}

You can also use a directory. For example, if your resources are in static directory:

use change_detection::ChangeDetection;

fn main() {
    ChangeDetection::path("static").generate();
}

One call to generate can have multiple path components:

use change_detection::ChangeDetection;

fn main() {
    ChangeDetection::path("static")
        .path("another_path")
        .path("build.rs")
        .generate();
}

Using path-matchers library you can specify include / exclude filters:

#[cfg(features = "glob")]
use change_detection::{path_matchers::glob, ChangeDetection};

fn main() {
    #[cfg(features = "glob")]
    ChangeDetection::exclude(glob("another_path/**/*.tmp").unwrap())
        .path("static")
        .path("another_path")
        .path("build.rs")
        .generate();
}

You can actual generated result with this command:

find . -name output | xargs cat
Commit count: 19

cargo fmt