#compile-time #binary-file #include-bytes #byte #build-time #include #build-script #binary #compile-times #linker

build include-blob

Include large binary files in an application without the compile time cost of include_bytes!

7 releases (2 stable)

1.0.1 May 12, 2025
1.0.0 Apr 19, 2024
0.1.5 Apr 18, 2024
0.1.4 Nov 7, 2023
0.1.1 Jan 24, 2023

#359 in Build Utils

Download history 4/week @ 2025-02-13 7/week @ 2025-02-27 1/week @ 2025-03-06 3/week @ 2025-03-13 114/week @ 2025-05-08 30/week @ 2025-05-15

144 downloads per month

0BSD license

10KB
149 lines

Include large files without the high compile time cost.

This crate provides the include_blob! macro as an alternative to the standard include_bytes! macro, which embeds a file by copying it to an object file and linking to it. This can reduce the (quite high) compile time cost of include_bytes!.

In order for this to work, the user code has to first add a build script that calls the make_includable function.

// build.rs
fn main() {
    include_blob::make_includable("../../directory-with-big-files");
}
let bytes: &[u8] = include_blob::include_blob!("test-project/blobs/file.txt");

include-blob

include-blob is a small crate that provides a replacement for include_bytes! that does not have the same severe impact on compile times when used with large files (several MB).

It works by pre-processing the files to be included in a build script, bundling them into static libraries, and telling Cargo to link against them.

Dependencies

~1.4–2.3MB
~48K SLoC