aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh70
1 files changed, 70 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..fbbd792
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+cd ${0%/*} # go to project root
+
+FLAGS="-Wall -Wextra -g -pedantic"
+FLAGS_RAYLIB="-lraylib -lm -lpthread -lGL -ldl -lrt -lX11"
+SRC="src"
+BIN="bin"
+OBJ="obj"
+NAME="kruskal"
+
+RUN=0
+VALGRIND=""
+
+WEB=0
+RAYLIB_SRC="/usr/local/src/raylib/src" #for web only
+
+function __run__ {
+ RUN=1
+}
+
+function __valgrind__ {
+ VALGRIND=valgrind
+ RUN=1
+}
+
+function __clean__ {
+ rm -rf $BIN
+ rm -rf $OBJ
+ kill $( ps -q $$ -o pgid= ) # exit
+}
+
+function __web__ {
+ WEB=1
+}
+
+set -xe
+
+if ! { [[ $# -eq 0 ]]; } 2> /dev/null
+then
+ __$1__
+fi
+
+
+mkdir -p $BIN
+mkdir -p $OBJ
+
+if { [[ $WEB -eq 0 ]]; } 2> /dev/null
+then
+ gcc -o $OBJ/main.o -c $SRC/main.c
+ gcc -o $OBJ/set.o -c $SRC/set.c
+ gcc -o $BIN/$NAME $OBJ/main.o $OBJ/set.o $FLAGS $FLAGS_RAYLIB
+
+ if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null
+ then
+ $VALGRIND $BIN/$NAME
+ fi
+else
+ source emsdk_env.sh
+
+ emcc -o $BIN/$NAME.html $SRC/main.c $SRC/set.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/$NAME.js -n | cut -d : -f 1)+1))d $BIN/$NAME.js > /dev/null
+fi