diff --git a/Cargo.toml b/Cargo.toml index c6932c6..629be57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ num-traits = "^0.2.19" num-derive = "^0.4.2" [build-dependencies] -bindgen = "0.70.1" +bindgen = "0.72.1" cmake = "0.1.51" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" diff --git a/build/bind.rs b/build/bind.rs index f6672b8..8d4c785 100644 --- a/build/bind.rs +++ b/build/bind.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::{env, path::PathBuf}; use crate::wrap::enums::get_blocked_enum_names; @@ -14,6 +14,12 @@ pub fn compile_raylib(raylib_path: &str) { cmake_config.define("BUILD_SHARED_LIBS", "ON"); } + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + + if target_os == "emscripten" { + cmake_config.define("PLATFORM", "Web"); + } + // Set the correct build profile #[cfg(debug_assertions)] { @@ -74,8 +80,7 @@ pub fn link_libs() { // Link raylib itself if cfg!(feature = "dylib") { println!("cargo:rustc-link-lib=dylib=raylib"); - } - else { + } else { println!("cargo:rustc-link-lib=static=raylib"); } } @@ -94,6 +99,12 @@ pub fn generate_bindings(header_file: &str) { .blocklist_item("false_") .blocklist_item("true_"); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + + if target_os == "emscripten" { + builder = builder.clang_arg("-fvisibility=default"); + } + // Deny all blocked enums for enum_name in get_blocked_enum_names() { builder = builder.blocklist_type(format!("{}.*", enum_name));