2018-05-18 00:42:54 +08:00
|
|
|
@echo off
|
2018-07-31 22:35:02 +08:00
|
|
|
setlocal
|
2018-05-18 00:42:54 +08:00
|
|
|
|
|
|
|
rem BAT script that downloads and installs a ready to use
|
|
|
|
rem boost build for CARLA (carla.org).
|
|
|
|
|
2018-07-30 22:52:29 +08:00
|
|
|
set LOCAL_PATH=%~dp0
|
2020-06-16 21:26:43 +08:00
|
|
|
set FILE_N= -[%~n0]:
|
2018-07-30 22:52:29 +08:00
|
|
|
|
2018-08-29 18:24:30 +08:00
|
|
|
rem Print batch params (debug purpose)
|
|
|
|
echo %FILE_N% [Batch params]: %*
|
|
|
|
|
|
|
|
rem ============================================================================
|
|
|
|
rem -- Parse arguments ---------------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
2018-05-22 22:50:32 +08:00
|
|
|
:arg-parse
|
|
|
|
if not "%1"=="" (
|
|
|
|
if "%1"=="-j" (
|
2018-07-27 22:16:58 +08:00
|
|
|
set NUMBER_OF_ASYNC_JOBS=%~2
|
2020-06-16 21:26:43 +08:00
|
|
|
shift
|
2018-05-22 22:50:32 +08:00
|
|
|
)
|
|
|
|
if "%1"=="--build-dir" (
|
2020-06-16 21:26:43 +08:00
|
|
|
set BUILD_DIR=%~dpn2
|
|
|
|
shift
|
2018-05-22 22:50:32 +08:00
|
|
|
)
|
|
|
|
if "%1"=="--toolset" (
|
2019-02-06 00:33:09 +08:00
|
|
|
set TOOLSET=%~2
|
2020-06-16 21:26:43 +08:00
|
|
|
shift
|
2019-02-06 00:33:09 +08:00
|
|
|
)
|
|
|
|
if "%1"=="--version" (
|
|
|
|
set BOOST_VERSION=%~2
|
2020-06-16 21:26:43 +08:00
|
|
|
shift
|
2019-02-06 00:33:09 +08:00
|
|
|
)
|
|
|
|
if "%1"=="-v" (
|
|
|
|
set BOOST_VERSION=%~2
|
2020-06-16 21:26:43 +08:00
|
|
|
shift
|
2019-02-06 00:33:09 +08:00
|
|
|
)
|
|
|
|
if "%1"=="-h" (
|
|
|
|
goto help
|
|
|
|
)
|
|
|
|
if "%1"=="--help" (
|
|
|
|
goto help
|
2018-05-22 22:50:32 +08:00
|
|
|
)
|
|
|
|
shift
|
|
|
|
goto :arg-parse
|
|
|
|
)
|
|
|
|
|
2020-06-16 21:26:43 +08:00
|
|
|
if "%BOOST_VERSION%" == "" (
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% You must specify a boost version using [-v^|--version]
|
|
|
|
goto bad_exit
|
|
|
|
)
|
|
|
|
|
2018-07-31 22:35:02 +08:00
|
|
|
rem If not set set the build dir to the current dir
|
2020-06-16 21:26:43 +08:00
|
|
|
if "%BUILD_DIR%" == "" set BUILD_DIR=%~dp0
|
|
|
|
if not "%BUILD_DIR:~-1%"=="\" set BUILD_DIR=%BUILD_DIR%\
|
2018-07-31 22:35:02 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
rem If not defined, use Visual Studio 2017 as tool set
|
2020-06-16 21:26:43 +08:00
|
|
|
if "%TOOLSET%" == "" set TOOLSET=msvc-14.1
|
2018-07-31 22:35:02 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
rem If is not set, set the number of parallel jobs to the number of CPU threads
|
2020-06-16 21:26:43 +08:00
|
|
|
if "%NUMBER_OF_ASYNC_JOBS%" == "" set NUMBER_OF_ASYNC_JOBS=%NUMBER_OF_PROCESSORS%
|
2018-05-22 22:50:32 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Local Variables ---------------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
|
|
|
set BOOST_BASENAME=boost-%BOOST_VERSION%
|
|
|
|
|
|
|
|
set BOOST_TEMP_FOLDER=boost_%BOOST_VERSION:.=_%
|
|
|
|
set BOOST_TEMP_FILE=%BOOST_TEMP_FOLDER%.zip
|
|
|
|
set BOOST_TEMP_FILE_DIR=%BUILD_DIR%%BOOST_TEMP_FILE%
|
|
|
|
|
2021-05-18 00:18:50 +08:00
|
|
|
set BOOST_REPO=https://boostorg.jfrog.io/artifactory/main/release/%BOOST_VERSION%/source/%BOOST_TEMP_FILE%
|
2020-06-16 21:26:43 +08:00
|
|
|
set BOOST_SRC_DIR=%BUILD_DIR%%BOOST_BASENAME%-source\
|
|
|
|
set BOOST_INSTALL_DIR=%BUILD_DIR%%BOOST_BASENAME%-install\
|
2020-06-17 22:41:04 +08:00
|
|
|
set BOOST_LIB_DIR=%BOOST_INSTALL_DIR%lib\
|
2018-05-18 00:42:54 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Get Boost ---------------------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
|
|
|
if exist "%BOOST_INSTALL_DIR%" (
|
2018-07-26 15:37:11 +08:00
|
|
|
goto already_build
|
2018-05-22 22:50:32 +08:00
|
|
|
)
|
2018-05-18 00:42:54 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
if not exist "%BOOST_SRC_DIR%" (
|
|
|
|
if not exist "%BOOST_TEMP_FILE_DIR%" (
|
|
|
|
echo %FILE_N% Retrieving boost.
|
2020-03-19 16:02:49 +08:00
|
|
|
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%BOOST_REPO%', '%BOOST_TEMP_FILE_DIR%')"
|
2019-02-06 00:33:09 +08:00
|
|
|
)
|
2020-03-28 19:07:08 +08:00
|
|
|
if not exist "%BOOST_TEMP_FILE_DIR%" (
|
2020-03-28 20:16:20 +08:00
|
|
|
echo %FILE_N% Using Boost backup
|
|
|
|
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/%BOOST_TEMP_FILE%', '%BOOST_TEMP_FILE_DIR%')"
|
2020-03-28 19:07:08 +08:00
|
|
|
)
|
2019-02-06 00:33:09 +08:00
|
|
|
if %errorlevel% neq 0 goto error_download
|
2020-03-05 20:16:18 +08:00
|
|
|
echo %FILE_N% Extracting boost from "%BOOST_TEMP_FILE%", this can take a while...
|
|
|
|
if exist "%ProgramW6432%/7-Zip/7z.exe" (
|
|
|
|
"%ProgramW6432%/7-Zip/7z.exe" x "%BOOST_TEMP_FILE_DIR%" -o"%BUILD_DIR%" -y
|
|
|
|
) else (
|
|
|
|
powershell -Command "Expand-Archive '%BOOST_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%' -Force"
|
|
|
|
)
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% Removing "%BOOST_TEMP_FILE%"
|
2020-06-16 21:26:43 +08:00
|
|
|
del "%BOOST_TEMP_FILE_DIR%"
|
2019-02-06 00:33:09 +08:00
|
|
|
rename "%BUILD_DIR%%BOOST_TEMP_FOLDER%" "%BOOST_BASENAME%-source"
|
2018-05-18 00:42:54 +08:00
|
|
|
) else (
|
2019-02-06 02:07:37 +08:00
|
|
|
echo %FILE_N% Not downloading boost because already exists the folder "%BOOST_SRC_DIR%".
|
2018-05-18 00:42:54 +08:00
|
|
|
)
|
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
cd "%BOOST_SRC_DIR%"
|
2018-05-22 22:50:32 +08:00
|
|
|
if not exist "b2.exe" (
|
2018-07-26 15:37:11 +08:00
|
|
|
echo %FILE_N% Generating build...
|
2020-06-22 20:45:41 +08:00
|
|
|
call bootstrap.bat vc141
|
2018-05-18 00:42:54 +08:00
|
|
|
)
|
|
|
|
|
2018-07-31 22:35:02 +08:00
|
|
|
if %errorlevel% neq 0 goto error_bootstrap
|
2018-05-22 22:50:32 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
rem This fix some kind of issue installing headers of boost < 1.67, not installing correctly
|
|
|
|
rem echo %FILE_N% Packing headers...
|
|
|
|
rem b2 headers link=static
|
2018-05-18 00:42:54 +08:00
|
|
|
|
|
|
|
echo %FILE_N% Building...
|
2018-07-31 22:35:02 +08:00
|
|
|
b2 -j%NUMBER_OF_ASYNC_JOBS%^
|
2018-07-26 15:37:11 +08:00
|
|
|
headers^
|
|
|
|
--layout=versioned^
|
2019-02-06 00:33:09 +08:00
|
|
|
--build-dir=.\build^
|
2019-02-08 21:38:12 +08:00
|
|
|
--with-system^
|
2019-02-06 00:33:09 +08:00
|
|
|
--with-filesystem^
|
|
|
|
--with-python^
|
2019-02-06 02:07:37 +08:00
|
|
|
--with-date_time^
|
2018-07-26 15:37:11 +08:00
|
|
|
architecture=x86^
|
|
|
|
address-model=64^
|
2019-02-06 00:33:09 +08:00
|
|
|
toolset=%TOOLSET%^
|
2018-07-26 15:37:11 +08:00
|
|
|
variant=release^
|
|
|
|
link=static^
|
2018-07-31 00:59:42 +08:00
|
|
|
runtime-link=shared^
|
2018-07-26 15:37:11 +08:00
|
|
|
threading=multi^
|
2020-06-16 21:26:43 +08:00
|
|
|
--prefix="%BOOST_INSTALL_DIR:~0,-1%"^
|
|
|
|
--libdir="%BOOST_LIB_DIR:~0,-1%"^
|
|
|
|
--includedir="%BOOST_INSTALL_DIR:~0,-1%"^
|
2018-07-26 15:37:11 +08:00
|
|
|
install
|
2018-07-31 22:35:02 +08:00
|
|
|
if %errorlevel% neq 0 goto error_install
|
2018-05-22 22:50:32 +08:00
|
|
|
|
2020-06-16 21:26:43 +08:00
|
|
|
for /d %%i in ("%BOOST_INSTALL_DIR%boost*") do rename "%%i" include
|
2018-05-22 22:50:32 +08:00
|
|
|
goto success
|
|
|
|
|
2018-07-31 22:35:02 +08:00
|
|
|
rem ============================================================================
|
|
|
|
rem -- Messages and Errors -----------------------------------------------------
|
|
|
|
rem ============================================================================
|
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
:help
|
|
|
|
echo %FILE_N% Download and install a boost version.
|
|
|
|
echo "Usage: %FILE_N% [-h^|--help] [-v^|--version] [--toolset] [--build-dir] [-j]"
|
|
|
|
goto eof
|
|
|
|
|
2018-05-18 00:42:54 +08:00
|
|
|
:success
|
2018-07-26 15:37:11 +08:00
|
|
|
echo.
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% Boost has been successfully installed in "%BOOST_INSTALL_DIR%"!
|
2018-07-26 15:37:11 +08:00
|
|
|
goto good_exit
|
2018-05-18 00:42:54 +08:00
|
|
|
|
|
|
|
:already_build
|
2018-07-26 15:37:11 +08:00
|
|
|
echo %FILE_N% A Boost installation already exists.
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% Delete "%BOOST_INSTALL_DIR%" if you want to force a rebuild.
|
2018-07-26 15:37:11 +08:00
|
|
|
goto good_exit
|
2018-05-18 00:42:54 +08:00
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
:error_download
|
2018-07-26 15:37:11 +08:00
|
|
|
echo.
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% [GIT ERROR] An error ocurred while downloading boost.
|
2018-07-26 15:37:11 +08:00
|
|
|
echo %FILE_N% [GIT ERROR] Possible causes:
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% - Make sure that the following url is valid:
|
|
|
|
echo %FILE_N% "%BOOST_REPO%"
|
|
|
|
echo %FILE_N% [GIT ERROR] Workaround:
|
|
|
|
echo %FILE_N% - Download the source code of boost "%BOOST_VERSION%" and
|
|
|
|
echo %FILE_N% extract the content of "%BOOST_TEMP_FOLDER%" in
|
|
|
|
echo %FILE_N% "%BOOST_SRC_DIR%"
|
2018-07-26 15:37:11 +08:00
|
|
|
goto bad_exit
|
2018-05-23 22:01:17 +08:00
|
|
|
|
2018-05-22 22:50:32 +08:00
|
|
|
:error_bootstrap
|
2018-07-26 15:37:11 +08:00
|
|
|
echo.
|
|
|
|
echo %FILE_N% [BOOTSTRAP ERROR] An error ocurred while executing "bootstrap.bat".
|
|
|
|
goto bad_exit
|
2018-05-22 22:50:32 +08:00
|
|
|
|
|
|
|
:error_install
|
2018-07-26 15:37:11 +08:00
|
|
|
echo.
|
|
|
|
echo %FILE_N% [B2 ERROR] An error ocurred while installing using "b2.exe".
|
|
|
|
goto bad_exit
|
2018-05-22 22:50:32 +08:00
|
|
|
|
|
|
|
:good_exit
|
2018-07-26 15:37:11 +08:00
|
|
|
echo %FILE_N% Exiting...
|
|
|
|
endlocal
|
2019-02-06 00:33:09 +08:00
|
|
|
rem A return value used for checking for errors
|
2018-07-26 15:37:11 +08:00
|
|
|
set install_boost=done
|
2018-07-31 22:35:02 +08:00
|
|
|
exit /b 0
|
2018-05-22 22:50:32 +08:00
|
|
|
|
|
|
|
:bad_exit
|
2019-02-06 00:33:09 +08:00
|
|
|
if exist "%BOOST_INSTALL_DIR%" rd /s /q "%BOOST_INSTALL_DIR%"
|
2018-07-26 15:37:11 +08:00
|
|
|
echo %FILE_N% Exiting with error...
|
|
|
|
endlocal
|
2018-07-31 22:35:02 +08:00
|
|
|
exit /b %errorlevel%
|