soywiz / Wasm2kt
Licence: mit
Web Assembly to Kotlin and Java converter. Allows to compile a C or C++ program/library, and generate a Kotlin or Java program/library.
Stars: ✭ 18
Projects that are alternatives of or similar to Wasm2kt
Asmble
Compile WebAssembly to JVM and other WASM tools
Stars: ✭ 466 (+2488.89%)
Mutual labels: webassembly, wasm, jvm
wasm2kt
Web Assembly to Kotlin and Java converter. Allows to compile a C or C++ program/library, and generate a Kotlin or Java program/library.
Stars: ✭ 20 (+11.11%)
Mutual labels: converter, jvm, wasm
Astro
A fun safe language for rapid prototyping and high performance applications
Stars: ✭ 588 (+3166.67%)
Mutual labels: webassembly, wasm
Vim.wasm
Vim editor ported to WebAssembly
Stars: ✭ 4,915 (+27205.56%)
Mutual labels: webassembly, wasm
Wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift
Stars: ✭ 6,413 (+35527.78%)
Mutual labels: webassembly, wasm
Graphql Client
Typed, correct GraphQL requests and responses in Rust
Stars: ✭ 620 (+3344.44%)
Mutual labels: webassembly, wasm
Awesome Wasm Runtimes
A list of webassemby runtimes
Stars: ✭ 490 (+2622.22%)
Mutual labels: webassembly, wasm
Markdown Wasm
Markdown parser and HTML generator implemented in WebAssembly, based on md4c
Stars: ✭ 833 (+4527.78%)
Mutual labels: webassembly, wasm
Awesome Wasm
😎 Curated list of awesome things regarding WebAssembly (wasm) ecosystem.
Stars: ✭ 6,377 (+35327.78%)
Mutual labels: webassembly, wasm
Webassembly
A minimal toolkit and runtime to produce and run WebAssembly modules.
Stars: ✭ 786 (+4266.67%)
Mutual labels: webassembly, wasm
Zwitterion
A web dev server that lets you import anything*
Stars: ✭ 514 (+2755.56%)
Mutual labels: webassembly, wasm
Dotnet Webassembly
Create, read, modify, write and execute WebAssembly (WASM) files from .NET-based applications.
Stars: ✭ 535 (+2872.22%)
Mutual labels: webassembly, wasm
Uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
Stars: ✭ 6,029 (+33394.44%)
Mutual labels: webassembly, wasm
Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+45283.33%)
Mutual labels: wasm, webassembly
Wasm And Rust
WebAssembly and Rust: A Web Love Story
Stars: ✭ 476 (+2544.44%)
Mutual labels: webassembly, wasm
Summary
This project allows to convert WASM (Web Assembly) from its binary format into Kotlin code. This allow for example to compile C or C++ libraries and use them in Kotlin common in any supported target including JVM, JS and Native.
The converter itself is written in kotlin.
How to use
Generate a Hello World in WASM:
echo -e "#include <stdio.h>\nint main() { printf(\"hello world\\\n\"); for (int n = 0; n < 10; n++) printf(\"%d,\", n); printf(\"\\\n\"); return 0; }" > hello.c
docker run --rm -v $(pwd):/src -t apiaryio/emcc:1.37 emconfigure emcc hello.c -o hello -O3 -s WASM=1
This will generate a hello.wasm
file.
After that, you can use this project to generate a kotlin executable kt
file from it:
echo '#!/usr/bin/env kscript' > hello.kt
cat src/main/kotlin/com/soywiz/wasm/WasmModule.kt >> hello.kt
./wasm2kt.kts hello.wasm >> hello.kt
echo -e "fun main(args: Array<String>) = Module.main(args)" >> hello.kt
chmod +x hello.kt
Now you can run it using kscript for example:
kscript hello.kt
Compile
wasm2kt.kts -lang kotlin -class Example a.out.wast > Example.kt
JAVA_OPTS="-Xmx2g -Xms128M" kotlinc Example.kt
What's working
- WAST parsing
- WASM parsing
- generating code from WAST generated by
emcc -O0 -g4
- buggy generating code from WAST generated by
emcc -O3 -g4
- buggy generated code from wasm
TO DO
- remaining fixes
- implementing remaining syscalls
- kotlin-common generator
- migrate code to kotlin-common
- generate a kotlin.js version of the generator and publish as a service online
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].