make build go fast
This commit is contained in:
+124
-83
@@ -11,7 +11,8 @@ set SCRIPT_DIR=%~dp0
|
||||
cd /d "%SCRIPT_DIR%.."
|
||||
|
||||
set FBUILD=misc\fbuild.exe
|
||||
set HELPER=powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%build_helper.ps1"
|
||||
set CHECK_TOOL=misc\build_check.exe
|
||||
set CHECK_SRC=tools\build_check.cpp
|
||||
|
||||
set TARGET_JULIET=0
|
||||
set TARGET_ROMEO=0
|
||||
@@ -37,20 +38,10 @@ shift
|
||||
goto parse_args
|
||||
|
||||
:check_defaults
|
||||
if !CONFIG_SPECIFIED! equ 0 (
|
||||
if !TARGET_SPECIFIED! equ 0 (
|
||||
set CONFIG_DEBUG=1& set CONFIG_RELEASE=1& set CONFIG_PROFILE=1
|
||||
set TARGET_JULIET=1& set TARGET_GAME=1& set TARGET_ROMEO=1& set TARGET_SHADER=1
|
||||
goto start_build
|
||||
)
|
||||
set CONFIG_DEBUG=1
|
||||
)
|
||||
if !TARGET_SPECIFIED! equ 0 (
|
||||
set TARGET_JULIET=1& set TARGET_GAME=1& set TARGET_ROMEO=1& set TARGET_SHADER=1
|
||||
)
|
||||
if !CONFIG_SPECIFIED! equ 0 set CONFIG_DEBUG=1& if !TARGET_SPECIFIED! equ 0 set CONFIG_RELEASE=1& set CONFIG_PROFILE=1
|
||||
if !TARGET_SPECIFIED! equ 0 set TARGET_JULIET=1& set TARGET_GAME=1& set TARGET_ROMEO=1& set TARGET_SHADER=1
|
||||
|
||||
:start_build
|
||||
%HELPER% -Action StartBuild >nul 2>&1
|
||||
if exist "Intermediate\built_outputs.tmp" del /f /q "Intermediate\built_outputs.tmp" >nul 2>&1
|
||||
|
||||
if not exist "%FBUILD%" (
|
||||
@@ -58,6 +49,7 @@ if not exist "%FBUILD%" (
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Find Clang / MSVC compiler
|
||||
set COMPILER=clang-cl.exe
|
||||
where %COMPILER% >nul 2>nul
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
@@ -69,21 +61,72 @@ if !ERRORLEVEL! neq 0 (
|
||||
)
|
||||
)
|
||||
|
||||
if !CONFIG_DEBUG! equ 1 call :build_config Debug
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
:: Check if build_check.exe needs to be compiled (missing, version changed, or source changed)
|
||||
set CHECK_TOOL_VER=3
|
||||
set NEED_RECOMPILE_CHECK_TOOL=0
|
||||
if not exist "%CHECK_TOOL%" (
|
||||
set NEED_RECOMPILE_CHECK_TOOL=1
|
||||
) else (
|
||||
set "CURR_VER="
|
||||
if exist "Intermediate\build_check.ver" (
|
||||
for /f "usebackq delims=" %%I in ("Intermediate\build_check.ver") do set "CURR_VER=%%I"
|
||||
)
|
||||
if not "!CURR_VER!"=="!CHECK_TOOL_VER!" set NEED_RECOMPILE_CHECK_TOOL=1
|
||||
set "SRC_TIME="
|
||||
for %%I in ("%CHECK_SRC%") do set "SRC_TIME=%%~tI"
|
||||
set "STAMP_TIME="
|
||||
if exist "Intermediate\build_check.stamp" (
|
||||
for /f "usebackq delims=" %%I in ("Intermediate\build_check.stamp") do set "STAMP_TIME=%%I"
|
||||
)
|
||||
if not "!SRC_TIME!"=="!STAMP_TIME!" set NEED_RECOMPILE_CHECK_TOOL=1
|
||||
)
|
||||
|
||||
if !CONFIG_PROFILE! equ 1 call :build_config Profile
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
if !NEED_RECOMPILE_CHECK_TOOL! equ 1 (
|
||||
if exist "Intermediate\build_check.stamp" del /f /q "Intermediate\build_check.stamp"
|
||||
if exist "Intermediate\build_check.ver" del /f /q "Intermediate\build_check.ver"
|
||||
if exist "%CHECK_TOOL%" (
|
||||
del /f /q "%CHECK_TOOL%" >nul 2>&1
|
||||
if exist "%CHECK_TOOL%" (
|
||||
echo [BUILD FAILED] Could not overwrite %CHECK_TOOL%. It may be in use by another process.
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
echo [BUILD] Compiling fast native helper tool [tools\build_check.cpp -^> misc\build_check.exe]...
|
||||
%COMPILER% /nologo /std:c++20 /MT /O2 /EHa- /W4 "%CHECK_SRC%" /Fe"%CHECK_TOOL%"
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo [BUILD FAILED] Could not compile build helper tool.
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%CHECK_TOOL%" (
|
||||
echo [BUILD FAILED] Compilation failed to produce %CHECK_TOOL%.
|
||||
exit /b 1
|
||||
)
|
||||
"%CHECK_TOOL%" check_alive >nul 2>&1
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo [BUILD FAILED] %CHECK_TOOL% was built but failed to execute ^(missing DLL or AV block^).
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "Intermediate" mkdir "Intermediate"
|
||||
(echo !CHECK_TOOL_VER!)>"Intermediate\build_check.ver"
|
||||
for %%I in ("%CHECK_SRC%") do (echo %%~tI)>"Intermediate\build_check.stamp"
|
||||
)
|
||||
|
||||
if !CONFIG_RELEASE! equ 1 call :build_config Release
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
"%CHECK_TOOL%" start_build
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo [BUILD FAILED] %CHECK_TOOL% start_build failed with exit code !ERRORLEVEL!.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if !CONFIG_DEBUG! equ 1 call :build_config Debug || exit /b !ERRORLEVEL!
|
||||
if !CONFIG_PROFILE! equ 1 call :build_config Profile || exit /b !ERRORLEVEL!
|
||||
if !CONFIG_RELEASE! equ 1 call :build_config Release || exit /b !ERRORLEVEL!
|
||||
|
||||
echo.
|
||||
echo ==============================================================================
|
||||
echo [BUILD SUMMARY]
|
||||
echo ==============================================================================
|
||||
echo Compiler Used : %COMPILER%
|
||||
%HELPER% -Action FinishBuild
|
||||
"%CHECK_TOOL%" finish_build
|
||||
echo ==============================================================================
|
||||
echo [ALL BUILDS SUCCEEDED] All requested targets processed successfully.
|
||||
echo ==============================================================================
|
||||
@@ -107,16 +150,23 @@ if !TARGET_GAME! equ 1 set FASTBUILD_TARGETS=!FASTBUILD_TARGETS! Game-Unity
|
||||
if !TARGET_ROMEO! equ 1 set FASTBUILD_TARGETS=!FASTBUILD_TARGETS! Romeo-Unity
|
||||
if !TARGET_SHADER! equ 1 set FASTBUILD_TARGETS=!FASTBUILD_TARGETS! JulietShaderCompiler-Unity
|
||||
|
||||
%HELPER% -Action StartUnity >nul 2>&1
|
||||
|
||||
"%CHECK_TOOL%" start_step "FASTBuild Unity Gen [!CFG!]"
|
||||
"%FBUILD%" !FASTBUILD_TARGETS!
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
set "FBUILD_ERR=!ERRORLEVEL!"
|
||||
"%CHECK_TOOL%" end_step
|
||||
if !FBUILD_ERR! neq 0 (
|
||||
echo [BUILD FAILED] FASTBuild failed to generate unity files for %CFG%.
|
||||
exit /b !ERRORLEVEL!
|
||||
exit /b !FBUILD_ERR!
|
||||
)
|
||||
|
||||
:: Evaluate all target needs in a single fast PowerShell pass
|
||||
%HELPER% -Action EvaluateConfig -CFG "!CFG!" -TargetJuliet "!TARGET_JULIET!" -TargetGame "!TARGET_GAME!" -TargetRomeo "!TARGET_ROMEO!" -TargetShader "!TARGET_SHADER!" >nul 2>&1
|
||||
:: Evaluate all target needs in a single fast native pass (<5ms)
|
||||
"%CHECK_TOOL%" start_step "Config Evaluation [!CFG!]"
|
||||
"%CHECK_TOOL%" evaluate "!CFG!" "!TARGET_JULIET!" "!TARGET_GAME!" "!TARGET_ROMEO!" "!TARGET_SHADER!"
|
||||
if !ERRORLEVEL! neq 0 (
|
||||
echo [BUILD FAILED] %CHECK_TOOL% evaluate failed with exit code !ERRORLEVEL!.
|
||||
exit /b 1
|
||||
)
|
||||
"%CHECK_TOOL%" end_step
|
||||
|
||||
set FASTBUILD_UNITY_CHANGED=0
|
||||
set JULIET_NEED_COMPILE=0
|
||||
@@ -128,7 +178,7 @@ set SHADER_NEED_COMPILE=0
|
||||
|
||||
if exist "Intermediate\config_status.tmp" (
|
||||
for /f "usebackq tokens=1,2 delims==" %%A in ("Intermediate\config_status.tmp") do set %%A=%%B
|
||||
del /f /q "Intermediate\config_status.tmp" >nul 2>&1
|
||||
del /f /q "Intermediate\config_status.tmp"
|
||||
)
|
||||
|
||||
if !FASTBUILD_UNITY_CHANGED! equ 1 (
|
||||
@@ -138,12 +188,9 @@ if !FASTBUILD_UNITY_CHANGED! equ 1 (
|
||||
)
|
||||
|
||||
set ANY_NEED_BUILD=0
|
||||
if !JULIET_NEED_COMPILE! equ 1 set ANY_NEED_BUILD=1
|
||||
if !IMGUI_NEED_COMPILE! equ 1 set ANY_NEED_BUILD=1
|
||||
if !GAME_NEED_COMPILE! equ 1 set ANY_NEED_BUILD=1
|
||||
if !JULIETAPP_NEED_COMPILE! equ 1 set ANY_NEED_BUILD=1
|
||||
if !ROMEO_NEED_COMPILE! equ 1 set ANY_NEED_BUILD=1
|
||||
if !SHADER_NEED_COMPILE! equ 1 set ANY_NEED_BUILD=1
|
||||
for %%T in (JULIET IMGUI GAME JULIETAPP ROMEO SHADER) do (
|
||||
if !%%T_NEED_COMPILE! equ 1 set ANY_NEED_BUILD=1
|
||||
)
|
||||
|
||||
if !ANY_NEED_BUILD! equ 0 (
|
||||
echo [SKIP / UP-TO-DATE] All requested targets in [%CFG%] are up-to-date.
|
||||
@@ -180,8 +227,11 @@ if !JULIET_NEED_COMPILE! equ 0 (
|
||||
echo [SKIP / UP-TO-DATE] Intermediate\x64-!CFG!\Juliet_Unity*.obj [Unity files unchanged]
|
||||
) else (
|
||||
echo [REBUILDING] Compiling Intermediate\x64-!CFG!\Juliet_Unity*.obj...
|
||||
"%CHECK_TOOL%" start_step "Compiling Juliet Shared Objs [!CFG!]"
|
||||
%COMPILER% %COMPILER_FLAGS% /DJULIET_EXPORT /c Intermediate\Juliet\*.cpp /Fo"Intermediate\x64-!CFG!\\"
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
set "COMP_ERR=!ERRORLEVEL!"
|
||||
"%CHECK_TOOL%" end_step
|
||||
if !COMP_ERR! neq 0 exit /b !COMP_ERR!
|
||||
)
|
||||
|
||||
:: --- ImGui Shared Objs ---
|
||||
@@ -190,8 +240,11 @@ if defined IMGUI_UNITY_SRCS (
|
||||
echo [SKIP / UP-TO-DATE] Intermediate\x64-!CFG!\ImGui_Unity*.obj [Unity files unchanged]
|
||||
) else (
|
||||
echo [REBUILDING] Compiling Intermediate\x64-!CFG!\ImGui_Unity*.obj...
|
||||
"%CHECK_TOOL%" start_step "Compiling ImGui Shared Objs [!CFG!]"
|
||||
%COMPILER% %COMPILER_FLAGS% /c !IMGUI_UNITY_SRCS! /Fo"Intermediate\x64-!CFG!\\"
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
set "COMP_ERR=!ERRORLEVEL!"
|
||||
"%CHECK_TOOL%" end_step
|
||||
if !COMP_ERR! neq 0 exit /b !COMP_ERR!
|
||||
)
|
||||
)
|
||||
|
||||
@@ -205,68 +258,56 @@ if !TARGET_GAME! equ 1 set BUILD_GAME_DLL=1
|
||||
|
||||
:: --- Game.dll ---
|
||||
if !BUILD_GAME_DLL! equ 1 (
|
||||
echo.
|
||||
echo --- Building Game.dll [%CFG%] ---
|
||||
if !GAME_NEED_COMPILE! equ 0 (
|
||||
echo [SKIP / UP-TO-DATE] bin\x64-!CFG!\Game.dll [Binary up to date, skipping compilation]
|
||||
) else (
|
||||
echo [REBUILDING] Compiling bin\x64-!CFG!\Game.dll...
|
||||
%COMPILER% %COMPILER_FLAGS% /DJULIET_EXPORT /LD /Fe"bin\x64-!CFG!\Game.dll" ^
|
||||
%JULIET_OBJS% Intermediate\Game\*.cpp %IMGUI_OBJS% ^
|
||||
/link %COMMON_LIBS% /INCREMENTAL /ILK:"Intermediate\x64-!CFG!\Game.ilk" /PDB:"Intermediate\x64-!CFG!\Game.pdb"
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
echo bin\x64-!CFG!\Game.dll>>Intermediate\built_outputs.tmp
|
||||
)
|
||||
call :link_target "Game.dll" "Building Game.dll [!CFG!]" "!GAME_NEED_COMPILE!" "%COMPILER_FLAGS% /DJULIET_EXPORT /LD" "%JULIET_OBJS% Intermediate\Game\*.cpp %IMGUI_OBJS%" "/link %COMMON_LIBS% /INCREMENTAL /ILK:\"Intermediate\x64-!CFG!\Game.ilk\" /PDB:\"Intermediate\x64-!CFG!\Game.pdb\""
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
)
|
||||
|
||||
:: --- JulietApp.exe ---
|
||||
if !TARGET_JULIET! equ 1 (
|
||||
echo.
|
||||
echo --- Building JulietApp.exe [%CFG%] ---
|
||||
if !JULIETAPP_NEED_COMPILE! equ 0 (
|
||||
echo [SKIP / UP-TO-DATE] bin\x64-!CFG!\JulietApp.exe [Binary up to date, skipping compilation]
|
||||
) else (
|
||||
echo [REBUILDING] Compiling bin\x64-!CFG!\JulietApp.exe...
|
||||
%COMPILER% %COMPILER_FLAGS% /Fe"bin\x64-!CFG!\JulietApp.exe" ^
|
||||
Intermediate\JulietApp\*.cpp %IMGUI_OBJS% ^
|
||||
/link %COMMON_LIBS% bin\x64-!CFG!\Game.lib /SUBSYSTEM:CONSOLE /INCREMENTAL /ILK:"Intermediate\x64-!CFG!\JulietApp.ilk" /PDB:"Intermediate\x64-!CFG!\JulietApp.pdb"
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
echo bin\x64-!CFG!\JulietApp.exe>>Intermediate\built_outputs.tmp
|
||||
)
|
||||
call :link_target "JulietApp.exe" "Building JulietApp.exe [!CFG!]" "!JULIETAPP_NEED_COMPILE!" "%COMPILER_FLAGS%" "Intermediate\JulietApp\*.cpp %IMGUI_OBJS%" "/link %COMMON_LIBS% bin\x64-!CFG!\Game.lib /SUBSYSTEM:CONSOLE /INCREMENTAL /ILK:\"Intermediate\x64-!CFG!\JulietApp.ilk\" /PDB:\"Intermediate\x64-!CFG!\JulietApp.pdb\""
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
)
|
||||
|
||||
:: --- Romeo.exe ---
|
||||
if !TARGET_ROMEO! equ 1 (
|
||||
echo.
|
||||
echo --- Building Romeo.exe [%CFG%] ---
|
||||
if !ROMEO_NEED_COMPILE! equ 0 (
|
||||
echo [SKIP / UP-TO-DATE] bin\x64-!CFG!\Romeo.exe [Binary up to date, skipping compilation]
|
||||
) else (
|
||||
echo [REBUILDING] Compiling bin\x64-!CFG!\Romeo.exe...
|
||||
%COMPILER% %COMPILER_FLAGS% /Fe"bin\x64-!CFG!\Romeo.exe" ^
|
||||
%JULIET_OBJS% Intermediate\Romeo\*.cpp %IMGUI_OBJS% ^
|
||||
/link %COMMON_LIBS% /SUBSYSTEM:CONSOLE /INCREMENTAL /ILK:"Intermediate\x64-!CFG!\Romeo.ilk" /PDB:"Intermediate\x64-!CFG!\Romeo.pdb"
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
echo bin\x64-!CFG!\Romeo.exe>>Intermediate\built_outputs.tmp
|
||||
)
|
||||
call :link_target "Romeo.exe" "Building Romeo.exe [!CFG!]" "!ROMEO_NEED_COMPILE!" "%COMPILER_FLAGS%" "%JULIET_OBJS% Intermediate\Romeo\*.cpp %IMGUI_OBJS%" "/link %COMMON_LIBS% /SUBSYSTEM:CONSOLE /INCREMENTAL /ILK:\"Intermediate\x64-!CFG!\Romeo.ilk\" /PDB:\"Intermediate\x64-!CFG!\Romeo.pdb\""
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
)
|
||||
|
||||
:: --- JulietShaderCompiler.exe ---
|
||||
if !TARGET_SHADER! equ 1 (
|
||||
echo.
|
||||
echo --- Building JulietShaderCompiler.exe [%CFG%] ---
|
||||
if exist "Intermediate\JulietShaderCompiler\*.cpp" (
|
||||
if !SHADER_NEED_COMPILE! equ 0 (
|
||||
echo [SKIP / UP-TO-DATE] bin\x64-!CFG!\JulietShaderCompiler.exe [Binary up to date, skipping compilation]
|
||||
) else (
|
||||
echo [REBUILDING] Compiling bin\x64-!CFG!\JulietShaderCompiler.exe...
|
||||
%COMPILER% %COMPILER_FLAGS% /I"JulietShaderCompiler" /Fe"bin\x64-!CFG!\JulietShaderCompiler.exe" ^
|
||||
%JULIET_OBJS% Intermediate\JulietShaderCompiler\*.cpp %IMGUI_OBJS% ^
|
||||
/link %COMMON_LIBS% dxcompiler.lib /DELAYLOAD:dxcompiler.dll /SUBSYSTEM:CONSOLE /INCREMENTAL /ILK:"Intermediate\x64-!CFG!\JulietShaderCompiler.ilk" /PDB:"Intermediate\x64-!CFG!\JulietShaderCompiler.pdb"
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
echo bin\x64-!CFG!\JulietShaderCompiler.exe>>Intermediate\built_outputs.tmp
|
||||
)
|
||||
call :link_target "JulietShaderCompiler.exe" "Building JulietShaderCompiler.exe [!CFG!]" "!SHADER_NEED_COMPILE!" "%COMPILER_FLAGS% /I\"JulietShaderCompiler\"" "%JULIET_OBJS% Intermediate\JulietShaderCompiler\*.cpp %IMGUI_OBJS%" "/link %COMMON_LIBS% dxcompiler.lib /DELAYLOAD:dxcompiler.dll /SUBSYSTEM:CONSOLE /INCREMENTAL /ILK:\"Intermediate\x64-!CFG!\JulietShaderCompiler.ilk\" /PDB:\"Intermediate\x64-!CFG!\JulietShaderCompiler.pdb\""
|
||||
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!
|
||||
)
|
||||
)
|
||||
|
||||
exit /b 0
|
||||
|
||||
:: ------------------------------------------------------------------------------
|
||||
:: Helper Subroutine: Link / Build Target Binary
|
||||
:: ------------------------------------------------------------------------------
|
||||
:link_target
|
||||
set "TARGET_NAME=%~1"
|
||||
set "STEP_TITLE=%~2"
|
||||
set "NEED_COMPILE=%~3"
|
||||
set "EXTRA_FLAGS=%~4"
|
||||
set "SOURCES_AND_OBJS=%~5"
|
||||
set "LINK_FLAGS=%~6"
|
||||
|
||||
echo.
|
||||
echo --- Building %TARGET_NAME% [%CFG%] ---
|
||||
if "%NEED_COMPILE%"=="0" (
|
||||
echo [SKIP / UP-TO-DATE] bin\x64-!CFG!\%TARGET_NAME% [Binary up to date, skipping compilation]
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
echo [REBUILDING] Compiling bin\x64-!CFG!\%TARGET_NAME%...
|
||||
"%CHECK_TOOL%" start_step "%STEP_TITLE%"
|
||||
%COMPILER% %EXTRA_FLAGS% /Fe"bin\x64-!CFG!\%TARGET_NAME%" %SOURCES_AND_OBJS% %LINK_FLAGS%
|
||||
set "COMP_ERR=!ERRORLEVEL!"
|
||||
"%CHECK_TOOL%" end_step
|
||||
if !COMP_ERR! neq 0 exit /b !COMP_ERR!
|
||||
|
||||
echo bin\x64-!CFG!\%TARGET_NAME%>>Intermediate\built_outputs.tmp
|
||||
exit /b 0
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
# misc/build_helper.ps1 - Unified Build Utility Script
|
||||
param(
|
||||
[string]$Action,
|
||||
[string]$CFG,
|
||||
[string]$TargetJuliet = "0",
|
||||
[string]$TargetGame = "0",
|
||||
[string]$TargetRomeo = "0",
|
||||
[string]$TargetShader = "0"
|
||||
)
|
||||
|
||||
if (-not (Test-Path "Intermediate")) {
|
||||
New-Item -ItemType Directory -Path "Intermediate" | Out-Null
|
||||
}
|
||||
|
||||
switch ($Action) {
|
||||
"StartBuild" {
|
||||
[System.IO.File]::WriteAllText("Intermediate\build_start.tmp", [System.DateTime]::Now.Ticks.ToString())
|
||||
}
|
||||
|
||||
"FinishBuild" {
|
||||
$elapsedStr = "00:00:00.000"
|
||||
if (Test-Path "Intermediate\build_start.tmp") {
|
||||
$startStr = Get-Content "Intermediate\build_start.tmp" -ErrorAction SilentlyContinue
|
||||
if ($startStr) {
|
||||
$startTicks = [long]$startStr
|
||||
$elapsed = New-Object System.TimeSpan ([System.DateTime]::Now.Ticks - $startTicks)
|
||||
$elapsedStr = "{0:D2}:{1:D2}:{2:D2}.{3:D3}" -f $elapsed.Hours, $elapsed.Minutes, $elapsed.Seconds, $elapsed.Milliseconds
|
||||
}
|
||||
Remove-Item "Intermediate\build_start.tmp" -ErrorAction SilentlyContinue
|
||||
}
|
||||
Write-Host "Total Duration : $elapsedStr"
|
||||
Write-Host "Output Binaries:"
|
||||
if (Test-Path "Intermediate\built_outputs.tmp") {
|
||||
$files = Get-Content "Intermediate\built_outputs.tmp" -ErrorAction SilentlyContinue | Where-Object { Test-Path $_ }
|
||||
if ($files) {
|
||||
foreach ($f in $files) {
|
||||
$item = Get-Item $f
|
||||
$size = "{0:N2} MB" -f ($item.Length / 1MB)
|
||||
$relPath = $item.FullName.Replace((Get-Location).Path + "\", "")
|
||||
Write-Host " - $relPath ($size)"
|
||||
}
|
||||
} else {
|
||||
Write-Host " - None built in this session (all requested targets up-to-date)"
|
||||
}
|
||||
Remove-Item "Intermediate\built_outputs.tmp" -ErrorAction SilentlyContinue
|
||||
} else {
|
||||
Write-Host " - None built in this session (all requested targets up-to-date)"
|
||||
}
|
||||
}
|
||||
|
||||
"StartUnity" {
|
||||
# Compute SHA256 hashes of all existing Unity files before FASTBuild runs
|
||||
$hashes = @{}
|
||||
Get-ChildItem -Path "Intermediate" -Recurse -Filter "*_Unity*.cpp" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
|
||||
$hashes[$_.FullName] = $hash
|
||||
}
|
||||
$hashes | ConvertTo-Json | Set-Content -Path "Intermediate\unity_hashes.tmp" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
"EvaluateConfig" {
|
||||
# 1. Strip '#pragma message' from generated Unity files if present
|
||||
Get-ChildItem -Path "Intermediate" -Recurse -Filter "*_Unity*.cpp" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
$filePath = $_.FullName
|
||||
$lines = [System.IO.File]::ReadAllLines($filePath)
|
||||
$filtered = $lines | Where-Object { $_ -notlike '*#pragma message*' }
|
||||
if ($lines.Count -ne $filtered.Count) {
|
||||
[System.IO.File]::WriteAllLines($filePath, $filtered)
|
||||
}
|
||||
}
|
||||
|
||||
# 2. Compare Unity hashes to detect Unity structure changes
|
||||
$oldHashes = @{}
|
||||
if (Test-Path "Intermediate\unity_hashes.tmp") {
|
||||
try {
|
||||
$json = Get-Content "Intermediate\unity_hashes.tmp" -Raw -ErrorAction SilentlyContinue
|
||||
if ($json) {
|
||||
$obj = $json | ConvertFrom-Json
|
||||
foreach ($prop in $obj.PSObject.Properties) {
|
||||
$oldHashes[$prop.Name] = $prop.Value
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
Remove-Item "Intermediate\unity_hashes.tmp" -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
$unityChanged = "0"
|
||||
$currentFiles = Get-ChildItem -Path "Intermediate" -Recurse -Filter "*_Unity*.cpp" -ErrorAction SilentlyContinue
|
||||
if (-not $currentFiles) {
|
||||
$unityChanged = "1"
|
||||
} else {
|
||||
foreach ($file in $currentFiles) {
|
||||
$path = $file.FullName
|
||||
$newHash = (Get-FileHash -Path $path -Algorithm SHA256).Hash
|
||||
if (-not $oldHashes.ContainsKey($path) -or $oldHashes[$path] -ne $newHash) {
|
||||
$unityChanged = "1"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Helper function to check if target binary/obj is missing or older than source files in dirs
|
||||
function Test-NeedRebuild([string]$targetFile, [string[]]$dirs) {
|
||||
if (-not (Test-Path $targetFile)) { return "1" }
|
||||
if ($unityChanged -eq "1") { return "1" }
|
||||
$targetTime = (Get-Item $targetFile).LastWriteTime
|
||||
foreach ($d in $dirs) {
|
||||
if (Test-Path $d) {
|
||||
$newer = Get-ChildItem -Path $d -Recurse -File -ErrorAction SilentlyContinue | Where-Object {
|
||||
($_.Extension -eq '.cpp' -or $_.Extension -eq '.h' -or $_.Extension -eq '.hpp' -or $_.Extension -eq '.inl') -and $_.LastWriteTime -gt $targetTime
|
||||
}
|
||||
if ($newer) { return "1" }
|
||||
}
|
||||
}
|
||||
return "0"
|
||||
}
|
||||
|
||||
$julietObj = "Intermediate\x64-$CFG\Juliet_Unity1.obj"
|
||||
$imguiObj = "Intermediate\x64-$CFG\ImGui_Unity1.obj"
|
||||
$gameDll = "bin\x64-$CFG\Game.dll"
|
||||
$julietApp = "bin\x64-$CFG\JulietApp.exe"
|
||||
$romeoExe = "bin\x64-$CFG\Romeo.exe"
|
||||
$shaderExe = "bin\x64-$CFG\JulietShaderCompiler.exe"
|
||||
|
||||
$julietNeed = Test-NeedRebuild $julietObj @("Juliet")
|
||||
$imguiNeed = Test-NeedRebuild $imguiObj @("External/imgui")
|
||||
|
||||
$gameNeed = "0"
|
||||
if ($TargetJuliet -eq "1" -or $TargetGame -eq "1") {
|
||||
$gameNeed = Test-NeedRebuild $gameDll @("Juliet", "Game", "External/imgui")
|
||||
if ($julietNeed -eq "1") { $gameNeed = "1" }
|
||||
}
|
||||
|
||||
$julietAppNeed = "0"
|
||||
if ($TargetJuliet -eq "1") {
|
||||
$julietAppNeed = Test-NeedRebuild $julietApp @("JulietApp", "Game", "Juliet", "External/imgui")
|
||||
if ($gameNeed -eq "1") { $julietAppNeed = "1" }
|
||||
}
|
||||
|
||||
$romeoNeed = "0"
|
||||
if ($TargetRomeo -eq "1") {
|
||||
$romeoNeed = Test-NeedRebuild $romeoExe @("Romeo", "Juliet", "External/imgui")
|
||||
if ($julietNeed -eq "1") { $romeoNeed = "1" }
|
||||
}
|
||||
|
||||
$shaderNeed = "0"
|
||||
if ($TargetShader -eq "1" -and (Test-Path "Intermediate\JulietShaderCompiler\*.cpp")) {
|
||||
$shaderNeed = Test-NeedRebuild $shaderExe @("JulietShaderCompiler", "Juliet", "External/imgui")
|
||||
if ($julietNeed -eq "1") { $shaderNeed = "1" }
|
||||
}
|
||||
|
||||
$lines = @(
|
||||
"FASTBUILD_UNITY_CHANGED=$unityChanged",
|
||||
"JULIET_NEED_COMPILE=$julietNeed",
|
||||
"IMGUI_NEED_COMPILE=$imguiNeed",
|
||||
"GAME_NEED_COMPILE=$gameNeed",
|
||||
"JULIETAPP_NEED_COMPILE=$julietAppNeed",
|
||||
"ROMEO_NEED_COMPILE=$romeoNeed",
|
||||
"SHADER_NEED_COMPILE=$shaderNeed"
|
||||
)
|
||||
$lines | Set-Content -Path "Intermediate\config_status.tmp"
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
# check_target.ps1 - Checks if target binary needs to be rebuilt based on binary existence and source file modification times
|
||||
param(
|
||||
[string]$TargetBinary,
|
||||
[string]$SearchDirs
|
||||
)
|
||||
|
||||
if (-not (Test-Path $TargetBinary)) {
|
||||
Set-Content -Path "Intermediate\need_build.tmp" -Value "1"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$binTime = (Get-Item $TargetBinary).LastWriteTime
|
||||
$dirs = $SearchDirs -split ','
|
||||
|
||||
$needsRebuild = "0"
|
||||
foreach ($dir in $dirs) {
|
||||
if (Test-Path $dir) {
|
||||
# Check source .cpp, .h, .hpp, .inl files for changes newer than target binary
|
||||
$newer = Get-ChildItem -Path $dir -Recurse -File -ErrorAction SilentlyContinue | Where-Object {
|
||||
($_.Extension -eq '.cpp' -or $_.Extension -eq '.h' -or $_.Extension -eq '.hpp' -or $_.Extension -eq '.inl') -and $_.LastWriteTime -gt $binTime
|
||||
}
|
||||
if ($newer) {
|
||||
$needsRebuild = "1"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set-Content -Path "Intermediate\need_build.tmp" -Value $needsRebuild
|
||||
@@ -1,61 +0,0 @@
|
||||
# clean_unity.ps1 - Manages Unity files content hashing and change detection
|
||||
param(
|
||||
[string]$Action = "Finish"
|
||||
)
|
||||
|
||||
if (-not (Test-Path "Intermediate")) { New-Item -ItemType Directory -Path "Intermediate" | Out-Null }
|
||||
|
||||
$hashFile = "Intermediate\unity_hashes.tmp"
|
||||
|
||||
if ($Action -eq "Start") {
|
||||
# Compute SHA256 hashes of all existing Unity files before FASTBuild runs
|
||||
$hashes = @{}
|
||||
Get-ChildItem -Path "Intermediate" -Recurse -Filter "*_Unity*.cpp" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
|
||||
$hashes[$_.FullName] = $hash
|
||||
}
|
||||
$hashes | ConvertTo-Json | Set-Content -Path $hashFile -ErrorAction SilentlyContinue
|
||||
}
|
||||
elseif ($Action -eq "Finish") {
|
||||
$oldHashes = @{}
|
||||
if (Test-Path $hashFile) {
|
||||
try {
|
||||
$json = Get-Content $hashFile -Raw -ErrorAction SilentlyContinue
|
||||
if ($json) {
|
||||
$obj = $json | ConvertFrom-Json
|
||||
foreach ($prop in $obj.PSObject.Properties) {
|
||||
$oldHashes[$prop.Name] = $prop.Value
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
Remove-Item $hashFile -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# Clean '#pragma message' from generated Unity files if present
|
||||
Get-ChildItem -Path "Intermediate" -Recurse -Filter "*_Unity*.cpp" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
$filePath = $_.FullName
|
||||
$lines = [System.IO.File]::ReadAllLines($filePath)
|
||||
$filtered = $lines | Where-Object { $_ -notlike '*#pragma message*' }
|
||||
if ($lines.Count -ne $filtered.Count) {
|
||||
[System.IO.File]::WriteAllLines($filePath, $filtered)
|
||||
}
|
||||
}
|
||||
|
||||
# Detect if any Unity file is new or has changed content
|
||||
$unityChanged = "0"
|
||||
$currentFiles = Get-ChildItem -Path "Intermediate" -Recurse -Filter "*_Unity*.cpp" -ErrorAction SilentlyContinue
|
||||
if (-not $currentFiles) {
|
||||
$unityChanged = "1"
|
||||
} else {
|
||||
foreach ($file in $currentFiles) {
|
||||
$path = $file.FullName
|
||||
$newHash = (Get-FileHash -Path $path -Algorithm SHA256).Hash
|
||||
if (-not $oldHashes.ContainsKey($path) -or $oldHashes[$path] -ne $newHash) {
|
||||
$unityChanged = "1"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set-Content -Path "Intermediate\unity_changed.tmp" -Value $unityChanged
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
# summary_helper.ps1 - Handles build timing and summary reporting cleanly
|
||||
param(
|
||||
[string]$Action
|
||||
)
|
||||
|
||||
if ($Action -eq "Start") {
|
||||
if (-not (Test-Path "Intermediate")) { New-Item -ItemType Directory -Path "Intermediate" | Out-Null }
|
||||
[System.IO.File]::WriteAllText("Intermediate\build_start.tmp", [System.DateTime]::Now.Ticks.ToString())
|
||||
}
|
||||
elseif ($Action -eq "Finish") {
|
||||
$elapsedStr = "00:00:00.000"
|
||||
if (Test-Path "Intermediate\build_start.tmp") {
|
||||
$startStr = Get-Content "Intermediate\build_start.tmp" -ErrorAction SilentlyContinue
|
||||
if ($startStr) {
|
||||
$startTicks = [long]$startStr
|
||||
$elapsed = New-Object System.TimeSpan ([System.DateTime]::Now.Ticks - $startTicks)
|
||||
$elapsedStr = "{0:D2}:{1:D2}:{2:D2}.{3:D3}" -f $elapsed.Hours, $elapsed.Minutes, $elapsed.Seconds, $elapsed.Milliseconds
|
||||
}
|
||||
Remove-Item "Intermediate\build_start.tmp" -ErrorAction SilentlyContinue
|
||||
}
|
||||
Write-Host "Total Duration : $elapsedStr"
|
||||
Write-Host "Output Binaries:"
|
||||
if (Test-Path "Intermediate\built_outputs.tmp") {
|
||||
$files = Get-Content "Intermediate\built_outputs.tmp" -ErrorAction SilentlyContinue | Where-Object { Test-Path $_ }
|
||||
if ($files) {
|
||||
foreach ($f in $files) {
|
||||
$item = Get-Item $f
|
||||
$size = "{0:N2} MB" -f ($item.Length / 1MB)
|
||||
$relPath = $item.FullName.Replace((Get-Location).Path + "\", "")
|
||||
Write-Host " - $relPath ($size)"
|
||||
}
|
||||
} else {
|
||||
Write-Host " - None built in this session (all requested targets up-to-date)"
|
||||
}
|
||||
Remove-Item "Intermediate\built_outputs.tmp" -ErrorAction SilentlyContinue
|
||||
} else {
|
||||
Write-Host " - None built in this session (all requested targets up-to-date)"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user