This repository has been archived by the owner on Mar 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·325 lines (271 loc) · 7.9 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#!/bin/bash
# TODO: Should not be like this, heh
LUCIDITY_ROOT=`pwd`
BUILD_DIR=$LUCIDITY_ROOT/build
BUILD_LOG=$BUILD_DIR/build.log
BUILD_CONFIG=Release
BUILT_PRODUCTS_DIR=$BUILD_DIR/$BUILD_CONFIG
UNLOCALIZED_RESOURCES_FOLDER_PATH=Lucidity.app/Contents/Resources
RESOURCES_INSTALL_DIR=$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
PYTHON_DEST=$RESOURCES_INSTALL_DIR/python
PYTHONEXE=$RESOURCES_INSTALL_DIR/python3.1
FRAMEWORKS_FOLDER_PATH=Lucidity.app/Contents/Frameworks
FRAMEWORKS_INSTALL_DIR=$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH
function startTask() {
TASK=$1
echo "== Building $TASK =="
echo >> $BUILD_LOG
echo >> $BUILD_LOG
echo "== Building $TASK ==" >> $BUILD_LOG
}
function startSubTask() {
TASK=$1
echo "--- $TASK ---"
echo "--- $TASK ---" >> $BUILD_LOG
}
function endSubTask() {
if [ $? -ne 0 ]
then
printf "*** Failed ***\n" $BUILD_LOG
exit $?
fi
}
function skipTask() {
TASK=$1
echo "---- $TASK already installed, skipping ----"
echo "---- $TASK already installed, skipping ----" >> $BUILD_LOG
}
function help() {
printf "Options are: \n"
printf " - %s: %s\n" \
"build" "Build the entire app" \
"clean" "Remove all build files" \
"full" "Perform a complete rebuild" \
"dmg" "Make a distribution disk image" \
"wtf" "Go to the first error in the build log" \
"help" "This screen"
exit 1
}
function clean() {
echo "== Cleaing =="
rm -rf $BUILD_DIR
}
function buildPython() {
startTask "Python"
if ! [ -e $PYTHON_DEST ] ; then
startSubTask "Untarring"
tar xj -C $BUILT_PRODUCTS_DIR -f ./third-party/python/Python-*.tar.bz2
cd $BUILT_PRODUCTS_DIR/Python-*
startSubTask "Configuring"
./configure --prefix=$PYTHON_DEST --with-wide-unicode >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Compiling"
make -j2 >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Installing"
make install >> $BUILD_LOG 2>&1
endSubTask
# Link python here so we don't run into weird linker errors
# Mac OSX assumes that frameworks and dylibs will all be found
# relative to the parent directory of executables in a bundle
startSubTask "Linking"
ln -s $PYTHON_DEST/bin/python3.1 $PYTHONEXE
endSubTask
else
skipTask "Python"
fi
}
function buildPythonDependencies() {
cd $LUCIDITY_ROOT
for x in ./third-party/python-deps/*.gz ; do
libname=`basename $x | rev | cut -f 3- -d '.' | rev`
startTask "$libname"
if ! [ -e $BUILT_PRODUCTS_DIR/$libname ] ; then
BUILD_ARGS=""
if [ `echo $libname | cut -f 1 -d '-'` = "numpy" ] ; then
BUILD_ARGS="--fcompiler=gfortran"
fi
cd $LUCIDITY_ROOT
startSubTask "Untarring"
tar xz -C $BUILT_PRODUCTS_DIR -f $x
endSubTask
cd $BUILT_PRODUCTS_DIR/$libname
startSubTask "Compiling"
$PYTHONEXE setup.py build $BUILD_ARGS >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Installing"
$PYTHONEXE setup.py install >> $BUILD_LOG 2>&1
endSubTask
else
skipTask "$libname"
fi
done
}
function buildSDLDependencies() {
cd $LUCIDITY_ROOT
for x in ./third-party/SDL-deps/*.dmg ; do
libname=`basename $x | cut -f 1 -d '-'`
startTask "$libname"
if ! [ -e $FRAMEWORKS_INSTALL_DIR/$libname.framework ] ; then
startSubTask "Mounting"
hdiutil attach $x >> $BUILD_LOG
endSubTask
startSubTask "Copying Framework"
cp -rp /Volumes/$libname/$libname.framework $FRAMEWORKS_INSTALL_DIR
endSubTask
startSubTask "Unmounting"
hdiutil detach /Volumes/$libname >> $BUILD_LOG
endSubTask
else
skipTask "$libname"
fi
done
}
function buildSDL() {
cd $LUCIDITY_ROOT
startSubTask "Compiling"
xcodebuild -workspace ./third-party/SDL/Xcode/SDL/SDL.xcodeproj/project.xcworkspace -scheme Framework -configuration Release install >> $BUILD_LOG
endSubTask
startSubTask "Installing"
if ! [ -e $FRAMEWORKS_INSTALL_DIR ] ; then
mkdir $FRAMEWORKS_INSTALL_DIR
fi
cp -rp ./third-party/SDL/Xcode/SDL/build/Frameworks/SDL.framework $FRAMEWORKS_INSTALL_DIR
endSubTask
}
function buildPygameDependencies() {
cd $LUCIDITY_ROOT
for x in ./third-party/pygame-deps/*.gz ; do
libname=`basename $x | rev | cut -f 3- -d '.' | rev`
startTask "$libname"
UNTAR_DIR=$BUILT_PRODUCTS_DIR/$libname
if [ `echo $libname | grep 'freetype'` ] ; then
# Freetype has a stupid makefile config error where it fails
# to remove this directory because it does not exist. Lame++
mkdir -p $RESOURCES_INSTALL_DIR/include/freetype2/freetype/internal
elif [ `echo $libname | grep 'jpeg'` ] ; then
# libjpg untars itself to a non-standard name
UNTAR_DIR=$BUILT_PRODUCTS_DIR/jpeg-8b
fi
cd $LUCIDITY_ROOT
if ! [ -e $UNTAR_DIR ] ; then
startSubTask "Untarring"
tar xz -C $BUILT_PRODUCTS_DIR -f $x
endSubTask
cd $UNTAR_DIR
startSubTask "Configuring"
./configure --prefix=$RESOURCES_INSTALL_DIR >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Compiling"
make -j2 >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Installing"
make install >> $BUILD_LOG 2>&1
endSubTask
else
skipTask "$libname"
fi
done
}
function buildPortMidi() {
cd $LUCIDITY_ROOT/third-party/portmidi/pm_mac
startTask "PortMidi"
if ! [ -e $BUILT_PRODUCTS_DIR/portmidi ] ; then
startSubTask "Cleaning"
make clean >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Compiling"
make >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Installing"
cp libportmidi.a $RESOURCES_INSTALL_DIR/lib/libportmidi.a
endSubTask
else
skipTask "PortMidi"
fi
}
function buildPygame() {
startTask "Pygame"
if ! [ -e $PYTHON_DEST/lib/python3.1/site-packages/pygame ] ; then
cd $LUCIDITY_ROOT/third-party/pygame
startSubTask "Cleaning"
rm -rf Setup build >> $BUILD_LOG
endSubTask
PATH=$PATH:$RESOURCES_INSTALL_DIR/bin
startSubTask "Configuring"
$PYTHONEXE config.py $RESOURCES_INSTALL_DIR $FRAMEWORKS_INSTALL_DIR /System/Library/Frameworks >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Compiling"
$PYTHONEXE setup.py build >> $BUILD_LOG 2>&1
endSubTask
startSubTask "Installing"
$PYTHONEXE setup.py install >> $BUILD_LOG 2>&1
endSubTask
else
skipTask "PyGame"
fi
}
function buildId3Reader {
startTask "id3reader"
cd $LUCIDITY_ROOT/third-party/id3reader
startSubTask "Cleaning"
$PYTHONEXE setup.py clean >> $BUILD_LOG
endSubTask
startSubTask "Compiling"
$PYTHONEXE setup.py build >> $BUILD_LOG
endSubTask
startSubTask "Installing"
$PYTHONEXE setup.py install >> $BUILD_LOG
endSubTask
}
function buildLucidityModules() {
startTask "Lucidity Modules"
cd $LUCIDITY_ROOT/source
startSubTask "Cleaning"
$PYTHONEXE setup.py clean >> $BUILD_LOG
endSubTask
startSubTask "Compiling"
$PYTHONEXE setup.py build >> $BUILD_LOG
endSubTask
startSubTask "Installing"
$PYTHONEXE setup.py install >> $BUILD_LOG
endSubTask
}
function buildLucidityResources() {
startTask "Resources"
cp -r $LUCIDITY_ROOT/resources $RESOURCES_INSTALL_DIR
}
function buildWrapper() {
startTask "Wrapper"
startSubTask "Compiling"
xcodebuild -configuration $BUILD_CONFIG -project ./source/wrapper/mac/Lucidity.xcodeproj >> $BUILD_LOG
endSubTask
}
function buildAll() {
[ ! -e $BUILD_DIR ] && mkdir $BUILD_DIR
buildWrapper
buildPython
buildPythonDependencies
buildSDL
buildSDLDependencies
buildPygameDependencies
buildPortMidi
buildPygame
buildId3Reader
buildLucidityModules
buildLucidityResources
growlnotify -a "Lucidity Builder" -m "Build successful" --image $LUCIDITY_ROOT/icon.png "Build Status"
}
function makeDmg() {
startTask "DMG"
# TODO: Bah, need to get this script from Xcode
}
case $1 in
"") buildAll ;;
"build") buildAll ;;
"clean") clean ;;
"full") clean && buildAll ;;
"dmg") clean && buildAll && makeDmg ;;
"wtf") less -p 'error:' $BUILD_LOG ;;
*) help ;;
esac