Skip to content

Commit

Permalink
添加修改后的脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
nongfugengxia committed Jul 31, 2024
1 parent 650ed9d commit 126aae6
Show file tree
Hide file tree
Showing 4 changed files with 533 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/tuto_D_windows_debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,24 @@ python setup.py build

需要将其他的.lib文件编译为debug模式:

1.切换到目录`Util\InstallersWin`,将`install_boost.bat`内的b2运行参数改为`variant=debug`,(根据`Setup.bat`)运行:
1.切换到目录`Util\InstallersWin`,将[`install_boost.bat`](https://github.com/carla-simulator/carla/blob/dev/Util/InstallersWin/install_boost.bat) 内的b2运行参数改为`variant=debug`,(根据`Setup.bat`)运行[`install_boost.bat`](https://github.com/OpenHUTB/carla_doc/tree/master/src/cmake/install_boost.bat)
```shell
install_boost.bat --build-dir D:\work\buffer --toolset msvc-14.2 --version 1.80.0 -j 4
```
会自动将boost的库和头文件安装到目录`D:\work\buffer\boost-1.80.0-install`里面。

[`install_recast.bat`](https://github.com/carla-simulator/carla/blob/dev/Util/InstallersWin/install_recast.bat) 中的`Relase`改为`Debug`
`-DCMAKE_CXX_FLAGS_RELASE="/MD /MP"`改为`-DCMAKE_CXX_FLAGS_DEBUG="/MDd /MP"`,运行[`install_recast.bat`](https://github.com/OpenHUTB/carla_doc/tree/master/src/cmake/install_recast.bat)
```shell
install_recast.bat --build-dir D:\work\buffer --generator "Visual Studio 16 2019"
```
`install_recast.bat`中的`Relase`改为`Debug`

[`install_rpclib.bat`](https://github.com/carla-simulator/carla/blob/dev/Util/InstallersWin/install_rpclib.bat) 中的`Relase`改为`Debug`,运行[`install_rpclib.bat`](https://github.com/OpenHUTB/carla_doc/tree/master/src/cmake/install_rpclib.bat)
`-DCMAKE_CXX_FLAGS_RELASE="/MD /MP"`改为`-DCMAKE_CXX_FLAGS_DEBUG="/MDd /MP"`
```shell
install_rpclib.bat --build-dir D:\work\buffer --generator "Visual Studio 16 2019"
```
`install_rpclib.bat`中的`Relase`改为`Debug`
`-DCMAKE_CXX_FLAGS_RELASE="/MD /MP"`改为`-DCMAKE_CXX_FLAGS_DEBUG="/MDd /MP"`


2.将第1步生成的安装文件目录配置到`Examples\CppClient\CMakeLists.txt`中,对应的头文件和库文件都改为Debug版本;

Expand Down
226 changes: 226 additions & 0 deletions src/cmake/install_boost.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
@echo off
setlocal enabledelayedexpansion

rem BAT script that downloads and installs a ready to use
rem boost build for CARLA (carla.org).

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"=="-j" (
set NUMBER_OF_ASYNC_JOBS=%~2
shift
)
if "%1"=="--build-dir" (
set BUILD_DIR=%~dpn2
shift
)
if "%1"=="--toolset" (
set TOOLSET=%~2
shift
)
if "%1"=="--version" (
set BOOST_VERSION=%~2
shift
)
if "%1"=="-v" (
set BOOST_VERSION=%~2
shift
)
if "%1"=="-h" (
goto help
)
if "%1"=="--help" (
goto help
)
shift
goto :arg-parse
)

if "%BOOST_VERSION%" == "" (
echo %FILE_N% You must specify a boost version using [-v^|--version]
goto bad_exit
)

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=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 -- Local Variables ---------------------------------------------------------
rem ============================================================================

set BOOST_BASENAME=boost-%BOOST_VERSION%
set BOOST_SHA256SUM="e34756f63abe8ac34b35352743f17d061fcc825969a2dd8458264edb38781782"

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://archives.boost.io/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\

rem ============================================================================
rem -- Get Boost ---------------------------------------------------------------
rem ============================================================================

if exist "%BOOST_INSTALL_DIR%" (
goto already_build
)

set _checksum=""

if not exist "%BOOST_SRC_DIR%" (
if not exist "%BOOST_TEMP_FILE_DIR%" (
echo %FILE_N% Retrieving boost.
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%BOOST_REPO%', '%BOOST_TEMP_FILE_DIR%')"
call :CheckSumEvaluate %BOOST_TEMP_FILE_DIR%,%BOOST_SHA256SUM%,_checksum
)
if "!_checksum!" == "1" (
echo %FILE_N% Using Boost backup
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('https://carla-releases.s3.us-east-005.backblazeb2.com/Backup/%BOOST_TEMP_FILE%', '%BOOST_TEMP_FILE_DIR%')"
call :CheckSumEvaluate %BOOST_TEMP_FILE_DIR%,%BOOST_SHA256SUM%,_checksum
)
if "!_checksum!" == "1" goto error_download
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"
)
echo %FILE_N% Removing "%BOOST_TEMP_FILE%"
del "%BOOST_TEMP_FILE_DIR%"
rename "%BUILD_DIR%%BOOST_TEMP_FOLDER%" "%BOOST_BASENAME%-source"
) else (
echo %FILE_N% Not downloading boost because already exists the folder "%BOOST_SRC_DIR%".
)

cd "%BOOST_SRC_DIR%"
if not exist "b2.exe" (
echo %FILE_N% Generating build...
call bootstrap.bat vc141
)

if %errorlevel% neq 0 goto error_bootstrap

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

echo %FILE_N% Building...
b2 -j%NUMBER_OF_ASYNC_JOBS%^
headers^
--layout=versioned^
--build-dir=.\build^
--with-system^
--with-filesystem^
--with-python^
--with-date_time^
architecture=x86^
address-model=64^
toolset=%TOOLSET%^
variant=debug^
link=static^
runtime-link=shared^
threading=multi^
--prefix="%BOOST_INSTALL_DIR:~0,-1%"^
--libdir="%BOOST_LIB_DIR:~0,-1%"^
--includedir="%BOOST_INSTALL_DIR:~0,-1%"^
install
if %errorlevel% neq 0 goto error_install

for /d %%i in ("%BOOST_INSTALL_DIR%boost*") do rename "%%i" include
goto success

rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================

:help
echo %FILE_N% Download and install a boost version.
echo "Usage: %FILE_N% [-h^|--help] [-v^|--version] [--toolset] [--build-dir] [-j]"
goto eof

:success
echo.
echo %FILE_N% Boost has been successfully installed in "%BOOST_INSTALL_DIR%"!
goto good_exit

:already_build
echo %FILE_N% A Boost installation already exists.
echo %FILE_N% Delete "%BOOST_INSTALL_DIR%" if you want to force a rebuild.
goto good_exit

:error_download
echo.
echo %FILE_N% [GIT ERROR] An error ocurred while downloading boost.
echo %FILE_N% [GIT ERROR] Possible causes:
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%"
goto bad_exit

:error_bootstrap
echo.
echo %FILE_N% [BOOTSTRAP ERROR] An error ocurred while executing "bootstrap.bat".
goto bad_exit

:error_install
echo.
echo %FILE_N% [B2 ERROR] An error ocurred while installing using "b2.exe".
goto bad_exit

:good_exit
echo %FILE_N% Exiting...
endlocal
rem A return value used for checking for errors
set install_boost=done
exit /b 0

:bad_exit
if exist "%BOOST_INSTALL_DIR%" rd /s /q "%BOOST_INSTALL_DIR%"
echo %FILE_N% Exiting with error...
endlocal
exit /b %errorlevel%

:CheckSumEvaluate
set filepath=%1
set checksum=%2

echo %FILE_N% calculating %filepath% checksum...

set PsCommand="(Get-FileHash %filepath%).Hash -eq '%checksum%'"

for /f %%F in ('Powershell -C %PsCommand%') do (
set filechecksum=%%F
)

if %filechecksum% == True (
echo %FILE_N% %filepath% checksum OK
set "%~3=0"
exit /b 0
) else (
echo %FILE_N% %filepath% BAD SHA256 checksum
set "%~3=1"
exit /b 1
)
Loading

0 comments on commit 126aae6

Please sign in to comment.