11#! /bin/bash
2+ #
3+ # This script can download and compile dependencies, compile SuperSlicer
4+ # and optional build a .tgz and an appimage.
5+ #
6+ # Original script from SuperSlicer by supermerill https://github.com/supermerill/SuperSlicer
7+ #
8+ # Change log:
9+ #
10+ # 20 Nov 2023, wschadow, branding and minor changes
11+ # 01 Jan 2024, wschadow, added build options
12+ #
213
314export ROOT=` pwd`
415export NCORES=` sysctl -n hw.ncpu`
5- export CMAKE_INSTALLED=` which cmake`
6- # export ARCH=$(uname -m)
16+
17+ OS_FOUND=$( command -v uname)
18+
19+ case $( " ${OS_FOUND} " | tr ' [:upper:]' ' [:lower:]' ) in
20+ linux* )
21+ TARGET_OS=" linux"
22+ ;;
23+ msys* |cygwin* |mingw* )
24+ # or possible 'bash on windows'
25+ TARGET_OS=' windows'
26+ ;;
27+ nt|win* )
28+ TARGET_OS=' windows'
29+ ;;
30+ darwin)
31+ TARGET_OS=' macos'
32+ ;;
33+ * )
34+ TARGET_OS=' unknown'
35+ ;;
36+ esac
37+
38+ # check operating system
39+ echo
40+ if [ $TARGET_OS == " macos" ]; then
41+ if [ $( uname -m) == " x86_64" ]; then
42+ echo -e " $( tput setaf 2) macOS x86_64 found$( tput sgr0) \n"
43+ Processor=" 64"
44+ elif [[ $( uname -m) == " i386" || $( uname -m) == " i686" ]]; then
45+ echo " $( tput setaf 2) macOS arm64 found$( tput sgr0) \n"
46+ Processor=" 64"
47+ else
48+ echo " $( tput setaf 1) Unsupported OS: macOS $( uname -m) "
49+ exit -1
50+ fi
51+ else
52+ echo -e " $( tput setaf 1) This script doesn't support your Operating system!"
53+ echo -e " Please use a macOS.$( tput sgr0) \n"
54+ exit -1
55+ fi
756
857# Check if CMake is installed
58+ export CMAKE_INSTALLED=` which cmake`
959if [[ -z " $CMAKE_INSTALLED " ]]
1060then
1161 echo " Can't find CMake. Either is not installed or not in the PATH. Aborting!"
1262 exit -1
1363fi
1464
15- while getopts " :iaxbhc" opt; do
65+ BUILD_ARCH=$( uname -m)
66+
67+ while getopts " :idaxbhcsltwr" opt; do
1668 case ${opt} in
1769 i )
18- export BUILD_IMAGE=" 1"
70+ BUILD_IMAGE=" 1"
71+ ;;
72+ d )
73+ BUILD_DEPS=" 1"
1974 ;;
2075 a )
21- export BUILD_ARCH=" arm64"
76+ BUILD_ARCH=" arm64"
77+ BUILD_IMG=" -a"
2278 ;;
2379 x )
24- export BUILD_ARCH=" x86_64"
80+ BUILD_ARCH=" x86_64"
81+ BUILD_IMG=" -x"
2582 ;;
2683 b )
27- export BUILD_DEBUG=" 1"
84+ BUILD_DEBUG=" 1"
85+ ;;
86+ s )
87+ BUILD_SUPERSLICER=" 1"
88+ ;;
89+ l )
90+ UPDATE_POTFILE=" 1"
2891 ;;
2992 c)
30- export BUILD_XCODE=" 1"
93+ BUILD_XCODE=" 1"
3194 ;;
32- h ) echo " Usage: ./BuildMacOS.sh [-i]"
33- echo " -i: Generate DMG image (optional)"
34- echo " -a: Build for arm64 (Apple Silicon)"
35- echo " -x: Build for x86_64 (Intel)"
36- echo " -b: Build with debug symbols"
37- echo " -c: Build for XCode"
95+ w )
96+ BUILD_WIPE=" 1"
97+ ;;
98+ r )
99+ BUILD_CLEANDEPEND=" 1"
100+ ;;
101+ h ) echo " Usage: ./BuildMacOS.sh [-h][-w][-a][-r][-x][-b][-c][-d][-s][-l][-t][-i]"
102+ echo " -h: this message"
103+ echo " -w: wipe build directories bfore building"
104+ echo " -a: build for arm64 (Apple Silicon)"
105+ echo " -r: clean dependencies"
106+ echo " -x: build for x86_64 (Intel)"
107+ echo " -b: build with debug symbols"
108+ echo " -c: build for XCode"
109+ echo " -d: build dependencies"
110+ echo " -s: build SuperSlicer"
111+ echo " -t: build tests (in combination with -s)"
112+ echo " -i: generate .tgz and DMG image (optional)\n"
38113 exit 0
39114 ;;
40115 esac
41116done
42117
43- echo " Build architecture: ${BUILD_ARCH} "
44-
45- echo " \n/Applications:\n"
46- ls /Applications
47- echo " \n/Applications/Xcode_13.2.1.app:\n"
48- ls /Applications/Xcode_13.2.1.app
49- echo " \n/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs:\n"
50- ls /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
51- echo " \n/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib:\n"
52- ls /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib
53-
54- # Iconv: /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/libiconv.tbd
55- echo " \nbrew --prefix libiconv:\n"
56- brew --prefix libiconv
57- echo " \nbrew --prefix zstd:\n"
58- brew --prefix zstd
59- export LIBRARY_PATH=$LIBRARY_PATH :$( brew --prefix zstd) /lib/
60- # not enough to fix the issue on cross-compiling
61- # if [[ -n "$BUILD_ARCH" ]]
62- # then
63- # export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix libiconv)/lib/
64- # fi
65-
66- # mkdir build
67- if [ ! -d " build" ]
118+ if [ $OPTIND -eq 1 ]
68119then
69- mkdir build
120+ echo " Usage: ./BuildLinux.sh [-h][-w][-a][-r][-x][-b][-c][-d][-s][-l][-t][-i]"
121+ echo " -h: this message"
122+ echo " -w: wipe build directories bfore building"
123+ echo " -a: Build for arm64 (Apple Silicon)"
124+ echo " -r: clean dependencies"
125+ echo " -x: build for x86_64 (Intel)"
126+ echo " -b: build with debug symbols"
127+ echo " -c: build for XCode"
128+ echo " -d: build dependencies"
129+ echo " -s: build SuperSlicer"
130+ echo " -t: build tests (in combination with -s)"
131+ echo -e " -i: Generate .tgz and DMG image (optional)\n"
132+ exit 0
70133fi
71134
72- echo -n " [1/9] Updating submodules..."
73- {
74- # update submodule profiles
75- pushd resources/profiles
76- git submodule update --init
77- popd
78- } # > $ROOT/build/Build.log # Capture all command output
79- echo " done"
80-
81- echo -n " [2/9] Changing date in version..."
82- {
83- # change date in version
84- sed " s/+UNKNOWN/_$( date ' +%F' ) /" version.inc > version.date.inc
85- mv version.date.inc version.inc
86- } # &> $ROOT/build/Build.log # Capture all command output
87- echo " done"
88-
89- # mkdir in deps
90- if [ ! -d " deps/build" ]
135+ export $BUILD_ARCH
136+ export LIBRARY_PATH=$LIBRARY_PATH :$( brew --prefix zstd) /lib/
137+
138+ if [[ -n " $BUILD_DEPS " ]]
91139then
140+ if [[ -n $BUILD_WIPE ]]
141+ then
142+ echo -e " \n wiping deps/build directory ...\n"
143+ rm -fr deps/build
144+ echo -e " ... done\n"
145+ fi
146+ # mkdir in deps
147+ if [ ! -d " deps/build" ]
148+ then
92149 mkdir deps/build
93- fi
94-
95- echo -n " [3/9] Configuring dependencies..."
96- {
150+ fi
151+ echo -e " \n[1/9] Configuring dependencies ... \n"
97152 BUILD_ARGS=" "
98153 if [[ -n " $BUILD_ARCH " ]]
99154 then
@@ -104,54 +159,57 @@ echo -n "[3/9] Configuring dependencies..."
104159 BUILD_ARGS=" ${BUILD_ARGS} -DCMAKE_BUILD_TYPE=Debug"
105160 fi
106161 # cmake deps
107- echo " Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\" 10.14\" ${BUILD_ARCH} "
108- pushd deps/build
109- cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=" 10.14" $BUILD_ARGS
110- echo " ls deps/build:"
111- ls -al
112- echo " ls deps/build/dep_GLEW-prefix"
113- ls -al dep_GLEW-prefix
114- } # &> $ROOT/build/Build.log # Capture all command output
115- echo " done"
116-
117- echo -n " [4/9] Building dependencies..."
118- {
162+ echo " Cmake command: cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=\" 10.15\" ${BUILD_ARCH} "
163+ pushd deps/build > /dev/null
164+ cmake .. -DCMAKE_OSX_DEPLOYMENT_TARGET=" 10.15" $BUILD_ARGS
165+
166+ echo -e " \n ... done\n"
167+
168+ echo -e " [2/9] Building dependencies ...\n"
169+
119170 # make deps
120- make -j$NCORES
121-
122- echo " ls $PWD /destdir/usr/local/lib"
123- ls $PWD /destdir/usr/local/lib
124-
125- echo " ls $PWD /destdir/usr/local/lib/cmake"
126- ls $PWD /destdir/usr/local/lib/cmake
127-
128- echo " ls $PWD /destdir/usr/local/lib/cmake/boost_locale-1.75.0"
129- ls $PWD /destdir/usr/local/lib/cmake/boost_locale-1.75.0
130-
131- } # &> $ROOT/build/Build.log # Capture all command output
132- echo " done"
133-
134- echo -n " [5/9] Renaming wxscintilla library..."
135- {
171+ make -j1
172+
173+ echo -e " \n ... done\n"
174+
175+ echo -e " [3/9] Renaming wxscintilla library ...\n"
176+
136177 # rename wxscintilla
137- pushd destdir/usr/local/lib
178+ pushd destdir/usr/local/lib > /dev/null
138179 cp libwxscintilla-3.1.a libwx_osx_cocoau_scintilla-3.1.a
139- echo " ls deps/build/destdir/usr/local/lib"
140- ls -al
141- popd
142- } # &> $ROOT/build/Build.log # Capture all command output
143- echo " done"
144-
145- echo -n " [6/9] Cleaning dependencies..."
146- {
147- # clean deps
148- rm -rf dep_*
149- popd
150- } # &> $ROOT/build/Build.log # Capture all command output
151- echo " done"
152-
153- echo -n " [7/9] Configuring Slic3r..."
154- {
180+
181+ popd > /dev/null
182+ popd > /dev/null
183+ echo -e " \n ... done\n"
184+ fi
185+
186+ if [[ -n " $BUILD_CLEANDEPEND " ]]
187+ then
188+ echo -e " [4/9] Cleaning dependencies...\n"
189+ pushd deps/build > /dev/null
190+ pwd
191+ rm -fr dep_*
192+ popd > /dev/null
193+ echo -e " \n ... done\n"
194+ fi
195+
196+ if [[ -n " $BUILD_SUPERSLICER " ]]
197+ then
198+ echo -e " [5/9] Configuring SuperSlicer ...\n"
199+
200+ if [[ -n $BUILD_WIPE ]]
201+ then
202+ echo -e " \n wiping build directory...\n"
203+ rm -fr build
204+ echo -e " ... done\n"
205+ fi
206+
207+ # mkdir build
208+ if [ ! -d " build" ]
209+ then
210+ mkdir build
211+ fi
212+
155213 BUILD_ARGS=" "
156214 if [[ -n " $BUILD_ARCH " ]]
157215 then
@@ -165,38 +223,51 @@ echo -n "[7/9] Configuring Slic3r..."
165223 then
166224 BUILD_ARGS=" -GXcode ${BUILD_ARGS} "
167225 fi
226+
227+ if [[ -n " $BUILD_TESTS " ]]
228+ then
229+ BUILD_ARGS=" ${BUILD_ARGS} -DCMAKE_BUILD_TESTS=1"
230+ else
231+ BUILD_ARGS=" ${BUILD_ARGS} -DCMAKE_BUILD_TESTS=0"
232+ fi
233+
168234 # cmake
169- pushd build
170- echo " Slic3r Cmake command: cmake .. -DCMAKE_PREFIX_PATH=\" $PWD /../deps/build/destdir/usr/local\" -DCMAKE_OSX_DEPLOYMENT_TARGET=\" 10.14\" -DSLIC3R_STATIC=1 ${BUILD_ARGS} "
235+ pushd build > /dev/null
171236 cmake .. -DCMAKE_PREFIX_PATH=" $PWD /../deps/build/destdir/usr/local" -DCMAKE_OSX_DEPLOYMENT_TARGET=" 10.14" -DSLIC3R_STATIC=1 ${BUILD_ARGS}
172- } # &> $ROOT/build/Build.log # Capture all command output
173- echo " done"
237+ echo -e " \n ... done"
174238
175- echo -n " [8/9] Building Slic3r..."
176- {
177239 # make Slic3r
178240 if [[ -z " $BUILD_XCODE " ]]
179241 then
180- make -j$NCORES Slic3r
242+ echo -e " \n[6/9] Building SuperSlicer ...\n"
243+ make -j$NCORES
244+ echo -e " \n ... done"
245+ fi
246+
247+ echo -e " \n[7/9] Generating language files ...\n"
248+ # make .mo
249+ if [[ -n " $UPDATE_POTFILE " ]]
250+ then
251+ make gettext_make_pot
181252 fi
182- # make .mo
183253 make gettext_po_to_mo
184- } # &> $ROOT/build/Build.log # Capture all command output
185- echo " done"
186- echo " ls ROOT"
187- ls $ROOT
188- echo " ls ROOT/build"
189- ls $ROOT /build
190- echo " ls -al ROOT/build/src"
191- ls -al $ROOT /build/src
192- # Give proper permissions to script
193- chmod 755 $ROOT /build/src/BuildMacOSImage.sh
254+
255+ popd > /dev/null
256+ echo -e " \n ... done"
257+
258+ # Give proper permissions to script
259+ chmod 755 $ROOT /build/src/BuildMacOSImage.sh
260+
261+ pushd build > /dev/null
262+ $ROOT /build/src/BuildMacOSImage.sh -a
263+ popd > /dev/null
264+ fi
194265
195266if [[ -n " $BUILD_IMAGE " ]]
196267then
197- $ROOT /build/src/BuildMacOSImage.sh -i
198- else
199- $ROOT /build/src/BuildMacOSImage.sh
268+ # Give proper permissions to script
269+ chmod 755 $ROOT /build/src/BuildMacOSImage.sh
270+ pushd build > /dev/null
271+ $ROOT /build/src/BuildMacOSImage.sh -i
272+ popd > /dev/null
200273fi
201- echo " ls -al ROOT/build"
202- ls -al $ROOT /build
0 commit comments