pub fn generate_resources<P: AsRef<Path>, G: AsRef<Path>>(
project_dir: P,
filter: Option<fn(p: &Path) -> bool>,
generated_filename: G,
fn_name: &str,
) -> Result<()>Expand description
Generate resources for project_dir using filter.
Result saved in generated_filename and function named as fn_name.
in build.rs:
use std::{env, path::Path};
use static_files::resource::generate_resources;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let generated_filename = Path::new(&out_dir).join("generated.rs");
generate_resources("./tests", None, generated_filename, "generate").unwrap();
}in main.rs:
include!(concat!(env!("OUT_DIR"), "/generated.rs"));
fn main() {
let generated_file = generate();
assert_eq!(generated_file.len(), 4);
}