Enable docker based Emscripten build on single file library test if emcc is not available.
parent
c6548eac8e
commit
a035654ab8
|
@ -6,6 +6,56 @@ OUT_FILE="tempbin"
|
|||
# Optional temporary compiled WebAssembly
|
||||
OUT_WASM="temp.wasm"
|
||||
|
||||
# Source files to compile using Emscripten.
|
||||
IN_FILES="examples/emscripten.c"
|
||||
|
||||
# Emscripten build using emcc.
|
||||
emscripten_emcc_build() {
|
||||
# Compile the the same example as above
|
||||
CC_FLAGS="-Wall -Wextra -Werror -Os -g0 -flto"
|
||||
emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES
|
||||
# Did compilation work?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compiling ${IN_FILES}: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "Compiling ${IN_FILES}: PASSED"
|
||||
rm -f $OUT_WASM
|
||||
}
|
||||
|
||||
# Emscripten build using docker.
|
||||
emscripten_docker_build() {
|
||||
docker container run --rm \
|
||||
--volume $PWD:/code \
|
||||
--workdir /code \
|
||||
trzeci/emscripten \
|
||||
emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES
|
||||
# Did compilation work?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compiling ${IN_FILES} (using docker): FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "Compiling ${IN_FILES} (using docker): PASSED"
|
||||
rm -f $OUT_WASM
|
||||
}
|
||||
|
||||
# Try Emscripten build using emcc or docker.
|
||||
try_emscripten_build() {
|
||||
which emcc > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
emscripten_emcc_build
|
||||
return $?
|
||||
fi
|
||||
|
||||
which docker > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
emscripten_docker_build
|
||||
return $?
|
||||
fi
|
||||
|
||||
echo "(Skipping Emscripten test)"
|
||||
}
|
||||
|
||||
# Amalgamate the sources
|
||||
./create_single_file_decoder.sh
|
||||
# Did combining work?
|
||||
|
@ -35,21 +85,7 @@ if [ $retVal -ne 0 ]; then
|
|||
fi
|
||||
echo "Running simple.c: PASSED"
|
||||
|
||||
# Is Emscripten available?
|
||||
which emcc > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "(Skipping Emscripten test)"
|
||||
else
|
||||
# Compile the Emscripten example
|
||||
CC_FLAGS="-Wall -Wextra -Werror -Os -g0 -flto --llvm-lto 3 -lGL -DNDEBUG=1"
|
||||
emcc $CC_FLAGS -s WASM=1 -o $OUT_WASM examples/emscripten.c
|
||||
# Did compilation work?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compiling emscripten.c: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "Compiling emscripten.c: PASSED"
|
||||
rm -f $OUT_WASM
|
||||
fi
|
||||
# Try Emscripten build if emcc or docker command is available.
|
||||
try_emscripten_build
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -9,6 +9,56 @@ OUT_FILE="tempbin"
|
|||
# Optional temporary compiled WebAssembly
|
||||
OUT_WASM="temp.wasm"
|
||||
|
||||
# Source files to compile using Emscripten.
|
||||
IN_FILES="zstd.c examples/roundtrip.c"
|
||||
|
||||
# Emscripten build using emcc.
|
||||
emscripten_emcc_build() {
|
||||
# Compile the the same example as above
|
||||
CC_FLAGS="-Wall -Wextra -Werror -Os -g0 -flto"
|
||||
emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES
|
||||
# Did compilation work?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compiling ${IN_FILES}: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "Compiling ${IN_FILES}: PASSED"
|
||||
rm -f $OUT_WASM
|
||||
}
|
||||
|
||||
# Emscripten build using docker.
|
||||
emscripten_docker_build() {
|
||||
docker container run --rm \
|
||||
--volume $PWD:/code \
|
||||
--workdir /code \
|
||||
trzeci/emscripten \
|
||||
emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM $IN_FILES
|
||||
# Did compilation work?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compiling ${IN_FILES} (using docker): FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "Compiling ${IN_FILES} (using docker): PASSED"
|
||||
rm -f $OUT_WASM
|
||||
}
|
||||
|
||||
# Try Emscripten build using emcc or docker.
|
||||
try_emscripten_build() {
|
||||
which emcc > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
emscripten_emcc_build
|
||||
return $?
|
||||
fi
|
||||
|
||||
which docker > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
emscripten_docker_build
|
||||
return $?
|
||||
fi
|
||||
|
||||
echo "(Skipping Emscripten test)"
|
||||
}
|
||||
|
||||
# Amalgamate the sources
|
||||
./create_single_file_library.sh
|
||||
# Did combining work?
|
||||
|
@ -41,21 +91,7 @@ if [ $retVal -ne 0 ]; then
|
|||
fi
|
||||
echo "Running roundtrip.c: PASSED"
|
||||
|
||||
# Is Emscripten available?
|
||||
which emcc > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "(Skipping Emscripten test)"
|
||||
else
|
||||
# Compile the the same example as above
|
||||
CC_FLAGS="-Wall -Wextra -Werror -Os -g0 -flto"
|
||||
emcc $CC_FLAGS -s WASM=1 -I. -o $OUT_WASM zstd.c examples/roundtrip.c
|
||||
# Did compilation work?
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Compiling emscripten.c: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
echo "Compiling emscripten.c: PASSED"
|
||||
rm -f $OUT_WASM
|
||||
fi
|
||||
# Try Emscripten build if emcc or docker command is available.
|
||||
try_emscripten_build
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue