3 # Temporary compiled binary
6 # Optional temporary compiled WebAssembly
9 # Source files to compile using Emscripten.
10 IN_FILES="examples/emscripten.c"
12 # Emscripten build using emcc.
13 emscripten_emcc_build() {
14 # Compile the same example as above
15 CC_FLAGS="-Wall -Wextra -Wshadow -Werror -Os -g0 -flto"
16 emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES
17 # Did compilation work?
19 echo "Compiling ${IN_FILES}: FAILED"
22 echo "Compiling ${IN_FILES}: PASSED"
26 # Emscripten build using docker.
27 emscripten_docker_build() {
28 docker container run --rm \
31 emscripten/emsdk:latest \
32 emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES
33 # Did compilation work?
35 echo "Compiling ${IN_FILES} (using docker): FAILED"
38 echo "Compiling ${IN_FILES} (using docker): PASSED"
42 # Try Emscripten build using emcc or docker.
43 try_emscripten_build() {
44 which emcc > /dev/null
50 which docker > /dev/null
52 emscripten_docker_build
56 echo "(Skipping Emscripten test)"
59 # Amalgamate the sources
60 ./create_single_file_decoder.sh
63 echo "Single file decoder creation script: FAILED"
66 echo "Single file decoder creation script: PASSED"
68 # Compile the generated output
69 cc -Wall -Wextra -Wshadow -Werror -Os -g0 -o $OUT_FILE examples/simple.c
70 # Did compilation work?
72 echo "Compiling simple.c: FAILED"
75 echo "Compiling simple.c: PASSED"
77 # Run then delete the compiled output
82 if [ $retVal -ne 0 ]; then
83 echo "Running simple.c: FAILED"
86 echo "Running simple.c: PASSED"
88 # Try Emscripten build if emcc or docker command is available.