2018-07-26 18:41:20 +08:00
|
|
|
@echo off
|
|
|
|
setlocal
|
|
|
|
|
2018-07-31 22:35:02 +08:00
|
|
|
rem BAT script that creates the client and the server of LibCarla (carla.org).
|
|
|
|
rem Run it through a cmd with the x64 Visual C++ Toolset enabled.
|
|
|
|
|
2018-07-26 18:41:20 +08:00
|
|
|
set LOCAL_PATH=%~dp0
|
2020-06-16 21:26:43 +08:00
|
|
|
set FILE_N=-[%~n0]:
|
2018-07-26 18:41:20 +08:00
|
|
|
|
2018-08-29 18:24:30 +08:00
|
|
|
rem Print batch params (debug purpose)
|
|
|
|
echo %FILE_N% [Batch params]: %*
|
|
|
|
|
2018-07-26 18:41:20 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Parse arguments ---------------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
|
|
|
set DOC_STRING=Build LibCarla.
|
2020-06-16 21:26:43 +08:00
|
|
|
set USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--server] [--client] [--clean]
|
2018-07-26 18:41:20 +08:00
|
|
|
|
|
|
|
set REMOVE_INTERMEDIATE=false
|
|
|
|
set BUILD_SERVER=false
|
|
|
|
set BUILD_CLIENT=false
|
|
|
|
|
|
|
|
:arg-parse
|
|
|
|
if not "%1"=="" (
|
|
|
|
if "%1"=="--rebuild" (
|
|
|
|
set REMOVE_INTERMEDIATE=true
|
|
|
|
set BUILD_SERVER=true
|
|
|
|
set BUILD_CLIENT=true
|
|
|
|
)
|
|
|
|
if "%1"=="--server" (
|
|
|
|
set BUILD_SERVER=true
|
|
|
|
)
|
|
|
|
if "%1"=="--client" (
|
|
|
|
set BUILD_CLIENT=true
|
|
|
|
)
|
|
|
|
if "%1"=="--clean" (
|
|
|
|
set REMOVE_INTERMEDIATE=true
|
|
|
|
)
|
2023-09-17 13:00:35 +08:00
|
|
|
if "%1"=="--generator" (
|
|
|
|
set GENERATOR=%2
|
|
|
|
shift
|
|
|
|
)
|
2018-07-26 18:41:20 +08:00
|
|
|
if "%1"=="-h" (
|
|
|
|
echo %DOC_STRING%
|
|
|
|
echo %USAGE_STRING%
|
|
|
|
GOTO :eof
|
|
|
|
)
|
|
|
|
if "%1"=="--help" (
|
|
|
|
echo %DOC_STRING%
|
|
|
|
echo %USAGE_STRING%
|
|
|
|
GOTO :eof
|
|
|
|
)
|
|
|
|
shift
|
|
|
|
goto :arg-parse
|
|
|
|
)
|
|
|
|
|
|
|
|
if %REMOVE_INTERMEDIATE% == false (
|
|
|
|
if %BUILD_SERVER% == false (
|
|
|
|
if %BUILD_CLIENT% == false (
|
|
|
|
echo Nothing selected to be done.
|
|
|
|
goto :eof
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Local Variables ---------------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
2018-07-26 18:41:20 +08:00
|
|
|
rem Set the visual studio solution directory
|
|
|
|
rem
|
2020-06-17 22:41:04 +08:00
|
|
|
set LIBCARLA_VSPROJECT_PATH=%INSTALLATION_DIR:/=\%libcarla-visualstudio\
|
2018-07-27 14:31:12 +08:00
|
|
|
|
2023-09-17 13:00:35 +08:00
|
|
|
if %GENERATOR% == "" set GENERATOR="Visual Studio 16 2019"
|
|
|
|
|
|
|
|
|
2020-06-17 22:41:04 +08:00
|
|
|
set LIBCARLA_SERVER_INSTALL_PATH=%ROOT_PATH:/=\%Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies\
|
|
|
|
set LIBCARLA_CLIENT_INSTALL_PATH=%ROOT_PATH:/=\%PythonAPI\carla\dependencies\
|
2018-07-26 18:41:20 +08:00
|
|
|
|
2018-07-27 14:31:12 +08:00
|
|
|
if %REMOVE_INTERMEDIATE% == true (
|
2019-02-12 19:27:28 +08:00
|
|
|
rem Remove directories
|
|
|
|
for %%G in (
|
2020-06-16 21:26:43 +08:00
|
|
|
"%LIBCARLA_SERVER_INSTALL_PATH%",
|
|
|
|
"%LIBCARLA_CLIENT_INSTALL_PATH%",
|
2019-02-12 19:27:28 +08:00
|
|
|
) do (
|
|
|
|
if exist %%G (
|
|
|
|
echo %FILE_N% Cleaning %%G
|
|
|
|
rmdir /s/q %%G
|
|
|
|
)
|
|
|
|
)
|
2018-07-31 22:35:02 +08:00
|
|
|
|
2019-02-12 19:27:28 +08:00
|
|
|
rem Remove files
|
|
|
|
for %%G in (
|
|
|
|
"%ROOT_PATH:/=\%LibCarla\source\carla\Version.h"
|
|
|
|
) do (
|
|
|
|
if exist %%G (
|
|
|
|
echo %FILE_N% Cleaning %%G
|
|
|
|
del %%G
|
|
|
|
)
|
|
|
|
)
|
2018-07-27 14:31:12 +08:00
|
|
|
)
|
|
|
|
|
2018-07-27 22:16:58 +08:00
|
|
|
if not exist "%LIBCARLA_VSPROJECT_PATH%" mkdir "%LIBCARLA_VSPROJECT_PATH%"
|
2018-07-30 22:52:29 +08:00
|
|
|
cd "%LIBCARLA_VSPROJECT_PATH%"
|
2018-07-26 18:41:20 +08:00
|
|
|
|
2023-09-17 13:00:35 +08:00
|
|
|
echo.%GENERATOR% | findstr /C:"Visual Studio" >nul && (
|
|
|
|
set PLATFORM=-A x64
|
|
|
|
) || (
|
|
|
|
set PLATFORM=
|
|
|
|
)
|
|
|
|
|
|
|
|
rem For some reason the findstr above sets an errorlevel even if it finds the string in this batch file.
|
|
|
|
set errorlevel=0
|
|
|
|
|
|
|
|
|
2018-07-26 18:41:20 +08:00
|
|
|
rem Build libcarla server
|
|
|
|
rem
|
2018-09-06 18:40:23 +08:00
|
|
|
if %BUILD_SERVER% == true (
|
2023-09-17 13:00:35 +08:00
|
|
|
cmake -G %GENERATOR% %PLATFORM%^
|
2019-02-11 22:29:18 +08:00
|
|
|
-DCMAKE_BUILD_TYPE=Server^
|
|
|
|
-DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^
|
2020-06-16 21:26:43 +08:00
|
|
|
-DCMAKE_INSTALL_PREFIX="%LIBCARLA_SERVER_INSTALL_PATH:\=/%"^
|
|
|
|
"%ROOT_PATH%"
|
2023-09-17 13:00:35 +08:00
|
|
|
|
2018-07-31 22:35:02 +08:00
|
|
|
if %errorlevel% neq 0 goto error_cmake
|
|
|
|
|
2018-09-06 18:40:23 +08:00
|
|
|
cmake --build . --config Release --target install | findstr /V "Up-to-date:"
|
2018-07-31 22:35:02 +08:00
|
|
|
if %errorlevel% neq 0 goto error_install
|
2018-07-26 18:41:20 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
rem Build libcarla client
|
|
|
|
rem
|
2018-09-06 18:40:23 +08:00
|
|
|
if %BUILD_CLIENT% == true (
|
2023-09-17 13:00:35 +08:00
|
|
|
cmake -G %GENERATOR% %PLATFORM%^
|
2019-02-11 22:29:18 +08:00
|
|
|
-DCMAKE_BUILD_TYPE=Client^
|
|
|
|
-DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^
|
2020-06-16 21:26:43 +08:00
|
|
|
-DCMAKE_INSTALL_PREFIX="%LIBCARLA_CLIENT_INSTALL_PATH:\=/%"^
|
|
|
|
"%ROOT_PATH%"
|
2018-07-31 22:35:02 +08:00
|
|
|
if %errorlevel% neq 0 goto error_cmake
|
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
cmake --build . --config Release --target install | findstr /V "Up-to-date:"
|
2018-07-31 22:35:02 +08:00
|
|
|
if %errorlevel% neq 0 goto error_install
|
2018-07-26 18:41:20 +08:00
|
|
|
)
|
2018-07-31 22:35:02 +08:00
|
|
|
|
|
|
|
goto success
|
|
|
|
|
|
|
|
rem ============================================================================
|
|
|
|
rem -- Messages and Errors -----------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
|
|
|
:success
|
2018-08-24 00:27:35 +08:00
|
|
|
if %BUILD_SERVER% == true echo %FILE_N% LibCarla server has been successfully installed in "%LIBCARLA_SERVER_INSTALL_PATH%"!
|
2018-07-31 22:35:02 +08:00
|
|
|
if %BUILD_CLIENT% == true echo %FILE_N% LibCarla client has been successfully installed in "%LIBCARLA_CLIENT_INSTALL_PATH%"!
|
|
|
|
goto good_exit
|
|
|
|
|
|
|
|
:error_cmake
|
|
|
|
echo.
|
2018-08-30 20:18:53 +08:00
|
|
|
echo %FILE_N% [ERROR] An error ocurred while executing the cmake.
|
|
|
|
echo [ERROR] Possible causes:
|
|
|
|
echo [ERROR] - Make sure "CMake" is installed.
|
|
|
|
echo [ERROR] - Make sure it is available on your Windows "path".
|
|
|
|
echo [ERROR] - CMake 3.9.0 or higher is required.
|
2018-07-31 22:35:02 +08:00
|
|
|
goto bad_exit
|
|
|
|
|
|
|
|
:error_install
|
|
|
|
echo.
|
2023-09-17 13:00:35 +08:00
|
|
|
echo %FILE_N% [ERROR] An error ocurred while installing using %GENERATOR% Win64.
|
2018-08-30 20:18:53 +08:00
|
|
|
echo [ERROR] Possible causes:
|
|
|
|
echo [ERROR] - Make sure you have Visual Studio installed.
|
|
|
|
echo [ERROR] - Make sure you have the "x64 Visual C++ Toolset" in your path.
|
|
|
|
echo [ERROR] For example using the "Visual Studio x64 Native Tools Command Prompt",
|
|
|
|
echo [ERROR] or the "vcvarsall.bat".
|
2018-07-31 22:35:02 +08:00
|
|
|
goto bad_exit
|
|
|
|
|
|
|
|
:good_exit
|
|
|
|
endlocal
|
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:bad_exit
|
|
|
|
endlocal
|
|
|
|
exit /b %errorlevel%
|