2018-07-27 22:16:58 +08:00
|
|
|
@echo off
|
2020-04-24 18:21:15 +08:00
|
|
|
setlocal enabledelayedexpansion
|
2018-07-27 22:16:58 +08:00
|
|
|
|
2018-08-24 20:58:46 +08:00
|
|
|
rem BAT script that creates the binaries for Carla (carla.org).
|
|
|
|
rem Run it through a cmd with the x64 Visual C++ Toolset enabled.
|
|
|
|
|
2018-07-27 22:16:58 +08:00
|
|
|
set LOCAL_PATH=%~dp0
|
2020-06-16 21:26:43 +08:00
|
|
|
set FILE_N=-[%~n0]:
|
2018-07-27 22:16:58 +08:00
|
|
|
|
2018-08-29 18:24:30 +08:00
|
|
|
rem Print batch params (debug purpose)
|
|
|
|
echo %FILE_N% [Batch params]: %*
|
|
|
|
|
2018-07-27 22:16:58 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Parse arguments ---------------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
2020-03-05 20:16:18 +08:00
|
|
|
set BUILD_UE4_EDITOR=false
|
2018-07-27 22:16:58 +08:00
|
|
|
set LAUNCH_UE4_EDITOR=false
|
|
|
|
set REMOVE_INTERMEDIATE=false
|
2020-12-04 23:33:41 +08:00
|
|
|
set USE_CARSIM=false
|
2021-01-29 23:57:40 +08:00
|
|
|
set USE_CHRONO=false
|
|
|
|
set CARSIM_STATE="CarSim OFF"
|
|
|
|
set CHRONO_STATE="Chrono OFF"
|
2018-07-27 22:16:58 +08:00
|
|
|
|
|
|
|
:arg-parse
|
2020-03-05 20:16:18 +08:00
|
|
|
echo %1
|
2018-07-27 22:16:58 +08:00
|
|
|
if not "%1"=="" (
|
2020-03-05 20:16:18 +08:00
|
|
|
if "%1"=="--build" (
|
|
|
|
set BUILD_UE4_EDITOR=true
|
|
|
|
)
|
2019-02-06 00:33:09 +08:00
|
|
|
if "%1"=="--launch" (
|
2018-07-27 22:16:58 +08:00
|
|
|
set LAUNCH_UE4_EDITOR=true
|
|
|
|
)
|
|
|
|
if "%1"=="--clean" (
|
|
|
|
set REMOVE_INTERMEDIATE=true
|
|
|
|
)
|
2020-12-04 23:33:41 +08:00
|
|
|
if "%1"=="--carsim" (
|
|
|
|
set USE_CARSIM=true
|
|
|
|
)
|
2021-01-29 23:57:40 +08:00
|
|
|
if "%1"=="--chrono" (
|
|
|
|
set USE_CHRONO=true
|
|
|
|
)
|
2018-07-27 22:16:58 +08:00
|
|
|
if "%1"=="-h" (
|
2019-02-06 00:33:09 +08:00
|
|
|
goto help
|
2018-07-27 22:16:58 +08:00
|
|
|
)
|
|
|
|
if "%1"=="--help" (
|
2019-02-06 00:33:09 +08:00
|
|
|
goto help
|
2018-07-27 22:16:58 +08:00
|
|
|
)
|
|
|
|
shift
|
2019-02-06 00:33:09 +08:00
|
|
|
goto arg-parse
|
2018-07-27 22:16:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
if %REMOVE_INTERMEDIATE% == false (
|
|
|
|
if %LAUNCH_UE4_EDITOR% == false (
|
2020-03-05 20:16:18 +08:00
|
|
|
if %BUILD_UE4_EDITOR% == false (
|
2020-06-16 21:26:43 +08:00
|
|
|
goto help
|
2020-03-05 20:16:18 +08:00
|
|
|
)
|
2018-07-27 22:16:58 +08:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2020-04-29 17:17:54 +08:00
|
|
|
rem Get Unreal Engine root path
|
2020-04-24 18:21:15 +08:00
|
|
|
if not defined UE4_ROOT (
|
2020-04-29 17:17:54 +08:00
|
|
|
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine"
|
2020-04-24 18:21:15 +08:00
|
|
|
set VALUE_NAME=InstalledDirectory
|
2020-04-29 17:17:54 +08:00
|
|
|
for /f "usebackq tokens=1,2,*" %%A in (`reg query !KEY_NAME! /s /reg:64`) do (
|
|
|
|
if "%%A" == "!VALUE_NAME!" (
|
2020-06-17 16:28:45 +08:00
|
|
|
set UE4_ROOT=%%C
|
2020-04-29 17:17:54 +08:00
|
|
|
)
|
|
|
|
)
|
2020-04-24 18:21:15 +08:00
|
|
|
if not defined UE4_ROOT goto error_unreal_no_found
|
|
|
|
)
|
2020-06-17 16:28:45 +08:00
|
|
|
if not "%UE4_ROOT:~-1%"=="\" set UE4_ROOT=%UE4_ROOT%\
|
2020-04-24 18:21:15 +08:00
|
|
|
|
2018-08-24 20:58:46 +08:00
|
|
|
rem Set the visual studio solution directory
|
|
|
|
rem
|
2020-06-16 21:26:43 +08:00
|
|
|
set UE4_PROJECT_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\
|
2019-02-06 00:33:09 +08:00
|
|
|
pushd "%UE4_PROJECT_FOLDER%"
|
2018-07-27 22:16:58 +08:00
|
|
|
|
2018-08-24 20:58:46 +08:00
|
|
|
rem Clear binaries and intermediates generated by the build system
|
|
|
|
rem
|
2018-07-27 22:16:58 +08:00
|
|
|
if %REMOVE_INTERMEDIATE% == true (
|
2019-02-08 21:38:12 +08:00
|
|
|
rem Remove directories
|
2019-02-06 00:33:09 +08:00
|
|
|
for %%G in (
|
2020-06-16 21:26:43 +08:00
|
|
|
"%UE4_PROJECT_FOLDER%Binaries",
|
|
|
|
"%UE4_PROJECT_FOLDER%Build",
|
|
|
|
"%UE4_PROJECT_FOLDER%Saved",
|
|
|
|
"%UE4_PROJECT_FOLDER%Intermediate",
|
|
|
|
"%UE4_PROJECT_FOLDER%Plugins\Carla\Binaries",
|
|
|
|
"%UE4_PROJECT_FOLDER%Plugins\Carla\Intermediate",
|
|
|
|
"%UE4_PROJECT_FOLDER%.vs"
|
2019-02-06 00:33:09 +08:00
|
|
|
) do (
|
|
|
|
if exist %%G (
|
2019-02-08 21:38:12 +08:00
|
|
|
echo %FILE_N% Cleaning %%G
|
2019-02-06 00:33:09 +08:00
|
|
|
rmdir /s/q %%G
|
|
|
|
)
|
|
|
|
)
|
2019-02-08 21:38:12 +08:00
|
|
|
|
|
|
|
rem Remove files
|
|
|
|
for %%G in (
|
2020-06-16 21:26:43 +08:00
|
|
|
"%UE4_PROJECT_FOLDER%CarlaUE4.sln"
|
2019-02-08 21:38:12 +08:00
|
|
|
) do (
|
|
|
|
if exist %%G (
|
|
|
|
echo %FILE_N% Cleaning %%G
|
|
|
|
del %%G
|
|
|
|
)
|
|
|
|
)
|
2018-08-24 16:43:22 +08:00
|
|
|
)
|
|
|
|
|
2020-03-05 20:16:18 +08:00
|
|
|
rem Build Carla Editor
|
|
|
|
rem
|
2021-01-29 23:57:40 +08:00
|
|
|
|
|
|
|
if %USE_CARSIM% == true (
|
|
|
|
py -3 %ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" -e
|
|
|
|
set CARSIM_STATE="CarSim ON"
|
|
|
|
) else (
|
|
|
|
py -3 %ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
|
|
|
|
set CARSIM_STATE="CarSim OFF"
|
|
|
|
)
|
|
|
|
if %USE_CHRONO% == true (
|
|
|
|
set CHRONO_STATE="Chrono ON"
|
|
|
|
) else (
|
|
|
|
set CHRONO_STATE="Chrono OFF"
|
|
|
|
)
|
|
|
|
set OPTIONAL_MODULES_TEXT=%CARSIM_STATE% %CHRONO_STATE%
|
|
|
|
echo %OPTIONAL_MODULES_TEXT% > "%ROOT_PATH%Unreal/CarlaUE4/Config/OptionalModules.ini"
|
|
|
|
|
2020-03-05 20:16:18 +08:00
|
|
|
if %BUILD_UE4_EDITOR% == true (
|
|
|
|
echo %FILE_N% Building Unreal Editor...
|
|
|
|
|
2020-06-16 21:26:43 +08:00
|
|
|
call "%UE4_ROOT%Engine\Build\BatchFiles\Build.bat"^
|
2020-03-05 20:16:18 +08:00
|
|
|
CarlaUE4Editor^
|
|
|
|
Win64^
|
|
|
|
Development^
|
|
|
|
-WaitMutex^
|
|
|
|
-FromMsBuild^
|
|
|
|
"%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
|
|
|
|
if errorlevel 1 goto bad_exit
|
|
|
|
|
2020-06-16 21:26:43 +08:00
|
|
|
call "%UE4_ROOT%Engine\Build\BatchFiles\Build.bat"^
|
2020-03-05 20:16:18 +08:00
|
|
|
CarlaUE4^
|
|
|
|
Win64^
|
|
|
|
Development^
|
|
|
|
-WaitMutex^
|
|
|
|
-FromMsBuild^
|
|
|
|
"%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
|
|
|
|
if errorlevel 1 goto bad_exit
|
|
|
|
)
|
|
|
|
|
2018-08-24 20:58:46 +08:00
|
|
|
rem Launch Carla Editor
|
|
|
|
rem
|
2018-07-27 22:16:58 +08:00
|
|
|
if %LAUNCH_UE4_EDITOR% == true (
|
|
|
|
echo %FILE_N% Launching Unreal Editor...
|
2020-11-24 22:02:22 +08:00
|
|
|
call "%UE4_ROOT%\Engine\Binaries\Win64\UE4Editor.exe"^
|
|
|
|
"%UE4_PROJECT_FOLDER%CarlaUE4.uproject"
|
2019-02-06 00:33:09 +08:00
|
|
|
if %errorlevel% neq 0 goto error_build
|
2018-07-27 22:16:58 +08:00
|
|
|
)
|
|
|
|
|
2018-08-24 00:08:06 +08:00
|
|
|
goto good_exit
|
|
|
|
|
2018-07-31 22:35:02 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Messages and Errors -----------------------------------------------------
|
|
|
|
rem ============================================================================
|
2018-08-24 00:08:06 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
:help
|
|
|
|
echo Build LibCarla.
|
2020-03-05 20:16:18 +08:00
|
|
|
echo "Usage: %FILE_N% [-h^|--help] [--build] [--launch] [--clean]"
|
2019-02-06 00:33:09 +08:00
|
|
|
goto good_exit
|
2018-08-24 00:08:06 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
:error_build
|
2018-08-24 20:58:46 +08:00
|
|
|
echo.
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% [ERROR] There was a problem building CarlaUE4.
|
|
|
|
echo %FILE_N% Please go to "Carla\Unreal\CarlaUE4", right click on
|
|
|
|
echo %FILE_N% "CarlaUE4.uproject" and select:
|
|
|
|
echo %FILE_N% "Generate Visual Studio project files"
|
|
|
|
echo %FILE_N% Open de generated "CarlaUE4.sln" and try to manually compile it
|
|
|
|
echo %FILE_N% and check what is causing the error.
|
2018-08-24 20:58:46 +08:00
|
|
|
goto bad_exit
|
|
|
|
|
2018-08-24 00:08:06 +08:00
|
|
|
:good_exit
|
|
|
|
endlocal
|
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:bad_exit
|
|
|
|
endlocal
|
2018-08-24 20:58:46 +08:00
|
|
|
exit /b %errorlevel%
|
2020-04-24 18:21:15 +08:00
|
|
|
|
|
|
|
:error_unreal_no_found
|
|
|
|
echo.
|
2020-04-29 17:17:54 +08:00
|
|
|
echo %FILE_N% [ERROR] Unreal Engine not detected
|
2020-04-24 18:21:15 +08:00
|
|
|
goto bad_exit
|