improve build.bat
This commit is contained in:
Vendored
+20
-11
@@ -4,6 +4,24 @@
|
||||
.ProjectName = 'ImGui'
|
||||
.ProjectPath = 'External/imgui'
|
||||
|
||||
// Unity
|
||||
//--------------------------------------------------------------------------
|
||||
Unity( '$ProjectName$-Unity' )
|
||||
{
|
||||
.UnityInputFiles = {
|
||||
'$ProjectPath$/imgui.cpp',
|
||||
'$ProjectPath$/imgui_demo.cpp',
|
||||
'$ProjectPath$/imgui_draw.cpp',
|
||||
'$ProjectPath$/imgui_tables.cpp',
|
||||
'$ProjectPath$/imgui_widgets.cpp',
|
||||
'$ProjectPath$/backends/imgui_impl_win32.cpp',
|
||||
'$ProjectPath$/backends/imgui_impl_dx12.cpp'
|
||||
}
|
||||
.UnityOutputPath = 'Intermediate/$ProjectPath$/'
|
||||
.UnityOutputPattern = '$ProjectName$_Unity*.cpp'
|
||||
.UnityMaxFiles = 1
|
||||
}
|
||||
|
||||
// Library
|
||||
//--------------------------------------------------------------------------
|
||||
ForEach( .BuildConfig in .BuildConfigs )
|
||||
@@ -15,17 +33,8 @@
|
||||
//--------------------------------------------------------------------------
|
||||
ObjectList( '$ProjectName$-Objs-$Platform$-$BuildConfigName$' )
|
||||
{
|
||||
// Core ImGui files
|
||||
.CompilerInputFiles = {
|
||||
'$ProjectPath$/imgui.cpp',
|
||||
'$ProjectPath$/imgui_demo.cpp',
|
||||
'$ProjectPath$/imgui_draw.cpp',
|
||||
'$ProjectPath$/imgui_tables.cpp',
|
||||
'$ProjectPath$/imgui_widgets.cpp',
|
||||
// Backends
|
||||
'$ProjectPath$/backends/imgui_impl_win32.cpp',
|
||||
'$ProjectPath$/backends/imgui_impl_dx12.cpp'
|
||||
}
|
||||
// Input (Unity)
|
||||
.CompilerInputUnity = '$ProjectName$-Unity'
|
||||
|
||||
// Extra Compiler Options
|
||||
.CompilerOptions + ' "-I$ProjectPath$"'
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ Settings
|
||||
]
|
||||
.Profile_Config =
|
||||
[
|
||||
.CompilerOptions = ' -DRELEASE -DPROFILING_ENABLED'
|
||||
.CompilerOptions = ' -DRELEASE -DPROFILING_ENABLED -DJULIET_ENABLE_IMGUI'
|
||||
.CompilerOptionsC = .CompilerOptions
|
||||
.BuildConfigName = 'Profile'
|
||||
]
|
||||
|
||||
+101
-28
@@ -15,6 +15,7 @@ set FBUILD=misc\fbuild.exe
|
||||
set TARGET_JULIET=0
|
||||
set TARGET_ROMEO=0
|
||||
set TARGET_SHADER=0
|
||||
set TARGET_GAME=0
|
||||
set TARGET_COUNT=0
|
||||
|
||||
set CONFIG_DEBUG=0
|
||||
@@ -53,6 +54,13 @@ if /i "%~1"=="juliet" (
|
||||
goto parse_args
|
||||
)
|
||||
|
||||
if /i "%~1"=="game" (
|
||||
set TARGET_GAME=1
|
||||
set /a TARGET_COUNT+=1
|
||||
shift
|
||||
goto parse_args
|
||||
)
|
||||
|
||||
if /i "%~1"=="romeo" (
|
||||
set TARGET_ROMEO=1
|
||||
set /a TARGET_COUNT+=1
|
||||
@@ -72,29 +80,34 @@ goto parse_args
|
||||
|
||||
:check_defaults
|
||||
:: If no arguments passed ("build"), build ALL targets across ALL configurations (Debug, Profile, Release)
|
||||
if %CONFIG_COUNT% equ 0 if %TARGET_COUNT% equ 0 (
|
||||
if !CONFIG_COUNT! equ 0 if !TARGET_COUNT! 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
|
||||
)
|
||||
|
||||
:: If targets specified but no configs specified, default to Debug
|
||||
if %CONFIG_COUNT% equ 0 (
|
||||
if !CONFIG_COUNT! equ 0 (
|
||||
set CONFIG_DEBUG=1
|
||||
)
|
||||
|
||||
:: If configs specified but no targets specified, build all targets for those configs
|
||||
if %TARGET_COUNT% equ 0 (
|
||||
if !TARGET_COUNT! equ 0 (
|
||||
set TARGET_JULIET=1
|
||||
set TARGET_GAME=1
|
||||
set TARGET_ROMEO=1
|
||||
set TARGET_SHADER=1
|
||||
)
|
||||
|
||||
:start_build
|
||||
set START_TIME=%TIME%
|
||||
powershell -Command "$global:startTime = [System.Diagnostics.Stopwatch]::StartNew(); Set-Variable -Name GLOBAL_START_TIME -Value $global:startTime -Scope Global" >nul 2>&1
|
||||
|
||||
if not exist "%FBUILD%" (
|
||||
echo.
|
||||
echo [BUILD FAILED] Could not find %FBUILD%.
|
||||
@@ -108,17 +121,36 @@ if %ERRORLEVEL% neq 0 (
|
||||
set COMPILER=cl.exe
|
||||
)
|
||||
|
||||
if %CONFIG_DEBUG% equ 1 call :build_config Debug
|
||||
:: Store start timestamp in PowerShell variable for exact timing across batch routines
|
||||
powershell -Command "[System.IO.File]::WriteAllText('Intermediate\build_start.tmp', [System.DateTime]::Now.Ticks.ToString())" >nul 2>&1
|
||||
|
||||
:: Clear temporary built output list file
|
||||
if exist "Intermediate\built_outputs.tmp" del "Intermediate\built_outputs.tmp"
|
||||
|
||||
if !CONFIG_DEBUG! equ 1 call :build_config Debug
|
||||
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
|
||||
|
||||
if %CONFIG_PROFILE% equ 1 call :build_config Profile
|
||||
if !CONFIG_PROFILE! equ 1 call :build_config Profile
|
||||
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
|
||||
|
||||
if %CONFIG_RELEASE% equ 1 call :build_config Release
|
||||
if !CONFIG_RELEASE! equ 1 call :build_config Release
|
||||
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
|
||||
|
||||
:: Calculate build elapsed time using PowerShell
|
||||
for /f "usebackq tokens=*" %%I in (`powershell -Command "$start = [long](Get-Content Intermediate\build_start.tmp); $elapsed = (New-Object System.TimeSpan ([System.DateTime]::Now.Ticks - $start)); Remove-Item Intermediate\build_start.tmp -ErrorAction SilentlyContinue; '{0:D2}:{1:D2}:{2:D2}.{3:D3}' -f $elapsed.Hours, $elapsed.Minutes, $elapsed.Seconds, $elapsed.Milliseconds"` ) do set ELAPSED_TIME=%%I
|
||||
|
||||
echo.
|
||||
echo ==============================================================================
|
||||
echo [BUILD SUMMARY]
|
||||
echo ==============================================================================
|
||||
echo Compiler Used : %COMPILER%
|
||||
echo Total Duration : %ELAPSED_TIME%
|
||||
echo Output Binaries:
|
||||
if exist "Intermediate\built_outputs.tmp" (
|
||||
powershell -Command "Get-Content Intermediate\built_outputs.tmp | Get-Item | ForEach-Object { $size = '{0:N2} MB' -f ($_.Length / 1MB); Write-Host (' - ' + $_.FullName.Replace((Get-Location).Path + '\', '') + ' (' + $size + ')') }"
|
||||
del "Intermediate\built_outputs.tmp" >nul 2>&1
|
||||
)
|
||||
echo ==============================================================================
|
||||
echo [ALL BUILDS SUCCEEDED] All requested executables built successfully.
|
||||
echo ==============================================================================
|
||||
exit /b 0
|
||||
@@ -135,9 +167,11 @@ echo Generating Unity Files into Intermediate/ via FASTBuild [%CFG%]...
|
||||
echo ==============================================================================
|
||||
|
||||
set FASTBUILD_TARGETS=Juliet-Unity
|
||||
if %TARGET_JULIET% equ 1 set FASTBUILD_TARGETS=!FASTBUILD_TARGETS! JulietApp-Unity 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
|
||||
if /i not "!CFG!"=="Release" set FASTBUILD_TARGETS=!FASTBUILD_TARGETS! ImGui-Unity
|
||||
if !TARGET_JULIET! equ 1 set FASTBUILD_TARGETS=!FASTBUILD_TARGETS! JulietApp-Unity Game-Unity
|
||||
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
|
||||
|
||||
"%FBUILD%" !FASTBUILD_TARGETS!
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
@@ -157,57 +191,96 @@ echo Compiling Unity Files directly via %COMPILER% [%CFG%]...
|
||||
echo ==============================================================================
|
||||
|
||||
if not exist "bin\x64-!CFG!" mkdir "bin\x64-!CFG!"
|
||||
if not exist "Intermediate\x64-!CFG!" mkdir "Intermediate\x64-!CFG!"
|
||||
|
||||
set COMMON_FLAGS=/nologo /std:c++20 /W4 /EHa- /utf-8 /DUNICODE /D_UNICODE /DWIN32_LEAN_AND_MEAN /D_CRT_SECURE_NO_WARNINGS /I"Juliet/include" /I"Juliet/src" /I"Game" /I"External/imgui" /I"External/imgui/backends" /DJULIET_WIN32 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 /wd4626 /wd5026 /wd5027 /wd4530
|
||||
set COMMON_FLAGS=/nologo /std:c++20 /W4 /EHa- /utf-8 /DUNICODE /D_UNICODE /DWIN32_LEAN_AND_MEAN /D_CRT_SECURE_NO_WARNINGS /I"Juliet/include" /I"Juliet/src" /I"Game" /I"External/imgui" /I"External/imgui/backends" /DJULIET_WIN32 /wd5267 /wd4061 /wd4505 /wd4514 /wd4577 /wd4625 /wd4710 /wd4711 /wd4746 /wd4820 /wd5045 /wd5220 /wd5245 /wd4626 /wd5026 /wd5027 /wd4530 /Fd"Intermediate\x64-!CFG!\vc140.pdb"
|
||||
|
||||
if /i "!CFG!"=="Debug" (
|
||||
set COMPILER_FLAGS=!COMMON_FLAGS! /MDd /Od /Zi /DDEBUG /DPROFILING_ENABLED /DJULIET_ENABLE_IMGUI /DJULIET_DEBUG
|
||||
set COMPILER_FLAGS=!COMMON_FLAGS! /MDd /Od /Zi /Gw /Gy /Zc:inline /DDEBUG /DPROFILING_ENABLED /DJULIET_ENABLE_IMGUI /DJULIET_DEBUG
|
||||
set IMGUI_UNITY_SRCS=Intermediate\External\imgui\*.cpp
|
||||
) else if /i "!CFG!"=="Profile" (
|
||||
set COMPILER_FLAGS=!COMMON_FLAGS! /MD /O2 /Zi /DRELEASE /DPROFILING_ENABLED
|
||||
set COMPILER_FLAGS=!COMMON_FLAGS! /MD /O2 /Zi /Gw /Gy /Zc:inline /DRELEASE /DPROFILING_ENABLED /DJULIET_ENABLE_IMGUI
|
||||
set IMGUI_UNITY_SRCS=Intermediate\External\imgui\*.cpp
|
||||
) else (
|
||||
set COMPILER_FLAGS=!COMMON_FLAGS! /MD /O2 /DRELEASE
|
||||
set COMPILER_FLAGS=!COMMON_FLAGS! /MD /O2 /Gw /Gy /Zc:inline /DRELEASE
|
||||
set IMGUI_UNITY_SRCS=
|
||||
)
|
||||
|
||||
set COMMON_LIBS=kernel32.lib user32.lib gdi32.lib dxguid.lib Ws2_32.lib dxgi.lib imm32.lib dwmapi.lib d3dcompiler.lib shell32.lib winhttp.lib
|
||||
set IMGUI_SRCS=External\imgui\imgui.cpp External\imgui\imgui_demo.cpp External\imgui\imgui_draw.cpp External\imgui\imgui_tables.cpp External\imgui\imgui_widgets.cpp External\imgui\backends\imgui_impl_win32.cpp External\imgui\backends\imgui_impl_dx12.cpp
|
||||
set COMMON_LIBS=kernel32.lib user32.lib gdi32.lib dxguid.lib Ws2_32.lib dxgi.lib imm32.lib dwmapi.lib d3dcompiler.lib shell32.lib winhttp.lib delayimp.lib
|
||||
|
||||
:: Compile shared Juliet (and ImGui) Object Files into Intermediate\x64-!CFG!\
|
||||
echo.
|
||||
echo --- Compiling Shared Object Files (Juliet / ImGui) [%CFG%] ---
|
||||
%COMPILER% %COMPILER_FLAGS% /DJULIET_EXPORT /c Intermediate\Juliet\*.cpp /Fo"Intermediate\x64-!CFG!\\"
|
||||
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
|
||||
|
||||
if defined IMGUI_UNITY_SRCS (
|
||||
%COMPILER% %COMPILER_FLAGS% /c !IMGUI_UNITY_SRCS! /Fo"Intermediate\x64-!CFG!\\"
|
||||
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
|
||||
)
|
||||
|
||||
set JULIET_OBJS=Intermediate\x64-!CFG!\Juliet_Unity*.obj
|
||||
set IMGUI_OBJS=
|
||||
if defined IMGUI_UNITY_SRCS (
|
||||
set IMGUI_OBJS=Intermediate\x64-!CFG!\ImGui_Unity*.obj
|
||||
)
|
||||
|
||||
set BUILD_GAME_DLL=0
|
||||
if !TARGET_JULIET! equ 1 set BUILD_GAME_DLL=1
|
||||
if !TARGET_GAME! equ 1 set BUILD_GAME_DLL=1
|
||||
|
||||
:: Compile Game.dll
|
||||
if !BUILD_GAME_DLL! equ 1 (
|
||||
echo.
|
||||
echo --- Building Game.dll [%CFG%] ---
|
||||
%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
|
||||
)
|
||||
|
||||
:: Compile JulietApp Executable
|
||||
if %TARGET_JULIET% equ 1 (
|
||||
if !TARGET_JULIET! equ 1 (
|
||||
echo.
|
||||
echo --- Building JulietApp.exe [%CFG%] ---
|
||||
%COMPILER% %COMPILER_FLAGS% /Fe"bin\x64-!CFG!\JulietApp.exe" ^
|
||||
Intermediate\Juliet\*.cpp ^
|
||||
Intermediate\JulietApp\*.cpp ^
|
||||
Intermediate\Game\*.cpp ^
|
||||
!IMGUI_SRCS! ^
|
||||
/link %COMMON_LIBS% /SUBSYSTEM:CONSOLE
|
||||
%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
|
||||
)
|
||||
|
||||
:: Compile Romeo Executable
|
||||
if %TARGET_ROMEO% equ 1 (
|
||||
if !TARGET_ROMEO! equ 1 (
|
||||
echo.
|
||||
echo --- Building Romeo.exe [%CFG%] ---
|
||||
%COMPILER% %COMPILER_FLAGS% /Fe"bin\x64-!CFG!\Romeo.exe" ^
|
||||
Intermediate\Juliet\*.cpp ^
|
||||
%JULIET_OBJS% ^
|
||||
Intermediate\Romeo\*.cpp ^
|
||||
!IMGUI_SRCS! ^
|
||||
/link %COMMON_LIBS% /SUBSYSTEM:CONSOLE
|
||||
%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
|
||||
)
|
||||
|
||||
:: Compile JulietShaderCompiler Executable
|
||||
if %TARGET_SHADER% equ 1 (
|
||||
if !TARGET_SHADER! equ 1 (
|
||||
echo.
|
||||
echo --- Building JulietShaderCompiler.exe [%CFG%] ---
|
||||
if exist "Intermediate\JulietShaderCompiler\*.cpp" (
|
||||
%COMPILER% %COMPILER_FLAGS% /I"JulietShaderCompiler" /Fe"bin\x64-!CFG!\JulietShaderCompiler.exe" ^
|
||||
Intermediate\Juliet\*.cpp ^
|
||||
%JULIET_OBJS% ^
|
||||
Intermediate\JulietShaderCompiler\*.cpp ^
|
||||
JulietShaderCompiler\DXShaderCompiler\dxcompiler.lib ^
|
||||
/link %COMMON_LIBS% /SUBSYSTEM:CONSOLE
|
||||
%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
|
||||
)
|
||||
)
|
||||
|
||||
exit /b 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user