#detection #change #static #time #build #generate #task #instructions #generating

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

#219 in Build Utils

Download history 1569/week @ 2022-12-02 1706/week @ 2022-12-09 1521/week @ 2022-12-16 1589/week @ 2022-12-23 1555/week @ 2022-12-30 1804/week @ 2023-01-06 1652/week @ 2023-01-13 1745/week @ 2023-01-20 1841/week @ 2023-01-27 2154/week @ 2023-02-03 1903/week @ 2023-02-10 2685/week @ 2023-02-17 2153/week @ 2023-02-24 2825/week @ 2023-03-03 2801/week @ 2023-03-10 2443/week @ 2023-03-17

10,754 downloads per month
Used in 19 crates (via static-files)

Unlicense OR MIT

24KB
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

~50KB