From 2616765530deb6d17674c40c9ef96f709b699190 Mon Sep 17 00:00:00 2001 From: iFuSiiOnzZ Date: Fri, 24 Aug 2018 14:58:46 +0200 Subject: [PATCH] Generate Visual Studio solution if not available --- Util/BuildTools/BuildCarlaUE4.bat | 61 +++++++++++++++++++++++++++++-- Util/BuildTools/Windows.mk | 12 +++--- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/Util/BuildTools/BuildCarlaUE4.bat b/Util/BuildTools/BuildCarlaUE4.bat index 08b84a17d..117361125 100644 --- a/Util/BuildTools/BuildCarlaUE4.bat +++ b/Util/BuildTools/BuildCarlaUE4.bat @@ -1,6 +1,9 @@ @echo off setlocal +rem BAT script that creates the binaries for Carla (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + set LOCAL_PATH=%~dp0 set "FILE_N=-[%~n0]:" @@ -18,6 +21,8 @@ set BUILD_CARLAUE4_EDITOR=false set LAUNCH_UE4_EDITOR=false set REMOVE_INTERMEDIATE=false +set UE_VERSION=4.19 + :arg-parse if not "%1"=="" ( if "%1"=="--rebuild" ( @@ -33,6 +38,11 @@ if not "%1"=="" ( set BUILD_CARLAUE4_EDITOR=true ) + if "%1"=="--ue-version" ( + set UE_VERSION=%~2 + shift + ) + if "%1"=="--launch" ( set LAUNCH_UE4_EDITOR=true ) @@ -68,12 +78,21 @@ if %REMOVE_INTERMEDIATE% == false ( ) ) +rem Extract Unreal Engine root path +rem +set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%UE_VERSION%" +set VALUE_NAME=InstalledDirectory + +for /f "usebackq tokens=2*" %%A in (`reg query %KEY_NAME% /v %VALUE_NAME% /reg:64`) do set UE4_ROOT=%%B +if not defined UE4_ROOT goto error_unreal_no_found + rem Set the visual studio solution directory rem - set CARLA_FOLDER=%ROOT_PATH%Unreal\CarlaUE4\ pushd "%CARLA_FOLDER%" +rem Clear binaries and intermediates generated by the build system +rem if %REMOVE_INTERMEDIATE% == true ( echo. @@ -94,8 +113,35 @@ if %REMOVE_INTERMEDIATE% == true ( echo %FILE_N% cleaning "%CARLA_FOLDER%Plugins\Carla\Intermediate" if exist "%CARLA_FOLDER%Plugins\Carla\Intermediate" rmdir /S /Q "%CARLA_FOLDER%Plugins\Carla\Intermediate" + + echo %FILE_N% cleaning "%CARLA_FOLDER%.vs" + if exist "%CARLA_FOLDER%CarlaUE4.sln" rmdir /S /Q "%CARLA_FOLDER%.vs" + + echo %FILE_N% cleaning "%CARLA_FOLDER%CarlaUE4.sln" + if exist "%CARLA_FOLDER%CarlaUE4.sln" del /F /Q "%CARLA_FOLDER%CarlaUE4.sln" 1>nul ) +rem Generate Visual Studio solution +rem +set genVsSolution=false +if %BUILD_CARLAUE4% == true set genVsSolution=true +if %BUILD_CARLAUE4_EDITOR% == true set genVsSolution=true + +if not exist "%CARLA_FOLDER%CarlaUE4.sln" set genVsSolution=true +if %REMOVE_INTERMEDIATE% == true set genVsSolution=false + +if %genVsSolution% == true ( + call "%UE4_ROOT%/Engine/Binaries/DotNET/UnrealBuildTool.exe" -projectfiles^ + -project="%CARLA_FOLDER%CarlaUE4.uproject"^ + -game -rocket -progress + + call "%UE4_ROOT%/Engine/Binaries/Win64/UE4Editor.exe" "%CARLA_FOLDER%CarlaUE4.uproject"^ + -targetplatform=WindowsNoEditor^ + -run=cook +) + +rem Build and launch Carla +rem if %BUILD_CARLAUE4% == true ( echo %FILE_N% Builing and starting Carla... @@ -105,8 +151,10 @@ if %BUILD_CARLAUE4% == true ( start "" "%CARLA_FOLDER%Binaries\Win64\CarlaUE4.exe" ) +rem Build and launch Carla Editor +rem if %BUILD_CARLAUE4_EDITOR% == true ( - echo %FILE_N% Builing and starting Carla... + echo %FILE_N% Builing and starting Carla Editor... call MsBuild.exe "%CARLA_FOLDER%CarlaUE4.sln" /m /p:configuration="Development Editor" /p:platform=Win64 if errorlevel 1 goto error_build @@ -114,6 +162,8 @@ if %BUILD_CARLAUE4_EDITOR% == true ( call "%CARLA_FOLDER%CarlaUE4.uproject" ) +rem Launch Carla Editor +rem if %LAUNCH_UE4_EDITOR% == true ( echo %FILE_N% Launching Unreal Editor... call "%CARLA_FOLDER%CarlaUE4.uproject" @@ -131,10 +181,15 @@ rem ============================================================================ echo %FILE_N% Please read the screen log for more information. goto bad_exit +:error_unreal_no_found + echo. + echo %FILE_N% Unreal Engine %UE_VERSION% not detected + goto bad_exit + :good_exit endlocal exit /b 0 :bad_exit endlocal - exit /b %errorlevel% \ No newline at end of file + exit /b %errorlevel% diff --git a/Util/BuildTools/Windows.mk b/Util/BuildTools/Windows.mk index c867970ba..28e96589b 100644 --- a/Util/BuildTools/Windows.mk +++ b/Util/BuildTools/Windows.mk @@ -12,12 +12,12 @@ help: @type "${CARLA_BUILD_TOOLS_FOLDER}\Linux.mk.help" launch: LibCarla - @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --build + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --build --ue-version 4.19 launch-only: - @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --launch + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --launch --ue-version 4.19 -package: CarlaUE4Editor PythonAPI +package: PythonAPI @${CARLA_BUILD_TOOLS_FOLDER}/Package.bat --ue-version 4.19 docs: @@ -25,14 +25,16 @@ docs: @echo "Documentation index at ./Doxygen/html/index.html" clean: + @${CARLA_BUILD_TOOLS_FOLDER}/Package.bat --clean --ue-version 4.19 @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --clean + @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat --clean @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat --clean rebuild: setup @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat --rebuild @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat --rebuild - @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --rebuild + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --rebuild --ue-version 4.19 check: PythonAPI @echo "Not implemented!" @@ -41,7 +43,7 @@ benchmark: LibCarla @echo "Not implemented!" CarlaUE4Editor: LibCarla - @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --build-editor + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat --build-editor --ue-version 4.19 .PHONY: PythonAPI PythonAPI: LibCarla