-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sh
executable file
·110 lines (88 loc) · 3.74 KB
/
build.sh
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
set -e
set -u
## was using c++11, but it didn't like variadic macros leaving a trailing
## comma if the "__VA_ARGS__" was empty, so I switched to gnu++11
CPPSTD="-std=gnu++11"
XCBLIBS="-lrt -lm -ldl -lxcb -lxcb-image -lxcb-icccm -lxcb-keysyms -lxcb-randr -lasound -lGL -lX11 -lX11-xcb"
CPPFLAGS="-pthread -I../iaca/include/ -DHANDMADE_INTERNAL=1 -DHANDMADE_SLOW=1"
WARNFLAGS="-Wall -Wno-unused-variable -Wno-unused-but-set-variable \
-Wno-write-strings -Wno-unused-function -Wno-strict-aliasing \
-Wno-switch -fpermissive -Wno-sign-compare -Wno-format \
-Wno-return-type -Wno-int-to-pointer-cast"
GAMEWARNFLAGS="${WARNFLAGS} -Wno-sign-compare"
DEBUG_FLAGS="-DDEBUG -g -DHANDMADE_SLOW=1 -DHHXCB_SLOW=1"
OPT_FLAGS="-Ofast"
buildType=""
dir=`basename $PWD`
if [ "$dir" == "debug" ]
then
buildType="debug"
cd ../..
fi
if [ "$dir" == "opt" ]
then
buildType="opt"
cd ../..
fi
dir=`basename $PWD`
if [ "$dir" == "src" ]
then
cd ..
fi
dir=`basename $PWD`
if [ "$dir" != "xcb_handmade" ]
then
exit
fi
mkdir -p build
if [ "$buildType" != "opt" ]
then
### Debug build
mkdir -p build/debug
## Simple preprocessor
#g++ ${CPPSTD} ${WARNFLAGS} -o build/debug/simple_preprocessor src/simple_preprocessor.cpp ${CPPFLAGS} ${DEBUG_FLAGS}
#pushd ../handmade/code
#../../xcb_handmade/build/debug/simple_preprocessor > handmade_generated.h
#popd
## Asset file builder
#g++ ${CPPSTD} ${WARNFLAGS} -o build/debug/multiplatform_test_asset_builder src/multiplatform_test_asset_builder.cpp ${CPPFLAGS} ${XCBLIBS} ${DEBUG_FLAGS} -lX11
## Shared library
g++ ${CPPSTD} ${GAMEWARNFLAGS} -shared -Wl,-soname,libhandmade.so.1 -fPIC -o build/debug/libhandmade.so.new src/handmade.cpp ${CPPFLAGS} ${DEBUG_FLAGS}
## Overwrite the old shared library with the new one
mv -f build/debug/libhandmade.so.new build/debug/libhandmade.so
## Alternate shared library
#g++ -std=c++0x ${GAMEWARNFLAGS} -shared -Wl,-soname,libalternate.so.1 -fPIC -o build/debug/libalternate.so.new src/alternate/alternate.cpp ${CPPFLAGS} ${DEBUG_FLAGS}
#mv -f build/debug/libalternate.so.new build/debug/libalternate.so
## Platform code
touch build/debug/lock.tmp
g++ ${CPPSTD} ${WARNFLAGS} -o build/debug/xcb_handmade src/xcb_handmade.cpp ${CPPFLAGS} ${XCBLIBS} ${DEBUG_FLAGS}
rm build/debug/lock.tmp
## Alternate platform code
#g++ -DGAME_CODE_FILENAME=libalternate.so -std=c++0x ${WARNFLAGS} -o build/debug/xcb_alternate src/xcb_handmade.cpp ${CPPFLAGS} ${XCBLIBS} ${DEBUG_FLAGS}
fi
if [ "$buildType" != "debug" ]
then
### Optimized build
mkdir -p build/opt
## Simple preprocessor
#g++ ${CPPSTD} ${WARNFLAGS} -o build/opt/simple_preprocessor src/simple_preprocessor.cpp ${CPPFLAGS}
#pushd ../handmade/code
#../../xcb_handmade/build/opt/simple_preprocessor > handmade_generated.h
#popd
## Asset file builder
#g++ ${CPPSTD} ${WARNFLAGS} -o build/opt/multiplatform_test_asset_builder src/multiplatform_test_asset_builder.cpp ${CPPFLAGS} ${XCBLIBS} -lX11
## Shared library
g++ ${CPPSTD} ${GAMEWARNFLAGS} -shared -Wl,-soname,libhandmade.so.1 -fPIC -o build/opt/libhandmade.so.new src/handmade.cpp ${CPPFLAGS} ${OPT_FLAGS}
## Overwrite the old shared library with the new one
mv -f build/opt/libhandmade.so.new build/opt/libhandmade.so
## Alternate shared library
#g++ -std=c++0x ${GAMEWARNFLAGS} -shared -Wl,-soname,libalternate.so.1 -fPIC -o build/opt/libalternate.so.new -I src src/alternate/alternate.cpp ${CPPFLAGS} ${OPT_FLAGS}
#mv -f build/opt/libalternate.so.new build/opt/libalternate.so
## Platform code
touch build/opt/lock.tmp
g++ ${CPPSTD} ${WARNFLAGS} -o build/opt/xcb_handmade src/xcb_handmade.cpp ${CPPFLAGS} ${XCBLIBS} ${OPT_FLAGS}
rm build/opt/lock.tmp
## Alternate platform code
#g++ -DGAME_CODE_FILENAME=libalternate.so -std=c++0x ${WARNFLAGS} -o build/opt/xcb_alternate src/xcb_handmade.cpp ${CPPFLAGS} ${XCBLIBS} ${OPT_FLAGS}
fi