.

dscripten-tools

I was playing a bit with targeting JavaScript / WebAssembly from D. Sebastien Alaiwan already did a great job of putting together a working toolchain, however it was aiming for a very narrow purpose (simple SDL games).

To improve on the situation, I wrote some wrappers around the toolchain which allow using existing D build tools and workflows for targeting emscripten / WASM. These come in the form of programs with the same general command-line syntax as dmd and rdmd, so build tools such as Dub should be usable. I’ve also included a copy of Phobos / Druntime hacked enough to get things like writeln working. Garbage collection is currently stubbed - allocations work but the memory is never freed (until the page is reloaded, of course).

See the test directory for some examples of what works.

If you’re OK with starting from scratch, working entirely with @nogc, and targeting WASM only, LDC’s new WebAssembly target might suit you better.

Note: this article is back-dated, and was originally written on 2018-11-06.

Comments