Minor fixes in simpleservo: improve embedding C header generation. Don't recursively panic if embedder doesn't throw on panic. Make init_with_gl unavailable when doing non-WGL windows build.

This commit is contained in:
Philip Lamb 2021-03-29 16:47:32 +13:00
parent 0539043e35
commit b19438ad07
3 changed files with 18 additions and 8 deletions

View file

@ -17,11 +17,7 @@ fn main() {
let profile_dir = env::var("PROFILE").unwrap();
path.push(profile_dir);
path.push("simpleservo.h");
cbindgen::Builder::new()
.with_crate(crate_dir)
.with_language(cbindgen::Language::C)
.exclude_item("OutputDebugStringA")
.generate()
.expect("Unable to generate bindings")
cbindgen::generate(crate_dir)
.expect("Unable to generate C bindings")
.write_to_file(path);
}

View file

@ -0,0 +1,9 @@
language = "C"
include_guard = "simpleservo_h"
cpp_compat = true
tab_width = 4
documentation_style = "c99"
[export]
exclude = ["OutputDebugStringA"]

View file

@ -58,7 +58,8 @@ fn report_panic(reason: &str, backtrace: Option<String>) {
};
let error = CString::new(message).expect("Can't create string");
(ON_PANIC.read().unwrap())(error.as_ptr());
panic!("At that point, embedder should have thrown");
// At this point, embedder should probably have thrown, so we never reach
// this point. But if it didn't, don't recursively panic.
}
#[cfg(not(target_os = "windows"))]
@ -490,7 +491,11 @@ pub extern "C" fn init_with_egl(
}
}
#[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
#[cfg(any(
target_os = "linux",
all(target_os = "windows", not(feature = "no-wgl")),
target_os = "macos"
))]
#[no_mangle]
pub extern "C" fn init_with_gl(
opts: CInitOptions,