diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 35 |
1 files changed, 29 insertions, 6 deletions
@@ -7,9 +7,13 @@ FLAGS_DISPLAY="-lraylib -lm -lpthread -lGL -ldl -lrt -lX11" SRC="src" BIN="bin" OBJ="obj" + RUN=0 VALGRIND="" +WEB=0 +RAYLIB_SRC="/usr/local/src/raylib/src" #for web only + function __run__ { RUN=1 } @@ -25,6 +29,10 @@ function __clean__ { kill $( ps -q $$ -o pgid= ) # exit } +function __web__ { + WEB=1 +} + set -xe if ! { [[ $# -eq 0 ]]; } 2> /dev/null @@ -36,11 +44,26 @@ fi mkdir -p $BIN mkdir -p $OBJ -gcc -c -o $OBJ/main.o $SRC/main.c -gcc -c -o $OBJ/display.o $SRC/display.c -gcc -o $BIN/main $OBJ/main.o $OBJ/display.o $FLAGS $FLAGS_DISPLAY - -if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null +if { [[ $WEB -eq 0 ]]; } 2> /dev/null then - $BIN/main + gcc -c -o $OBJ/main.o $SRC/main.c + gcc -c -o $OBJ/display.o $SRC/display.c + gcc -o $BIN/main $OBJ/main.o $OBJ/display.o $FLAGS $FLAGS_DISPLAY + + if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null + then + $BIN/main + fi +else + source emsdk_env.sh + + emcc -o $BIN/pendulum.html $SRC/main.c $SRC/display.c \ + $FLAGS -DPLATFORM_WEB -DRAYLIB_SRC="\"$RAYLIB_SRC/raylib.h\"" \ + $RAYLIB_SRC/libraylib.a \ + -I$RAYLIB_SRC/raylib.h \ + -s USE_GLFW=3 -s ASYNCIFY \ + --shell-file $SRC/shell.html + + # delete e line that blocks backspace and tab + sed -i $(($(grep "keyCode === 8" $BIN/pendulum.js -n | cut -d : -f 1)+1))d $BIN/pendulum.js > /dev/null fi |