wasm-test/build.sh

26 lines
562 B
Bash
Raw Normal View History

2024-10-14 21:42:29 +02:00
#!/bin/bash
2024-11-14 12:40:52 +01:00
export_sym="init draw key_pressed key_released set_velocity set_mouse BUFFER width height"
2024-10-14 21:42:29 +02:00
export_cmd=""
for e in $export_sym; do
export_cmd="$export_cmd -Wl,--export=$e";
done;
2024-11-13 10:05:35 +01:00
if [[ "$1" == "" ]]; then
f='app'
2024-11-14 11:05:49 +01:00
a='app.c'
2024-11-13 10:05:35 +01:00
else
f=$(echo $1 | sed "s/\..*$//g")
2024-11-14 11:05:49 +01:00
a=$1
2024-11-13 10:05:35 +01:00
fi
2024-10-14 21:42:29 +02:00
2024-11-13 10:05:35 +01:00
set -xe
clang png2c.c -o png2c -lm
./png2c "penger.png" > penger.c
2024-11-14 12:40:52 +01:00
./png2c "hand.png" > hand.c
2024-11-13 10:05:35 +01:00
2024-11-14 11:05:49 +01:00
clang -O2 --target=wasm32 -fno-builtin -nostdlib --no-standard-libraries -Wl,--no-entry $export_cmd -Wl,--allow-undefined -o $f.wasm $a
2024-10-14 21:42:29 +02:00
wasm2wat $f.wasm > $f.wat