Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 14 additions & 3 deletions build/bind.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::{env, path::PathBuf};

use crate::wrap::enums::get_blocked_enum_names;

Expand All @@ -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");
}
Comment on lines +17 to +21

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new Emscripten-specific behavior is introduced here, but the repo CI currently only builds/tests native targets (Linux/Windows/macOS). Without a CI job that at least runs cargo build --target wasm32-unknown-emscripten (with emsdk installed), regressions to the Web path are likely to go unnoticed.

Copilot uses AI. Check for mistakes.

// Set the correct build profile
#[cfg(debug_assertions)]
{
Expand Down Expand Up @@ -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");
}
Comment on lines 81 to 85

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link_libs() uses cfg!(windows), cfg!(target_os = "macos"), and cfg!(unix) to decide which system libraries to link. In a build script those cfg! values reflect the host (where the build script runs), not the Cargo target. When building wasm32-unknown-emscripten from a Unix host this will still emit -lX11/etc, which should not be linked for Emscripten and can break the build. Use CARGO_CFG_TARGET_OS (and/or CARGO_CFG_TARGET_ENV) to branch on the target and add an emscripten path that avoids the desktop-only link directives.

Copilot uses AI. Check for mistakes.
}
Expand All @@ -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));
Expand Down
Loading