-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·147 lines (120 loc) · 2.61 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
# echo $1
# echo $2
CMD=$1
BUILD=$2
NOCODE=$3
cwd=${PWD##*/}
if [[ $OSTYPE == 'linux-gnu' || $OSTYPE == 'cygwin' ]]; then
export PLATFORM=linux
export NAME=$cwd
elif [[ $OSTYPE == 'darwin'* ]]; then
export PLATFORM=osx
export NAME=$cwd
elif [[ $OSTYPE == 'msys' || $OSTYPE == 'win32' ]]; then
export PLATFORM=windows
export NAME=$cwd.exe
fi
if [[ $NOCODE == 'nocode' ]] ; then
if [[ $PLATFORM == 'windows' ]]; then
export PATH="$PATH:/c/mingw32/bin:/c/SFML-2.5.1/bin"
else
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
fi
fi
export MAKE_EXEC=make
if [[ $PLATFORM == 'windows' ]]; then
if [ $(type -P "mingw32-make.exe") ]; then
export MAKE_EXEC=mingw32-make.exe
elif [ $(type -P "make.exe") ]; then
export MAKE_EXEC=make.exe
fi
fi
if [[ $BUILD != "Release" && $BUILD != 'Debug' ]]; then
BUILD=Release
fi
PROF_EXEC=gprof
PROF_ANALYSIS_FILE=profiler_analysis.stats
dec=\=\=\=\=\=\=
display_styled() {
tput setaf $1
tput bold
echo $dec $2 $dec
tput sgr0
}
build_success() {
display_styled 2 "Build Succeeded"
}
build_success_launch() {
display_styled 2 "Build Succeeded: Launching bin/$BUILD/$NAME"
}
build_fail() {
display_styled 1 "Build Failed: Review the compile errors above"
}
launch() {
display_styled 2 "Launching bin/$BUILD/$NAME"
}
launch_prod() {
display_styled 2 "Launching Production Build: $NAME"
}
profiler_done() {
display_styled 2 "Profiler Completed: View $PROF_ANALYSIS_FILE for details"
}
profiler_error() {
display_styled 1 "Error: Profiler must be run on Debug build."
}
profiler_osx() {
display_styled 1 "Error: Profiling (with gprof) is not supported on Mac OSX."
}
tput setaf 4
if [[ $CMD == 'buildrun' ]] ; then
if $MAKE_EXEC BUILD=$BUILD; then
build_success_launch
bin/$BUILD/$NAME
else
build_fail
fi
elif [[ $CMD == 'build' ]] ; then
if $MAKE_EXEC BUILD=$BUILD; then
build_success
else
build_fail
fi
elif [[ $CMD == 'rebuild' ]] ; then
if $MAKE_EXEC BUILD=$BUILD rebuild; then
build_success
else
build_fail
fi
elif [[ $CMD == 'run' ]] ; then
launch
bin/$BUILD/$NAME
elif [[ $CMD == 'buildprod' ]] ; then
if $MAKE_EXEC BUILD=$BUILD buildprod; then
build_success
else
build_fail
fi
elif [[ $CMD == 'profile' ]] ; then
if [[ $PLATFORM == 'osx' ]] ; then
profiler_osx
elif [[ $BUILD == 'Debug' ]] ; then
if $MAKE_EXEC BUILD=$BUILD; then
build_success_launch
tput sgr0
bin/$BUILD/$NAME
tput setaf 4
gprof bin/Debug/$NAME gmon.out > $PROF_ANALYSIS_FILE
profiler_done
else
build_fail
fi
else
profiler_error
fi
else
tput setaf 1
tput bold
echo $dec Error: Command \"$CMD\" not recognized. $dec
tput sgr0
fi
tput sgr0