From 04ea6ebc3f0f0f5277b402fab1557da617e273ea Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 8 Sep 2024 00:01:49 +0200 Subject: refactor(glfw): use C-unwind ABI --- glfw/build.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'glfw/build.rs') diff --git a/glfw/build.rs b/glfw/build.rs index aaf4446..18ac677 100644 --- a/glfw/build.rs +++ b/glfw/build.rs @@ -1,8 +1,10 @@ use std::env; use std::error::Error; +use std::fs::OpenOptions; +use std::io::Write; use std::path::PathBuf; -use bindgen::MacroTypeVariation; +use bindgen::{Abi, MacroTypeVariation}; fn main() -> Result<(), Box> { @@ -17,12 +19,24 @@ fn main() -> Result<(), Box> .allowlist_function("glfw.*") .allowlist_type("GLFW.*") .allowlist_var("GLFW.*") + .blocklist_type("GLFWglproc") .default_macro_constant_type(MacroTypeVariation::Signed) + .override_abi(Abi::CUnwind, ".*") .generate()?; let out_path = PathBuf::from(env::var("OUT_DIR")?); - bindings.write_to_file(out_path.join("bindings.rs"))?; + let bindings_file_path = out_path.join("bindings.rs"); + + bindings.write_to_file(&bindings_file_path)?; + + let mut bindings_file = OpenOptions::new().append(true).open(bindings_file_path)?; + + // Cannot be C-unwind :( + writeln!( + bindings_file, + "pub type GLFWglproc = ::std::option::Option;" + )?; Ok(()) } -- cgit v1.2.3-18-g5258