From 2e2c57a8c04575eec164279a49947cfdba250853 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Fri, 26 Jul 2024 23:15:22 +1000 Subject: scenes and pbr cleanup to handle missing texture of param --- bindgen/rust/celeritas-sys/build.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'bindgen/rust/celeritas-sys/build.rs') diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs index 097e26b..f7bf741 100644 --- a/bindgen/rust/celeritas-sys/build.rs +++ b/bindgen/rust/celeritas-sys/build.rs @@ -1,7 +1,33 @@ use std::env; use std::path::PathBuf; +use bindgen::callbacks::ParseCallbacks; + +const serializable_types: &[&'static str] = &[ + "Vec2", + "Vec3", + "Vec4", + "Mat4", + "Quat", + "DirectionalLight", + "PointLight", +]; + +#[derive(Debug)] +struct DeriveSerialize; +impl ParseCallbacks for DeriveSerialize { + fn add_derives(&self, info: &bindgen::callbacks::DeriveInfo<'_>) -> Vec { + if (serializable_types.contains(&info.name)) { + vec!["Serialize".to_string(), "Deserialize".to_string()] + } else { + vec![] + } + } +} + fn main() { + /* */ + // Tell cargo to look for shared libraries in the specified directory // TODO: we need to look based on OS println!("cargo:rustc-link-search=../../../build/macosx/arm64/debug"); @@ -43,6 +69,7 @@ fn main() { // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) + .parse_callbacks(Box::new(DeriveSerialize)) // Finish the builder and generate the bindings. .generate() // Unwrap the Result and panic on failure. -- cgit v1.2.3-70-g09d2