-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
111 lines (89 loc) · 2.47 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
111
if [ "$1" == "help" ] || [ "$1" == "?" ]
then
echo "Build script:"
echo "Use 'help' or '?' to show this message"
echo "Use 'debug' or nothing to build and run a debug-build of the project"
echo "Use 'debug-norun' or 'norun' to build a debug-build of the project"
echo "Use 'release' to build the project with optimizations"
echo "Use 'setup' to create the folder structure. (src/ bin/ bin/debug/ bin/release/ res/ include/)"
echo
echo "When building all .o files will be deleted and the 'res' folder (excluding the dev folder) will be copied beside the executable"
elif [ "$1" == "debug" ] || [ "$1" == "" ]
then
echo "Building and Running Debug"
# count=`ls -1 *.o 2>/dev/null | wc -l`
# if [ $count -gt 0 ]
# then
# rm *.o
# fi
if [ -d "bin/debug/res/" ]
then
rm -r bin/debug/res/
fi
rsync -a --exclude 'dev/' res bin/debug/
g++ -c src/*.cpp -std=c++14 -m64 -g -Wall -Wextra -I include &&
g++ *.o -o bin/debug/main -lSDL2main -lSDL2 -lSDL2_image &&
rm *.o &&
./bin/debug/main
elif [ "$1" == "release" ]
then
echo "Building Release"
# count=`ls -1 *.o 2>/dev/null | wc -l`
# if [ $count -gt 0 ]
# then
# rm *.o
# fi
if [ -d "bin/release/res/" ]
then
rm -r bin/release/res/
fi
rsync -a --exclude 'dev/' res bin/release/
g++ -c src/*.cpp -std=c++14 -m64 -O3 -Wall -Wextra -I include &&
g++ *.o -o bin/release/main -s -lSDL2main -lSDL2 -lSDL2_image &&
rm *.o
elif [ "$1" == "debug-norun" ] || [ "$1" == "norun" ]
then
echo "Building Debug"
# count=`ls -1 *.o 2>/dev/null | wc -l`
# if [ $count -gt 0 ]
# then
# rm *.o
# fi
if [ -d "bin/debug/res/" ]
then
rm -r bin/debug/res/
fi
rsync -a --exclude 'dev/' res bin/debug/
g++ -c src/*.cpp -std=c++14 -m64 -g -Wall -Wextra -I include &&
g++ *.o -o bin/debug/main -lSDL2main -lSDL2 -lSDL2_image &&
rm *.o
elif [ "$1" == "setup" ]
then
echo "Creating folder structure"
if [ ! -d "src" ]
then
mkdir -v src/
fi
if [ ! -d "bin" ]
then
mkdir -v bin/
fi
if [ ! -d "bin/debug/" ]
then
mkdir -v bin/debug
fi
if [ ! -d "bin/release/" ]
then
mkdir -v bin/release/
fi
if [ ! -d "include" ]
then
mkdir -v include/
fi
if [ ! -d "res" ]
then
mkdir -v res/
fi
else
echo "Unknown option '$1', use 'help' if your lost"
fi