-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmakeWin.bat
More file actions
331 lines (270 loc) · 8.31 KB
/
Copy pathmakeWin.bat
File metadata and controls
331 lines (270 loc) · 8.31 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
@echo off
setlocal enabledelayedexpansion
:: makeWin.bat -- Build PBE for Windows using MSVC + Ninja + Conan
::
:: Prerequisites (edit the CONFIG section below to match your machine):
:: - Visual Studio 2022 Community with C++ workload
:: - Qt 6 installed at QT path
:: - Conan 2 on PATH
:: - 7-Zip installed at SEVENZIP path
:: - For --release: OpenSees, Dakota, and a Python 3.12 embedded zip
::
:: Usage:
:: makeWin.bat -- dev build only
:: makeWin.bat --release -- full deployable bundle + zip
:: makeWin.bat --wipe -- delete build dir before building
:: makeWin.bat -r -w -- wipe build folder then release build
:: =====================================================================
:: CONFIG -- adjust these paths for your machine
:: =====================================================================
set "QT=C:\Qt6\6.10.2\msvc2022_64"
set "SEVENZIP=C:\Program Files\7-Zip\7z.exe"
set "VCVARS=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
set "pathToOpenSees=%USERPROFILE%\bin\OpenSees3.8.0"
set "pathToDakota=%USERPROFILE%\dakota\dakota6.24"
set "pathToPython=%USERPROFILE%\python_releases\python3.12.zip"
set "APPLICATIONS_DIR=%CD%\..\SimCenterBackendApplications\applications"
:: =====================================================================
set "PROJECT_NAME=PBE"
set "CONAN_PROFILE=default"
set "BUILD_DIR=build"
set "PREFIX=%CD%\DEPS"
set "RELEASE=NO"
set "RELEASE_FLAG=-DNO_RELEASE"
set "WIPE=FALSE"
:: ---- Argument parsing ----
:parse_args
if "%~1"=="" goto :args_done
if /i "%~1"=="--release" goto :arg_release
if /i "%~1"=="-r" goto :arg_release
if /i "%~1"=="--wipe" goto :arg_wipe
if /i "%~1"=="-w" goto :arg_wipe
echo Unknown argument: %~1
echo Usage: %~nx0 [--release^|-r] [--wipe^|-w]
exit /b 1
:arg_release
set "RELEASE=YES"
set "RELEASE_FLAG=-D_SC_RELEASE"
shift
goto :parse_args
:arg_wipe
set "WIPE=TRUE"
shift
goto :parse_args
:args_done
echo.
echo Project : %PROJECT_NAME%
echo Conan profile: %CONAN_PROFILE%
echo Build dir : %BUILD_DIR%
echo Release : %RELEASE%
echo.
:: ---- Pre-flight checks ----
if not exist "%VCVARS%" (
echo FAIL: vcvars64.bat not found at %VCVARS%
exit /b 1
)
if not exist "%QT%\bin\qmake.exe" (
echo FAIL: Qt not found at %QT%
exit /b 1
)
if not exist "%SEVENZIP%" (
echo FAIL: 7-Zip not found at %SEVENZIP%
exit /b 1
)
where conan >nul 2>&1
if errorlevel 1 (
echo FAIL: 'conan' not found on PATH. Please install Conan 2.
exit /b 1
)
:: Release-only pre-flight checks
if "%RELEASE%"=="YES" (
if not exist "%APPLICATIONS_DIR%" (
echo FAIL: SimCenterBackendApplications not found at %APPLICATIONS_DIR%
exit /b 1
)
if not exist "%pathToOpenSees%" (
echo FAIL: OpenSees not found at %pathToOpenSees%
exit /b 1
)
if not exist "%pathToDakota%" (
echo FAIL: Dakota not found at %pathToDakota%
exit /b 1
)
if not exist "%pathToPython%" (
echo FAIL: Python zip not found at %pathToPython%
exit /b 1
)
if not exist "unwanted_apps.txt" (
echo FAIL: unwanted_apps.txt not found in project root
exit /b 1
)
)
:: ---- Initialize MSVC environment (required for Ninja) ----
call "%VCVARS%"
:: ---- Wipe build dir if requested ----
if "%WIPE%"=="TRUE" (
if exist "%BUILD_DIR%" (
echo Cleaning up old build directory...
rmdir /s /q "%BUILD_DIR%"
)
)
:: ---- Conan install ----
echo.
echo Running conan install...
echo.
set "CONAN_FILE_SWAPPED=NO"
if exist conanfile2.py (
move conanfile.py conanfile.old >nul
copy conanfile2.py conanfile.py >nul
set "CONAN_FILE_SWAPPED=YES"
)
conan install . --output-folder="%BUILD_DIR%" --build missing -s build_type=Release -pr "%CONAN_PROFILE%" -c tools.cmake.cmaketoolchain:generator=Ninja
if errorlevel 1 (
if "%CONAN_FILE_SWAPPED%"=="YES" if exist conanfile.old move /y conanfile.old conanfile.py >nul
echo.
echo FAIL: Conan install failed.
echo.
exit /b 1
)
if "%CONAN_FILE_SWAPPED%"=="YES" if exist conanfile.old move /y conanfile.old conanfile.py >nul
:: ---- Build QuaZip and other dependencies if needed ----
if not exist "%PREFIX%" (
echo.
echo --- Building DEPS in %PREFIX% ---
echo.
set "CONAN_BUILD_DIR=%CD%\%BUILD_DIR%"
call makeWinDeps.bat
if errorlevel 1 (
echo.
echo FAIL: makeWinDeps.bat failed.
echo.
exit /b 1
)
) else (
echo.
echo --- DEPS already present in %PREFIX%, skipping ---
echo.
)
:: ---- CMake configure ----
echo.
echo Configuring CMake...
echo.
cmake -B "%BUILD_DIR%" -S . ^
-G Ninja ^
-DCMAKE_TOOLCHAIN_FILE="%BUILD_DIR%\conan_toolchain.cmake" ^
-DCMAKE_PREFIX_PATH="%PREFIX%;%QT%" ^
-DCMAKE_CXX_FLAGS="%RELEASE_FLAG%" ^
-DCMAKE_DAKOTA_VERSION=624 ^
-DCMAKE_BUILD_TYPE=Release
if errorlevel 1 (
echo.
echo FAIL: CMake configure failed.
echo.
exit /b 1
)
:: Touch main entry points so the version string baked into them is always fresh
copy /b WorkflowApp_quoFEM.cpp +,, >nul 2>&1
copy /b main.cpp +,, >nul 2>&1
if exist "%BUILD_DIR%\%PROJECT_NAME%.exe" del /f /q "%BUILD_DIR%\%PROJECT_NAME%.exe"
:: ---- Build ----
echo.
echo Building...
echo.
cmake --build "%BUILD_DIR%"
if errorlevel 1 (
echo.
echo FAIL: CMake build failed.
echo.
exit /b 1
)
:: ---- Set up deploy directory ----
set "APP_DIR=%BUILD_DIR%\%PROJECT_NAME%_Windows_Download"
if exist "%APP_DIR%" rmdir /s /q "%APP_DIR%"
mkdir "%APP_DIR%"
:: ---- Copy executable and run windeployqt ----
copy "%BUILD_DIR%\%PROJECT_NAME%.exe" "%APP_DIR%\" >nul
"%QT%\bin\windeployqt.exe" "%APP_DIR%\%PROJECT_NAME%.exe"
if errorlevel 1 (
echo.
echo FAIL: windeployqt failed.
echo.
exit /b 1
)
:: Copy additional runtime DLLs
copy "%PREFIX%\bin\quazip1-qt6.dll" "%APP_DIR%\" >nul
:: Ninja puts DLLs directly in BUILD_DIR, not a Release\ subdirectory
for %%f in ("%BUILD_DIR%\*.dll") do copy "%%f" "%APP_DIR%\" >nul
copy "%QT%\bin\Qt6Core5Compat.dll" "%APP_DIR%\" >nul
if "%RELEASE%"=="NO" (
echo.
echo Build complete: %APP_DIR%
echo.
exit /b 0
)
:: ===============================
:: Release Build
:: ===============================
echo.
echo Building release bundle...
echo.
:: ---- Copy QS3hark resources, backend applications, OpenSees, Dakota ----
xcopy /s /e /i /q "%USERPROFILE%\NHERI\QS3hark\resources" "%APP_DIR%\resources\" >nul
mkdir "%APP_DIR%\applications"
mkdir "%APP_DIR%\applications\opensees"
mkdir "%APP_DIR%\applications\dakota"
mkdir "%APP_DIR%\Examples"
xcopy /s /e /Q ".\Examples" "%APP_DIR%\Examples"
xcopy /s /e /i /q "%APPLICATIONS_DIR%" "%APP_DIR%\applications\" >nul
xcopy /s /e /i /q "%pathToOpenSees%" "%APP_DIR%\applications\opensees\" >nul
xcopy /s /e /i /q "%pathToDakota%" "%APP_DIR%\applications\dakota\" >nul
:: ---- Extract embedded Python and install SimCenter packages ----
echo.
echo Extracting Python and installing nheri-simcenter...
echo.
"%SEVENZIP%" x "%pathToPython%" -o"%APP_DIR%\applications\" -y
if errorlevel 1 (
echo FAIL: Python extraction failed.
exit /b 1
)
set "PYTHON=%APP_DIR%\applications\python\python.exe"
if not exist "%PYTHON%" (
echo FAIL: python.exe not found at %PYTHON% after extraction.
exit /b 1
)
"%PYTHON%" -m pip install pip --upgrade
"%PYTHON%" -m pip install nheri-simcenter[pbe] --upgrade
:: "%PYTHON%" -m pelicun.cli dlml update
:: "%PYTHON%" -m pip install femora --upgrade
:: ---- Remove unwanted applications ----
echo.
echo Removing unwanted applications...
echo.
for /f "usebackq tokens=* eol=#" %%a in ("unwanted_apps.txt") do (
if not "%%a"=="" (
echo Removing: %%a
if exist "%APP_DIR%\applications\%%a" rmdir /s /q "%APP_DIR%\applications\%%a"
)
)
:: ---- Clean up __pycache__ directories ----
for /d /r "%APP_DIR%" %%d in (__pycache__) do (
if exist "%%d" rmdir /s /q "%%d"
)
echo Cleanup complete.
:: ---- Zip the release bundle ----
echo.
echo Creating release zip...
echo.
pushd "%BUILD_DIR%"
set "RELEASE_ZIP=%PROJECT_NAME%_Windows_Download.zip"
if exist "%RELEASE_ZIP%" del "%RELEASE_ZIP%"
"%SEVENZIP%" a -tzip "%RELEASE_ZIP%" "%PROJECT_NAME%_Windows_Download"
if errorlevel 1 (
popd
echo FAIL: 7-Zip packaging failed.
exit /b 1
)
popd
echo.
echo Release build complete: %BUILD_DIR%\%PROJECT_NAME%_Windows_Download.zip
echo.
exit /b 0