#codegen #include #assets #time #build #generation

includer_codegen

Dynamically include assets at build time through code generation

1 unstable release

0.1.0 Sep 14, 2018

#52 in Build Utils

Download history 41/week @ 2018-09-20 18/week @ 2018-09-27 6/week @ 2018-10-04 1/week @ 2018-10-11 28/week @ 2018-10-18 2/week @ 2018-10-25 5/week @ 2018-11-01 32/week @ 2018-11-08 19/week @ 2018-11-15 4/week @ 2018-11-22 33/week @ 2018-11-29 12/week @ 2018-12-06

2 downloads per month

Apache-2.0 OR MIT

31KB
469 lines

includer_codegen Build Status Documentation

This crate is intended to be used at build time to generate code that includes your assets. The "frontend" library includer provides the types for your library/binary that includer_codegen outputs, along with some helpers.

The following is a build.rs file that includes all the files (recursively) in the subdirectory resources in a cargo project.

extern crate includer_codegen;

use includer_codegen::prelude::*;
use std::env;
use std::path::PathBuf;

fn main() {
    let cargo_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
    let resources_path = PathBuf::from(cargo_dir).join("resources");
    let resources = Assets::new("ASSETS", resources_path).build();

    Codegen::new().pipe(resources).write();
}

Filtering

Filtering files is possible by included filter types. Currently there are built-in ways to include/exclude based on file extension or regex. See the documentation for the api to use these built-in filters.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.5MB
~43K SLoC