Got a basic WebAssembly module compiling with support for calling jsStdPrint through printf implementation (provided by stb_sprintf.h). We have a single function "HelloFromWasm" exported for testing purposes. Pulled in a bunch of standard library headers from PigCore's wasm layer.

This commit is contained in:
Taylor Robbins (Piggybank Studios)
2025-08-28 09:44:32 -07:00
parent aa2faca658
commit deae3ccd12
20 changed files with 2882 additions and 85 deletions

View File

@@ -1,3 +1,11 @@
# CWasm
A minimal layer for compiling C applications that render graphics through WebGL from a WebAssembly module using Clang (not Emscripten)
A minimal layer for compiling C applications that render graphics through WebGL from a WebAssembly module using Clang (not Emscripten)
# Compilation
CWasm is compiled with the applicaiton as a [Unity Build](https://en.wikipedia.org/wiki/Unity_build). The application's main source file must #include cwasm.c before anything else. The code in this repository is only tested with Clang as the compiler and `wasm32-unknown-unknown` as the target architecture. You must have a version of Clang that supports compiling to WebAssembly.
1. Install Clang (LLVM's Compiler) from [LLVM's Download Page](https://releases.llvm.org/download.html)
2. Make sure Clang is available from the command-line by doing `clang -v`. If it's not, make sure you update your `PATH` environment variable to include the `bin/` folder of the LLVM install directory
3. Ensure you have **Clang 11.0** or greater for proper WebAssembly support (we recommend using the latest, that's **v18.1.8** as this is written)
4. On Windows run the `build.bat [path/to/app.c]`. On Linux or OSX run the `build.sh [path/to/app.c]`. If compiling CWasm without a real application the app.c argument may be ommitted and test_app.c will be used instead.