-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·173 lines (142 loc) · 3.02 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
oldCC=$CC
oldCXX=$CXX
# Set the compiler to clang
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
usage()
{
cat << EOF
usage: $0 options
This script can build, clean, and grab new versions,
Rebuild = Clean and Build
Pull = Clean, Pull Dependencies and Build
OPTIONS:
-h Show this message
-v Verbose
-o Option, can be 'run', 'rebuild', 'run' or 'pull' [default: run]
-n No Clean
-g Game Name
EOF
}
makeIt()
{
beLoud=$1
if [[ $beLoud == 1 ]]; then
cmake .
make
else
cmake . >> /dev/null
make >> /dev/null
fi
}
pullCode()
{
beLoud=$1
if [[ $beLoud == 1 ]]; then
git submodule init
git submodule update --recursive
git submodule foreach git pull origin master --recurse-submodules
else
git submodule init >> /dev/null
git submodule update --recursive >> /dev/null
git submodule foreach git pull origin master --recurse-submodules >> /dev/null
fi
}
# Build Number
buildNumber()
{
buildName=$1
beLoud=$2
# Text file
awk -F, '{$1=$1+1}1' OFS= buildNumber.txt > buildNumberNew.txt && mv buildNumberNew.txt buildNumber.txt
# Get the result
buildNumber=$(cat buildNumber.txt)
# Build the header
l1="#ifndef NORDICARTS_"
l1+=$buildName
l1+="_BUILDNUMBER"
l2="#define NORDICARTS_"
l2+=$buildName
l2+="_BUILDNUMBER "
l2+=$buildNumber
l3="#endif"
echo -e $l1 > $buildName/buildNumber.hpp
echo -e $l2 >> $buildName/buildNumber.hpp
echo -e $l3 >> $buildName/buildNumber.hpp
}
GAMENAME="Valkyrie"
OPT="run"
VERBOSE=false
PULL=false
CLEAN=1
while getopts ":o:g:vhnp?" OPTION
do
case $OPTION in
o)
OPT=$OPTARG
;;
n)
CLEAN=false
;;
p)
PULL=1
;;
h)
usage
exit 1
;;
v)
VERBOSE=1
;;
g)
GAMENAME=$OPTARG
;;
esac
done
# Clear window
clear
# Remove the GameLink and make the one in the gamename
cd GameWrapper
rm -rf Game
ln -s ../../$GAMENAME Game
cd ../
if [[ $PULL == 1 ]]; then
pullCode $VERBOSE
fi
if [[ $OPT == "build" ]]; then
buildNumber "GameWrapper" $VERBOSE
makeIt $VERBOSE
if [[ $CLEAN == 1 ]]; then
./cleaner.sh -t cmake
fi
fi
if [[ $OPT == "rebuild" ]]; then
if [[ $CLEAN == 1 ]]; then
./cleaner.sh -t all
fi
buildNumber "GameWrapper" $VERBOSE
makeIt $VERBOSE
if [[ $CLEAN == 1 ]]; then
./cleaner.sh -t cmake
fi
fi
if [[ $OPT == "run" ]]; then
if [[ $CLEAN == 1 ]]; then
./cleaner.sh -t all
fi
buildNumber "GameWrapper" $VERBOSE
makeIt $VERBOSE
if [[ $CLEAN == 1 ]]; then
./cleaner.sh -t cmake
fi
cd Build
if [[ -d ../../$GAMENAME/GameFiles ]]; then
cp -r ../../$GAMENAME/GameFiles .
else
cp -r ../GameFiles .
fi
./GameWrapper.app
fi
export CC=$oldCC
export CXX=$oldCXX