Last active
May 12, 2018 17:24
-
-
Save gballet/f94bdfdb685882f856a1b93bf396994a to your computer and use it in GitHub Desktop.
Script to generate host functions from C with emscripten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script takes a rather dumb approach to declare external functions and | |
# tell emscripten not to link any library. This has the disadvantage that | |
# standard C libraries don't get linked either. This is fine if your WASM | |
# code doesn't need anything from the standard library. If your project is | |
# made of several modules, you need to #include them all which is not very | |
# nice. | |
if [ $# -lt 2 ] | |
then | |
echo "Syntax: $0 <file name>" | |
exit 0 | |
fi | |
name=$1 | |
emcc $name.c -s WASM=1 -s SIDE_MODULE=1 -O1 -o $name.wasm | |
wasm-dis $name.wasm > $name.wast |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment