forked from surge-synthesizer/surge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-osx.sh
executable file
·347 lines (281 loc) · 8.67 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
#!/bin/sh
#
# 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
--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!
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 [[ ( ! -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()
{
premake5 xcode4
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_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
}
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_install_local()
{
rsync -r "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 "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_build_install_vst2()
{
run_premake_if
run_build "vst2"
rsync -r "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 "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_all()
{
run_clean_builds
echo "Cleaning additional assets (directories, XCode, etc)"
rm -rf Surge.xcworkspace *xcodeproj target products build_logs obj
}
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
}
# 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
;;
--build-install-vst2)
run_build_install_vst2
;;
--build-install-vst3)
run_build_install_vst3
;;
--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
;;
"")
default_action
;;
*)
help_message
;;
esac