Added chrono compilation support for windows.

This commit is contained in:
Axel1092 2021-01-29 16:57:40 +01:00 committed by bernat
parent 2117794dd7
commit 14a634aa29
8 changed files with 270 additions and 23 deletions

View File

@ -48,6 +48,7 @@
# pragma clang diagnostic ignored "-Wmissing-braces"
# pragma clang diagnostic ignored "-Wunusable-partial-specialization"
# pragma clang diagnostic ignored "-Wundef"
# pragma clang diagnostic ignored "-Wall"
#endif
#pragma push_macro("TEXT")

View File

@ -20,6 +20,7 @@ public class Carla : ModuleRules
if (IsWindows(Target))
{
bEnableExceptions = true;
bUseRTTI = true;
}
// Read config about carsim
@ -42,9 +43,9 @@ public class Carla : ModuleRules
UsingChrono = true;
PublicDefinitions.Add("WITH_CHRONO");
PrivateDefinitions.Add("WITH_CHRONO");
}
}
}
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
@ -166,6 +167,15 @@ public class Carla : ModuleRules
{
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("carla_server")));
}
if (UsingChrono)
{
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("ChronoEngine")));
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("ChronoEngine_vehicle")));
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("ChronoModels_vehicle")));
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "dll/ChronoEngine.dll"));
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "dll/ChronoEngine_vehicle.dll"));
RuntimeDependencies.Add(Path.Combine(LibCarlaInstallPath, "dll/ChronoModels_vehicle.dll"));
}
}
else
{

View File

@ -12,8 +12,6 @@
#ifdef WITH_CHRONO
#include "compiler/disable-ue4-macros.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wall"
#include "chrono/physics/ChSystemNSC.h"
#include "chrono_vehicle/ChVehicleModelData.h"
@ -21,7 +19,6 @@
#include "chrono_vehicle/driver/ChDataDriver.h"
#include "chrono_models/vehicle/hmmwv/HMMWV.h"
#pragma clang diagnostic pop
#include "compiler/enable-ue4-macros.h"
#endif

View File

@ -18,6 +18,9 @@ set BUILD_UE4_EDITOR=false
set LAUNCH_UE4_EDITOR=false
set REMOVE_INTERMEDIATE=false
set USE_CARSIM=false
set USE_CHRONO=false
set CARSIM_STATE="CarSim OFF"
set CHRONO_STATE="Chrono OFF"
:arg-parse
echo %1
@ -34,6 +37,9 @@ if not "%1"=="" (
if "%1"=="--carsim" (
set USE_CARSIM=true
)
if "%1"=="--chrono" (
set USE_CHRONO=true
)
if "%1"=="-h" (
goto help
)
@ -102,17 +108,25 @@ if %REMOVE_INTERMEDIATE% == true (
rem Build Carla Editor
rem
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"
if %BUILD_UE4_EDITOR% == true (
echo %FILE_N% Building Unreal Editor...
if %USE_CARSIM% == true (
py -3 %ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject" -e
echo CarSim ON > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
) else (
py -3 %ROOT_PATH%Util/BuildTools/enable_carsim_to_uproject.py -f="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
echo CarSim OFF > "%ROOT_PATH%Unreal/CarlaUE4/Config/CarSimConfig.ini"
)
call "%UE4_ROOT%Engine\Build\BatchFiles\Build.bat"^
CarlaUE4Editor^
Win64^

View File

@ -121,20 +121,20 @@ fi
if ${BUILD_CARLAUE4} ; then
FILE_TEXT=""
OPTIONAL_MODULES_TEXT=""
if ${USE_CARSIM} ; then
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject" -e
FILE_TEXT="CarSim ON"$'\n'"${FILE_TEXT}"
OPTIONAL_MODULES_TEXT="CarSim ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
else
python ${PWD}/../../Util/BuildTools/enable_carsim_to_uproject.py -f="CarlaUE4.uproject"
FILE_TEXT="CarSim OFF"$'\n'"${FILE_TEXT}"
OPTIONAL_MODULES_TEXT="CarSim OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
fi
if ${USE_CHRONO} ; then
FILE_TEXT="Chrono ON"$'\n'"${FILE_TEXT}"
OPTIONAL_MODULES_TEXT="Chrono ON"$'\n'"${OPTIONAL_MODULES_TEXT}"
else
FILE_TEXT="Chrono OFF"$'\n'"${FILE_TEXT}"
OPTIONAL_MODULES_TEXT="Chrono OFF"$'\n'"${OPTIONAL_MODULES_TEXT}"
fi
echo ${FILE_TEXT} > ${PWD}/Config/OptionalModules.ini
echo ${OPTIONAL_MODULES_TEXT} > ${PWD}/Config/OptionalModules.ini
if [ ! -f Makefile ]; then

View File

@ -28,6 +28,8 @@ 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 USE_CHRONO=false
:arg-parse
if not "%1"=="" (
@ -37,6 +39,9 @@ if not "%1"=="" (
if "%1"=="--boost-toolset" (
set TOOLSET=%2
)
if "%1"=="--chrono" (
set USE_CHRONO=true
)
if "%1"=="-h" (
goto help
)
@ -184,7 +189,35 @@ rem ============================================================================
echo %FILE_N% Installing Xercesc...
call "%INSTALLERS_DIR%install_xercesc.bat"^
--build-dir "%INSTALLATION_DIR%"^
--build-dir "%INSTALLATION_DIR%"
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\*"
xcopy /Y /S /I "%INSTALLATION_DIR%chrono-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*"
copy "%INSTALLATION_DIR%chrono-install\lib\*.lib" "%CARLA_DEPENDENCIES_FOLDER%lib\*.lib"
copy "%INSTALLATION_DIR%chrono-install\bin\*.dll" "%CARLA_DEPENDENCIES_FOLDER%dll\*.dll"
xcopy /Y /S /I "%INSTALLATION_DIR%eigen-install\include\*" "%CARLA_DEPENDENCIES_FOLDER%include\*"
)
rem ============================================================================
rem -- Assets download URL -----------------------------------------------------
@ -228,7 +261,6 @@ set CMAKE_CONFIG_FILE=%INSTALLATION_DIR%CMakeLists.txt.in
>>"%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_compile_options(/GR-)
>>"%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)

View File

@ -20,7 +20,7 @@ CarlaUE4Editor: LibCarla
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --build $(ARGS)
launch: CarlaUE4Editor
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --launch
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --launch $(ARGS)
launch-only:
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --launch
@ -71,7 +71,7 @@ LibCarla: setup
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat" --server --client
setup:
@"${CARLA_BUILD_TOOLS_FOLDER}/Setup.bat" --boost-toolset msvc-14.1
@"${CARLA_BUILD_TOOLS_FOLDER}/Setup.bat" --boost-toolset msvc-14.1 $(ARGS)
.PHONY: Plugins
plugins:

View File

@ -0,0 +1,193 @@
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 -- Get Eigen (Chrono dependency) -------------------------------------------
rem ============================================================================
set EIGEN_VERSION=3.3.7
set EIGEN_REPO=https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip
set EIGEN_BASENAME=eigen-%EIGEN_VERSION%
set EIGEN_SRC_DIR=%BUILD_DIR%%EIGEN_BASENAME%
set EIGEN_INSTALL_DIR=%BUILD_DIR%eigen-install
set EIGEN_INCLUDE=%EIGEN_INSTALL_DIR%\include
set EIGEN_TEMP_FILE=eigen-%EIGEN_VERSION%.zip
set EIGEN_TEMP_FILE_DIR=%BUILD_DIR%eigen-%EIGEN_VERSION%.zip
if not exist "%EIGEN_INSTALL_DIR%" (
if not exist "%EIGEN_TEMP_FILE_DIR%" (
echo %FILE_N% Retrieving %EIGEN_TEMP_FILE_DIR%.
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%EIGEN_REPO%', '%EIGEN_TEMP_FILE_DIR%')"
)
if %errorlevel% neq 0 goto error_download_eigen
rem Extract the downloaded library
echo %FILE_N% Extracting eigen from "%EIGEN_TEMP_FILE%".
powershell -Command "Expand-Archive '%EIGEN_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'"
if %errorlevel% neq 0 goto error_extracting
echo %EIGEN_SRC_DIR%
if not exist "%EIGEN_INSTALL_DIR%" (
mkdir %EIGEN_INSTALL_DIR%
mkdir %EIGEN_INCLUDE%
mkdir %EIGEN_INCLUDE%\unsupported
)
move "%EIGEN_SRC_DIR%\Eigen" "%EIGEN_INCLUDE%\"
move "%EIGEN_SRC_DIR%\unsupported\Eigen" "%EIGEN_INCLUDE%\unsupported\"
del %EIGEN_TEMP_FILE_DIR%
echo here1
)
rem ============================================================================
rem -- Get Chrono -------------------------------------------
rem ============================================================================
set CHRONO_VERSION=5.0.1
set CHRONO_REPO=https://github.com/projectchrono/chrono.git
set CHRONO_BASENAME=chrono
set CHRONO_SRC_DIR=%BUILD_DIR%%CHRONO_BASENAME%-src
set CHRONO_INSTALL_DIR=%BUILD_DIR%chrono-install
set CHRONO_BUILD_DIR=%CHRONO_SRC_DIR%\build
if not exist %CHRONO_INSTALL_DIR% (
echo %FILE_N% Retrieving Chrono.
call git clone --depth 1 --branch %CHRONO_VERSION% %CHRONO_REPO% %CHRONO_SRC_DIR%
mkdir %CHRONO_BUILD_DIR%
mkdir %CHRONO_INSTALL_DIR%
cd "%CHRONO_BUILD_DIR%"
echo %FILE_N% Compiling Chrono.
cmake -G "Visual Studio 15 2017 Win64"^
-DCMAKE_BUILD_TYPE=Release^
-DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^
-DEIGEN3_INCLUDE_DIR="%EIGEN_INCLUDE%"^
-DCMAKE_INSTALL_PREFIX="%CHRONO_INSTALL_DIR%"^
-DENABLE_MODULE_VEHICLE=ON^
%CHRONO_SRC_DIR%
echo %FILE_N% Building...
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% Chrono has been successfully installed in "%EIGEN_INSTALL_DIR%"!
goto good_exit
:already_build
echo %FILE_N% A xerces installation already exists.
echo %FILE_N% Delete "%EIGEN_INSTALL_DIR%" if you want to force a rebuild.
goto good_exit
:error_download_eigen
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% "%EIGEN_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% "%EIGEN_SRC_DIR%"
echo %FILE_N% And re-run the setup script.
goto bad_exit
:error_download_chrono
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% "%EIGEN_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% "%EIGEN_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_chrono=%CHRONO_INSTALL_DIR%
exit /b 0
:bad_exit
if exist "%EIGEN_INSTALL_DIR%" rd /s /q "%EIGEN_INSTALL_DIR%"
echo %FILE_N% Exiting with error...
endlocal
exit /b %errorlevel%