-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add experimental WASM32 support #63
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2279fb9
to
b96adca
Compare
fb65adc
to
0c8dd57
Compare
Building multiple targets now will reuse the same source code download of opencascade.
…nknown-unknown While upstream OpenCASCADE has support for wasm32-unknown-emscripten, we require wasm32-unknown-unknown for wasm-bindgen (and therefore iced).
The `pkg` folder contains the build wasm binary.
Building for WASM requires some extra flags passed through CXXFLAGS_wasm32_unknown_unknown. `autocxx` currently ignores compiler flags set through env vars, therefore we manually pass them.
… wasm32-unknown-unknown
For easier use with wasm-bindgen.
wasm-pack can only work on library crates, so we will split cadara into: - cadara (binary crate): will just call `cadara_lib::run_cadara()` - cadara_lib (library crate): library with a single public function `run_cadara` (previously `main`)
This will be the entry point for all native builds. We rename the former `main` function to `run_cadara` to keep compatibility with wasm-bindgen-test if later required (crashes if a function is called `main`).
This commit both enables the webgl backend of iced by default and enables wasm compatibilty in the getrandom crate.
tracing is now only used when not running on wasm, for wasm we use console_log and attach a panic handler.
This new crate implements remaining functions of `wasm32-unknown-unknown-libcxx` that can not be implemented in pure c. This is incomplete yet and will be addressed in future PRs.
For Rust/C++ interop to work correctly, we must manually call `wasm_libc::init`, which calls all global constructors in the C++ code. Not doing this, makes wasm-bindgen fail.
`run_cadara` (so effectively `main`) will now be automatically started when the wasm binrary is loaded in the browser.
Autocxx currently does not support constructors with WASM. This is a workaround for that.
This unsafe workaround will be removed in a future PR.
This adds a couple of `cargo-make` commands that ease building for wasm by automatically setting up a build environment for building CADara for WebAssembly.
0c8dd57
to
f544565
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds initial support for building and running
CADara
in WebAssembly (wasm32-unknown-unknown target). The changes include:cargo-make
commands for building and serving CADara for WebAssemblyTODO(wasm32)
comments throughout the codebase. These will be addressed in follow-up PRs.To build:
rustup install nightly
cargo make dev
(seecargo make help
for more wasm related commands)Known limitations:
Closes #58