-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·48 lines (35 loc) · 1.57 KB
/
build.sh
File metadata and controls
executable file
·48 lines (35 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -e
# --- CONFIGURE ---------------------------------------------------------------------
MODE="dev"
if [[ $1 != "" ]]; then MODE=$1; fi
if [[ $MODE != "dev" && $MODE != "debug" && $MODE != "release" ]]; then
echo "Failed to build. '$MODE' is not valid mode."
exit 1
fi
TARGET="linux_amd64"
if [[ $2 != "" ]]; then TARGET=$2; fi
if [[ $TARGET != "darwin_amd64" && $TARGET != "darwin_arm64" && $TARGET != "linux_amd64" ]]; then
echo "Failed to build. '$TARGET' is not a valid target."
exit 1
fi
CFLAGS="-std=gnu17 -Iext -ftrapv"
if [[ $MODE == "dev" ]]; then CFLAGS="$CFLAGS -O0 -DDEBUG"; fi
if [[ $MODE == "debug" ]]; then CFLAGS="$CFLAGS -Og -g -DDEBUG"; fi
if [[ $MODE == "release" ]]; then CFLAGS="$CFLAGS -O2 -fno-strict-aliasing"; fi
WFLAGS=""
if [[ $MODE == "debug" ]]; then WFLAGS="-Wall -Wno-missing-braces"; fi
LFLAGS="-Lext/sokol/lib"
if [[ $TARGET == "darwin_amd64" ]]; then LFLAGS="$LFLAGS -lsokol_darwin -framework OpenGL -framework Cocoa"; fi
if [[ $TARGET == "linux_amd64" ]]; then LFLAGS="$LFLAGS -lsokol_linux -lX11 -lXi -lXcursor -lEGL -lGL -ldl -lpthread -lm"; fi
echo "[target:$TARGET]"
echo "[mode:$MODE]"
# --- PREPROCESS --------------------------------------------------------------------
echo "[preprocess]"
#bin/shadertoh-$TARGET src/shaders/ src/render/shaders.h
# --- BUILD -------------------------------------------------------------------------
# -target arm64-apple-macos14
echo "[build]"
if [[ ! -d "out" ]]; then mkdir out; fi
cc src/main.c -o out/undeadwest $CFLAGS $WFLAGS $LFLAGS
if [[ $MODE == "dev" ]]; then out/undeadwest; fi