kassane / sokol-d

D bindings for the sokol headers (https://github.com/floooh/sokol)
http://sokol-d.dub.pm/
zlib License
11 stars 5 forks source link

WASM support #7

Closed kassane closed 10 months ago

kassane commented 10 months ago

Need Emscripten-specific glue APIs.

References

kassane commented 10 months ago

cc: @floooh

I tried to reuse sokol-zig like pacman.zig and kc85.zig. However, the artifact (Step.Compile) is not shared, only the zig module (Step.Module).

WiP - preview (-DbetterC) image

kassane commented 10 months ago

cmd: zig build --summary all -DbetterC -Dtarget=wasm32-emscripten -Doptimize=ReleaseSmall

wasm-ld: warning: function signature mismatch: sg_alloc_pass
>>> defined as (i32) -> void in /home/kassane/sokol-d/zig-out/obj/examples.mrt.o
>>> defined as () -> i32 in /home/kassane/sokol-d/zig-cache/o/70d9f9df8b12bc72256f2b4309b1c6dd/libsokol.a(/home/kassane/sokol-d/zig-cache/o/513a9afc4f42b191deaec7167b382274/sokol_gfx.o)
Build Summary: 20/20 steps succeeded
install success
├─ install zcc success
│  └─ zig build-exe zcc ReleaseSafe native success 6s MaxRSS:233M
├─ emcc success 6s MaxRSS:650M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten success 6s MaxRSS:115M
│  └─ clear success 127ms MaxRSS:119M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
├─ clear (+1 more reused dependencies)
├─ emcc success 6s MaxRSS:647M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
│  └─ triangle success 142ms MaxRSS:124M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
├─ triangle (+1 more reused dependencies)
├─ emcc success 6s MaxRSS:638M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
│  └─ cube success 179ms MaxRSS:129M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
├─ cube (+1 more reused dependencies)
├─ emcc success 6s MaxRSS:648M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
│  └─ blend success 284ms MaxRSS:128M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
├─ blend (+1 more reused dependencies)
├─ emcc success 6s MaxRSS:641M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
│  └─ mrt success 345ms MaxRSS:132M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
├─ mrt (+1 more reused dependencies)
├─ emcc success 6s MaxRSS:650M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
│  └─ saudio success 190ms MaxRSS:120M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
├─ saudio (+1 more reused dependencies)
├─ emcc success 6s MaxRSS:648M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
│  └─ sgl_context success 250ms MaxRSS:127M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
├─ sgl_context (+1 more reused dependencies)
├─ emcc success 6s MaxRSS:652M
│  ├─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
│  └─ debugtext_print success 146ms MaxRSS:120M
│     └─ zig build-lib sokol ReleaseSmall wasm32-emscripten (reused)
└─ debugtext_print (+1 more reused dependencies)

--- Edit

https://github.com/kassane/sokol-d/actions/runs/7596015793 :heavy_check_mark:

floooh commented 10 months ago

FYI, I'm currently a bit busy with other (work-related) stuff. So don't expect to hear back from me for a few days. I hope to be able to look into the D bindings (and kick off a similar process as with the Zig bindings) some time next week :)

kassane commented 10 months ago

Don't worry! :+1: Sorry for the multiple notifications. I just want to inform you about the project updates... to say "I haven't given up on the binding project". :smile:

If you have spare time. Contribute and report any bugs that you find (there's always a :lady_beetle:).

kassane commented 9 months ago

For wasm target replace core.math, core.stdc.math and std.math to zig std.math.

https://github.com/kassane/sokol-d/blob/17140462f0a7100fb508921dbe753e64c5f55287/src/handmade/math.d#L13-L34

/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4563,13): Error: undefined identifier `c_long`
/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4563,13): Error: undefined identifier `c_long`
/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4565,13): Error: undefined identifier `c_long`
/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4565,13): Error: undefined identifier `c_long`
/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4665,13): Error: undefined identifier `c_long`
/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4665,13): Error: undefined identifier `c_long`
/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4667,13): Error: undefined identifier `c_long`
/home/kassane/ldcup/ldc2-08cc8408-linux-x86_64/bin/../import/core/stdc/math.d(4667,13): Error: undefined identifier `c_long`