summaryrefslogtreecommitdiff
path: root/glfw/build.rs
diff options
context:
space:
mode:
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(())
}