#build-time #change #detection #generate #instructions #static #cargo

build change-detection

A library to generate change detection instructions during build time

3 stable releases

1.2.0 Apr 17, 2021
1.1.0 Dec 12, 2020
1.0.0 Dec 5, 2020

#640 in Build Utils

Download history 1840/week @ 2024-07-27 2031/week @ 2024-08-03 1829/week @ 2024-08-10 1628/week @ 2024-08-17 2103/week @ 2024-08-24 2128/week @ 2024-08-31 2067/week @ 2024-09-07 1996/week @ 2024-09-14 2714/week @ 2024-09-21 2293/week @ 2024-09-28 2187/week @ 2024-10-05 2310/week @ 2024-10-12 2476/week @ 2024-10-19 2598/week @ 2024-10-26 2920/week @ 2024-11-02 1832/week @ 2024-11-09

10,245 downloads per month
Used in 26 crates (via static-files)

Unlicense OR MIT

25KB
387 lines

A library to generate change detection instructions during build time

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

Dependencies

~51KB