forked from surge-synthesizer/surge
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-osx.sh
executable file
·373 lines (305 loc) · 8.96 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
#!/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
--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.
Increasingly, build-osx.sh is just a convenience wrapper on running cmake + xcode. If you want
you can do almost all the core things here from the xcode project cmake ejects.
Options are:
--verbose Verbose output
Environment variables are:
VST2SDK_DIR=path If this points at a valid VST2 SDK, VST2 assets will be built
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
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 [ ! $(which xcpretty) ]; then
echo
echo ${GREEN}You will get better output if you `brew install xcpretty`${NC}
echo
fi
}
run_clean()
{
flavor=$1
echo
echo "Cleaning build - $flavor"
xcodebuild clean -configuration Release -project build/Surge.xcodeproj/ -target $flavor
}
run_cmake_build()
{
target=$1
echo Building ${target} with cmake
# Don't let TEE eat my return status
mkdir -p build
cmake -GXcode -Bbuild
if [ $(which xcpretty) ]; then
set -o pipefail && xcodebuild build -configuration Release -project build/Surge.xcodeproj -target ${target} | xcpretty
else
xcodebuild build -configuration Release -project build/Surge.xcodeproj -target ${target}
fi
build_suc=$?
if [[ $build_suc = 0 ]]; then
echo ${GREEN}Build of $target succeeded${NC}
else
echo
echo ${RED}** Build of $target failed**${NC}
exit 2
fi
}
default_action()
{
run_cmake_build "all-components"
}
run_all_builds()
{
default_action
}
run_install_local()
{
run_cmake_build "install-everything-local"
}
run_build_validate_au()
{
run_cmake_build "validate-au"
}
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_cmake_build "install-vst2-local"
}
run_build_install_vst3()
{
run_cmake_build "install-vst3-local"
}
run_clean_builds()
{
if [ ! -d "build/Surge.xcodeproj" ]; then
echo "No surge workspace; no builds to clean"
return 0
else
xcodebuild clean -project build/Surge.xcodeproj
fi
}
run_clean_all()
{
run_clean_builds
echo "Cleaning additional assets (directories, XCode, etc)"
rm -rf build products
}
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
}
build_iwyu()
{
set -x
mkdir buildiwyu
IWYU=/usr/local/bin/include-what-you-use
cd buildiwyu
CC="clang" CXX="clang++" cmake -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="${IWYU};-Xiwyu;any;-Xiwyu;iwyu;-Xiwyu;args" -G Ninja ..
cmake --build . > iwyu.output
}
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
--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_cmake_build "surge-headless"
;;
--run-headless)
run_cmake_build "run-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
;;
--build-iwyu)
build_iwyu
;;
"")
default_action
;;
*)
help_message
;;
esac