-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·70 lines (60 loc) · 1.82 KB
/
build.sh
File metadata and controls
executable file
·70 lines (60 loc) · 1.82 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
#!/bin/bash
NPROC=$(nproc)
if [ "$NPROC" -lt 1 ]; then NPROC=1; fi
DEBUG=OFF
MINGW=OFF
EMSCRIPTEN=OFF
ALPINE=OFF
RERUN_CMAKE=false
BUILD_DIR=build/release
C=clang
CXX=clang++
for arg in "$@"; do
if [ "$arg" = "-debug" ]; then
printf "Building as debug...\n"
DEBUG=ON
BUILD_DIR=build/debug
elif [ "$arg" = "-cmake" ]; then
printf "Re-running cmake...\n"
RERUN_CMAKE=true
elif [ "$arg" = "-mingw" ]; then
printf "Building targeting Mingw...\n"
MINGW=ON
BUILD_DIR=build-mingw
elif [ "$arg" = "-emscripten" ]; then
printf "Building targeting Emscripten...\n"
EMSCRIPTEN=ON
BUILD_DIR=build-emscripten
elif [ "$arg" = "-alpine" ]; then
printf "Building targeting Alpine...\n"
ALPINE=ON
BUILD_DIR=build-alpine
fi
done
# Check for the existence of the build dir, if it doesn't exist, we need to rerun cmake.
if [ ! -d $BUILD_DIR ]; then
RERUN_CMAKE=true
fi
rm $BUILD_DIR/ResourceDragon
if [ "$MINGW" = "ON" ]; then
build-scripts/build_mingw.sh "$@"
else
if [ "$RERUN_CMAKE" = "true" ]; then
rm ${BUILD_DIR}/ResourceDragon
if [ $EMSCRIPTEN = "ON" ]; then
emcmake cmake -B ${BUILD_DIR} -G Ninja -DDEBUG=${DEBUG} -DEMSCRIPTEN=${EMSCRIPTEN}
else
cmake -B ${BUILD_DIR} -G Ninja -DDEBUG=${DEBUG} -DALPINE=${ALPINE} -DCMAKE_C_COMPILER=${C} -DCMAKE_CXX_COMPILER=${CXX}
fi;
fi
cd ${BUILD_DIR}
ninja -j$NPROC
cd ../../
if [ -f ${BUILD_DIR}/ResourceDragon ] || ([ $EMSCRIPTEN = "ON" ] && [ -f build-emscripten/ResourceDragon.wasm ]); then
printf "\x1B[1;32mCompiled successfully!\nOutput files are in $PWD/build/\x1B[0m \n"
exit 0
else
printf "\x1B[1;31mBuild Failed!! Check the build output.\n"
exit -1
fi
fi