forked from prusa3d/PrusaSlicer
-
-
Notifications
You must be signed in to change notification settings - Fork 543
Expand file tree
/
Copy pathBuildMacOS.sh
More file actions
executable file
·476 lines (442 loc) · 14.4 KB
/
BuildMacOS.sh
File metadata and controls
executable file
·476 lines (442 loc) · 14.4 KB
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
#!/bin/bash
#
# This script can download and compile dependencies, compile SuperSlicer
# and optional build a .tgz and an appimage.
#
# Original script from SuperSlicer by supermerill https://github.com/supermerill/SuperSlicer
#
# Change log:
#
# 20 Nov 2023, wschadow, branding and minor changes
# 01 Jan 2024, wschadow, added build options
#
export ROOT=`pwd`
export NCORES=`sysctl -n hw.ncpu`
export CMAKE_POLICY_VERSION_MINIMUM=3.5
OS_FOUND=$( command -v uname)
case $( "${OS_FOUND}" | tr '[:upper:]' '[:lower:]') in
linux*)
TARGET_OS="linux"
;;
msys*|cygwin*|mingw*)
# or possible 'bash on windows'
TARGET_OS='windows'
;;
nt|win*)
TARGET_OS='windows'
;;
darwin)
TARGET_OS='macos'
;;
*)
TARGET_OS='unknown'
;;
esac
export TERM=xterm-256color
# check operating system
BUILD_IMG_ARCH=""
echo
if [ $TARGET_OS == "macos" ]; then
if [ $(uname -m) == "x86_64" ]; then
echo -e "$(tput setaf 2)macOS x86_64 found$(tput sgr0)\n"
Processor="x86_64"
BUILD_IMG_ARCH="-x"
echo "x86 BUILD_IMG_ARCH=${BUILD_IMG_ARCH}\n"
elif [[ $(uname -m) == "i386" || $(uname -m) == "i686" ]]; then
echo "$(tput setaf 2)macOS i386 / i686 (arm?) found$(tput sgr0)\n"
Processor="arm64"
BUILD_IMG_ARCH="-a"
elif [ $(uname -m) == "arm64" ]; then
echo "$(tput setaf 2)macOS arm64 found$(tput sgr0)\n"
Processor="arm64"
BUILD_IMG_ARCH="-a"
else
echo "$(tput setaf 1)Unsupported OS: macOS $(uname -m)"
exit -1
fi
else
echo -e "$(tput setaf 1)This script doesn't support your Operating system!"
echo -e "Please use a macOS.$(tput sgr0)\n"
exit -1
fi
echo "BUILD_IMG_ARCH=${BUILD_IMG_ARCH}\n"
# Check if CMake is installed
export CMAKE_INSTALLED=`which cmake`
if [[ -z "$CMAKE_INSTALLED" ]]
then
echo "Can't find CMake. Either is not installed or not in the PATH. Aborting!"
exit -1
fi
BUILD_ARCH="x86_64"
BUILD_ARCH_x86="x86_64"
while getopts ":idaxbhcsltwrv" opt; do
case ${opt} in
i )
BUILD_IMAGE="1"
;;
d )
BUILD_DEPS="1"
;;
a )
BUILD_ARCH="arm64"
BUILD_IMG_ARCH="-a"
;;
x )
BUILD_ARCH="x86_64"
BUILD_IMG_ARCH="-x"
;;
b )
BUILD_DEBUG="1"
;;
s )
BUILD_SLIC3R="1"
;;
t)
BUILD_TESTS="1"
;;
l )
UPDATE_POTFILE="1"
;;
c)
BUILD_XCODE="1"
;;
v )
VERSION_DATE="1"
;;
w )
BUILD_WIPE="1"
;;
r )
BUILD_CLEANDEPEND="1"
;;
h ) echo "Usage: ./BuildMacOS.sh [-h][-w][-d][-r][-a][-x][-b][-c][-s][-t][-i]"
echo " -h: this message"
echo " -w: wipe build directories before building"
echo " -d: build dependencies"
echo " -r: clean dependencies building files (reduce disk usage)"
echo " -a: build for arm64 (Apple Silicon)"
echo " -x: build for x86_64 (Intel)"
echo " -b: build with debug symbols"
echo " -c: build for XCode"
echo " -s: build Slic3r/SuperSlicer"
echo " -t: build tests (in combination with -s)"
echo " -i: generate DMG image (optional)\n"
echo " -v: change the version 'UNKNOWN' to the date of the day"
exit 0
;;
esac
done
if [ $OPTIND -eq 1 ]
then
echo "Usage: ./BuildLinux.sh [-h][-w][-d][-r][-a][-x][-b][-c][-s][-t][-i]"
echo " -h: this message"
echo " -w: wipe build directories before building"
echo " -d: build dependencies"
echo " -r: clean dependencies building files (reduce disk usage)"
echo " -a: build for arm64 (Apple Silicon)"
echo " -x: build for x86_64 (Intel)"
echo " -b: build with debug symbols"
echo " -c: build for XCode"
echo " -s: build Slic3r/SuperSlicer"
echo " -t: build tests (in combination with -s)"
echo -e " -i: Generate DMG image (optional)\n"
exit 0
fi
echo "Build architecture: ${BUILD_ARCH}"
echo "Build IMG_ARCH=${BUILD_IMG_ARCH}\n"
echo "ls /Applications:"
ls /Applications
echo "ls /Applications/Xcode_14.3.1.app:"
ls /Applications/Xcode_14.3.1.app
echo "ls /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs:"
ls /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
echo "ls /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib:"
ls /Applications/Xcode_14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib
echo "ls /Applications/Xcode_15.2.0.app:"
ls /Applications/Xcode_15.2.0.app
echo "ls /Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs:"
ls /Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
echo "ls /Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib:"
ls /Applications/Xcode_15.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib
echo "ls /Applications/Xcode_15.4.0.app:"
ls /Applications/Xcode_15.4.0.app
echo "ls /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs:"
ls /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
echo "ls /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib:"
ls /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/usr/lib
echo "ls /Applications/Xcode_16.2.0.app:"
ls /Applications/Xcode_16.2.0.app
echo "ls /Applications/Xcode_16.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs:"
ls /Applications/Xcode_16.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
echo "ls /Applications/Xcode_16.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/lib:"
ls /Applications/Xcode_16.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/lib
echo "ls /usr/bin/:"
ls /usr/bin/
# if [[ "$BUILD_ARCH" == "$BUILD_ARCH_x86" ]]
# then
# echo "Switch to xcode Xcode_14.3.1"
# sudo xcode-select -s /Applications/Xcode_14.3.1.app/Contents/Developer
# sudo mv -f /Applications/Xcode_15.0.1.app /Applications/NO_Xcode_15.0.1.app
# sudo mv -f /Applications/Xcode_15.0.app /Applications/NO_Xcode_15.0.app
# sudo mv -f /Applications/Xcode_15.1.0.app Applications/NO_Xcode_15.1.0.app
# sudo mv -f /Applications/Xcode_15.1.app /Applications/NO_Xcode_15.1.app
# sudo mv -f /Applications/Xcode_15.2.0.app /Applications/NO_Xcode_15.2.0.app
# sudo mvv /Applications/Xcode_15.2.app /Applications/NO_Xcode_15.2.app
# fi
# Iconv: /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/libiconv.tbd
echo "\nbrew --prefix libiconv:\n"
brew --prefix libiconv
echo "\nbrew --prefix zstd:\n"
brew --prefix zstd
# not enough to fix the issue on cross-compiling
#if [[ -n "$BUILD_ARCH" ]]
#then
# export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix libiconv)/lib/
#fi
export $BUILD_ARCH
export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix zstd)/lib/
echo -n "[1/8] Updating submodules..."
{
# update submodule profiles
pushd resources/profiles
git submodule update --init
popd
} #> $ROOT/build/Build.log # Capture all command output
echo "done"
if [[ -n "$VERSION_DATE" ]]
then
echo -n "[2/8] Changing date in version ... "
# change date in version
sed "s/+UNKNOWN/-$(date '+%F')/" version.inc > version.date.inc
echo "done"
else
echo -n "[2/8] Changing date in version: remove UNKNOWN ... "
sed "s/+UNKNOWN//" version.inc > version.date.inc
echo "done"
fi
if [[ -n "$BUILD_DEPS" ]]
then
if [[ -n $BUILD_WIPE ]]
then
echo -e "\n wiping deps/build directory ...\n"
rm -fr deps/build
echo -e " ... done\n"
fi
# mkdir in deps
if [ ! -d "deps/build" ]
then
mkdir deps/build
fi
echo -e " \n[3/8] Configuring dependencies ... \n"
BUILD_ARGS=""
if [[ -n "$BUILD_ARCH" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES:STRING=${BUILD_ARCH}"
fi
if [[ -n "$BUILD_DEBUG" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
fi
pushd deps/build > /dev/null
# cmake deps
if [[ "$BUILD_ARCH" == "$BUILD_ARCH_x86" ]]
then
echo "Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.14\" ${BUILD_ARCH} "
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" $BUILD_ARGS
else
echo "Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\"10.14\" ${BUILD_ARCH} "
cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" $BUILD_ARGS
fi
if [ $? -eq 0 ]
then
echo -e "\n ... done\n"
else
echo -e "\n ... fail\n"
exit 1 # terminate and indicate error
fi
echo -e "[4/8] Building dependencies ...\n"
# if [[ "$BUILD_ARCH" == "$BUILD_ARCH_x86" ]]
# then
# build each dep separatly, seems like it fails less to compile this way.
ls .
echo -e "[4/8] Building dep_OCCT ...\n"
make dep_OCCT -j$NCORES
echo -e "[4/8] Building dep_CGAL ...\n"
make dep_CGAL -j$NCORES
echo -e "[4/8] Building dep_GLEW ...\n"
make dep_GLEW -j$NCORES
echo -e "[4/8] Building dep_OpenCSG ...\n"
make dep_OpenCSG -j$NCORES
echo -e "[4/8] Building dep_Cereal ...\n"
make dep_Cereal -j$NCORES
echo -e "[4/8] Building dep_NLopt ...\n"
make dep_NLopt -j$NCORES
echo -e "[4/8] Building dep_TBB ...\n"
make dep_TBB -j$NCORES
echo -e "[4/8] Building dep_OpenEXR ...\n"
make dep_OpenEXR -j$NCORES
echo -e "[4/8] Building dep_Qhull ...\n"
make dep_Qhull -j$NCORES
echo -e "[4/8] Building dep_wxWidgets ...\n"
make dep_wxWidgets -j$NCORES
echo -e "[4/8] Building dep_EXPAT ...\n"
make dep_EXPAT -j$NCORES
echo -e "[4/8] Building dep_PNG ...\n"
make dep_PNG -j$NCORES
echo -e "[4/8] Building dep_JPEG ...\n"
make dep_JPEG -j$NCORES
echo -e "[4/8] Building dep_NanoSVG ...\n"
make dep_NanoSVG -j$NCORES
echo -e "[4/8] Building dep_Boost ...\n"
make dep_Boost -j$NCORES
echo -e "[4/8] Building dep_Blosc ...\n"
make dep_Blosc -j$NCORES
echo -e "[4/8] Building dep_OpenVDB ...\n"
make dep_OpenVDB -j$NCORES
echo -e "[4/8] Building dep_heatshrink ...\n"
make dep_heatshrink -j$NCORES
echo -e "[4/8] Building dep_LibBGCode ...\n"
make dep_LibBGCode -j$NCORES
echo -e "[4/8] Building dep_GMP ...\n"
make dep_GMP -j$NCORES
echo -e "[4/8] Building dep_MPFR ...\n"
make dep_MPFR -j$NCORES
echo -e "[4/8] Building dep_Catch2 ...\n"
make dep_Catch2 -j$NCORES
# fi
# make deps
make -j$NCORES
if [ $? -eq 0 ]
then
echo -e "\n ... done\n"
else
echo -e "\n ... fail\n"
exit 1 # terminate and indicate error
fi
popd > /dev/null
fi
if [[ -n "$BUILD_CLEANDEPEND" ]]
then
echo -e "[5/8] Cleaning dependencies...\n"
pushd deps/build
pwd
rm -fr dep_*
popd > /dev/null
echo -e "\n ... done\n"
fi
if [[ -n "$BUILD_SLIC3R" ]]
then
echo -e "[4/8] Configuring Slicer ...\n"
if [[ -n $BUILD_WIPE ]]
then
echo -e "\n wiping build directory...\n"
rm -fr build
echo -e " ... done\n"
fi
# mkdir build
if [ ! -d "build" ]
then
mkdir build
fi
BUILD_ARGS=""
if [[ -n "$BUILD_ARCH" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_OSX_ARCHITECTURES=${BUILD_ARCH}"
fi
if [[ -n "$BUILD_DEBUG" ]]
then
BUILD_ARGS="-DCMAKE_BUILD_TYPE=Debug ${BUILD_ARGS}"
fi
if [[ -n "$BUILD_XCODE" ]]
then
BUILD_ARGS="-GXcode ${BUILD_ARGS}"
fi
if [[ -n "$BUILD_TESTS" ]]
then
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TESTS=1"
else
BUILD_ARGS="${BUILD_ARGS} -DCMAKE_BUILD_TESTS=0"
fi
# cmake
pushd build > /dev/null
if [[ "$BUILD_ARCH" == "$BUILD_ARCH_x86" ]]
then
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
else
cmake .. -DCMAKE_PREFIX_PATH="$PWD/../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.14" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
fi
if [ $? -eq 0 ]
then
echo -e "\n ... done\n"
else
echo -e "\n ... fail\n"
exit 1 # terminate and indicate error
fi
# make Slic3r
if [[ -z "$BUILD_XCODE" ]]
then
echo -e "\n[5/8] Building Slicer ...\n"
make -j$NCORES Slic3r
if [ $? -eq 0 ]
then
echo -e "\n ... done\n"
else
echo -e "\n ... fail\n"
exit 1 # terminate and indicate error
fi
fi
echo -e "\n[6/8] Generating language files ...\n"
#make .mo
if [[ -n "$UPDATE_POTFILE" ]]
then
make gettext_make_pot
fi
make gettext_po_to_mo
if [ $? -eq 0 ]
then
echo -e "\n ... done\n"
else
echo -e "\n ... fail\n"
exit 1 # terminate and indicate error
fi
popd > /dev/null
echo "> ls ROOT"
ls -al $ROOT
echo "> ls ROOT/build"
ls -al $ROOT/build
echo "> ls -al ROOT/build/bin"
ls -al $ROOT/build/bin
echo "> ls -al ROOT/build/src"
ls -al $ROOT/build/src
fi
if [[ -n "$BUILD_IMAGE" ]]
then
# Give proper permissions to script
chmod 755 $ROOT/build/src/BuildMacOSImage.sh
pushd build > /dev/null
echo "> $ROOT/build/src/BuildMacOSImage.sh -i ${BUILD_IMG_ARCH}"
if [[ "$BUILD_ARCH" == "$BUILD_ARCH_x86" ]]
then
$ROOT/build/src/BuildMacOSImage.sh -i $BUILD_IMG_ARCH -z
else
$ROOT/build/src/BuildMacOSImage.sh -i $BUILD_IMG_ARCH -z
fi
if [ $? -eq 0 ]
then
echo -e "\n BuildMacOSImage done\n"
else
echo -e "\n BuildMacOSImage fail\n"
# exit 1 # terminate and indicate error
fi
popd > /dev/null
echo "> ls ROOT"
ls -al $ROOT
echo "> ls ROOT/build"
ls -al $ROOT/build
echo "> ls -al ROOT/build/bin"
ls -al $ROOT/build/bin
echo "> ls -al ROOT/build/bin"
ls -al $ROOT/build/bin
echo "> ls -al ROOT/build/src"
ls -al $ROOT/build/src
fi