-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Expand file tree
/
Copy pathbuild_release_vs.bat
More file actions
355 lines (300 loc) · 11.4 KB
/
Copy pathbuild_release_vs.bat
File metadata and controls
355 lines (300 loc) · 11.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
@REM OrcaSlicer build script for Windows with VS auto-detect
@echo off
set WP=%CD%
set _START_TIME=%TIME%
@REM Check for Ninja Multi-Config option (-x)
set USE_NINJA=0
for %%a in (%*) do (
if "%%a"=="-x" set USE_NINJA=1
)
if "%USE_NINJA%"=="1" (
echo Using Ninja Multi-Config generator
set CMAKE_GENERATOR="Ninja Multi-Config"
set VS_VERSION=Ninja
goto :generator_ready
)
@REM Detect Visual Studio version using msbuild
echo Detecting Visual Studio version using msbuild...
@REM Try to get MSBuild version - the output format varies by VS version
set VS_MAJOR=
for /f "tokens=*" %%i in ('msbuild -version 2^>^&1 ^| findstr /r "^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"') do (
for /f "tokens=1 delims=." %%a in ("%%i") do set VS_MAJOR=%%a
set MSBUILD_OUTPUT=%%i
goto :version_found
)
@REM Alternative method for newer MSBuild versions
if "%VS_MAJOR%"=="" (
for /f "tokens=*" %%i in ('msbuild -version 2^>^&1 ^| findstr /r "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"') do (
for /f "tokens=1 delims=." %%a in ("%%i") do set VS_MAJOR=%%a
set MSBUILD_OUTPUT=%%i
goto :version_found
)
)
:version_found
echo MSBuild version detected: %MSBUILD_OUTPUT%
echo Major version: %VS_MAJOR%
if "%VS_MAJOR%"=="" (
echo Error: Could not determine Visual Studio version from msbuild
echo Please ensure Visual Studio and MSBuild are properly installed
exit /b 1
)
if "%VS_MAJOR%"=="16" (
set VS_VERSION=2019
set CMAKE_GENERATOR="Visual Studio 16 2019"
) else if "%VS_MAJOR%"=="17" (
set VS_VERSION=2022
set CMAKE_GENERATOR="Visual Studio 17 2022"
) else if "%VS_MAJOR%"=="18" (
set VS_VERSION=2026
set CMAKE_GENERATOR="Visual Studio 18 2026"
) else (
echo Error: Unsupported Visual Studio version: %VS_MAJOR%
echo Supported versions: VS2019 ^(16.x^), VS2022 ^(17.x^), VS2026 ^(18.x^)
exit /b 1
)
echo Detected Visual Studio %VS_VERSION% (version %VS_MAJOR%)
echo Using CMake generator: %CMAKE_GENERATOR%
:generator_ready
@REM Pack deps
if "%1"=="pack" (
setlocal ENABLEDELAYEDEXPANSION
cd %WP%/deps/build
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set build_date=%%c%%b%%a
echo packing deps: OrcaSlicer_dep_win64_!build_date!_vs!VS_VERSION!.zip
%WP%/tools/7z.exe a OrcaSlicer_dep_win64_!build_date!_vs!VS_VERSION!.zip OrcaSlicer_dep
goto :done
)
set debug=OFF
set debuginfo=OFF
if "%1"=="debug" set debug=ON
if "%2"=="debug" set debug=ON
if "%1"=="debuginfo" set debuginfo=ON
if "%2"=="debuginfo" set debuginfo=ON
if "%debug%"=="ON" (
set build_type=Debug
set build_dir=build-dbg
) else (
if "%debuginfo%"=="ON" (
set build_type=RelWithDebInfo
set build_dir=build-dbginfo
) else (
set build_type=Release
set build_dir=build
)
)
echo build type set to %build_type%
setlocal DISABLEDELAYEDEXPANSION
cd deps
mkdir %build_dir%
cd %build_dir%
set "SIG_FLAG="
if defined ORCA_UPDATER_SIG_KEY set "SIG_FLAG=-DORCA_UPDATER_SIG_KEY=%ORCA_UPDATER_SIG_KEY%"
if "%1"=="slicer" (
GOTO :slicer
)
echo "building deps.."
echo on
REM Set minimum CMake policy to avoid <3.5 errors
set CMAKE_POLICY_VERSION_MINIMUM=3.5
if "%USE_NINJA%"=="1" (
cmake ../ -G %CMAKE_GENERATOR% -DCMAKE_BUILD_TYPE=%build_type%
if errorlevel 1 exit /b 1
cmake --build . --config %build_type% --target deps
if errorlevel 1 exit /b 1
) else (
cmake ../ -G %CMAKE_GENERATOR% -A x64 -DCMAKE_BUILD_TYPE=%build_type%
if errorlevel 1 exit /b 1
cmake --build . --config %build_type% --target deps -- -m
if errorlevel 1 exit /b 1
)
@echo off
if "%1"=="deps" goto :done
:slicer
call :check_linux_bridge_runtime_inputs
if errorlevel 1 exit /b 1
echo "building Orca Slicer..."
cd %WP%
mkdir %build_dir%
cd %build_dir%
echo on
set CMAKE_POLICY_VERSION_MINIMUM=3.5
if "%USE_NINJA%"=="1" (
cmake .. -G %CMAKE_GENERATOR% -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_BUILD_TYPE=%build_type%
if errorlevel 1 exit /b 1
cmake --build . --config %build_type% --target ALL_BUILD
if errorlevel 1 exit /b 1
) else (
cmake .. -G %CMAKE_GENERATOR% -A x64 -DORCA_TOOLS=ON %SIG_FLAG% -DCMAKE_BUILD_TYPE=%build_type%
if errorlevel 1 exit /b 1
cmake --build . --config %build_type% --target ALL_BUILD -- -m
if errorlevel 1 exit /b 1
)
@echo off
cd ..
call scripts/run_gettext.bat
if errorlevel 1 exit /b 1
cd %build_dir%
cmake --build . --target install --config %build_type%
if errorlevel 1 exit /b 1
call :copy_linux_bridge_runtime
if errorlevel 1 exit /b 1
:done
@echo off
for /f "tokens=1-3 delims=:.," %%a in ("%_START_TIME: =0%") do set /a "_start_s=(1%%a-100)*3600 + (1%%b-100)*60 + (1%%c-100)"
for /f "tokens=1-3 delims=:.," %%a in ("%TIME: =0%") do set /a "_end_s=(1%%a-100)*3600 + (1%%b-100)*60 + (1%%c-100)"
set /a "_elapsed=_end_s - _start_s"
if %_elapsed% lss 0 set /a "_elapsed+=86400"
set /a "_hours=_elapsed / 3600"
set /a "_remainder=_elapsed - _hours * 3600"
set /a "_mins=_remainder / 60"
set /a "_secs=_remainder - _mins * 60"
echo.
echo Build completed in %_hours%h %_mins%m %_secs%s
exit /b 0
:resolve_rootfs_tar
if defined PJARCZAK_ROOTFS_TAR exit /b 0
if defined PJARCZAK_WSL_ROOTFS_TAR (
if exist "%PJARCZAK_WSL_ROOTFS_TAR%" (
set "PJARCZAK_ROOTFS_TAR=%PJARCZAK_WSL_ROOTFS_TAR%"
exit /b 0
)
echo Missing file from PJARCZAK_WSL_ROOTFS_TAR: %PJARCZAK_WSL_ROOTFS_TAR%
exit /b 1
)
if exist "%WP%\tools\pjarczak_bambu_runtime\rootfs\windows-wsl2-rootfs.tar" (
set "PJARCZAK_ROOTFS_TAR=%WP%\tools\pjarczak_bambu_runtime\rootfs\windows-wsl2-rootfs.tar"
exit /b 0
)
if exist "%WP%\tools\pjarczak_bambu_runtime\windows-wsl2-rootfs.tar" (
set "PJARCZAK_ROOTFS_TAR=%WP%\tools\pjarczak_bambu_runtime\windows-wsl2-rootfs.tar"
exit /b 0
)
echo Missing windows-wsl2-rootfs.tar
echo Expected one of:
echo %WP%\tools\pjarczak_bambu_runtime\rootfs\windows-wsl2-rootfs.tar
echo %WP%\tools\pjarczak_bambu_runtime\windows-wsl2-rootfs.tar
echo Or set PJARCZAK_WSL_ROOTFS_TAR to an absolute path.
exit /b 1
:check_linux_bridge_runtime_inputs
set "HOST_RUNTIME_DIR=%WP%\tools\pjarczak_bambu_linux_host\runtime\linux-x86_64"
call :resolve_rootfs_tar
if errorlevel 1 exit /b 1
if not exist "%HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host" (
echo Missing linux host runtime: %HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host
echo Build it first on Linux with:
echo tools\pjarczak_bambu_linux_host\package_linux_host_runtime.sh
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi1" (
echo Missing linux host ABI1 runtime: %HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi1
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi0" (
echo Missing linux host ABI0 runtime: %HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi0
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\ca-certificates.crt" (
echo Missing CA bundle for linux bridge runtime: %HOST_RUNTIME_DIR%\ca-certificates.crt
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\slicer_base64.cer" (
echo Missing slicer certificate for linux bridge runtime: %HOST_RUNTIME_DIR%\slicer_base64.cer
exit /b 1
)
echo Linux bridge preflight OK
echo host runtime: %HOST_RUNTIME_DIR%
echo rootfs tar: %PJARCZAK_ROOTFS_TAR%
exit /b 0
:copy_linux_bridge_runtime
set "INSTALL_DIR=%WP%\%build_dir%\OrcaSlicer"
set "HOST_RUNTIME_DIR=%WP%\tools\pjarczak_bambu_linux_host\runtime\linux-x86_64"
if not defined PJARCZAK_ROOTFS_TAR (
call :resolve_rootfs_tar
if errorlevel 1 exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host" (
echo Missing linux host runtime: %HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host
echo Build it first on Linux with:
echo tools\pjarczak_bambu_linux_host\package_linux_host_runtime.sh
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi1" (
echo Missing linux host ABI1 runtime: %HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi1
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi0" (
echo Missing linux host ABI0 runtime: %HOST_RUNTIME_DIR%\pjarczak_bambu_linux_host_abi0
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\ca-certificates.crt" (
echo Missing CA bundle for linux bridge runtime: %HOST_RUNTIME_DIR%\ca-certificates.crt
exit /b 1
)
if not exist "%HOST_RUNTIME_DIR%\slicer_base64.cer" (
echo Missing slicer certificate for linux bridge runtime: %HOST_RUNTIME_DIR%\slicer_base64.cer
exit /b 1
)
if not exist "%INSTALL_DIR%" (
echo Missing install directory: %INSTALL_DIR%
exit /b 1
)
if not exist "%INSTALL_DIR%\pjarczak_bambu_networking_bridge.dll" (
if exist "%WP%\%build_dir%\pjarczak_bambu_networking_bridge.dll" (
copy /Y "%WP%\%build_dir%\pjarczak_bambu_networking_bridge.dll" "%INSTALL_DIR%\pjarczak_bambu_networking_bridge.dll" >nul
)
)
if not exist "%INSTALL_DIR%\pjarczak_bambu_networking_bridge.dll" (
if exist "%WP%\%build_dir%\src\%build_type%\pjarczak_bambu_networking_bridge.dll" (
copy /Y "%WP%\%build_dir%\src\%build_type%\pjarczak_bambu_networking_bridge.dll" "%INSTALL_DIR%\pjarczak_bambu_networking_bridge.dll" >nul
)
)
if not exist "%INSTALL_DIR%\pjarczak_bambu_networking_bridge.dll" (
echo Missing bridge DLL in install output: %INSTALL_DIR%\pjarczak_bambu_networking_bridge.dll
exit /b 1
)
xcopy "%HOST_RUNTIME_DIR%\*" "%INSTALL_DIR%\\" /I /Y >nul
if errorlevel 4 (
echo Failed to copy flat linux host runtime files into %INSTALL_DIR%
exit /b 1
)
copy /Y "%PJARCZAK_ROOTFS_TAR%" "%INSTALL_DIR%\windows-wsl2-rootfs.tar" >nul
if errorlevel 1 (
echo Failed to copy windows-wsl2-rootfs.tar into %INSTALL_DIR%
exit /b 1
)
copy /Y "%WP%\tools\pjarczak_bambu_runtime\wsl\pjarczak_wsl_run_host.sh" "%INSTALL_DIR%\pjarczak_wsl_run_host.sh" >nul
if errorlevel 1 (
echo Failed to copy pjarczak_wsl_run_host.sh into %INSTALL_DIR%
exit /b 1
)
copy /Y "%WP%\tools\pjarczak_bambu_runtime\wsl\install_runtime.ps1" "%INSTALL_DIR%\install_runtime.ps1" >nul
if errorlevel 1 (
echo Failed to copy install_runtime.ps1 into %INSTALL_DIR%
exit /b 1
)
copy /Y "%WP%\tools\pjarczak_bambu_runtime\wsl\install_runtime.cmd" "%INSTALL_DIR%\install_runtime.cmd" >nul
if errorlevel 1 (
echo Failed to copy install_runtime.cmd into %INSTALL_DIR%
exit /b 1
)
copy /Y "%WP%\tools\pjarczak_bambu_runtime\wsl\verify_runtime.ps1" "%INSTALL_DIR%\verify_runtime.ps1" >nul
if errorlevel 1 (
echo Failed to copy verify_runtime.ps1 into %INSTALL_DIR%
exit /b 1
)
copy /Y "%WP%\tools\pjarczak_bambu_runtime\wsl\pjarczak_wsl_distro.txt" "%INSTALL_DIR%\pjarczak_wsl_distro.txt" >nul
if errorlevel 1 (
echo Failed to copy pjarczak_wsl_distro.txt into %INSTALL_DIR%
exit /b 1
)
copy /Y "%WP%\tools\pjarczak_bambu_runtime\wsl\pjarczak_plugin_cache_subdir.txt" "%INSTALL_DIR%\pjarczak_plugin_cache_subdir.txt" >nul
if errorlevel 1 (
echo Failed to copy pjarczak_plugin_cache_subdir.txt into %INSTALL_DIR%
exit /b 1
)
copy /Y "%WP%\tools\pjarczak_bambu_runtime\release\assemble_windows_runtime_bundle.ps1" "%INSTALL_DIR%\assemble_windows_runtime_bundle.ps1" >nul
if errorlevel 1 (
echo Failed to copy assemble_windows_runtime_bundle.ps1 into %INSTALL_DIR%
exit /b 1
)
exit /b 0