forked from surge-synthesizer/surge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-osx.sh
executable file
·497 lines (412 loc) · 12.7 KB
/
build-osx.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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
#!/bin/bash
#
# build-osx.sh is the master script we use to control the multi-step build processes
#
# To understand what it does, run
#
# ./build-osx.sh --help
help_message()
{
cat << EOHELP
build-osx.sh is the master script we use to control the multi-step build processes
You can do a lot with xcode but for things like starting releasing and installing
locally you will need to interact with this script
To see this message run
./build-osx.sh --help
To do a simple local build which is not installed do
./build-osx.sh
Other usages take the form of
./build-osx.sh <command> <options?>
Commands are:
--help Show this message
--premake Run premake only
--build Run the builds without cleans
--install-local Once assets are built, install them locally
--build-and-install Build and install the assets
--build-validate-au Build and install the audio unit then validate it
--build-install-vst2 Build and install only the VST2
--build-install-vst3 Build and install only the VST3
--build-headless Build the headless application
--get-and-build-fx Get and build the surge-fx project. This is only needed if you
want to make a release with that asset included
--package Creates a .pkg file from current built state in products
--clean-and-package Cleans everything; runs all the builds; makes an installer; drops it in products
Equivalent of running --clean-all then --build then --package
--clean Clean all the builds
--clean-all Clean all the builds and remove the xcode files and target directories
--uninstall-surge Uninstall surge both from user and system areas. Be very careful!
We also have a few useful defaults to run in a DAW if you have the DAW installed. Your favorite dev combo
not listed here? Feel free to add one and send in a Pull Request!
--run-hosting-au Run the Audio Unit in Hosting AU
--run-logic-au Run the Audio Unit in Logic Pro X
--run-reaper-vst3 Run the VST3 in Reaper64
The default behaviour without arguments is to clean and rebuild everything.
Options are:
--verbose Verbose output
Environment variables are:
VST2SDK_DIR=path If this points at a valid VST2 SDK, VST2 assets will be built
BREWBUILD=TRUE Uses LLVM clang rather than xcode. If you are XCode < 9.4 you will need this
SURGE_USE_VECTOR_SKIN={skin} Uses the new vector skins in assets/classic-vector in built asset.
For SURGE_USE_VECTOR_SKIN you need to give the name of a subdirectory in assets. For instance
SURGE_USE_VECTOR_SKIN=original-vector ./build-osx.sh --build-validate-au
will use the 'original-vector' skin and locally build an AU
EOHELP
}
RED=`tput setaf 1`
GREEN=`tput setaf 2`
NC=`tput init`
prerequisite_check()
{
if [ ! -f vst3sdk/LICENSE.txt ]; then
echo
echo ${RED}ERROR: You have not gotten the submodules required to build Surge. Run the following command to get them.${NC}
echo
echo git submodule update --init --recursive
echo
exit 1
fi
# TODO: Check premake is installed
if [ ! $(which premake5) ]; then
echo
echo ${RED}ERROR: You do not have premake5 on your path${NC}
echo
echo Please download and install premake from https://premake.github.io per the Surge README.md
echo
exit 1
fi
if [ ! $(which cmake) ]; then
echo
echo ${RED}ERROR: You do not have cmake on your path${NC}
echo
echo Please install cmake. "brew install cmake" or visit https://cmake.org
echo
exit 1
fi
if [[ ( ! -z $SURGE_USE_VECTOR_SKIN ) && ( ! -d assets/${SURGE_USE_VECTOR_SKIN}/exported ) ]]; then
echo
echo ${RED}SURGE_USE_VECTOR_SKIN does not point to assets${NC}
echo
echo SURGE_USE_VECTOR_SKIN should be the name of an asset sub-dir which contains the directory
echo exported. Example values are 'original-vector' or 'classic-vector'
echo
exit 1
fi
}
run_premake()
{
if [[ -z $SURGE_PREMAKE ]]; then
premake5 xcode4
else
echo
echo ${RED}Using custom premake binary${NC}
echo $SURGE_PREMAKE
echo
$SURGE_PREMAKE xcode4
fi
touch Surge.xcworkspace/premake-stamp
}
run_premake_if()
{
if [[ premake5.lua -nt Surge.xcworkspace/premake-stamp ]]; then
run_premake
fi
}
run_clean()
{
flavor=$1
echo
echo "Cleaning build - $flavor"
xcodebuild clean -configuration Release -project surge-${flavor}.xcodeproj
}
run_clean_headless()
{
if [ -d "build/Surge.xcodeproj" ]; then
echo
echo "Cleaning build - headless"
xcodebuild clean -configuration Release -project build/Surge.xcodeproj
fi
}
run_build()
{
flavor=$1
mkdir -p build_logs
echo
echo Building surge-${flavor} with output in build_logs/build_${flavor}.log
# Don't let TEE eat my return status
set -o pipefail
if [[ -z "$OPTION_verbose" ]]; then
xcodebuild build -configuration Release -project surge-${flavor}.xcodeproj > build_logs/build_${flavor}.log
else
xcodebuild build -configuration Release -project surge-${flavor}.xcodeproj | tee build_logs/build_${flavor}.log
fi
build_suc=$?
set +o pipefail
if [[ $build_suc = 0 ]]; then
echo ${GREEN}Build of surge-${flavor} succeeded${NC}
else
echo
echo ${RED}** Build of ${flavor} failed**${NC}
grep -i ": error" build_logs/build_${flavor}.log
echo
echo Complete information is in build_logs/build_${flavor}.log
exit 2
fi
}
run_build_headless()
{
mkdir -p build_logs
echo
echo Building surge-headless with output in build_logs/build_headless.log
mkdir -p build
cmake -GXcode -Bbuild
# Don't let TEE eat my return status
set -o pipefail
if [[ -z "$OPTION_verbose" ]]; then
xcodebuild build -configuration Release \
-project build/Surge.xcodeproj > \
build_logs/build_headless.log
else
xcodebuild build -configuration Release \
-project build/Surge.xcodeproj | \
tee build_logs/build_headless.log
fi
build_suc=$?
set +o pipefail
if [[ $build_suc = 0 ]]; then
echo ${GREEN}Build of surge-headless succeeded${NC}
else
echo
echo ${RED}** Build of headless failed**${NC}
grep -i ": error" build_logs/build_headless.log
echo
echo Complete information is in build_logs/build_headless.log
exit 2
fi
}
default_action()
{
run_premake
if [ -d "surge-vst2.xcodeproj" ]; then
run_clean "vst2"
run_build "vst2"
fi
run_clean "vst3"
run_build "vst3"
run_clean "au"
run_build "au"
}
run_all_builds()
{
run_premake_if
if [ -d "surge-vst2.xcodeproj" ]; then
run_build "vst2"
fi
run_build "vst3"
run_build "au"
run_build_headless
}
run_install_local()
{
rsync -r --delete "resources/data/" "$HOME/Library/Application Support/Surge/"
if [ -d "surge-vst2.xcodeproj" ]; then
rsync -r --delete "products/Surge.vst/" ~/Library/Audio/Plug-Ins/VST/Surge.vst/
fi
rsync -r --delete "products/Surge.component/" ~/Library/Audio/Plug-Ins/Components/Surge.component/
rsync -r --delete "products/Surge.vst3/" ~/Library/Audio/Plug-Ins/VST3/Surge.vst3/
}
run_build_validate_au()
{
run_premake_if
run_build "au"
rsync -r --delete "resources/data/" "$HOME/Library/Application Support/Surge/"
rsync -r --delete "products/Surge.component/" ~/Library/Audio/Plug-Ins/Components/Surge.component/
auval -vt aumu VmbA
}
run_hosting_au()
{
if [ ! -d "/Applications/Hosting AU.app" ]; then
echo
echo "Hosting AU is not installed. Please install it from http://ju-x.com/hostingau.html"
echo
exit 1;
fi
"/Applications/Hosting AU.app/Contents/MacOS/Hosting AU" "test-data/daw-files/mac/Surge.hosting"
}
run_logic_au()
{
if [ ! -d "/Applications/Logic Pro X.app" ]; then
echo
echo "Logic is not installed. Please install it!"
echo
exit 1;
fi
"/Applications/Logic Pro X.app/Contents/MacOS/Logic Pro X" "test-data/daw-files/mac/Surge_AU.logicx"
}
run_reaper_vst3()
{
if [ ! -d "/Applications/REAPER64.app" ]; then
echo
echo "REAPER64 is not installed. Please install it!"
echo
exit 1;
fi
"/Applications/REAPER64.app/Contents/MacOS/REAPER" "test-data/daw-files/mac/Surge_VST3.RPP"
}
run_build_install_vst2()
{
run_premake_if
run_build "vst2"
rsync -r --delete "resources/data/" "$HOME/Library/Application Support/Surge/"
rsync -r --delete "products/Surge.vst/" ~/Library/Audio/Plug-Ins/VST/Surge.vst/
}
run_build_install_vst3()
{
run_premake_if
run_build "vst3"
rsync -r --delete "resources/data/" "$HOME/Library/Application Support/Surge/"
rsync -r --delete "products/Surge.vst3/" ~/Library/Audio/Plug-Ins/VST3/Surge.vst3/
}
run_clean_builds()
{
if [ ! -d "Surge.xcworkspace" ]; then
echo "No surge workspace; no builds to clean"
return 0
else
echo "Clean build on all flavors"
fi
if [ -d "surge-vst2.xcodeproj" ]; then
run_clean "vst2"
fi
run_clean "vst3"
run_clean "au"
run_clean_headless
}
run_clean_all()
{
run_clean_builds
echo "Cleaning additional assets (directories, XCode, etc)"
rm -rf Surge.xcworkspace *xcodeproj target products build_logs obj build fxbuild
}
run_uninstall_surge()
{
sudo rm -rf /Library/Audio/Plug-Ins/Components/Surge.component
sudo rm -rf /Library/Audio/Plug-Ins/VST/Surge.vst
sudo rm -rf /Library/Audio/Plug-Ins/VST3/Surge.vst3
sudo rm -rf ~/Library/Audio/Plug-Ins/Components/Surge.component
sudo rm -rf ~/Library/Audio/Plug-Ins/VST/Surge.vst
sudo rm -rf ~/Library/Audio/Plug-Ins/VST3/Surge.vst3
sudo rm -rf ~/Library/Application\ Support/Surge
}
run_package()
{
pkgver=`cat VERSION`beta-`(date +%Y-%m-%d-%H%M)`
echo "Building with version [${pkgver}]"
cd installer_mac/
./make_installer.sh ${pkgver}
cd ..
mv installer_mac/installer/*${pkgver}*.pkg products/
echo
echo "Package completed and in products/ directory"
echo
ls -l products/*${pkgver}*.pkg
echo
echo "Have a lovely day!"
echo
}
get_and_build_fx()
{
set -x
mkdir -p fxbuild
mkdir -p products
cd fxbuild
git clone https://github.com/surge-synthesizer/surge-fx
cd surge-fx
git submodule update --init --recursive
make -f Makefile.mac build
cd Builds/MacOSX/build/Release
tar cf - SurgeEffectsBank.component/* | ( cd ../../../../../../products ; tar xf - )
tar cf - SurgeEffectsBank.vst3/* | ( cd ../../../../../../products ; tar xf - )
}
# This is the main section of the script
command="$1"
for option in ${@:2}
do
eval OPTION_${option//-}="true"
done
# put help up here so it runs even without the prerequisite check
if [ "$command" = "--help" ]; then
help_message
exit 0
fi
prerequisite_check
# if you add a Key here then you need to implement it as a function and add it to the help above
# to get the PR swept. Thanks!
case $command in
--premake)
run_premake
;;
--build)
run_all_builds
;;
--install-local)
run_install_local
;;
--build-and-install)
run_all_builds
run_install_local
;;
--build-validate-au)
run_build_validate_au
;;
--run-hosting-au)
run_build_validate_au
run_hosting_au
;;
--run-logic-au)
run_build_validate_au
run_logic_au
;;
--run-reaper-vst3)
run_build_install_vst3
run_reaper_vst3
;;
--build-install-vst2)
run_build_install_vst2
;;
--build-install-vst3)
run_build_install_vst3
;;
--build-headless)
run_build_headless
;;
--run-headless)
run_build_headless
./build/Release/surge-headless
;;
--clean)
run_clean_builds
;;
--clean-all)
run_clean_all
;;
--clean-and-package)
run_clean_all
run_all_builds
run_package
;;
--package)
run_package
;;
--uninstall-surge)
run_uninstall_surge
;;
--get-and-build-fx)
get_and_build_fx
;;
"")
default_action
;;
*)
help_message
;;
esac