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

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

#312 in Build Utils

Download history 2755/week @ 2023-11-20 2395/week @ 2023-11-27 2395/week @ 2023-12-04 2099/week @ 2023-12-11 2782/week @ 2023-12-18 2074/week @ 2023-12-25 2164/week @ 2024-01-01 2560/week @ 2024-01-08 2409/week @ 2024-01-15 2508/week @ 2024-01-22 2428/week @ 2024-01-29 2255/week @ 2024-02-05 2514/week @ 2024-02-12 2144/week @ 2024-02-19 2021/week @ 2024-02-26 2171/week @ 2024-03-04

9,115 downloads per month
Used in 23 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