summaryrefslogtreecommitdiff
path: root/glfw/build.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-09-08 00:01:49 +0200
committerHampusM <hampus@hampusmat.com>2024-10-13 17:40:25 +0200
commit04ea6ebc3f0f0f5277b402fab1557da617e273ea (patch)
tree87d55fd310080c4e3ce182d32c2dea4978e4f1d9 /glfw/build.rs
parent3711d559f8df7eb7598cc2b828455831eff44a56 (diff)
refactor(glfw): use C-unwind ABI
Diffstat (limited to 'glfw/build.rs')
-rw-r--r--glfw/build.rs18
1 files changed, 16 insertions, 2 deletions
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<dyn Error>>
{
@@ -17,12 +19,24 @@ fn main() -> Result<(), Box<dyn Error>>
.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<unsafe extern \"C\" fn()>;"
+ )?;
Ok(())
}