summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2023-04-11 00:03:29 +0300
committerkartofen <mladenovnasko0@gmail.com>2023-04-11 00:03:29 +0300
commita058f92f77438f7df07fa0e557595c620bce8f02 (patch)
tree8351621e60e907e18656be28328f7ac5147a4471 /build.sh
parent878726dbc3fd8803f436ee45b1e3ccff5693de24 (diff)
web build works
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh34
1 files changed, 24 insertions, 10 deletions
diff --git a/build.sh b/build.sh
index 8405053..9a37dce 100755
--- a/build.sh
+++ b/build.sh
@@ -5,15 +5,22 @@ cd ${0%/*} # go to project root
NAME="main"
DEBUG_FLAGS="-std=c99 -Wall -Wextra -g -pedantic -DDEBUG"
-# PROD_FLAGS="-std=c99 ???"
+PROD_FLAGS="-std=c99 -O2"
SDL_FLAGS="`sdl2-config --cflags --libs`"
-FLAGS="$DEBUG_FLAGS $SDL_FLAGS -lm"
+LIB_FLAGS="-lm"
+
+FLAGS="$DEBUG_FLAGS $SDL_FLAGS $LIB_FLAGS"
SRC="src"
OBJ="obj"
BIN="bin"
FILES="files"
RUN=0
+WEB=0
+
+function __web__ {
+ WEB=1
+}
function __run__ {
RUN=1
@@ -25,7 +32,7 @@ function __leak__ {
}
function __prod__ {
- FLAGS="$PROD_FLAGS $SDL_FLAGS"
+ FLAGS="$PROD_FLAGS $SDL_FLAGS $LIB_FLAGS"
}
function __clean__ {
@@ -45,13 +52,20 @@ then
__$1__
fi
-gcc -o $OBJ/main.o -c $SRC/main.c $FLAGS
-gcc -o $OBJ/player.o -c $SRC/player.c $FLAGS
-gcc -o $OBJ/sector.o -c $SRC/sector.c $FLAGS
+if { [[ $WEB -eq 0 ]]; } 2> /dev/null; then
+ gcc -o $OBJ/main.o -c $SRC/main.c $FLAGS
+ gcc -o $OBJ/player.o -c $SRC/player.c $FLAGS
+ gcc -o $OBJ/sector.o -c $SRC/sector.c $FLAGS
-gcc -o $BIN/$NAME $OBJ/*.o $FLAGS
+ gcc -o $BIN/$NAME $OBJ/*.o $FLAGS
-if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null
-then
- $VALGRND $BIN/$NAME
+ if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null; then
+ $VALGRND $BIN/$NAME
+ fi
+else
+ emcc -o $BIN/portal-engine.html $SRC/*.c \
+ $PROD_FLAGS $LIB_FLAGS \
+ -s USE_SDL=2 -s ASYNCIFY \
+ --shell-file $SRC/shell.html \
+ --preload-file $FILES/map_clear.txt
fi