Skip to main content

rusteal_codegen/rust_gen/
manual.rs

1// Hand-written binding extensions: glam conversions, FKey helpers, world and
2// widget wrappers.
3//
4// They live in this crate's `manual/` directory, are embedded at build time and
5// written verbatim into every generated `bindings` crate, where they compile
6// against the generated modules (`crate::core_ue`, `crate::engine`, ...).
7
8use std::path::Path;
9
10include!(concat!(env!("OUT_DIR"), "/manual_files.rs"));
11
12/// Write `src/manual/`, replacing whatever a previous run left behind.
13pub fn write_manual_module(src_dir: &Path) {
14    let manual_dir = src_dir.join("manual");
15    if manual_dir.exists() {
16        std::fs::remove_dir_all(&manual_dir)
17            .unwrap_or_else(|e| panic!("Failed to clean {}: {e}", manual_dir.display()));
18    }
19    std::fs::create_dir_all(&manual_dir)
20        .unwrap_or_else(|e| panic!("Failed to create {}: {e}", manual_dir.display()));
21
22    for (name, contents) in MANUAL_FILES {
23        std::fs::write(manual_dir.join(name), contents)
24            .unwrap_or_else(|e| panic!("Failed to write manual/{name}: {e}"));
25    }
26    eprintln!("  manual/: {} files", MANUAL_FILES.len());
27}