#rebuild #times #modification #source #output-file #build-artifact #rebuilt

needs_rebuild

A utility to check if files need to be rebuilt based on their modification times

4 stable releases

Uses new Rust 2024

1.2.1 Nov 27, 2025
1.2.0 Nov 20, 2025
1.1.0 Nov 18, 2025
1.0.0 Nov 18, 2025

#853 in Filesystem

MIT license

11KB
188 lines

needs_rebuild

Checks whether a project needs to be rebuilt based on the modification times of its source files and build artifacts.

Usage

This crate is generally most useful in build scripts (build.rs) to conditionally trigger rebuilds.

For example, to check if a rebuild is necessary for C source files:

use needs_rebuild::{needs_rebuild, ScanOptions};
fn main() {
    const OUTPUT_FILE: &str = "build/lib/liboutput.a";
    let options = ScanOptions::new(&["*.c", "*.h"]);
    if needs_rebuild("libs/my_c_lib", OUTPUT_FILE, options) {
        rebuild_c_library();
    }
}

Dependencies

~3–7MB
~127K SLoC