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).
|
|
|
|
rem Just put it in `Util/Build` and run it.
|
|
|
|
|
2018-07-30 22:52:29 +08:00
|
|
|
set LOCAL_PATH=%~dp0
|
|
|
|
set "FILE_N= -[%~n0]:"
|
|
|
|
|
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
|
2018-05-22 22:50:32 +08:00
|
|
|
)
|
|
|
|
if "%1"=="--build-dir" (
|
2018-07-27 22:16:58 +08:00
|
|
|
set BUILD_DIR=%~2
|
2018-05-22 22:50:32 +08:00
|
|
|
)
|
|
|
|
if "%1"=="--toolset" (
|
2019-02-06 00:33:09 +08:00
|
|
|
set TOOLSET=%~2
|
|
|
|
)
|
|
|
|
if "%1"=="--version" (
|
|
|
|
set BOOST_VERSION=%~2
|
|
|
|
)
|
|
|
|
if "%1"=="-v" (
|
|
|
|
set BOOST_VERSION=%~2
|
|
|
|
)
|
|
|
|
if "%1"=="-h" (
|
|
|
|
goto help
|
|
|
|
)
|
|
|
|
if "%1"=="--help" (
|
|
|
|
goto help
|
2018-05-22 22:50:32 +08:00
|
|
|
)
|
|
|
|
shift
|
|
|
|
goto :arg-parse
|
|
|
|
)
|
|
|
|
|
2019-02-06 00:33:09 +08:00
|
|
|
if [%BOOST_VERSION%] == [] (
|
|
|
|
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
|
2018-05-22 22:50:32 +08:00
|
|
|
if [%BUILD_DIR%] == [] set 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
|
|
|
|
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
|
2018-07-31 22:35:02 +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%
|
|
|
|
|
|
|
|
set BOOST_REPO=https://dl.bintray.com/boostorg/release/%BOOST_VERSION%/source/%BOOST_TEMP_FILE%
|
|
|
|
set BOOST_SRC_DIR=%BUILD_DIR%%BOOST_BASENAME%-source
|
|
|
|
set BOOST_INSTALL_DIR=%BUILD_DIR%%BOOST_BASENAME%-install
|
|
|
|
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.
|
|
|
|
powershell -Command "Start-BitsTransfer -Source '%BOOST_REPO%' -Destination '%BOOST_TEMP_FILE_DIR%'"
|
|
|
|
)
|
|
|
|
echo %FILE_N% Extracting boost from "%BOOST_TEMP_FILE%", this can take a while...
|
|
|
|
powershell -Command "Expand-Archive '%BOOST_TEMP_FILE_DIR%' -DestinationPath '%BUILD_DIR%'"
|
|
|
|
if %errorlevel% neq 0 goto error_download
|
|
|
|
echo %FILE_N% Removing "%BOOST_TEMP_FILE%"
|
|
|
|
del "%BOOST_TEMP_FILE_DIR:/=\%"
|
|
|
|
rename "%BUILD_DIR%%BOOST_TEMP_FOLDER%" "%BOOST_BASENAME%-source"
|
2018-05-18 00:42:54 +08:00
|
|
|
) else (
|
2019-02-06 00:33:09 +08:00
|
|
|
echo %FILE_N% Not downloading boost because already exists a folder called "%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...
|
|
|
|
call bootstrap.bat
|
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^
|
|
|
|
--with-filesystem^
|
|
|
|
--with-python^
|
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^
|
2019-02-06 00:33:09 +08:00
|
|
|
--prefix="%BOOST_INSTALL_DIR%"^
|
|
|
|
--libdir="%BOOST_LIB_DIR%"^
|
|
|
|
--includedir="%BOOST_INSTALL_DIR%"^
|
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
|
|
|
|
2019-02-06 00:33:09 +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%
|