diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f9fd58..c7e9d15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## DReyeVR 0.1.2 (for Carla 0.9.13) +- Update documentation to refer to CarlaUnreal UE4 fork rather than HarpLab fork +- Apply patches for installation of zlib (broken link) and xerces (broken link & `-Dtranscoder=windows` flag) and PythonAPI +- Fix crash on BeginPlay when EgoVehicle blueprint is already present in map (before world start) +- Prefer building PythonAPI with `python` rather than Windows built-in `py -3` (good if using conda) but fallback if `python` is not available + ## DReyeVR 0.1.1 (for Carla 0.9.13) - Update documentation, add developer-centric in-depth documentation - Adding missing includes for TrafficSign RoadInfoSignal in SignComponent @@ -20,4 +26,4 @@ - Improved vehicle dash with blinking turn signal and fixed bugs with inconsistent gear indicator. - Fixed bugs and inconsistencies with replayer media control and special actions such as toggling reverse/turn signals in replay. - Enabled cooking for `Town06` and `Town07` in package/shipping mode. -- Updated documentation and config file \ No newline at end of file +- Updated documentation and config file diff --git a/DReyeVR/EgoVehicle.cpp b/DReyeVR/EgoVehicle.cpp index 35cf499..3cf2b83 100644 --- a/DReyeVR/EgoVehicle.cpp +++ b/DReyeVR/EgoVehicle.cpp @@ -347,7 +347,7 @@ FVector AEgoVehicle::GetCameraOffset() const } FVector AEgoVehicle::GetCameraPosn() const { - return GetCamera()->GetComponentLocation(); + return GetCamera() ? GetCamera()->GetComponentLocation() : FVector::ZeroVector; } FVector AEgoVehicle::GetNextCameraPosn(const float DeltaSeconds) const { @@ -356,7 +356,7 @@ FVector AEgoVehicle::GetNextCameraPosn(const float DeltaSeconds) const } FRotator AEgoVehicle::GetCameraRot() const { - return GetCamera()->GetComponentRotation(); + return GetCamera() ? GetCamera()->GetComponentRotation() : FRotator::ZeroRotator; } const class AEgoSensor *AEgoVehicle::GetSensor() const { diff --git a/Docs/Install.md b/Docs/Install.md index 5ff04a9..d3ee8c6 100644 --- a/Docs/Install.md +++ b/Docs/Install.md @@ -291,18 +291,7 @@ make check CARLA=../carla ```bat conda activate carla13 ``` - 2. When trying to `make PythonAPI` you'll need to apply [this fix](https://github.com/carla-simulator/carla/issues/2881#issuecomment-699452386) (Replace `py` with `python` in `BuildPythonAPI.bat`) - ```bat - ... - rem previously called "py -3 setup.py ..." --> replace with just "python setup.py ..." - if %BUILD_FOR_PYTHON3%==true ( - echo Building Python API for Python 3. - python setup.py bdist_egg bdist_wheel - if %errorlevel% neq 0 goto error_build_wheel - ) - ``` - - This is because Carla (by default) installs the PythonAPI to the native Python client that comes pre-installed with every Windows machine. This goes 100% against compartmentalizing python environments so we have to patch this file to proceed. - 3. Add carla to "path" to locate the PythonAPI and ScenarioRunner. But since Anaconda [does not use the traditional `PYTHONPATH`](https://stackoverflow.com/questions/37006114/anaconda-permanently-include-external-packages-like-in-pythonpath) you'll need to: + 2. Add carla to "path" to locate the PythonAPI and ScenarioRunner. But since Anaconda [does not use the traditional `PYTHONPATH`](https://stackoverflow.com/questions/37006114/anaconda-permanently-include-external-packages-like-in-pythonpath) you'll need to: - 3.1. Create a file `carla.pth` in `\PATH\TO\ANACONDA\envs\carla\Lib\site-packages\` - 3.2. Insert the following content into `carla.pth`: ```bat @@ -313,22 +302,22 @@ make check CARLA=../carla C:\PATH\TO\CARLA\PythonAPI\examples C:\PATH\TO\SCENARIO_RUNNER\ ``` - 4. Install the specific carla wheel (`whl`) to Anaconda + 3. Install the specific carla wheel (`whl`) to Anaconda ```bash - conda activate carla + conda activate carla13 pip install --no-deps --force-reinstall PATH\TO\CARLA\PythonAPI\carla\dist\carla-0.9.13-cp37-cp37m-win_amd64.whl # if applicable (and you installed Scenario runner) cd %SCENARIO_RUNNER_ROOT% pip install -r requirements.txt # install all SR dependencies ``` - 5. Finally, there are some problems with `shapely` (SR dependency) and Conda. Luckily the solution is simple: + 4. Finally, you might run into problems with `shapely` (scenario-runner dependency) and Conda. Luckily the solution is simple: - Copy the files: - `PATH\TO\ANACONDA\envs\carla13\Lib\site-packages\shapely\DLLs\geos.dll` - `PATH\TO\ANACONDA\envs\carla13\Lib\site-packages\shapely\DLLs\geos_c.dll` - To destination: - `PATH\TO\ANACONDA\envs\carla13\Library\bin\` - 6. Now finally, you should be able to verify all PythonAPI actions work as expected via: + 5. Now finally, you should be able to verify all PythonAPI actions work as expected via: ```bat conda activate carla13 python diff --git a/Scripts/Paths/DReyeVR.csv b/Scripts/Paths/DReyeVR.csv index e928b88..b3214cf 100644 --- a/Scripts/Paths/DReyeVR.csv +++ b/Scripts/Paths/DReyeVR.csv @@ -9,6 +9,6 @@ Content,Unreal/CarlaUE4/ LibCarla,/ PythonAPI,/ Carla,Unreal/CarlaUE4/Plugins/Carla/Source/ -Tools/BuildTools/*.sh,Util/BuildTools/ +Util,/ Scripts/Other/.gitignore,/ Shaders/*.uasset,Unreal/CarlaUE4/Plugins/Carla/Content/PostProcessingMaterials/ diff --git a/Tools/BuildTools/BuildOSM2ODR.sh b/Util/BuildTools/BuildOSM2ODR.sh similarity index 100% rename from Tools/BuildTools/BuildOSM2ODR.sh rename to Util/BuildTools/BuildOSM2ODR.sh diff --git a/Util/BuildTools/BuildPythonAPI.bat b/Util/BuildTools/BuildPythonAPI.bat new file mode 100644 index 0000000..4375aa4 --- /dev/null +++ b/Util/BuildTools/BuildPythonAPI.bat @@ -0,0 +1,165 @@ +@echo off +setlocal + +rem BAT script that creates the client python api of LibCarla (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set LOCAL_PATH=%~dp0 +set FILE_N=-[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set DOC_STRING=Build and package CARLA Python API. +set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--clean]" + +set REMOVE_INTERMEDIATE=false +set BUILD_FOR_PYTHON2=false +set BUILD_FOR_PYTHON3=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="--rebuild" ( + set REMOVE_INTERMEDIATE=true + rem We don't provide support for py2 right now + set BUILD_FOR_PYTHON2=false + set BUILD_FOR_PYTHON3=true + ) + + if "%1"=="--py2" ( + set BUILD_FOR_PYTHON2=true + ) + + if "%1"=="--py3" ( + set BUILD_FOR_PYTHON3=true + ) + + + if "%1"=="--clean" ( + set REMOVE_INTERMEDIATE=true + ) + + 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 +) + +set PYTHON_LIB_PATH=%ROOT_PATH:/=\%PythonAPI\carla\ + +if %REMOVE_INTERMEDIATE% == false ( + if %BUILD_FOR_PYTHON3% == false ( + if %BUILD_FOR_PYTHON2% == false ( + echo Nothing selected to be done. + goto :eof + ) + ) +) + +if %REMOVE_INTERMEDIATE% == true ( + rem Remove directories + for %%G in ( + "%PYTHON_LIB_PATH%build", + "%PYTHON_LIB_PATH%dist", + "%PYTHON_LIB_PATH%source\carla.egg-info" + ) do ( + if exist %%G ( + echo %FILE_N% Cleaning %%G + rmdir /s/q %%G + ) + ) + if %BUILD_FOR_PYTHON3% == false ( + if %BUILD_FOR_PYTHON2% == false ( + goto good_exit + ) + ) +) + +cd "%PYTHON_LIB_PATH%" +rem if exist "%PYTHON_LIB_PATH%dist" goto already_installed + +rem ============================================================================ +rem -- Check for py ------------------------------------------------------------ +rem ============================================================================ + +rem prefer invoking 'python' (for externally installed, eg conda) over 'py' (built in to Windows) +rem +set PYTHON_EXEC=python + +where %PYTHON_EXEC%>nul +if %errorlevel% neq 0 set PYTHON_EXEC=py -3 + +where %PYTHON_EXEC%>nul +if %errorlevel% neq 0 goto error_py + +rem Build for Python 2 +rem +if %BUILD_FOR_PYTHON2%==true ( + goto py2_not_supported +) + +rem Build for Python 3 +rem +if %BUILD_FOR_PYTHON3%==true ( + echo Building Python API for Python 3. + %PYTHON_EXEC% setup.py bdist_egg bdist_wheel + if %errorlevel% neq 0 goto error_build_wheel +) + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo. + if %BUILD_FOR_PYTHON3%==true echo %FILE_N% Carla lib for python has been successfully installed in "%PYTHON_LIB_PATH%dist"! + goto good_exit + +:already_installed + echo. + echo %FILE_N% [ERROR] Already installed in "%PYTHON_LIB_PATH%dist" + goto good_exit + +:py2_not_supported + echo. + echo %FILE_N% [ERROR] Python 2 is not currently suported in Windows. + goto bad_exit + +:error_py + echo. + echo %FILE_N% [ERROR] An error ocurred while executing the py. + echo %FILE_N% [ERROR] Possible causes: + echo %FILE_N% [ERROR] - Make sure "py" is installed. + echo %FILE_N% [ERROR] - py = python launcher. This utility is bundled with Python installation but not installed by default. + echo %FILE_N% [ERROR] - Make sure it is available on your Windows "py". + goto bad_exit + +:error_build_wheel + echo. + echo %FILE_N% [ERROR] An error occurred while building the wheel file. + goto bad_exit + +:good_exit + endlocal + exit /b 0 + +:bad_exit + endlocal + exit /b %errorlevel% + diff --git a/Tools/BuildTools/BuildPythonAPI.sh b/Util/BuildTools/BuildPythonAPI.sh similarity index 100% rename from Tools/BuildTools/BuildPythonAPI.sh rename to Util/BuildTools/BuildPythonAPI.sh diff --git a/Util/BuildTools/Setup.bat b/Util/BuildTools/Setup.bat new file mode 100644 index 0000000..cc19758 --- /dev/null +++ b/Util/BuildTools/Setup.bat @@ -0,0 +1,377 @@ +@echo off +setlocal + +rem BAT script that downloads and generates +rem rpclib, gtest and boost libraries 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]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Check for compiler ------------------------------------------------------ +rem ============================================================================ + +where cl 1>nul +if %errorlevel% neq 0 goto error_cl + +rem TODO: check for x64 and not x86 or x64_x86 + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +set BOOST_VERSION=1.72.0 +set INSTALLERS_DIR=%ROOT_PATH:/=\%Util\InstallersWin\ +set VERSION_FILE=%ROOT_PATH:/=\%Util\ContentVersions.txt +set CONTENT_DIR=%ROOT_PATH:/=\%Unreal\CarlaUE4\Content\Carla\ +set CARLA_DEPENDENCIES_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies\ +set CARLA_BINARIES_FOLDER=%ROOT_PATH:/=\%Unreal\CarlaUE4\Plugins\Carla\Binaries\Win64 +set CARLA_PYTHON_DEPENDENCIES=%ROOT_PATH:/=\%PythonAPI\carla\dependencies\ +set USE_CHRONO=false + +:arg-parse +if not "%1"=="" ( + if "%1"=="-j" ( + set NUMBER_OF_ASYNC_JOBS=%2 + ) + if "%1"=="--boost-toolset" ( + set TOOLSET=%2 + ) + if "%1"=="--chrono" ( + set USE_CHRONO=true + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not defined, use Visual Studio 2019 as tool set +if "%TOOLSET%" == "" set TOOLSET=msvc-14.2 + +rem If is not set, set the number of parallel jobs to the number of CPU threads +if "%NUMBER_OF_ASYNC_JOBS%" == "" set NUMBER_OF_ASYNC_JOBS=%NUMBER_OF_PROCESSORS% + +rem ============================================================================ +rem -- Basic info and setup ---------------------------------------------------- +rem ============================================================================ + +set INSTALLATION_DIR=%INSTALLATION_DIR:/=\% + +echo %FILE_N% Asynchronous jobs: %NUMBER_OF_ASYNC_JOBS% +echo %FILE_N% Boost toolset: %TOOLSET% +echo %FILE_N% Install directory: "%INSTALLATION_DIR%" + +if not exist "%CONTENT_DIR%" ( + echo %FILE_N% Creating "%CONTENT_DIR%" folder... + mkdir "%CONTENT_DIR%" +) + +if not exist "%INSTALLATION_DIR%" ( + echo %FILE_N% Creating "%INSTALLATION_DIR%" folder... + mkdir "%INSTALLATION_DIR%" +) + +rem ============================================================================ +rem -- Download and install zlib ----------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing zlib... +call "%INSTALLERS_DIR%install_zlib.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_zlib ( + echo %FILE_N% Failed while installing zlib. + goto failed +) else ( + set ZLIB_INSTALL_DIR=%install_zlib% +) + +rem ============================================================================ +rem -- Download and install libpng --------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing libpng... +call "%INSTALLERS_DIR%install_libpng.bat"^ + --build-dir "%INSTALLATION_DIR%"^ + --zlib-install-dir "%ZLIB_INSTALL_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_libpng ( + echo %FILE_N% Failed while installing libpng. + goto failed +) else ( + set LIBPNG_INSTALL_DIR=%install_libpng% +) + +rem ============================================================================ +rem -- Download and install rpclib --------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing rpclib... +call "%INSTALLERS_DIR%install_rpclib.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_rpclib ( + echo %FILE_N% Failed while installing rpclib. + goto failed +) + +rem ============================================================================ +rem -- Download and install Google Test ---------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Google Test... +call "%INSTALLERS_DIR%install_gtest.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_gtest ( + + echo %FILE_N% Failed while installing Google Test. + goto failed +) + +rem ============================================================================ +rem -- Download and install Recast & Detour ------------------------------------ +rem ============================================================================ + +echo %FILE_N% Installing "Recast & Detour"... +call "%INSTALLERS_DIR%install_recast.bat"^ + --build-dir "%INSTALLATION_DIR%" + +if %errorlevel% neq 0 goto failed + +if not defined install_recast ( + + echo %FILE_N% Failed while installing "Recast & Detour". + goto failed +) else ( + set RECAST_INSTALL_DIR=%install_recast:\=/% +) + +rem ============================================================================ +rem -- Download and install Boost ---------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Boost... +call "%INSTALLERS_DIR%install_boost.bat"^ + --build-dir "%INSTALLATION_DIR%"^ + --toolset %TOOLSET%^ + --version %BOOST_VERSION%^ + -j %NUMBER_OF_ASYNC_JOBS% + +if %errorlevel% neq 0 goto failed + +if not defined install_boost ( + echo %FILE_N% Failed while installing Boost. + goto failed +) + +copy /Y "%INSTALLATION_DIR%..\Util\BoostFiles\rational.hpp" "%INSTALLATION_DIR%boost-%BOOST_VERSION%-install\include\boost\rational.hpp" +copy /Y "%INSTALLATION_DIR%..\Util\BoostFiles\read.hpp" "%INSTALLATION_DIR%boost-%BOOST_VERSION%-install\include\boost\geometry\io\wkt\read.hpp" + +if not exist "%CARLA_PYTHON_DEPENDENCIES%" ( + mkdir "%CARLA_PYTHON_DEPENDENCIES%"\lib +) +rem ============================================================================ +rem -- Download and install Xercesc -------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Xercesc... +call "%INSTALLERS_DIR%install_xercesc.bat"^ + --build-dir "%INSTALLATION_DIR%" +copy %INSTALLATION_DIR%\xerces-c-3.2.3-install\lib\xerces-c_3.lib %CARLA_PYTHON_DEPENDENCIES%\lib + +rem ============================================================================ +rem -- Download and install Sqlite3 -------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing Sqlite3 +call "%INSTALLERS_DIR%install_sqlite3.bat"^ + --build-dir "%INSTALLATION_DIR%" +copy %INSTALLATION_DIR%\sqlite3-install\lib\sqlite3.lib %CARLA_PYTHON_DEPENDENCIES%\lib + +rem ============================================================================ +rem -- Download and install PROJ -------------------------------------------- +rem ============================================================================ + +echo %FILE_N% Installing PROJ +call "%INSTALLERS_DIR%install_proj.bat"^ + --build-dir "%INSTALLATION_DIR%" +copy %INSTALLATION_DIR%\proj-install\lib\proj.lib %CARLA_PYTHON_DEPENDENCIES%\lib + +rem ============================================================================ +rem -- Download and install Chrono ---------------------------------------------- +rem ============================================================================ + +if %USE_CHRONO% == true ( + echo %FILE_N% Installing Chrono... + call "%INSTALLERS_DIR%install_chrono.bat"^ + --build-dir "%INSTALLATION_DIR%" + + if not exist "%CARLA_DEPENDENCIES_FOLDER%" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%" + ) + if not exist "%CARLA_DEPENDENCIES_FOLDER%include" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%include" + ) + if not exist "%CARLA_DEPENDENCIES_FOLDER%lib" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%lib" + ) + if not exist "%CARLA_DEPENDENCIES_FOLDER%dll" ( + mkdir "%CARLA_DEPENDENCIES_FOLDER%dll" + ) + echo "%INSTALLATION_DIR%chrono-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL + xcopy /Y /S /I "%INSTALLATION_DIR%chrono-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL + copy "%INSTALLATION_DIR%chrono-install\lib\*.lib" "%CARLA_DEPENDENCIES_FOLDER%lib\*.lib" > NUL + copy "%INSTALLATION_DIR%chrono-install\bin\*.dll" "%CARLA_DEPENDENCIES_FOLDER%dll\*.dll" > NUL + xcopy /Y /S /I "%INSTALLATION_DIR%eigen-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*" > NUL +) + +rem ============================================================================ +rem -- Assets download URL ----------------------------------------------------- +rem ============================================================================ + +FOR /F "usebackq tokens=1,2" %%i in ("%VERSION_FILE%") do ( + set ASSETS_VERSION=%%i + set HASH=%%j +) +set URL=http://carla-assets.s3.amazonaws.com/%HASH%.tar.gz + +rem ============================================================================ +rem -- Generate CMake ---------------------------------------------------------- +rem ============================================================================ + +for /f %%i in ('git describe --tags --dirty --always') do set carla_version=%%i +set CMAKE_INSTALLATION_DIR=%INSTALLATION_DIR:\=/% + +echo %FILE_N% Creating "CMakeLists.txt.in"... + +set CMAKE_CONFIG_FILE=%INSTALLATION_DIR%CMakeLists.txt.in + + >"%CMAKE_CONFIG_FILE%" echo # Automatically generated by Setup.bat +>>"%CMAKE_CONFIG_FILE%" echo set(CARLA_VERSION %carla_version%) +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo set(CMAKE_CXX_STANDARD 14) +>>"%CMAKE_CONFIG_FILE%" echo set(CMAKE_CXX_STANDARD_REQUIRED ON) +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-D_WIN32_WINNT=0x0600) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DHAVE_SNPRINTF) +>>"%CMAKE_CONFIG_FILE%" echo STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DLIBCARLA_IMAGE_WITH_PNG_SUPPORT) +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo set(BOOST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%boost-%BOOST_VERSION%-install/include") +>>"%CMAKE_CONFIG_FILE%" echo set(BOOST_LIB_PATH "%CMAKE_INSTALLATION_DIR%boost-%BOOST_VERSION%-install/lib") +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo set(RPCLIB_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/include") +>>"%CMAKE_CONFIG_FILE%" echo set(RPCLIB_LIB_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/lib") +>>"%CMAKE_CONFIG_FILE%" echo. +>>"%CMAKE_CONFIG_FILE%" echo if (CMAKE_BUILD_TYPE STREQUAL "Server") +>>"%CMAKE_CONFIG_FILE%" echo # Prevent exceptions +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY) +>>"%CMAKE_CONFIG_FILE%" echo add_compile_options(/EHsc) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DASIO_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DBOOST_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DLIBCARLA_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo add_definitions(-DPUGIXML_NO_EXCEPTIONS) +>>"%CMAKE_CONFIG_FILE%" echo # Specific libraries for server +>>"%CMAKE_CONFIG_FILE%" echo set(GTEST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/include") +>>"%CMAKE_CONFIG_FILE%" echo set(GTEST_LIB_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/lib") +>>"%CMAKE_CONFIG_FILE%" echo elseif (CMAKE_BUILD_TYPE STREQUAL "Client") +>>"%CMAKE_CONFIG_FILE%" echo # Specific libraries for client +>>"%CMAKE_CONFIG_FILE%" echo set(ZLIB_INCLUDE_PATH "%ZLIB_INSTALL_DIR:\=/%/include") +>>"%CMAKE_CONFIG_FILE%" echo set(ZLIB_LIB_PATH "%ZLIB_INSTALL_DIR:\=/%/lib") +>>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_INCLUDE_PATH "%LIBPNG_INSTALL_DIR:\=/%/include") +>>"%CMAKE_CONFIG_FILE%" echo set(LIBPNG_LIB_PATH "%LIBPNG_INSTALL_DIR:\=/%/lib") +>>"%CMAKE_CONFIG_FILE%" echo set(RECAST_INCLUDE_PATH "%RECAST_INSTALL_DIR:\=/%/include") +>>"%CMAKE_CONFIG_FILE%" echo set(RECAST_LIB_PATH "%RECAST_INSTALL_DIR:\=/%/lib") +>>"%CMAKE_CONFIG_FILE%" echo endif () + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:success + echo %FILE_N% + echo ########### + echo # SUCCESS # + echo ########### + echo. + echo IMPORTANT! + echo. + echo All the CARLA library dependences should be installed now. + echo (You can remove all "*-src" folders in %INSTALLATION_DIR% directory) + echo. + echo You only need the ASSET PACK with all the meshes and textures. + echo. + echo This script provides the assets for CARLA %ASSETS_VERSION% + echo You can download the assets from here: + echo. + echo %URL% + echo. + echo Unzip it in the "%CONTENT_DIR%" folder. + echo If you want another version, search it in %VERSION_FILE%. + echo. + goto good_exit + +:help + echo Download and compiles all the necessary libraries to build CARLA. + echo. + echo Commands: + echo -h, --help -^> Shows this dialog. + echo -j ^ -^> N is the integer number of async jobs while compiling (default=1). + echo --boost-toolset [T] -^> Toolset corresponding to your compiler ^(default=^*^): + echo Visual Studio 2013 -^> msvc-12.0 + echo Visual Studio 2015 -^> msvc-14.0 + echo Visual Studio 2017 -^> msvc-14.1 + echo Visual Studio 2019 -^> msvc-14.2 * + goto good_exit + +:error_cl + echo. + echo %FILE_N% [ERROR] Can't find Visual Studio compiler (cl.exe). + echo [ERROR] Possible causes: + echo [ERROR] - Make sure you use x64 (not x64_x86!) + echo [ERROR] - You are not using "Visual Studio x64 Native Tools Command Prompt". + goto failed + +:failed + echo. + echo %FILE_N% + echo Ok, and error ocurred, don't panic! + echo We have different platforms where you can find some help :) + echo. + echo - Make sure you have read the documentation: + echo http://carla.readthedocs.io/en/latest/how_to_build_on_windows/ + echo. + echo - If the problem persists, you can ask on our Github's "Building on Windows" issue: + echo https://github.com/carla-simulator/carla/issues/21 + echo. + echo - Or just use our Discord channel! + echo We'll be glad to help you there :) + echo https://discord.gg/42KJdRj + endlocal + exit /b %errorlevel% + +:good_exit + endlocal + exit /b 0 diff --git a/Tools/BuildTools/Setup.sh b/Util/BuildTools/Setup.sh similarity index 100% rename from Tools/BuildTools/Setup.sh rename to Util/BuildTools/Setup.sh diff --git a/Util/InstallersWin/install_xercesc.bat b/Util/InstallersWin/install_xercesc.bat new file mode 100644 index 0000000..fb5cd51 --- /dev/null +++ b/Util/InstallersWin/install_xercesc.bat @@ -0,0 +1,196 @@ +REM @echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem x64 xerces-c build 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]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +rem ============================================================================ +rem -- Local Variables --------------------------------------------------------- +rem ============================================================================ + +set XERCESC_BASENAME=xerces-c +set XERCESC_VERSION=3.2.3 + +rem xerces-c-x.x.x +set XERCESC_TEMP_FOLDER=%XERCESC_BASENAME%-%XERCESC_VERSION% +rem ../xerces-c-x.x.x +set XERCESC_TEMP_FOLDER_DIR=%BUILD_DIR%%XERCESC_TEMP_FOLDER% +rem xerces-c-x.x.x-src.zip +set XERCESC_TEMP_FILE=%XERCESC_TEMP_FOLDER%-src.zip +rem ../xerces-c-x.x.x-src.zip +set XERCESC_TEMP_FILE_DIR=%BUILD_DIR%%XERCESC_TEMP_FILE% + +set XERCESC_REPO=https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-%XERCESC_VERSION%.zip + +rem ../xerces-c-x.x.x-source/ +set XERCESC_SRC_DIR=%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-source\ +rem ../xerces-c-x.x.x-install/ +set XERCESC_INSTALL_DIR=%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-install\ + +rem ============================================================================ +rem -- Get xerces -------------------------------------------------------------- +rem ============================================================================ + +if exist "%XERCESC_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%XERCESC_SRC_DIR%" ( + if not exist "%XERCESC_TEMP_FILE_DIR%" ( + echo %FILE_N% Retrieving %XERCESC_BASENAME%. + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%XERCESC_REPO%', '%XERCESC_TEMP_FILE_DIR%')" + ) + if not exist "%XERCESC_TEMP_FILE_DIR%" ( + echo %FILE_N% Using %XERCESC_BASENAME% from backup. + goto error_download + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/xerces-c-%XERCESC_VERSION%-src.zip', '%XERCESC_TEMP_FILE_DIR%')" + ) + if %errorlevel% neq 0 goto error_download + rem Extract the downloaded library + echo %FILE_N% Extracting xerces from "%XERCESC_TEMP_FILE%". + powershell -Command "Expand-Archive '%XERCESC_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'" + if %errorlevel% neq 0 goto error_extracting + + rem Remove unnecessary files and folders + echo %FILE_N% Removing "%XERCESC_TEMP_FILE%" + del "%XERCESC_TEMP_FILE_DIR%" + echo %FILE_N% Removing dir "%BUILD_DIR%manifest" + rmdir /s/q "%BUILD_DIR%manifest" + + echo %FILE_N% Renaming dir %XERCESC_TEMP_FOLDER_DIR% to %XERCESC_BASENAME%-%XERCESC_VERSION%-source + rename "%XERCESC_TEMP_FOLDER_DIR%" "%XERCESC_BASENAME%-%XERCESC_VERSION%-source" +) else ( + echo %FILE_N% Not downloading xerces because already exists the folder "%XERCESC_SRC_DIR%". +) + +rem ============================================================================ +rem -- Compile xerces ---------------------------------------------------------- +rem ============================================================================ + +if not exist "%XERCESC_SRC_DIR%build" ( + echo %FILE_N% Creating "%XERCESC_SRC_DIR%build" + mkdir "%XERCESC_SRC_DIR%build" +) + +cd "%XERCESC_SRC_DIR%build" + +if not exist "%XERCESC_INSTALL_DIR%lib" ( + echo %FILE_N% Creating "%XERCESC_INSTALL_DIR%lib" + mkdir "%XERCESC_INSTALL_DIR%lib" +) + +if not exist "%XERCESC_INSTALL_DIR%include" ( + echo %FILE_N% Creating "%XERCESC_INSTALL_DIR%include" + mkdir "%XERCESC_INSTALL_DIR%include" +) + +cmake .. -G "Visual Studio 16 2019" -A x64^ + -DCMAKE_INSTALL_PREFIX="%XERCESC_INSTALL_DIR:\=/%"^ + -DBUILD_SHARED_LIBS=OFF^ + -Dtranscoder=windows^ + "%BUILD_DIR%%XERCESC_BASENAME%-%XERCESC_VERSION%-source" +if %errorlevel% neq 0 goto error_cmake + +cmake --build . --config Release --target install + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo %FILE_N% Download and install a xerces. + echo "Usage: %FILE_N% [-h^|--help] [--build-dir] [--zlib-install-dir]" + goto eof + +:success + echo. + echo %FILE_N% xerces has been successfully installed in "%XERCESC_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A xerces installation already exists. + echo %FILE_N% Delete "%XERCESC_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_download + echo. + echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading xerces. + echo %FILE_N% [DOWNLOAD ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%XERCESC_REPO%" + echo %FILE_N% [DOWNLOAD ERROR] Workaround: + echo %FILE_N% - Download the xerces's source code and + echo %FILE_N% extract the content in + echo %FILE_N% "%XERCESC_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_extracting + echo. + echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. + echo %FILE_N% [EXTRACTING ERROR] Workaround: + echo %FILE_N% - Download the xerces's source code and + echo %FILE_N% extract the content manually in + echo %FILE_N% "%XERCESC_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_compiling + echo. + echo %FILE_N% [COMPILING ERROR] An error ocurred while compiling with cl.exe. + echo %FILE_N% Possible causes: + echo %FILE_N% - Make sure you have Visual Studio installed. + echo %FILE_N% - Make sure you have the "x64 Visual C++ Toolset" in your path. + echo %FILE_N% For example, using the "Visual Studio x64 Native Tools Command Prompt", + echo %FILE_N% or the "vcvarsall.bat". + goto bad_exit + +:error_generating_lib + echo. + echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + rem A return value used for checking for errors + endlocal & set install_xerces=%XERCESC_INSTALL_DIR% + exit /b 0 + +:bad_exit + if exist "%XERCESC_INSTALL_DIR%" rd /s /q "%XERCESC_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel% diff --git a/Util/InstallersWin/install_zlib.bat b/Util/InstallersWin/install_zlib.bat new file mode 100644 index 0000000..1e4adbc --- /dev/null +++ b/Util/InstallersWin/install_zlib.bat @@ -0,0 +1,178 @@ +@echo off +setlocal + +rem BAT script that downloads and installs a ready to use +rem x64 zlib build for CARLA (carla.org). +rem Run it through a cmd with the x64 Visual C++ Toolset enabled. + +set MAKEFLAGS= +set LOCAL_PATH=%~dp0 +set FILE_N= -[%~n0]: + +rem Print batch params (debug purpose) +echo %FILE_N% [Batch params]: %* + +rem ============================================================================ +rem -- Parse arguments --------------------------------------------------------- +rem ============================================================================ + +:arg-parse +if not "%1"=="" ( + if "%1"=="--build-dir" ( + set BUILD_DIR=%~dpn2 + shift + ) + if "%1"=="--toolset" ( + set TOOLSET=%~2 + shift + ) + if "%1"=="-h" ( + goto help + ) + if "%1"=="--help" ( + goto help + ) + shift + goto :arg-parse +) + +rem If not set set the build dir to the current dir +if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0 +if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\ + +rem If not defined, use Visual Studio 2019 as tool set +if "%TOOLSET%" == "" set TOOLSET="" + +rem ============================================================================ +rem -- Local Variables --------------------------------------------------------- +rem ============================================================================ + +set ZLIB_BASENAME=zlib +set ZLIB_VERSION=1.2.11 + +set ZLIB_TEMP_FOLDER=%ZLIB_BASENAME%-%ZLIB_VERSION% +set ZLIB_TEMP_FILE=%ZLIB_TEMP_FOLDER%.zip +set ZLIB_TEMP_FILE_DIR=%BUILD_DIR%%ZLIB_TEMP_FILE% + +set ZLIB_REPO=https://github.com/madler/zlib/archive/refs/tags/v%ZLIB_VERSION%.zip + +set ZLIB_SRC_DIR=%BUILD_DIR%%ZLIB_BASENAME%-source\ +set ZLIB_INSTALL_DIR=%BUILD_DIR%%ZLIB_BASENAME%-install\ + +rem ============================================================================ +rem -- Get zlib --------------------------------------------------------------- +rem ============================================================================ + +if exist "%ZLIB_INSTALL_DIR%" ( + goto already_build +) + +if not exist "%ZLIB_SRC_DIR%" ( + if not exist "%ZLIB_TEMP_FILE_DIR%" ( + echo %FILE_N% Retrieving %ZLIB_BASENAME%. + powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%ZLIB_REPO%', '%ZLIB_TEMP_FILE_DIR%')" + if %errorlevel% neq 0 goto error_download + ) + rem Extract the downloaded library + echo %FILE_N% Extracting zlib from "%ZLIB_TEMP_FILE%". + powershell -Command "Expand-Archive '%ZLIB_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'" + if %errorlevel% neq 0 goto error_extracting + + rem Remove the no longer needed downloaded file + echo %FILE_N% Removing "%ZLIB_TEMP_FILE%" + del "%ZLIB_TEMP_FILE_DIR%" + rename "%BUILD_DIR%%ZLIB_TEMP_FOLDER%" "%ZLIB_BASENAME%-source" +) else ( + echo %FILE_N% Not downloading zlib because already exists the folder "%ZLIB_SRC_DIR%". +) + +if not exist "%ZLIB_SRC_DIR%build" ( + echo %FILE_N% Creating "%ZLIB_SRC_DIR%build" + mkdir "%ZLIB_SRC_DIR%build" +) + +cd "%ZLIB_SRC_DIR%build" + +rem -DCMAKE_BUILD_TYPE=Release^ +rem -DCMAKE_CONFIGURATION_TYPES=Release^ +cmake -G "NMake Makefiles"^ + -DCMAKE_INSTALL_PREFIX="%ZLIB_INSTALL_DIR:\=/%"^ + -DCMAKE_BUILD_TYPE=Release^ + "%ZLIB_SRC_DIR%" +if %errorlevel% neq 0 goto error_cmake + +rem https://stackoverflow.com/questions/601970/how-do-i-utilise-all-the-cores-for-nmake +set CL=/MP + +nmake install +if %errorlevel% neq 0 goto error_install + +goto success + +rem ============================================================================ +rem -- Messages and Errors ----------------------------------------------------- +rem ============================================================================ + +:help + echo %FILE_N% Download and install a zlib. + echo "Usage: %FILE_N% [-h^|--help] [--toolset] [--build-dir]" + goto eof + +:success + echo. + echo %FILE_N% zlib has been successfully installed in "%ZLIB_INSTALL_DIR%"! + goto good_exit + +:already_build + echo %FILE_N% A zlib installation already exists. + echo %FILE_N% Delete "%ZLIB_INSTALL_DIR%" if you want to force a rebuild. + goto good_exit + +:error_download + echo. + echo %FILE_N% [DOWNLOAD ERROR] An error ocurred while downloading zlib. + echo %FILE_N% [DOWNLOAD ERROR] Possible causes: + echo %FILE_N% - Make sure that the following url is valid: + echo %FILE_N% "%ZLIB_REPO%" + echo %FILE_N% [DOWNLOAD ERROR] Workaround: + echo %FILE_N% - Download the zlib's source code and + echo %FILE_N% extract the content in + echo %FILE_N% "%ZLIB_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_extracting + echo. + echo %FILE_N% [EXTRACTING ERROR] An error ocurred while extracting the zip. + echo %FILE_N% [EXTRACTING ERROR] Workaround: + echo %FILE_N% - Download the libpng's source code and + echo %FILE_N% extract the content manually in + echo %FILE_N% "%ZLIB_SRC_DIR%" + echo %FILE_N% And re-run the setup script. + goto bad_exit + +:error_cmake + echo. + echo %FILE_N% [CMAKE ERROR] An error ocurred while executing cmake command. + echo %FILE_N% [CMAKE ERROR] Possible causes: + echo %FILE_N% - Make sure "CMake" is installed. + echo %FILE_N% - Make sure it is available on your Windows "path". + echo %FILE_N% - Make sure you have cmake 3.12.4 or higher installed. + goto bad_exit + +:error_install + echo. + echo %FILE_N% [NMAKE ERROR] An error ocurred while compiling and installing using nmake. + goto bad_exit + +:good_exit + echo %FILE_N% Exiting... + rem A return value used for checking for errors + endlocal & set install_zlib=%ZLIB_INSTALL_DIR% + exit /b 0 + +:bad_exit + if exist "%ZLIB_INSTALL_DIR%" rd /s /q "%ZLIB_INSTALL_DIR%" + echo %FILE_N% Exiting with error... + endlocal + exit /b %errorlevel%