forked from avilleret/OSSIA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.sh
executable file
·469 lines (396 loc) · 13.8 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#!/bin/bash -x
########################################
###### Intro & Parameter handling ######
########################################
ISCORE_CMAKE_DEBUG=""
ISCORE_QMAKE_DEBUG=""
ISCORE_CMAKE_TOOLCHAIN=""
ISCORE_QMAKE_TOOLCHAIN=""
ISCORE_BREW_UNIVERSAL_FLAGS=""
ISCORE_CMAKE_UNIVERSAL_FLAGS=""
ISCORE_DEPTH_GIT="--depth=1"
ISCORE_FOLDER="i-score"
ISCORE_JAMOMA_BRANCH="dev"
ISCORE_JAMOMAMAX_BRANCH="dev"
ISCORE_SCORE_BRANCH="dev"
ISCORE_ISCORE_BRANCH="dev"
ISCORE_BREW_FLAGS="--build-bottle"
ISCORE_CMAKE_PD_FLAGS="-DDONT_BUILD_JAMOMAPD:bool==True" # don't build JamomaPd for now
source settings.sh
function fixup_deb_pkg {
PKG=$1
echo "Fixing package : $PKG"
echo
mkdir fix_up_deb
dpkg-deb -x $PKG fix_up_deb
dpkg-deb --control $PKG fix_up_deb/DEBIAN
rm $PKG
chmod 0644 fix_up_deb/DEBIAN/md5sums
find -type d -print0 |xargs -0 chmod 755
fakeroot dpkg -b fix_up_deb $PKG
rm -rf fix_up_deb
}
HELP_MESSAGE="Usage : $(basename "$0") [software] [options]
Builds Jamoma, Score, and i-score 0.2, 0.3 on Linux and OS X systems.
Software :
iscore
Builds and packages i-score. Requires jamoma to be installed.
(Calling the script with jamoma will do)
i-score_player
Builds the i-score command-line player. Requires jamoma to be installed.
jamoma
Builds and installs Jamoma on the system folders, or creates release packages.
Options :
--clone
Clones the git repositories.
--fetch-all
Fetches the full git repositories instead of the tip of the feature/cmake branch. Useful for development.
--install-deps
Installs dependencies using apt-get / yum on Linux and brew / port on OS X.
--no-jamoma-pd
Does not build Jamoma PureData implementation.
--no-jamoma-max
Does not build Jamoma Max implementation. Only effective on OS X (since there is no Max on Linux)
--debug
Builds everything with debug informations.
--use-clang
Builds everything with the Clang compiler. Only useful on Linux systems.
--multi
Builds using all your cores.
--android
Cross-build for Android. Only i-score 0.3. Requires the NDK & a toolchain with compiled libs. See AndroidBuild.txt.
To cross-build, please set ANDROID_NDK_ROOT to your NDK path and ANDROID_QT_BIN to the corresponding qmake executable folder.
--universal
Builds an universal binary for OS X. Warning: does not work well with brew; portmidi and gecode have to be built by hand
--optimize
Builds with optimizations enabled. More speed, but is not suitable for distribution on older computers or different processors.
--clean
Removes the build folder and the executables prior to building.
--uninstall
Will try to uninstall Jamoma.
--help
Shows this message
"
while test $# -gt 0
do
case "$1" in
--help) echo "$HELP_MESSAGE"
exit
;;
--debug) echo "Debug build"
ISCORE_CMAKE_DEBUG="-DCMAKE_BUILD_TYPE=Debug"
ISCORE_QMAKE_DEBUG="CONFIG+=debug"
;;
--use-clang) echo "Build uses Clang (only for Linux)"
ISCORE_USE_CLANG=1
;;
--android) echo "Android cross-build (only Jamoma for now, i-score needs to be ported to Qt5.x)"
OSTYPE="android"
;;
--install-deps) echo "Required dependencies will be installed"
ISCORE_INSTALL_DEPS=1
;;
--clone) echo "Will clone the git repositories"
ISCORE_CLONE_GIT=1
;;
--fetch-all) echo "Will fetch the entire repositories. Useful for development".
ISCORE_FETCH_GIT=1
ISCORE_DEPTH_GIT=""
;;
--classic) echo "Will build using the Ruby script"
ISCORE_CLASSIC_BUILD=1
;;
--clean-classic) echo "Will clean the classic stuff"
ISCORE_CLEAN_CLASSIC_BUILD=1
;;
--jamoma-path=*)
ISCORE_JAMOMA_PATH=$(cd "${1#*=}"; pwd)
echo "Will use the Jamoma installation located in ${ISCORE_JAMOMA_PATH}"
;;
--multi) echo "Will build using every logical core on the computer (faster)"
ISCORE_ENABLE_MULTICORE=1
;;
--master) echo "Using the master branch"
ISCORE_SCORE_BRANCH="master"
ISCORE_ISCORE_BRANCH="master"
;;
--optimize) echo "Optimized build"
ISCORE_BREW_FLAGS=""
CFLAGS="-Ofast -march=native"
CXXFLAGS="$CFLAGS"
;;
--universal) echo "OS X only: Universal build (i386; x86_64)"
ISCORE_BREW_UNIVERSAL_FLAGS="--universal"
ISCORE_CMAKE_UNIVERSAL_FLAGS="-DCMAKE_OSX_ARCHITECTURES=x86_64;i386"
;;
--uninstall) echo "Will uninstall Jamoma"
ISCORE_UNINSTALL_JAMOMA=1
;;
--no-jamoma-pd) echo "Will not install JamomaPd"
ISCORE_CMAKE_PD_FLAGS="-DDONT_BUILD_JAMOMAPD:bool==True"
;;
--no-jamoma-max) echo "Will not install JamomaMax"
ISCORE_CMAKE_MAX_FLAGS="-DDONT_BUILD_JAMOMAMAX:bool==True"
;;
i-score_player) echo "Will build the command line player"
ISCORE_INSTALL_PLAYER=1
;;
iscore) echo "Will build iscore"
ISCORE_INSTALL_ISCORE=1
;;
jamoma) echo "Will install Jamoma in the system folders"
ISCORE_INSTALL_JAMOMA=1
;;
--clean) echo "Removal of the build folder"
rm -rf build
;;
*) echo "Wrong option : $1"
echo "$HELP_MESSAGE"
exit 1
;;
esac
shift
done
########## GENERAL CONFIG ##########
###### Check of the Linux distribution ######
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
ISCORE_CMAKE_MAX_FLAGS="-DDONT_BUILD_JAMOMAMAX:bool==True" # don't need to try to build JamomaMax under Linux
if [ -f /etc/fedora-release ] ; then # yum
ISCORE_FEDORA=1
elif [[ `lsb_release -si` = 'Debian' || `lsb_release -si` = 'Ubuntu' || `lsb_release -si` = 'LinuxMint' || -f /etc/debian_version ]]; then # apt
ISCORE_DEBIAN=1
fi
fi
###### Build using all the cores ######
if [[ $ISCORE_ENABLE_MULTICORE ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
ISCORE_NUM_THREADS=`nproc`
elif [[ "$OSTYPE" == "darwin"* ]]; then
ISCORE_NUM_THREADS=`sysctl -n hw.ncpu`
fi
else
ISCORE_NUM_THREADS=1
fi
#####################################
######### Standard Build ############
#####################################
####### Uninstallation ? #############
if [[ $ISCORE_UNINSTALL_JAMOMA ]]; then
if [[ $ISCORE_FEDORA ]]; then
su -c 'yum remove jamomacore'
sudo rm -rf /usr/lib/libJamoma*
elif [[ $ISCORE_DEBIAN ]]; then
sudo apt-get -y remove jamomacore
sudo rm -rf /usr/lib/libJamoma*
elif [[ "$OSTYPE" == "darwin"* ]]; then
sudo rm -rf /usr/local/jamoma*
fi
exit 0
fi
###### Set compiler toolchains ######
if [[ $ISCORE_USE_CLANG ]]; then
if [[ "$OSTYPE" == "android"* ]]; then
ISCORE_CMAKE_TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=../../Jamoma/Core/Shared/CMake/toolchains/android-clang.cmake"
ISCORE_QMAKE_TOOLCHAIN="-spec android-clang"
elif [[ "$OSTYPE" != "darwin"* ]]; then
ISCORE_CMAKE_TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=../../Jamoma/Core/Shared/CMake/toolchains/linux-clang.cmake"
ISCORE_QMAKE_TOOLCHAIN="-spec linux-clang"
fi
else
if [[ "$OSTYPE" == "android"* ]]; then
ISCORE_CMAKE_TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=../../Jamoma/Core/Shared/CMake/toolchains/android-gcc.cmake"
ISCORE_QMAKE_TOOLCHAIN="-spec android-g++"
fi
fi
###### Install dependencies ######
if [[ $ISCORE_INSTALL_DEPS ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Desktop & Embedded Linux
if [[ $ISCORE_FEDORA ]]; then
su -c 'yum install qt5-qtbase qt5-qtbase-devel qt5-qttools qt5-qtsvg qt5-qtsvg-devel cmake git gecode-devel libxml2-devel libsndfile-devel portaudio-devel portmidi portmidi-tools portmidi-devel libstdc++-devel wget'
elif [[ $ISCORE_DEBIAN ]]; then
sudo apt-get -y install libgecode-dev g++ qtchooser qt5-default qt5-qmake qtbase5-dev qtbase5-dev-tools libqt5svg5-dev qtdeclarative5-dev libqt5svg5-dev cmake git libgl1-mesa-dev libxml2-dev libsndfile-dev portaudio19-dev libportmidi-dev clang-3.4 libstdc++-4.8-dev libc++-dev wget fakeroot
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS X
if command which brew; then # Brew
brew update
brew install cmake wget # Tools, no need for fancy build options
# The libraries we use
declare -a brew_pkgs=("gecode" "portaudio" "portmidi" "libsndfile")
for PKG in "${brew_pkgs[@]}"
do
brew install $PKG $ISCORE_BREW_FLAGS $ISCORE_BREW_UNIVERSAL_FLAGS
brew postinstall $PKG
done
brew install qt5 # It's already a bottle, it would take too much time to build.
brew link gecode
brew linkapps
elif command which port; then # MacPorts
sudo port install cmake gecode portaudio portmidi libsndfile qt5-mac wget
else
echo "Warning : --install-deps was specified but no suitable package manager was found.
Please install Homebrew or Macports."
exit
fi
fi
fi
###### Configure qmake ######
ISCORE_QMAKE=qmake
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [[ $ISCORE_FEDORA ]]; then
ISCORE_QMAKE=qmake-qt5
elif command which qtchooser; then
ISCORE_QMAKE="qtchooser -run-tool=qmake -qt=qt5"
fi
fi
########################################
##### Installation #####
########################################
##### Cloning #####
if [[ $ISCORE_CLONE_GIT ]]; then
# Jamoma
export GIT_SSL_NO_VERIFY=1
git clone https://github.com/Jamoma/Jamoma
git clone -b $ISCORE_JAMOMA_BRANCH https://github.com/i-score/JamomaCore.git Jamoma/Core $ISCORE_DEPTH_GIT
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
git clone -b $ISCORE_JAMOMAMAX_BRANCH https://github.com/jamoma/JamomaMax.git Jamoma/Implementations/Max $ISCORE_DEPTH_GIT #todo
fi
git clone -b $ISCORE_SCORE_BRANCH https://github.com/i-score/Score.git Jamoma/Core/Score $ISCORE_DEPTH_GIT
export ISCORE_JAMOMA_PATH=`pwd`/Jamoma
git clone -b $ISCORE_ISCORE_BRANCH https://github.com/i-score/i-score.git $ISCORE_FOLDER $ISCORE_DEPTH_GIT
if [[ $ISCORE_FETCH_GIT ]]; then
(cd $ISCORE_JAMOMA_PATH/Core; git fetch --all)
(cd $ISCORE_JAMOMA_PATH/Core/Score; git fetch --all)
(cd $ISCORE_JAMOMA_PATH/Implementations/Max; git fetch --all)
(cd $ISCORE_FOLDER; git fetch --all)
fi
fi
##### Build Jamoma #####
# Path setting
if [[ ! $ISCORE_JAMOMA_PATH ]]; then
export ISCORE_JAMOMA_PATH=`pwd`/Jamoma
fi
export JAMOMA_INCLUDE_PATH=$ISCORE_JAMOMA_PATH/Core
# Create build folders
mkdir -p build/jamoma
cd build/jamoma
# Build
if [[ $ISCORE_INSTALL_JAMOMA ]]; then
cmake "$ISCORE_JAMOMA_PATH/Core" $ISCORE_CMAKE_DEBUG $ISCORE_CMAKE_UNIVERSAL_FLAGS $ISCORE_CMAKE_MAX_FLAGS $ISCORE_CMAKE_PD_FLAGS $ISCORE_CMAKE_TOOLCHAIN
if [ $? -ne 0 ]; then
exit 1
fi
# Creation of Jamoma packages
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Desktop & Embedded Linux
if [[ $ISCORE_FEDORA ]]; then # RPM
cpack -G RPM
if [ $? -ne 0 ]; then
exit 1
fi
# Install
su -c 'rpm -Uvh --force JamomaCore-0.6-dev-Linux.rpm'
su -c 'ln -s /usr/local/lib/jamoma/lib/* -t /usr/lib'
elif [[ $ISCORE_DEBIAN ]]; then # DEB
make -j$ISCORE_NUM_THREADS package
if [ $? -ne 0 ]; then
exit 1
fi
# Install
fixup_deb_pkg JamomaCore-0.6-dev-Linux.deb
sudo dpkg -i JamomaCore-0.6-dev-Linux.deb
cp JamomaCore-0.6-dev-Linux.deb ../../
else
echo "Warning : no suitable packaging method found. Please package Jamoma yourself or run make install."
fi
elif [[ "$OSTYPE" == "android" ]]; then # Android
make -j$ISCORE_NUM_THREADS
sudo cp *.so /opt/android-toolchain/arm-linux-androideabi/lib/jamoma
elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS X
make -j$ISCORE_NUM_THREADS && sudo make install
if [ $? -ne 0 ]; then
exit 1
fi
sudo cpack -G TGZ
if [ $? -ne 0 ]; then
exit 1
fi
sudo chown $USER JamomaCore-0.6-dev-Darwin.tar.gz
sudo chmod a+rw JamomaCore-0.6-dev-Darwin.tar.gz
cp JamomaCore-0.6-dev-Darwin.tar.gz ../../
else
echo "Not supported yet."
fi
fi
##### BUILD COMMAND LINE PLAYER ######
if [[ $ISCORE_INSTALL_PLAYER ]]; then
(
mkdir -p build/iscore_player
cd build/iscore_player
cmake $ISCORE_JAMOMA_PATH/Core/Score/implementations/i-score $ISCORE_CMAKE_DEBUG $ISCORE_CMAKE_TOOLCHAIN
make -j$ISCORE_NUM_THREADS
sudo make install
)
fi
##### Build i-score #####
if [[ $ISCORE_INSTALL_ISCORE ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Desktop & Embedded Linux
#
(
cd ../../$ISCORE_FOLDER/;
if [[ ! -f installer_data.zip ]]; then
wget "https://www.dropbox.com/sh/iwqky9vh1xuu9qq/AAAaWdkqHHDFGiVDr05jUxrra?dl=1" -O installer_data.zip;
unzip installer_data.zip -d installer_data;
fi
)
# Build i-score
cd ..
mkdir $ISCORE_FOLDER
cd $ISCORE_FOLDER
cmake ../../$ISCORE_FOLDER -DCMAKE_BUILD_TYPE=Release
make -j$ISCORE_NUM_THREADS
if [ $? -ne 0 ]; then
exit 1
fi
make package
fixup_deb_pkg i-score-0.2.3-Linux.deb
cp i-score-0.2.3-Linux.deb ../..
elif [[ "$OSTYPE" == "android" ]]; then # Android
cd ..
mkdir $ISCORE_FOLDER
cd $ISCORE_FOLDER
mkdir android_build_output
echo "Using following NDK root : $ANDROID_NDK_ROOT."
$ANDROID_QT_BIN/qmake -r $ISCORE_QMAKE_TOOLCHAIN $ISCORE_QMAKE_DEBUG ../../$ISCORE_FOLDER/i-scoreNew.pro
make -j$ISCORE_NUM_THREADS
make install INSTALL_ROOT=android_build_output
$ANDROID_QT_BIN/androiddeployqt --output android_build_output --input android-libi-scoreRecast.so-deployment-settings.json
cp android_build_output/bin/QtApp-debug.apk ../../i-score-debug.apk
elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS X
cd ..
mkdir $ISCORE_FOLDER
cd $ISCORE_FOLDER
if [[ -z "$ISCORE_QT_PATH" ]]; then
ISCORE_CMAKE_QT_CONFIG="$(find /usr/local/Cellar/qt5 -name Qt5Config.cmake)"
ISCORE_CMAKE_QT_PATH="$(dirname $(dirname $ISCORE_CMAKE_QT_CONFIG))"
else
ISCORE_CMAKE_QT_PATH="$ISCORE_QT_PATH/lib/cmake"
fi
(
cd ../../$ISCORE_FOLDER/;
if [[ ! -f installer_data.zip ]]; then
wget "https://www.dropbox.com/sh/iwqky9vh1xuu9qq/AAAaWdkqHHDFGiVDr05jUxrra?dl=1" -O installer_data.zip;
unzip installer_data.zip -d installer_data;
fi
)
cmake ../../$ISCORE_FOLDER -DCMAKE_PREFIX_PATH="$ISCORE_CMAKE_QT_PATH/Qt5;$ISCORE_CMAKE_QT_PATH/Qt5Widgets;$ISCORE_CMAKE_QT_PATH/Qt5Test;$ISCORE_CMAKE_QT_PATH/Qt5Gui;$ISCORE_CMAKE_QT_PATH/Qt5Xml;$ISCORE_CMAKE_QT_PATH/Qt5Core;/usr/local/jamoma/lib" -DCMAKE_BUILD_TYPE=Release
make -j$ISCORE_NUM_THREADS
if [ $? -ne 0 ]; then
exit 1
fi
sudo make package
sudo chown $USER i-score.dmg
sudo chmod a+rw i-score.dmg
cp i-score.dmg ../..
else
echo "System not supported yet."
fi
fi