Last active
August 31, 2022 22:10
-
-
Save AMZN-alexpete/e35815d56597b393e89a5d942ef9ecdf to your computer and use it in GitHub Desktop.
Batch script for building an O3DE project or engine using common settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal ENABLEDELAYEDEXPANSION | |
rem find latest VS version available | |
pushd "c:\Program Files (x86)\Microsoft Visual Studio\Installer" | |
for /f "usebackq tokens=*" %%i in (`call "vswhere.exe" -latest -format value -property catalog_productLineVersion`) do ( | |
set Params=%* | |
for /f "tokens=1*" %%a in ("!%%i!") do EndLocal & set %1=%%b | |
set VSVERSIONYEAR=%%i | |
) | |
for /f "usebackq tokens=*" %%i in (`call "vswhere.exe" -latest -format value -property catalog_productDisplayVersion`) do ( | |
set Params=%* | |
for /f "tokens=1*" %%a in ("!%%i!") do EndLocal & set %1=%%b | |
set VSVERSION=%%i | |
) | |
popd | |
rem trim off excess characters | |
set VSVERSIONYEAR=%VSVERSIONYEAR:~0,4% | |
set VSVERSION=%VSVERSION:~0,2% | |
echo VS version is %VSVERSION% (%VSVERSIONYEAR%) | |
set CMAKE_BUILD_FOLDER=build/windows_vs%VSVERSIONYEAR% | |
set CMAKE_PARAMS=--config profile -- -m | |
set CMAKE_TARGETS=Editor | |
if exist CMakeLists.txt ( | |
if exist engine.json ( | |
set CMAKE_TARGETS=!CMAKE_TARGETS! AutomatedTesting.GameLauncher | |
) else ( | |
for /F "tokens=* USEBACKQ" %%f in (`Powershell -Nop -C "(Get-Content .\project.json|ConvertFrom-Json).project_name"`) do set PROJECT_NAME=%% | |
set CMAKE_TARGETS=!CMAKE_TARGETS! !PROJECT_NAME!.GameLauncher !PROJECT_NAME!.ServerLauncher | |
) | |
set CMD=cmake --build !CMAKE_BUILD_FOLDER! --target !CMAKE_TARGETS! !CMAKE_PARAMS! | |
echo !CMD! | |
powershell -Command "Measure-Command {!CMD! | OUT-Default}" | |
) else if exist wscript ( | |
lmbr_waf build_win_x64_vs2019_profile -p all | |
) else ( | |
echo No CMakeLists.txt found, run this command in an engine or project folder | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment