-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
193 lines (176 loc) · 7.48 KB
/
build.bat
File metadata and controls
193 lines (176 loc) · 7.48 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
@echo off
REM build.bat — Update repo then build Falcor + VisCache from source.
REM
REM Usage: build.bat [--config Release|Debug] [--preset <preset>] [--skip-setup] [--skip-scenes] [--scene <name>] [--clean] [--open]
REM
REM Presets: windows-vs2022 (default), windows-ninja-msvc, windows-vs2022-ci, windows-ninja-msvc-ci
REM Configs: Release (default), Debug
REM
REM Options:
REM --skip-setup Skip update + setup (submodules/packman/plugin integration)
REM --skip-scenes Skip scene downloads during update
REM --clean Remove stale CMakeCache before configure (fixes toolset mismatches)
REM --open Open the VS solution after build (VS2022 presets only)
REM
REM Steps:
REM 1. setup-build-system.bat (submodules, packman deps, copy sources, patch CMake)
REM 2. cmake --preset ... && cmake --build ... (parallel: /m for MSBuild, native for Ninja)
REM 3. verify-build-output.bat (check Mogwai.exe + data files)
REM 4. deploy build output to release\
REM
REM Safe to re-run: all steps are idempotent.
setlocal enabledelayedexpansion
set "ROOT=%~dp0"
set "VISCACHE_ROOT=%ROOT%"
set "FALCOR_ROOT=%ROOT%Falcor"
set "CONFIG=Release"
set "PRESET=windows-vs2022"
set "UPDATE_ARGS="
set "SKIP_SETUP=0"
set "CLEAN_CACHE=0"
set "OPEN_IDE=0"
set "TARGETS="
REM ---------------------------------------------------------------------------
REM Parse arguments
REM ---------------------------------------------------------------------------
:parse_args
if "%~1"=="" goto :args_done
if /i "%~1"=="--config" (set "CONFIG=%~2" & shift & shift & goto :parse_args)
if /i "%~1"=="--preset" (set "PRESET=%~2" & shift & shift & goto :parse_args)
if /i "%~1"=="--skip-setup" (set "SKIP_SETUP=1" & shift & goto :parse_args)
if /i "%~1"=="--skip-scenes" (set "UPDATE_ARGS=!UPDATE_ARGS! --skip-scenes" & shift & goto :parse_args)
if /i "%~1"=="--scene" (set "UPDATE_ARGS=!UPDATE_ARGS! --scene %~2" & shift & shift & goto :parse_args)
if /i "%~1"=="--clean" (set "CLEAN_CACHE=1" & shift & goto :parse_args)
if /i "%~1"=="--open" (set "OPEN_IDE=1" & shift & goto :parse_args)
if /i "%~1"=="--target" (set "TARGETS=!TARGETS! --target %~2" & shift & shift & goto :parse_args)
echo Unknown argument: %~1
echo Usage: %~nx0 [--config Release^|Debug] [--preset ^<preset^>] [--target ^<name^>] [--skip-setup] [--skip-scenes] [--scene ^<name^>] [--clean] [--open]
exit /b 1
:args_done
REM ---------------------------------------------------------------------------
REM Clean stale CMake cache (before setup, since setup_vs2022.bat also configures)
REM ---------------------------------------------------------------------------
set "BUILD_DIR=%FALCOR_ROOT%\build\%PRESET%"
set "CLEAN_CMAKE=cmake"
if exist "%FALCOR_ROOT%\tools\.packman\cmake\bin\cmake.exe" (
set "CLEAN_CMAKE=%FALCOR_ROOT%\tools\.packman\cmake\bin\cmake.exe"
)
if "%CLEAN_CACHE%"=="1" (
if exist "!BUILD_DIR!" (
echo [build] --clean: cleaning build artifacts...
REM cmake --build --target clean removes all build outputs via the
REM native build system (MSBuild/Ninja), ensuring no stale .obj files
REM survive header changes.
if exist "!BUILD_DIR!\CMakeCache.txt" (
"!CLEAN_CMAKE!" --build "!BUILD_DIR!" --target clean 2>nul
)
echo [build] --clean: removing CMake cache for full reconfigure...
if exist "!BUILD_DIR!\CMakeCache.txt" del /q "!BUILD_DIR!\CMakeCache.txt"
if exist "!BUILD_DIR!\CMakeFiles" rmdir /s /q "!BUILD_DIR!\CMakeFiles"
)
)
REM ---------------------------------------------------------------------------
REM Step 1: Setup (submodules, packman deps, copy sources, patch CMake)
REM ---------------------------------------------------------------------------
if "%SKIP_SETUP%"=="1" (
echo.
echo ========================================
echo Step 1: Setup -- skipped ^(--skip-setup^)
echo ========================================
) else (
echo.
echo ========================================
echo Step 1: Setup ^(submodules + packman + plugins^)
echo ========================================
call "%ROOT%setup-build-system.bat"
if errorlevel 1 (
echo [build] ERROR: setup-build-system.bat failed!
exit /b 1
)
)
REM ---------------------------------------------------------------------------
REM Step 2: CMake configure + build
REM ---------------------------------------------------------------------------
echo.
echo ========================================
echo Step 2: CMake configure + build (%PRESET% / %CONFIG%)
echo ========================================
REM Use packman cmake if available, otherwise system cmake
set "CMAKE=cmake"
if exist "%FALCOR_ROOT%\tools\.packman\cmake\bin\cmake.exe" (
set "CMAKE=%FALCOR_ROOT%\tools\.packman\cmake\bin\cmake.exe"
)
set "PLUGIN_DIRS=%ROOT%Source\RenderPasses\VisCache;%ROOT%Source\RenderPasses\ReSTIRPTPass"
echo [build] Configuring: %CMAKE% --preset %PRESET%
"%CMAKE%" --preset %PRESET% -S "%FALCOR_ROOT%" -DFALCOR_PLUGIN_DIRS="!PLUGIN_DIRS!" -DFALCOR_RUNTIME_OUTPUT_DIRECTORY="%ROOT%runtime" -DFALCOR_FLAT_OUTPUT=ON
if errorlevel 1 (
echo [build] ERROR: CMake configure failed!
exit /b 1
)
REM VS2022 presets use MSBuild; Ninja presets use native parallel.
REM --target limits the build to specific targets (e.g. --target VisCachePass --target Mogwai).
if "!TARGETS!"=="" (
echo [build] Building: all targets (%CONFIG%)
) else (
echo [build] Building:%TARGETS% (%CONFIG%)
)
echo "%PRESET%" | findstr /i "ninja" >nul
if errorlevel 1 (
"%CMAKE%" --build "%FALCOR_ROOT%\build\%PRESET%" --config %CONFIG% !TARGETS!
) else (
"%CMAKE%" --build "%FALCOR_ROOT%\build\%PRESET%" --config %CONFIG% !TARGETS!
)
if errorlevel 1 (
echo [build] ERROR: Build failed!
exit /b 1
)
REM ---------------------------------------------------------------------------
REM Step 3: Verify build output
REM ---------------------------------------------------------------------------
echo.
echo ========================================
echo Step 3: Verify build output
echo ========================================
set "BUILD_OUT=%FALCOR_ROOT%\build\%PRESET%\bin\%CONFIG%"
if exist "%ROOT%scripts\verify-build-output.bat" (
call "%ROOT%scripts\verify-build-output.bat" "!BUILD_OUT!"
if errorlevel 1 (
echo [build] WARNING: Build verification found issues
)
) else (
echo [build] verify-build-output.bat not found, skipping verification
)
REM ---------------------------------------------------------------------------
REM Step 4: Deploy build output to release\
REM ---------------------------------------------------------------------------
echo.
echo ========================================
echo Step 4: Verify runtime output
echo ========================================
set "RUNTIME_DIR=%ROOT%runtime"
if not exist "!BUILD_OUT!\Mogwai.exe" (
echo [build] WARNING: Mogwai.exe not found at !BUILD_OUT!
goto :done
)
REM Sync shaders, scripts, data, and scenes from source to runtime.
echo [build] Syncing shaders, scripts, data...
bash "%ROOT%\.scripts\sync_to_runtime.sh"
:done
echo.
echo ========================================
echo Build complete
echo ========================================
echo [build] Build output: !BUILD_OUT!
echo [build] Deployed to: %RUNTIME_DIR%\
echo.
REM Open VS solution if requested
if "%OPEN_IDE%"=="1" (
set "SLN=%FALCOR_ROOT%\build\%PRESET%\Falcor.sln"
if exist "!SLN!" (
echo [build] Opening Visual Studio: !SLN!
start "" "!SLN!"
) else (
echo [build] No .sln found at !SLN! ^(--open only works with VS2022 presets^)
)
)
endlocal