2021-01-29 23:57:40 +08:00
|
|
|
REM @echo off
|
|
|
|
setlocal
|
|
|
|
|
|
|
|
rem BAT script that downloads and installs a ready to use
|
2022-06-02 20:35:42 +08:00
|
|
|
rem x64 chrono for CARLA (carla.org).
|
2021-01-29 23:57:40 +08:00
|
|
|
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
|
|
|
|
)
|
2023-09-17 13:00:35 +08:00
|
|
|
if "%1"=="--generator" (
|
|
|
|
set GENERATOR=%2
|
|
|
|
shift
|
|
|
|
)
|
2021-01-29 23:57:40 +08:00
|
|
|
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%\
|
2023-09-17 13:00:35 +08:00
|
|
|
if %GENERATOR% == "" set GENERATOR="Visual Studio 16 2019"
|
2021-01-29 23:57:40 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-06-02 20:35:42 +08:00
|
|
|
if not exist "%EIGEN_SRC_DIR%" (
|
2021-01-29 23:57:40 +08:00
|
|
|
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%
|
|
|
|
|
|
|
|
del %EIGEN_TEMP_FILE_DIR%
|
|
|
|
)
|
|
|
|
|
2022-06-02 20:35:42 +08:00
|
|
|
if not exist "%EIGEN_INSTALL_DIR%" (
|
|
|
|
mkdir %EIGEN_INSTALL_DIR%
|
|
|
|
mkdir %EIGEN_INCLUDE%
|
|
|
|
mkdir %EIGEN_INCLUDE%\unsupported
|
|
|
|
mkdir %EIGEN_INCLUDE%\Eigen
|
|
|
|
)
|
|
|
|
|
|
|
|
xcopy /q /Y /S /I "%EIGEN_SRC_DIR%\Eigen" "%EIGEN_INCLUDE%\Eigen"
|
|
|
|
xcopy /q /Y /S /I "%EIGEN_SRC_DIR%\unsupported\Eigen" "%EIGEN_INCLUDE%\unsupported\Eigen"
|
|
|
|
|
2021-01-29 23:57:40 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Get Chrono -------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
2021-02-11 18:17:11 +08:00
|
|
|
set CHRONO_VERSION=6.0.0
|
|
|
|
@REM set CHRONO_VERSION=develop
|
2021-01-29 23:57:40 +08:00
|
|
|
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%
|
2021-02-11 18:17:11 +08:00
|
|
|
|
2021-01-29 23:57:40 +08:00
|
|
|
mkdir %CHRONO_BUILD_DIR%
|
|
|
|
mkdir %CHRONO_INSTALL_DIR%
|
|
|
|
|
|
|
|
cd "%CHRONO_BUILD_DIR%"
|
|
|
|
|
2023-09-17 13:00:35 +08:00
|
|
|
echo.%GENERATOR% | findstr /C:"Visual Studio" >nul && (
|
|
|
|
set PLATFORM=-A x64
|
|
|
|
) || (
|
|
|
|
set PLATFORM=
|
|
|
|
)
|
|
|
|
|
2021-01-29 23:57:40 +08:00
|
|
|
echo %FILE_N% Compiling Chrono.
|
2023-09-17 13:00:35 +08:00
|
|
|
cmake -G %GENERATOR% %PLATFORM%^
|
2021-01-29 23:57:40 +08:00
|
|
|
-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%
|
2021-02-11 18:17:11 +08:00
|
|
|
|
2021-01-29 23:57:40 +08:00
|
|
|
echo %FILE_N% Building...
|
|
|
|
cmake --build . --config Release --target install
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
goto success
|
|
|
|
|
|
|
|
rem ============================================================================
|
|
|
|
rem -- Messages and Errors -----------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
|
|
|
:help
|
2021-02-16 22:50:25 +08:00
|
|
|
echo %FILE_N% Download and install a the Chrono library.
|
2021-01-29 23:57:40 +08:00
|
|
|
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%
|