wasm: support more vendor libraries

Adds support for:
- box2d
- cgltf
- stb image
- stb rect pack
This commit is contained in:
Laytan Laats
2024-09-09 18:49:13 +02:00
parent d783bca297
commit 5ae27c6ebc
45 changed files with 2828 additions and 231 deletions
+5
View File
@@ -5,6 +5,7 @@ LIB :: (
"lib/cgltf.lib" when ODIN_OS == .Windows
else "lib/cgltf.a" when ODIN_OS == .Linux
else "lib/darwin/cgltf.a" when ODIN_OS == .Darwin
else "lib/cgltf_wasm.o" when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32
else ""
)
@@ -13,7 +14,11 @@ when LIB != "" {
// Windows library is shipped with the compiler, so a Windows specific message should not be needed.
#panic("Could not find the compiled cgltf library, it can be compiled by running `make -C \"" + ODIN_ROOT + "vendor/cgltf/src\"`")
}
}
when ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32 {
foreign import lib "lib/cgltf_wasm.o"
} else when LIB != "" {
foreign import lib { LIB }
} else {
foreign import lib "system:cgltf"
+4
View File
@@ -0,0 +1,4 @@
//+build wasm32, wasm64p32
package cgltf
@(require) import _ "vendor:libc"
BIN
View File
Binary file not shown.
+4
View File
@@ -6,6 +6,10 @@ else
all: unix
endif
wasm:
mkdir -p ../lib
$(CC) -c -Os --target=wasm32 --sysroot=$(shell odin root)/vendor/libc cgltf.c -o ../lib/cgltf_wasm.o
unix:
mkdir -p ../lib
$(CC) -c -O2 -Os -fPIC cgltf.c