pub fn generate_resources_sets<P, G, S>(
project_dir: P,
filter: Option<fn(p: &Path) -> bool>,
generated_filename: G,
module_name: &str,
fn_name: &str,
set_split_strategie: &mut S,
) -> Result<()>Expand description
Generate resources for project_dir using filter
breaking them into separate modules using set_split_strategie (recommended for large > 128 Mb setups).
Result saved in module named module_name. It exports
only one function named fn_name. It is then exported from
generated_filename. generated_filename is also used to determine
the parent directory for the module.
in build.rs:
use std::{env, path::Path};
use static_files::sets::{generate_resources_sets, SplitByCount};
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let generated_filename = Path::new(&out_dir).join("generated_sets.rs");
generate_resources_sets(
"./tests",
None,
generated_filename,
"sets",
"generate",
&mut SplitByCount::new(2),
)
.unwrap();
}in main.rs:
include!(concat!(env!("OUT_DIR"), "/generated_sets.rs"));
fn main() {
let generated_file = generate();
assert_eq!(generated_file.len(), 4);
}