-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for Wasm/emscripten target #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
|
|
||
|
|
@@ -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"); | ||
| } | ||
|
Comment on lines
81
to
85
|
||
| } | ||
|
|
@@ -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)); | ||
|
|
||
There was a problem hiding this comment.
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.