-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsdl_build.sh
More file actions
88 lines (76 loc) · 1.64 KB
/
sdl_build.sh
File metadata and controls
88 lines (76 loc) · 1.64 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# Flags
CLEAN=''
DEBUG=''
GUI_DEBUG=''
RUN=''
while getopts 'cdgr' flag; do
case "${flag}" in
c) CLEAN='true' ;;
d) DEBUG='true' ;;
g) GUI_DEBUG='true' ;;
r) RUN='true' ;;
esac
done
# Clean
if [ "${CLEAN}" ]; then
echo "Removing /build"
rm -rf ./build
rm -rf *.dylib
rm -rf *.dSYM
if [ ! "${RUN}" ] && [ ! "${DEBUG}" ]; then
exit 1
fi
fi
# Build
CC="clang"
CFLAGS="-g
-std=c99
-Wall
-Wextra
-Wno-unused-parameter
-Wno-null-dereference"
D_FLAGS="-DHANDMADE_SDL=1
-DHANDMADE_SLOW=1
-DHANDMADE_INTERNAL=1"
echo "Building Handmade Hero"
mkdir -p ./build/bin/
SRC_DIR="../../../src/"
pushd ./build/bin/
if ! $CC $CFLAGS $D_FLAGS -fPIC -shared -o libhandmade.dylib "../../src/handmade.c" ; then
exit 1
fi
popd
pushd ./build/bin/
if ! $CC $CFLAGS $D_FLAGS -o "sdl_handmade" ./libhandmade.dylib "../../src/sdl.c" $(pkgconf --cflags --libs sdl3) ; then
exit 1
fi
popd
# Debug / Run
if [ "${DEBUG}" ]; then
if [ "${CC}" == "clang" ]; then
pushd ./build/bin/
lldb ./sdl_handmade
popd
exit 1
elif [ "${CC}" == "gcc" ]; then
if [ "$(uname)" == "Darwin" ] && [ "$(uname -p)" == "arm" ]; then
echo gdb not supported on $(sysctl -n machdep.cpu.brand_string)
exit 1
fi
pushd ./build/bin/
gdb ./sdl_handmade
popd
exit 1
fi
fi
if [ "${GUI_DEBUG}" ]; then
open -a Xcode ./debug/macos_debug/macos_debug.xcodeproj
exit 1
fi
if [ "${RUN}" ]; then
echo "Running Handmade Hero"
pushd ./build/bin/
./sdl_handmade
popd
fi