Merge pull request #689 from carla-simulator/0.9-win32

0.9 win32
This commit is contained in:
Néstor Subirón 2018-09-03 11:43:30 +02:00 committed by GitHub
commit b8fd764d8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 1593 additions and 438 deletions

View File

@ -1,23 +1,22 @@
<h1>How to build CARLA on Windows</h1>
!!! important
Since version 0.9.0 the build system changed, the instructions in this
document are no longer valid. While we work on fixing this, we recommend
either compile Carla on Linux or switch to the `stable` branch. Sorry for
the inconvenience.
---
<h3>Necessary software</h3>
- [Git](https://git-scm.com/downloads)
- [Make](http://gnuwin32.sourceforge.net/downlinks/make-bin-zip.php)
- [Cmake](https://cmake.org/download/)
- [Make](http://gnuwin32.sourceforge.net/packages/make.htm)
- [CMake](https://cmake.org/download/)
- [Python3 x64](https://www.python.org/downloads/)
!!! important
Be sure that these programs are added to your path, so you can use them from your command prompt.
Be sure that these programs are added to your environment path, so you can use them from your command prompt.
!!! important
If make complins about missing libintl3.dll or/and libiconv2.dll please donwload the [dependencies](http://gnuwin32.sourceforge.net/downlinks/make-dep-zip.php) and extract the bin contento into the make installation path.
Also:
- [Unreal Engine](https://www.unrealengine.com/download) (v4.18.x)
- [Visual Studio](https://www.visualstudio.com/downloads/) (2017 preferably)
- [Unreal Engine](https://www.unrealengine.com/download) (v4.19.x)
- [Visual Studio](https://www.visualstudio.com/downloads/) (2017)
<h3>Environment Setup</h3>
In order to build CARLA you must **enable the x64 Visual C++ Toolset**.
@ -27,10 +26,6 @@ You have different options:
- **Recomended:** Use [`Visual Studio x64 Native Tools Command Prompt`](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs). Just press the `Win` button and search for `x64` (be careful to not **unintentionally open a `x86_x64` prompt**), because the name of this Command Prompt can change depending on the lenguage you have Visual Studio installed.
- [Enable a 64-Bit Visual C++ Toolset on the Command Line](https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx) (the instructions will depend on the version of VS that you have).
!!! note
Take care if you have **Cygwin** installed. This could cause the errors like
`/usr/bin/sh: rd: command not found` While executing `Reuild.bat`.
<h3>Clone the repository</h3>
Go to the path you want to install CARLA and use git to download the project using the following command:
@ -44,146 +39,63 @@ and get in the created folder:
cd carla
```
# Automatic installation
Once you have downloaded the repo you can start with the automatic installation.
This process may take a while, it will download and install the necessary Boost and Protobuf libraries. Expect 20-40 minutes, depending on your hardware and internet connection.
<h3>Download Carla contents</h3>
Depending on the Carla version that you are unsing download one of the links that you can find in `\Util\ContentVersions.txt` and extract the content to `Unreal\CarlaUE4\Content\Carla`, if the path doesn't exist, create it.
Script | Use
------------- | ----
`Setup.bat` | Downloads and installs all the external dependencies, automatically calling the scripts in `Util/InstallersWin/`.
`Rebuild.bat` | Builds carlaserver and launch the Unreal project.
# Build Carla
---
<h3>Installation</h3>
1. After navigate to your carla folder, run:
Once you have downloaded the repo and extract the Carla contents you can start with the automatic build. The process may take a while, it will download and install the necessary libraries (Boost, RPCLib and googletest). Expect 20-40 minutes, depending on your hardware and internet connection. If you get any error comment on [GitHub #647](https://github.com/carla-simulator/carla/issues/647) issue or just ask on the [Windows Discord channel](https://discord.gg/42KJdRj).
Setup.bat -j 8 --boost-toolset msvc-14.1
<h3>Build commands</h3>
`-j n` will try to parallelize the git download and NMake compilation. If not specified, no optimization will be made.
| Command | Description |
| --- | --- |
| `make help` | Print all available commands |
| `make launch`| Builds and launches Carla |
| `make launch-editor` | Launches Carla Editor |
| `make package` | Builds CARLA and creates a packaged version for distribution |
| `make clean` | Deletes all the binaries and temporals generated by the build system |
| `make rebuild` | Rebuilds Carla project, dependencies not build |
To see available commands, like which `--boost-toolset` you have to use depending on your Visual Studio version, use:
Setup.bat --help
If you build Carla for the first time or after you clean the project it will probably ask you to build the `UE4Editor-CarlaUE4.dll` and `UE4Editor-Carla.dll` also (as is needed for coocking the content for launch Carla), agree and the project will be opened in the Unreal Engine in a few minutes.
1. When it's done, and if everything went well, `Setup.bat` will provide a link where you can download the assets manually. If you get some errors you can try the **Manual Installation**, open a new issue on [GitHub](https://github.com/carla-simulator/carla/issues/) or just ask on the [Windows Discord channel](https://discord.gg/42KJdRj).
Example of building Carla 0.9.0 for first time:
```cmd
1) git clone https://github.com/carla-simulator/carla.git
1. Unzip these assets into `Unreal/CarlaUE4/Content`. Create it if the folder is not there.
2) Download https://drive.google.com/uc?id=1FtC00CrDb7Kz5StBAwb6vqOGbzZtpROx&export=download
3) Extract to Unreal/CarlaUE4/Content/Carla
1. Now let's compile carlaserver and start the Unreal project. Run:
Rebuild.bat
1. Later on it will ask you to rebuild:
UE4Editor-CarlaUE4.dll
UE4Editor-Carla.dll
Agree and the project will be opened in the Unreal Engine in a few minutes.
# Manual Installation
!!! note
Since version **0.8.3**, it is recomended to follow the automatic installation.
<h3>Download the assets</h3>
Download the assets from the version you need. Take a look at [`Util/ContentVersions.txt`](https://github.com/carla-simulator/carla/blob/master/Util/ContentVersions.txt) and follow the provided instructions to build the download link from the version's hash.
Create the folder `Content` in `Unreal/CarlaUE4/` and unzip the content you just downloaded here.
<h3>Dependencies</h3>
Download and build **for win64**:
- Boost 1.64
- Protobuf 3.3.2
<h3>Building Boost for CARLA</h3>
Follow the official documentation to compile boost.
Put the generated binaries in `Util/Build/boost-install`:
```c
Util
└── Build
└── boost-install
├── boost-1_64
| └── boost
| ├── accumulators
| ├── algorithm
| ├── align
| └── [...] // and all the other libraries
└── lib
├── libboost_date_time-vc141-mt-1_64.lib
└── libboost_system-vc141-mt-1_64.lib
4) make launch
```
<h3>Building Protobuf for CARLA</h3>
<h4>From our batch file</h4>
Just use [this batch](https://gist.github.com/marcgpuig/57946f9b684f64e5f08487089c437ea3) script, it will download and compile a ready-to-use version. Put it in`Util/Build` and just run it.
# Update Carla
---
<h4>Manually</h4>
If something goes wrong, just follow the protobuf [cmake tutorials](https://github.com/google/protobuf/blob/master/cmake/README.md), but add these cmake arguments:
```
-DCMAKE_BUILD_TYPE=Release
-Dprotobuf_BUILD_TESTS=OFF
-DCMAKE_CXX_FLAGS_RELEASE=/MD
-Dprotobuf_MSVC_STATIC_RUNTIME=OFF
```
Put the generated binaries in `Util/Build/protobuf-install`.
<h3>Compiling CARLA server</h3>
With your Visual Studio propmt, navigate into the `carla` folder where you cloned the repo with
Every new release of CARLA we release a new package with the latest changes in the CARLA assets. To download the latest version and recompile CARLA, run:
```cmd
cd carla
```
and use:
```cmd
path\to\carla> make
1) make clean # Deletes all the binaries and temporals generated by the build system
2) git pull # Download the las Carla modifications
3) Download the latest version of assets (if needed)
4) make launch # Build and launch Carla
```
If you have done everything alright, **carla server** must be installed successfully in `Unreal/CarlaUE4/Plugins/Carla/CarlaServer`.
# Possible build errors
---
<h3>Launch Unreal Engine</h3>
Double click `Unreal/CarlaUE4/CarlaUE4.uproject` and it will ask you to rebuild:
If you also have installed other version of Visual Studio or Microsoft Compiler and get any error during the build as C2440 or C2672 this is probably because is not using the 2017 compiler, so try first to uninstall the other ones and rebuild again.
UE4Editor-CarlaUE4.dll
UE4Editor-Carla.dll
Agree.
<h3>Compilation failures</h3>
If there are problems generating the dlls, right click on `CarlaUE4.uproject` and select `Generate Visual Studio project files`, so you can try compiling from the Visual Studio Editor and check the errors.
# Recompiling
<h4>Automatic</h4>
Just run `Rebuild.bat`:
If you would like to keep the other version of Visual Studio edit ```%appdata%\Unreal Engine\UnrealBuildTool\BuildConfiguration.xml``` adding the following lines:
```
path\to\carla> Rebuild
```
<VCProjectFileGenerator>
<Version>VisualStudio2017</Version>
</VCProjectFileGenerator>
<h4>Manual</h4>
You must delete the following folders to **completely rebuild** your project:
```cmd
Unreal/CarlaUE4/Binaries
Unreal/CarlaUE4/Intermediate
Unreal/CarlaUE4/Plugins/Carla/Binaries
Unreal/CarlaUE4/Plugins/Carla/Intermediate
```
Then you can clean the project and compile it again:
```
path\to\carla> make clean & make
```
You can do it more automatically with your prompt in `carla` folder:
```
path\to\carla> rmdir /q /s Unreal/CarlaUE4/Binaries Unreal/CarlaUE4/Intermediate Unreal/CarlaUE4/Saved Unreal/CarlaUE4/Plugins/Carla/Binaries Unreal/CarlaUE4/Plugins/Carla/Intermediate
path\to\carla> make clean
path\to\carla> make
path\to\carla> Unreal/CarlaUE4/CarlaUE4.uproject
<WindowsPlatform>
<Compiler>VisualStudio2017</Compiler>
</WindowsPlatform>
```

View File

@ -13,7 +13,10 @@ if (CMAKE_BUILD_TYPE STREQUAL "Client")
add_subdirectory("client")
elseif (CMAKE_BUILD_TYPE STREQUAL "Server")
add_subdirectory("server")
add_subdirectory("test")
if (NOT WIN32) # TODO(Andrei): Fix compilation for Windows
add_subdirectory("test")
endif()
else ()
message(FATAL_ERROR "Unknown build type '${CMAKE_BUILD_TYPE}'")
endif ()

View File

@ -3,7 +3,8 @@ project(libcarla-client)
# Install rpclib.
install(DIRECTORY "${RPCLIB_INCLUDE_PATH}/rpc" DESTINATION include)
install(FILES "${RPCLIB_LIB_PATH}/librpc.a" DESTINATION lib)
file(GLOB libcarla_carla_rpclib "${RPCLIB_LIB_PATH}/*.*")
install(FILES ${libcarla_carla_rpclib} DESTINATION lib)
file(GLOB libcarla_sources
"${libcarla_source_path}/carla/*.h"

View File

@ -7,7 +7,8 @@ install(FILES ${LibCXX_Libraries} DESTINATION lib)
# Install rpclib.
install(DIRECTORY "${RPCLIB_INCLUDE_PATH}/rpc" DESTINATION include)
install(FILES "${RPCLIB_LIB_PATH}/librpc.a" DESTINATION lib)
file(GLOB libcarla_carla_rpclib "${RPCLIB_LIB_PATH}/*.*")
install(FILES ${libcarla_carla_rpclib} DESTINATION lib)
# Install headers.
@ -33,6 +34,14 @@ install(FILES ${libcarla_carla_streaming_low_level_headers} DESTINATION include/
install(DIRECTORY "${BOOST_INCLUDE_PATH}/boost" DESTINATION include)
if(WIN32)
file(GLOB boostlib_date_time "${BOOST_LIB_PATH}/libboost_date_time-*-mt-*.lib")
install(FILES ${boostlib_date_time} DESTINATION lib)
file(GLOB boostlib_system "${BOOST_LIB_PATH}/libboost_system-*-mt-*.lib")
install(FILES ${boostlib_system} DESTINATION lib)
endif()
# carla_server library.
file(GLOB_RECURSE libcarla_server_sources

View File

@ -13,19 +13,28 @@ link_directories(
# Create targets for debug and release in the same build type.
foreach(target libcarla_test_debug libcarla_test_release)
add_executable(${target} ${libcarla_test_sources})
add_executable(${target} ${libcarla_test_sources})
target_compile_definitions(${target} PUBLIC
-DLIBCARLA_ENABLE_PROFILER
-DLIBCARLA_WITH_GTEST)
target_compile_definitions(${target} PUBLIC
-DLIBCARLA_ENABLE_PROFILER
-DLIBCARLA_WITH_GTEST)
target_include_directories(${target} PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}"
"${GTEST_INCLUDE_PATH}")
target_link_libraries(${target} "-lrpc -lgtest_main -lgtest")
target_include_directories(${target} PRIVATE
"${BOOST_INCLUDE_PATH}"
"${RPCLIB_INCLUDE_PATH}"
"${GTEST_INCLUDE_PATH}")
install(TARGETS ${target} DESTINATION test)
if (WIN32)
target_link_libraries(${target} "gtest_main.lib")
target_link_libraries(${target} "gtest.lib")
target_link_libraries(${target} "rpc.lib")
else()
target_link_libraries(${target} "-lrpc")
target_link_libraries(${target} "-lgtest_main")
target_link_libraries(${target} "-lgtest")
endif()
install(TARGETS ${target} DESTINATION test)
endforeach(target)
# Specific options for debug.

View File

@ -13,8 +13,10 @@
#pragma push_macro("check")
#undef check
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-braces"
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmissing-braces"
#endif
#define LIBCARLA_INCLUDED_FROM_UE4
@ -40,3 +42,6 @@ namespace boost {
}
} // namespace boost
#pragma push_macro("TEXT")
#undef TEXT

View File

@ -5,7 +5,10 @@
// For a copy, see <https://opensource.org/licenses/MIT>.
#pragma pop_macro("check")
#pragma pop_macro("TEXT")
#pragma clang diagnostic pop
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
#undef LIBCARLA_INCLUDED_FROM_UE4

View File

@ -32,6 +32,20 @@ def get_libcarla_extensions():
include_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7/include']
library_dirs += ['/usr/lib/gcc/x86_64-linux-gnu/7']
extra_link_args += ['/usr/lib/gcc/x86_64-linux-gnu/7/libstdc++.a']
else:
libraries += ["boost_python"]
elif os.name == "nt":
pwd = os.path.dirname(os.path.realpath(__file__))
pylib = "libboost_python%d%d-vc141-mt-x64-1_67.lib" % (sys.version_info.major, sys.version_info.minor)
extra_link_args = [
'shlwapi.lib',
os.path.join(pwd, 'dependencies/lib/rpc.lib'),
os.path.join(pwd, 'dependencies/lib', pylib)]
# https://docs.microsoft.com/es-es/cpp/porting/modifying-winver-and-win32-winnt
extra_compile_args = ['/DPYTHON3X', '/DBOOST_ALL_NO_LIB', '/DBOOST_PYTHON_STATIC_LIB',
'/DBOOST_ERROR_CODE_HEADER_ONLY', '/D_WIN32_WINNT=0x0501' ]
else:
raise NotImplementedError
@ -44,6 +58,7 @@ def get_libcarla_extensions():
depends += [x for x in walk('dependencies')]
def make_extension(name, sources):
return Extension(
name,
sources=sources,

View File

@ -68,7 +68,14 @@ void export_actor() {
})
.add_property("fov", &cc::Image::GetFOV)
.add_property("raw_data", +[](cc::Image &self) {
#if PYTHON3X
//NOTE(Andrei): python37
auto *ptr = PyMemoryView_FromMemory(reinterpret_cast<char *>(self.GetData()), self.GetSize(), PyBUF_READ);
#else
//NOTE(Andrei): python2.7
auto *ptr = PyBuffer_FromMemory(self.GetData(), self.GetSize());
#endif
return object(handle<>(ptr));
})
;
@ -114,8 +121,8 @@ void export_actor() {
GILLockGuard gil_lock;
try {
call<void>(callback.ptr(), object(image));
} catch (const error_already_set &e) {
boost::python::call<void>(callback.ptr(), boost::python::object(image));
} catch (const boost::python::error_already_set &e) {
PyErr_Print();
}
});

View File

@ -1,56 +0,0 @@
@echo off
setlocal
set LOCAL_PATH=%~dp0
set FILE_N=---%~n0%~x0:
set LIB_FOLDER=%LOCAL_PATH%Util\Build\
set CARLA_FOLDER=%LOCAL_PATH%Unreal\CarlaUE4\
if not exist "%LIB_FOLDER%" (
echo %FILE_N% Creating %LIB_FOLDER% folder...
mkdir %LIB_FOLDER%
)
echo %FILE_N% Deleting intermediate folders...
for %%G in (
"%CARLA_FOLDER%Binaries",
"%CARLA_FOLDER%Intermediate",
"%CARLA_FOLDER%Plugins\Carla\Binaries",
"%CARLA_FOLDER%Plugins\Carla\Intermediate"
) do (
if exist %%G (
echo %FILE_N% Deleting: %%G
rmdir /s/q %%G
)
)
echo.
echo %FILE_N% Building carlaserver...
make clean & make
if errorlevel 1 goto compiling_error
echo.
echo %FILE_N% Launching Unreal Editor...
start %CARLA_FOLDER%CarlaUE4.uproject
:success
goto eof
:error_git
echo %FILE_N% [GIT ERROR] An error ocurred while executing the git.
echo %FILE_N% [GIT ERROR] Possible causes:
echo %FILE_N% - Make sure "git" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
:compiling_error
echo.
echo.
echo %FILE_N% Error while compiling carlaserver
goto eof
:eof
endlocal

138
Setup.bat
View File

@ -1,138 +0,0 @@
@echo off
setlocal
set LOCAL_PATH=%~dp0
set INSTALLERS_DIR=%LOCAL_PATH%Util\InstallersWin\
set INSTALLATION_DIR=%LOCAL_PATH%Util\Build\
set VERSION_FILE=%LOCAL_PATH%Util\ContentVersions.txt
set CONTENT_DIR=%LOCAL_PATH%Unreal\CarlaUE4\Content
:arg-parse
if not "%1"=="" (
if "%1"=="-j" (
set NUMBER_OF_ASYNC_JOBS=%2
shift
)
if "%1"=="--boost-toolset" (
set TOOLSET=%2
shift
)
if "%1"=="-h" (
goto help
)
if "%1"=="--help" (
goto help
)
shift
goto :arg-parse
)
if [%TOOLSET%] == [] set TOOLSET=msvc-14.1
if [%NUMBER_OF_ASYNC_JOBS%] == [] set NUMBER_OF_ASYNC_JOBS=1
echo Asynchronous jobs: %NUMBER_OF_ASYNC_JOBS%
echo Boost toolset: %TOOLSET%
echo Install directory: %INSTALLATION_DIR%
if not exist "%CONTENT_DIR%" (
echo Creating %CONTENT_DIR% folder...
mkdir %CONTENT_DIR%
)
echo.
echo Installing Protobuf...
call %INSTALLERS_DIR%install_proto.bat ^
--build-dir %INSTALLATION_DIR% ^
-j %NUMBER_OF_ASYNC_JOBS%
if not defined install_proto (
echo.
echo Failed while installing Protobuf.
goto failed
)
echo.
echo Installing Boost...
call %INSTALLERS_DIR%install_boost.bat ^
--build-dir %INSTALLATION_DIR% ^
--toolset %TOOLSET% ^
-j %NUMBER_OF_ASYNC_JOBS%
if not defined install_boost (
echo.
echo Failed while installing Boost.
goto failed
)
FOR /F "tokens=2" %%i in (%VERSION_FILE%) do (
set HASH=%%i
)
set URL=https://drive.google.com/open?id=%HASH%
FOR /F "tokens=1 delims=:" %%i in (%VERSION_FILE%) do (
set ASSETS_VERSION=%%i
)
goto success
:success
echo.
echo.
echo ###########
echo # SUCCESS #
echo ###########
echo.
echo IMPORTANT!
echo.
echo All the CARLA library dependences should be installed now.
echo (You can remove all "*-src" folders in %INSTALLATION_DIR% directory)
echo.
echo You only need the ASSET PACK with all the meshes and textures.
echo.
echo This script provides the assets for CARLA %ASSETS_VERSION%
echo If you want another asset version, search it in %VERSION_FILE%.
echo You can download the assets from here:
echo.
echo %URL%
echo.
echo Unzip it in the "%CONTENT_DIR%" folder.
echo After that, please run the "Rebuild.bat".
goto eof
:help
echo --------
echo HELP
echo --------
echo.
echo Commands:
echo -h, --help -^> Shows this dialog.
echo -j ^<N^> -^> N is the integer number of async jobs while compiling (default=1).
echo --boost-toolset [T] -^> Toolset corresponding to your compiler ^(default=^*^):
echo Visual Studio 2013 -^> msvc-12.0
echo Visual Studio 2015 -^> msvc-14.0
echo Visual Studio 2017 -^> msvc-14.1 *
goto eof
:failed
echo.
echo Ok, and error ocurred, don't panic!
echo We have different platforms where you can find some help :)
echo.
echo - First of all you can try to build CARLA manually:
echo http://carla.readthedocs.io/en/latest/how_to_build_on_windows/
echo.
echo - If the problem persists, you can ask on our Github's "Building on Windows" issue:
echo https://github.com/carla-simulator/carla/issues/21
echo.
echo - Or just use our Discord channel!
echo We'll be glad to help you there :)
echo https://discord.gg/42KJdRj
goto eof
:eof
endlocal

View File

@ -77,6 +77,12 @@ public class Carla : ModuleRules
delegate string ADelegate(string s);
private void AddBoostLibs(string LibPath)
{
string [] files = Directory.GetFiles(LibPath, "*boost*.lib");
foreach (string file in files) PublicAdditionalLibraries.Add(file);
}
private void AddCarlaServerDependency(ReadOnlyTargetRules Target)
{
string LibCarlaInstallPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "../../CarlaDependencies"));
@ -95,7 +101,17 @@ public class Carla : ModuleRules
// Link dependencies.
if (IsWindows(Target))
{
throw new NotImplementedException();
AddBoostLibs(Path.Combine(LibCarlaInstallPath, "lib"));
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("rpc")));
if (UseDebugLibs(Target))
{
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("carla_server_debug")));
}
else
{
PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("carla_server")));
}
}
else
{
@ -113,6 +129,7 @@ public class Carla : ModuleRules
// Include path.
string LibCarlaIncludePath = Path.Combine(LibCarlaInstallPath, "include");
PublicIncludePaths.Add(LibCarlaIncludePath);
PrivateIncludePaths.Add(LibCarlaIncludePath);

View File

@ -11,6 +11,23 @@
#include "GameFramework/SpectatorPawn.h"
// NOTE(Andrei): disable warning generated by undefined macros
// __GNUC__, __GNUC_MINOR__
// MSGPACK_ARCH_AMD64
// DBG, BETA, OFFICIAL_BUILD
// NTDDI_WIN7SP1
// _APISET_RTLSUPPORT_VER
// _APISET_INTERLOCKED_VER
// _APISET_SECURITYBASE_VER
// _WIN32_WINNT_WINTHRESHOLD
// NOTE(Andrei): Macros to detect which compiler is
//http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4668 4191)
#endif
#include <compiler/disable-ue4-macros.h>
#include <carla/Version.h>
#include <carla/rpc/Actor.h>
@ -22,6 +39,9 @@
#include <carla/streaming/Server.h>
#include <compiler/enable-ue4-macros.h>
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#include <vector>
// =============================================================================

View File

@ -64,19 +64,19 @@ void ACarlaVehicleController::Tick(float DeltaTime)
Super::Tick(DeltaTime);
if (IsPossessingAVehicle()) {
auto Vehicle = GetPossessedVehicle();
auto CurrentVehicle = GetPossessedVehicle();
CarlaPlayerState->UpdateTimeStamp(DeltaTime);
const FVector PreviousSpeed = CarlaPlayerState->ForwardSpeed * CarlaPlayerState->GetOrientation();
CarlaPlayerState->Transform = Vehicle->GetVehicleTransform();
CarlaPlayerState->ForwardSpeed = Vehicle->GetVehicleForwardSpeed();
CarlaPlayerState->Transform = CurrentVehicle->GetVehicleTransform();
CarlaPlayerState->ForwardSpeed = CurrentVehicle->GetVehicleForwardSpeed();
const FVector CurrentSpeed = CarlaPlayerState->ForwardSpeed * CarlaPlayerState->GetOrientation();
CarlaPlayerState->Acceleration = (CurrentSpeed - PreviousSpeed) / DeltaTime;
const auto &AutopilotControl = GetAutopilotControl();
CarlaPlayerState->Steer = AutopilotControl.Steer;
CarlaPlayerState->Throttle = AutopilotControl.Throttle;
CarlaPlayerState->Brake = AutopilotControl.Brake;
CarlaPlayerState->bHandBrake = AutopilotControl.bHandBrake;
CarlaPlayerState->CurrentGear = Vehicle->GetVehicleCurrentGear();
const auto &AutopilotCtrl = GetAutopilotControl();
CarlaPlayerState->Steer = AutopilotCtrl.Steer;
CarlaPlayerState->Throttle = AutopilotCtrl.Throttle;
CarlaPlayerState->Brake = AutopilotCtrl.Brake;
CarlaPlayerState->bHandBrake = AutopilotCtrl.bHandBrake;
CarlaPlayerState->CurrentGear = CurrentVehicle->GetVehicleCurrentGear();
CarlaPlayerState->SpeedLimit = GetSpeedLimit();
CarlaPlayerState->TrafficLightState = GetTrafficLightState();
IntersectPlayerWithRoadMap();
@ -106,18 +106,18 @@ void ACarlaVehicleController::OnCollisionEvent(
void ACarlaVehicleController::IntersectPlayerWithRoadMap()
{
auto RoadMap = GetRoadMap();
if (RoadMap == nullptr) {
auto CurrentRoadMap = GetRoadMap();
if (CurrentRoadMap == nullptr) {
UE_LOG(LogCarla, Error, TEXT("Controller doesn't have a road map!"));
return;
}
check(IsPossessingAVehicle());
auto Vehicle = GetPossessedVehicle();
auto CurrentVehicle = GetPossessedVehicle();
constexpr float ChecksPerCentimeter = 0.1f;
const auto *BoundingBox = Vehicle->GetVehicleBoundingBox();
const auto *BoundingBox = CurrentVehicle->GetVehicleBoundingBox();
check(BoundingBox != nullptr);
auto Result = RoadMap->Intersect(
auto Result = CurrentRoadMap->Intersect(
BoundingBox->GetComponentTransform(),
BoundingBox->GetUnscaledBoxExtent(),
ChecksPerCentimeter);

View File

@ -0,0 +1,193 @@
@echo off
setlocal
rem BAT script that creates the binaries 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 ============================================================================
set DOC_STRING=Build LibCarla.
set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--build] [--rebuild] [--launch] [--clean]"
set BUILD_CARLAUE4=false
set BUILD_CARLAUE4_EDITOR=false
set LAUNCH_UE4_EDITOR=false
set REMOVE_INTERMEDIATE=false
set UE_VERSION=4.19
:arg-parse
if not "%1"=="" (
if "%1"=="--rebuild" (
set REMOVE_INTERMEDIATE=true
set BUILD_CARLAUE4=true
)
if "%1"=="--build" (
set BUILD_CARLAUE4=true
)
if "%1"=="--build-editor" (
set BUILD_CARLAUE4_EDITOR=true
)
if "%1"=="--ue-version" (
set UE_VERSION=%~2
shift
)
if "%1"=="--launch-editor" (
set LAUNCH_UE4_EDITOR=true
)
if "%1"=="--clean" (
set REMOVE_INTERMEDIATE=true
)
if "%1"=="-h" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
if "%1"=="--help" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
shift
goto :arg-parse
)
if %REMOVE_INTERMEDIATE% == false (
if %LAUNCH_UE4_EDITOR% == false (
if %BUILD_CARLAUE4% == false (
if %BUILD_CARLAUE4_EDITOR% == false (
echo Nothing selected to be done.
goto :eof
)
)
)
)
rem Extract Unreal Engine root path
rem
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%UE_VERSION%"
set VALUE_NAME=InstalledDirectory
for /f "usebackq tokens=2*" %%A in (`reg query %KEY_NAME% /v %VALUE_NAME% /reg:64`) do set UE4_ROOT=%%B
if not defined UE4_ROOT goto error_unreal_no_found
rem Set the visual studio solution directory
rem
set CARLA_FOLDER=%ROOT_PATH%Unreal\CarlaUE4\
pushd "%CARLA_FOLDER%"
rem Clear binaries and intermediates generated by the build system
rem
if %REMOVE_INTERMEDIATE% == true (
echo %FILE_N% cleaning "%CARLA_FOLDER%Saved"
if exist "%CARLA_FOLDER%Saved" rmdir /S /Q "%CARLA_FOLDER%Saved"
echo %FILE_N% cleaning "%CARLA_FOLDER%Build"
if exist "%CARLA_FOLDER%Build" rmdir /S /Q "%CARLA_FOLDER%Build"
echo %FILE_N% cleaning "%CARLA_FOLDER%Binaries"
if exist "%CARLA_FOLDER%Binaries" rmdir /S /Q "%CARLA_FOLDER%Binaries"
echo %FILE_N% cleaning "%CARLA_FOLDER%Intermediate"
if exist "%CARLA_FOLDER%Intermediate" rmdir /S /Q "%CARLA_FOLDER%Intermediate"
echo %FILE_N% cleaning "%CARLA_FOLDER%Plugins\Carla\Binaries"
if exist "%CARLA_FOLDER%Plugins\Carla\Binaries" rmdir /S /Q "%CARLA_FOLDER%Plugins\Carla\Binaries"
echo %FILE_N% cleaning "%CARLA_FOLDER%Plugins\Carla\Intermediate"
if exist "%CARLA_FOLDER%Plugins\Carla\Intermediate" rmdir /S /Q "%CARLA_FOLDER%Plugins\Carla\Intermediate"
echo %FILE_N% cleaning "%CARLA_FOLDER%.vs"
if exist "%CARLA_FOLDER%CarlaUE4.sln" rmdir /S /Q "%CARLA_FOLDER%.vs"
echo %FILE_N% cleaning "%CARLA_FOLDER%CarlaUE4.sln"
if exist "%CARLA_FOLDER%CarlaUE4.sln" del /F /Q "%CARLA_FOLDER%CarlaUE4.sln" 1>nul
)
rem Generate Visual Studio solution
rem
set genVsSolution=false
if not exist "%CARLA_FOLDER%CarlaUE4.sln" set genVsSolution=true
if %REMOVE_INTERMEDIATE% == true set genVsSolution=false
if %genVsSolution% == true (
call "%UE4_ROOT%/Engine/Binaries/DotNET/UnrealBuildTool.exe" -projectfiles^
-project="%CARLA_FOLDER%CarlaUE4.uproject"^
-game -rocket -progress
call "%UE4_ROOT%/Engine/Binaries/Win64/UE4Editor.exe" "%CARLA_FOLDER%CarlaUE4.uproject"^
-targetplatform=WindowsNoEditor^
-run=cook
)
rem Build and launch Carla
rem
if %BUILD_CARLAUE4% == true (
echo %FILE_N% Builing and starting Carla...
call MsBuild.exe "%CARLA_FOLDER%CarlaUE4.sln" /m /p:configuration=Development /p:platform=Win64
if errorlevel 1 goto error_build
start "" "%CARLA_FOLDER%Binaries\Win64\CarlaUE4.exe"
)
rem Build and launch Carla Editor
rem
if %BUILD_CARLAUE4_EDITOR% == true (
echo %FILE_N% Builing and starting Carla Editor...
call MsBuild.exe "%CARLA_FOLDER%CarlaUE4.sln" /m /p:configuration="Development Editor" /p:platform=Win64
if errorlevel 1 goto error_build
call "%CARLA_FOLDER%CarlaUE4.uproject"
)
rem Launch Carla Editor
rem
if %LAUNCH_UE4_EDITOR% == true (
echo %FILE_N% Launching Unreal Editor...
call "%CARLA_FOLDER%CarlaUE4.uproject"
)
goto good_exit
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:error_build
echo.
echo %FILE_N% [ERROR] There was a problem building Carla.
echo [ERROR] Please read the screen log for more information.
goto bad_exit
:error_unreal_no_found
echo.
echo %FILE_N% [ERROR] Unreal Engine %UE_VERSION% not detected
goto bad_exit
:good_exit
endlocal
exit /b 0
:bad_exit
endlocal
exit /b %errorlevel%

View File

@ -0,0 +1,143 @@
@echo off
setlocal
rem BAT script that creates the client and the server of LibCarla (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 ============================================================================
set DOC_STRING=Build LibCarla.
set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--server] [--client] [--clean]"
set REMOVE_INTERMEDIATE=false
set BUILD_SERVER=false
set BUILD_CLIENT=false
:arg-parse
if not "%1"=="" (
if "%1"=="--rebuild" (
set REMOVE_INTERMEDIATE=true
set BUILD_SERVER=true
set BUILD_CLIENT=true
)
if "%1"=="--server" (
set BUILD_SERVER=true
)
if "%1"=="--client" (
set BUILD_CLIENT=true
)
if "%1"=="--clean" (
set REMOVE_INTERMEDIATE=true
)
if "%1"=="-h" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
if "%1"=="--help" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
shift
goto :arg-parse
)
if %REMOVE_INTERMEDIATE% == false (
if %BUILD_SERVER% == false (
if %BUILD_CLIENT% == false (
echo Nothing selected to be done.
goto :eof
)
)
)
rem Set the visual studio solution directory
rem
set LIBCARLA_VSPROJECT_PATH=%INSTALLATION_DIR%libcarla-visualstudio
set LIBCARLA_SERVER_INSTALL_PATH=%ROOT_PATH%Unreal\CarlaUE4\Plugins\Carla\CarlaDependencies
set LIBCARLA_CLIENT_INSTALL_PATH=%ROOT_PATH%PythonAPI\dependencies
if %REMOVE_INTERMEDIATE% == true (
echo %FILE_N% Cleaning "%LIBCARLA_SERVER_INSTALL_PATH%"
if exist "%LIBCARLA_SERVER_INSTALL_PATH%" rmdir /S /Q "%LIBCARLA_SERVER_INSTALL_PATH%"
echo %FILE_N% Cleaning "%LIBCARLA_CLIENT_INSTALL_PATH%"
if exist "%LIBCARLA_CLIENT_INSTALL_PATH%" rmdir /S /Q "%LIBCARLA_CLIENT_INSTALL_PATH%"
)
if not exist "%LIBCARLA_VSPROJECT_PATH%" mkdir "%LIBCARLA_VSPROJECT_PATH%"
cd "%LIBCARLA_VSPROJECT_PATH%"
rem Build libcarla server
rem
if %BUILD_SERVER% == true if not exist "%LIBCARLA_SERVER_INSTALL_PATH%" (
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Server -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP" -DCMAKE_INSTALL_PREFIX=%LIBCARLA_SERVER_INSTALL_PATH% %ROOT_PATH%
if %errorlevel% neq 0 goto error_cmake
cmake --build . --config Release --target install
if %errorlevel% neq 0 goto error_install
)
rem Build libcarla client
rem
if %BUILD_CLIENT% == true if not exist "%LIBCARLA_CLIENT_INSTALL_PATH%" (
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Client -DCMAKE_CXX_FLAGS_RELEASE="/MD /MP" -DCMAKE_INSTALL_PREFIX=%LIBCARLA_CLIENT_INSTALL_PATH% %ROOT_PATH%
if %errorlevel% neq 0 goto error_cmake
cmake --build . --config Release --target install
if %errorlevel% neq 0 goto error_install
)
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
if %BUILD_SERVER% == true echo %FILE_N% LibCarla server has been successfully installed in "%LIBCARLA_SERVER_INSTALL_PATH%"!
if %BUILD_CLIENT% == true echo %FILE_N% LibCarla client has been successfully installed in "%LIBCARLA_CLIENT_INSTALL_PATH%"!
goto good_exit
:error_cmake
echo.
echo %FILE_N% [ERROR] An error ocurred while executing the cmake.
echo [ERROR] Possible causes:
echo [ERROR] - Make sure "CMake" is installed.
echo [ERROR] - Make sure it is available on your Windows "path".
echo [ERROR] - CMake 3.9.0 or higher is required.
goto bad_exit
:error_install
echo.
echo %FILE_N% [ERROR] An error ocurred while installing using Visual Studio 15 2017 Win64.
echo [ERROR] Possible causes:
echo [ERROR] - Make sure you have Visual Studio installed.
echo [ERROR] - Make sure you have the "x64 Visual C++ Toolset" in your path.
echo [ERROR] For example using the "Visual Studio x64 Native Tools Command Prompt",
echo [ERROR] or the "vcvarsall.bat".
goto bad_exit
:good_exit
endlocal
exit /b 0
:bad_exit
endlocal
exit /b %errorlevel%

View File

@ -0,0 +1,149 @@
@echo off
setlocal
rem BAT script that creates the client python api of LibCarla (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 ============================================================================
set DOC_STRING=Build and package CARLA Python API.
set "USAGE_STRING=Usage: %FILE_N% [-h^|--help] [--rebuild] [--clean]"
set REMOVE_INTERMEDIATE=false
set BUILD_FOR_PYTHON2=false
set BUILD_FOR_PYTHON3=false
:arg-parse
if not "%1"=="" (
if "%1"=="--rebuild" (
set REMOVE_INTERMEDIATE=true
set BUILD_FOR_PYTHON2=true
set BUILD_FOR_PYTHON3=true
)
if "%1"=="--py2" (
set BUILD_FOR_PYTHON2=true
)
if "%1"=="--py3" (
set BUILD_FOR_PYTHON3=true
)
if "%1"=="--clean" (
set REMOVE_INTERMEDIATE=true
)
if "%1"=="-h" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
if "%1"=="--help" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
shift
goto :arg-parse
)
set PYTHON_LIB_PATH=%ROOT_PATH%PythonAPI\
set PYTHON_LIB_BUILD=%PYTHON_LIB_PATH%build\
set PYTHON_LIB_DEPENDENCIES=%PYTHON_LIB_PATH%dependencies\
if %REMOVE_INTERMEDIATE% == false (
if %BUILD_FOR_PYTHON3% == false (
if %BUILD_FOR_PYTHON2% == false (
echo Nothing selected to be done.
goto :eof
)
)
)
if %REMOVE_INTERMEDIATE% == true (
echo %FILE_N% Cleaning "%PYTHON_LIB_BUILD%"
if exist "%PYTHON_LIB_BUILD%" rmdir /S /Q "%PYTHON_LIB_BUILD%"
echo %FILE_N% Cleaning "%PYTHON_LIB_DEPENDENCIES%"
if exist "%PYTHON_LIB_DEPENDENCIES%" rmdir /S /Q "%PYTHON_LIB_DEPENDENCIES%"
echo %FILE_N% Cleaning "%PYTHON_LIB_PATH%dist"
if exist "%PYTHON_LIB_PATH%dist" rmdir /S /Q "%PYTHON_LIB_PATH%dist"
)
cd "%PYTHON_LIB_PATH%"
if exist "%PYTHON_LIB_PATH%dist" goto already_installed
rem ============================================================================
rem -- Check for py ------------------------------------------------------------
rem ============================================================================
where py 1>nul
if %errorlevel% neq 0 goto error_py
rem Build for Python 2
rem
if %BUILD_FOR_PYTHON2%==true (
goto py2_not_supported
)
rem Build for Python 2
rem
if %BUILD_FOR_PYTHON3%==true (
echo Building Python API for Python 3.
call py -3 setup.py bdist_egg
if %errorlevel% neq 0 goto error_build_egg
)
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
echo.
if %BUILD_FOR_PYTHON3%==true echo %FILE_N% Carla lib for python has been successfully installed in "%PYTHON_LIB_PATH%dist"!
goto good_exit
:already_installed
echo.
echo %FILE_N% [ERROR] Already installed in "%PYTHON_LIB_PATH%dist"
goto good_exit
:py2_not_supported
echo.
echo %FILE_N% [ERROR] Python 2 is not currently suported in Windows.
goto bad_exit
:error_py
echo.
echo %FILE_N% [ERROR] An error ocurred while executing the py.
echo %FILE_N% [ERROR] Possible causes:
echo %FILE_N% [ERROR] - Make sure "py" is installed.
echo %FILE_N% [ERROR] - Make sure it is available on your Windows "py".
goto bad_exit
:error_build_egg
echo.
echo %FILE_N% [ERROR] An error occurred while building the egg file.
goto bad_exit
:good_exit
endlocal
exit /b 0
:bad_exit
endlocal
exit /b %errorlevel%

230
Util/BuildTools/Package.bat Normal file
View File

@ -0,0 +1,230 @@
@echo off
setlocal enabledelayedexpansion
rem Bat script that compiles and exports the carla project (carla.org)
rem Run it through a cmd with the x64 Visual C++ Toolset enabled.
rem https://wiki.unrealengine.com/How_to_package_your_game_with_commands
set LOCAL_PATH=%~dp0
set "FILE_N=-[%~n0]:"
rem Print batch params (debug purpose)
echo %FILE_N% [Batch params]: %*
rem ==============================================================================
rem -- Parse arguments -----------------------------------------------------------
rem ==============================================================================
set DOC_STRING="Makes a packaged version of CARLA for distribution."
set USAGE_STRING="Usage: %FILE_N% [-h|--help] [--no-packaging] [--no-zip] [--clean]"
set DO_PACKAGE=true
set DO_COPY_FILES=true
set DO_TARBALL=true
set DO_CLEAN=false
set UE_VERSION=4.19
:arg-parse
if not "%1"=="" (
if "%1"=="--clean" (
set DO_CLEAN=true
set DO_TARBALL=false
set DO_PACKAGE=false
set DO_COPY_FILES=false
)
if "%1"=="--no-zip" (
set DO_TARBALL=false
)
if "%1"=="--no-packaging" (
set DO_PACKAGE=false
)
if "%1"=="--ue-version" (
set UE_VERSION=%~2
shift
)
if "%1"=="-h" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
if "%1"=="--help" (
echo %DOC_STRING%
echo %USAGE_STRING%
GOTO :eof
)
shift
goto :arg-parse
)
rem Extract Unreal Engine root path
rem
set KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\EpicGames\Unreal Engine\%UE_VERSION%"
set VALUE_NAME=InstalledDirectory
for /f "usebackq tokens=2*" %%A in (`reg query %KEY_NAME% /v %VALUE_NAME% /reg:64`) do set UE4_ROOT=%%B
if not defined UE4_ROOT goto error_unreal_no_found
rem Set packaging paths
rem
for /f %%i in ('git describe --tags --dirty --always') do set CARLA_VERSION=%%i
if not defined CARLA_VERSION goto error_carla_version
set BUILD_FOLDER=%INSTALLATION_DIR%UE4Carla/%CARLA_VERSION%/
if not exist "%BUILD_FOLDER%" mkdir "%BUILD_FOLDER%"
set DESTINATION_ZIP="%BUILD_FOLDER%../CARLA_%CARLA_VERSION%.zip"
set SOURCE=%BUILD_FOLDER%WindowsNoEditor/
rem ============================================================================
rem -- Create Carla package ----------------------------------------------------
rem ============================================================================
if %DO_PACKAGE%==true (
call "%UE4_ROOT%\Engine\Build\BatchFiles\Build.bat"^
CarlaUE4Editor^
Win64^
Development^
-WaitMutex^
-FromMsBuild^
"%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
if errorlevel 1 goto error_build_editor
call "%UE4_ROOT%\Engine\Build\BatchFiles\Build.bat"^
CarlaUE4^
Win64^
Development^
-WaitMutex^
-FromMsBuild^
"%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"
if errorlevel 1 goto error_build
call "%UE4_ROOT%\Engine\Build\BatchFiles\RunUAT.bat"^
BuildCookRun^
-nocompileeditor^
-TargetPlatform=Win64^
-Platform=Win64^
-installed^
-nop4^
-project="%ROOT_PATH%Unreal/CarlaUE4/CarlaUE4.uproject"^
-cook^
-stage^
-build^
-archive^
-archivedirectory="%BUILD_FOLDER%"^
-package^
-clientconfig=Development
if errorlevel 1 goto error_runUAT
)
rem ==============================================================================
rem -- Adding extra files to package ---------------------------------------------
rem ==============================================================================
if %DO_COPY_FILES%==true (
echo "%FILE_N% Adding extra files to package..."
set XCOPY_FROM=%ROOT_PATH:/=\%
set XCOPY_TO=%SOURCE:/=\%
echo f | xcopy /y "!XCOPY_FROM!LICENSE" "!XCOPY_TO!LICENSE"
echo f | xcopy /y "!XCOPY_FROM!CHANGELOG.md" "!XCOPY_TO!CHANGELOG"
echo f | xcopy /y "!XCOPY_FROM!Docs\release_readme.md" "!XCOPY_TO!README"
echo f | xcopy /y "!XCOPY_FROM!Util\Docker\Release.Dockerfile" "!XCOPY_TO!Dockerfile"
echo f | xcopy /y "!XCOPY_FROM!PythonAPI\dist\*.egg" "!XCOPY_TO!PythonAPI\"
echo f | xcopy /y "!XCOPY_FROM!PythonAPI\example.py" "!XCOPY_TO!example.py"
echo f | xcopy /y "!XCOPY_FROM!PythonAPI\manual_control.py" "!XCOPY_TO!manual_control.py"
echo f | xcopy /y "!XCOPY_FROM!PythonAPI\vehicle_gallery.py" "!XCOPY_TO!vehicle_gallery.py"
)
rem ==============================================================================
rem -- Zip the project -----------------------------------------------------------
rem ==============================================================================
if %DO_TARBALL%==true (
echo "%FILE_N% Building package..."
set DST_ZIP=%DESTINATION_ZIP:/=\%
set SRC_PATH=%SOURCE:/=\%
if exist "!SRC_PATH!Manifest_NonUFSFiles_Win64.txt" del /Q "!SRC_PATH!Manifest_NonUFSFiles_Win64.txt"
if exist "!SRC_PATH!Manifest_DebugFiles_Win64.txt" del /Q "!SRC_PATH!Manifest_DebugFiles_Win64.txt"
if exist "!SRC_PATH!Manifest_UFSFiles_Win64.txt" del /Q "!SRC_PATH!Manifest_UFSFiles_Win64.txt"
if exist "!SRC_PATH!CarlaUE4/Saved" rmdir /S /Q "!SRC_PATH!CarlaUE4/Saved"
if exist "!SRC_PATH!Engine/Saved" rmdir /S /Q "!SRC_PATH!Engine/Saved"
pushd "!SRC_PATH!"
rem https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-6
powershell -command "& { Compress-Archive -Path * -CompressionLevel Fastest -DestinationPath '!DST_ZIP!' }"
popd
)
rem ==============================================================================
rem -- Remove intermediate files -------------------------------------------------
rem ==============================================================================
if %DO_CLEAN%==true (
echo %FILE_N% Removing intermediate build.
rmdir /S /Q "%BUILD_FOLDER%"
goto :eof
)
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
echo.
if %DO_PACKAGE%==true echo %FILE_N% Carla project successful exported to "%CARLA_OUTPUT_PATH%"!
if %DO_TARBALL%==true echo %FILE_N% Compress carla project exported to "%DESTINATION_ZIP%"!
goto good_exit
:error_carla_version
echo.
echo %FILE_N% [ERROR] Carla Version is not set
goto bad_exit
:error_unreal_no_found
echo.
echo %FILE_N% [ERROR] Unreal Engine %UE_VERSION% not detected
goto bad_exit
:error_build_editor
echo.
echo %FILE_N% [ERROR] There was a problem while building the CarlaUE4Editor.
echo [ERROR] Please read the screen log for more information.
goto bad_exit
:error_build
echo.
echo %FILE_N% [ERROR] There was a problem while building the CarlaUE4.
echo [ERROR] Please read the screen log for more information.
goto bad_exit
:error_runUAT
echo.
echo %FILE_N% [ERROR] There was a problem while packaging Unreal project.
echo [ERROR] Please read the screen log for more information.
goto bad_exit
:good_exit
endlocal
exit /b 0
:bad_exit
endlocal
exit /b 1

237
Util/BuildTools/Setup.bat Normal file
View File

@ -0,0 +1,237 @@
@echo off
setlocal
rem BAT script that downloads and generates
rem rpclib, gtest and boost libraries 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 -- Check for compiler ------------------------------------------------------
rem ============================================================================
where cl 1>nul
if %errorlevel% neq 0 goto error_cl
rem TODO: check for x64 and not x86 or x64_x86
rem ============================================================================
rem -- Parse arguments ---------------------------------------------------------
rem ============================================================================
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 TOOLSET=msvc-14.1
set NUMBER_OF_ASYNC_JOBS=%NUMBER_OF_PROCESSORS%
:arg-parse
if not "%1"=="" (
if "%1"=="-j" (
set NUMBER_OF_ASYNC_JOBS=%2
shift
)
if "%1"=="--boost-toolset" (
set TOOLSET=%2
shift
)
if "%1"=="-h" (
goto help
)
if "%1"=="--help" (
goto help
)
shift
goto :arg-parse
)
rem ============================================================================
rem -- Basic info and setup ----------------------------------------------------
rem ============================================================================
echo %FILE_N% Asynchronous jobs: %NUMBER_OF_ASYNC_JOBS%
echo %FILE_N% Boost toolset: %TOOLSET%
echo %FILE_N% Install directory: "%INSTALLATION_DIR%"
if not exist "%CONTENT_DIR%" (
echo %FILE_N% Creating "%CONTENT_DIR%" folder...
mkdir "%CONTENT_DIR%"
)
if not exist "%INSTALLATION_DIR%" (
echo %FILE_N% Creating "%INSTALLATION_DIR%" folder...
mkdir "%INSTALLATION_DIR%"
)
rem ============================================================================
rem -- Download and install rpclib ---------------------------------------------
rem ============================================================================
echo %FILE_N% Installing rpclib...
call "%INSTALLERS_DIR%install_rpclib.bat"^
--build-dir "%INSTALLATION_DIR%"
if %errorlevel% neq 0 goto failed
if not defined install_rpclib (
echo %FILE_N% Failed while installing rpclib.
goto failed
)
rem ============================================================================
rem -- Download and install Google Test ----------------------------------------
rem ============================================================================
echo %FILE_N% Installing Google Test...
call "%INSTALLERS_DIR%install_gtest.bat"^
--build-dir "%INSTALLATION_DIR%"
if %errorlevel% neq 0 goto failed
if not defined install_gtest (
echo %FILE_N% Failed while installing Google Test.
goto failed
)
rem ============================================================================
rem -- Download and install Boost ----------------------------------------------
rem ============================================================================
echo %FILE_N% Installing Boost...
call "%INSTALLERS_DIR%install_boost.bat"^
--build-dir "%INSTALLATION_DIR%"^
--toolset %TOOLSET%^
-j %NUMBER_OF_ASYNC_JOBS%
if %errorlevel% neq 0 goto failed
if not defined install_boost (
echo %FILE_N% Failed while installing Boost.
goto failed
)
rem ============================================================================
rem -- Assets download URL -----------------------------------------------------
rem ============================================================================
FOR /F "tokens=2" %%i in (%VERSION_FILE%) do (
set HASH=%%i
)
set URL=https://drive.google.com/open?id=%HASH%
FOR /F "tokens=1 delims=:" %%i in (%VERSION_FILE%) do (
set ASSETS_VERSION=%%i
)
rem ============================================================================
rem -- Generate CMake ----------------------------------------------------------
rem ============================================================================
for /f %%i in ('git describe --tags --dirty --always') do set carla_version=%%i
set CMAKE_INSTALLATION_DIR=%INSTALLATION_DIR:\=/%
>"%INSTALLATION_DIR%CMakeLists.txt.in" echo # Automatically generated by Setup.bat
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo set(CARLA_VERSION %carla_version%)
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo.
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo if (WIN32)
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo add_definitions(-D_WIN32_WINNT=0x0501)
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo STRING (REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo endif()
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo.
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo.
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo set(BOOST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%boost-install/include")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo set(BOOST_LIB_PATH "%CMAKE_INSTALLATION_DIR%boost-install/lib")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo.
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo set(RPCLIB_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/include")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo set(RPCLIB_LIB_PATH "%CMAKE_INSTALLATION_DIR%rpclib-install/lib")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo.
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo if (CMAKE_BUILD_TYPE STREQUAL "Server")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo # Specific libraries for server
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo set(GTEST_INCLUDE_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/include")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo set(GTEST_LIB_PATH "%CMAKE_INSTALLATION_DIR%gtest-install/lib")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo elseif (CMAKE_BUILD_TYPE STREQUAL "Client")
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo # Specific libraries for client
>>"%INSTALLATION_DIR%CMakeLists.txt.in" echo endif ()
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
echo %FILE_N%
echo ###########
echo # SUCCESS #
echo ###########
echo.
echo IMPORTANT!
echo.
echo All the CARLA library dependences should be installed now.
echo (You can remove all "*-src" folders in %INSTALLATION_DIR% directory)
echo.
echo You only need the ASSET PACK with all the meshes and textures.
echo.
echo This script provides the assets for CARLA %ASSETS_VERSION%
echo You can download the assets from here:
echo.
echo %URL%
echo.
echo Unzip it in the "%CONTENT_DIR%" folder.
echo If you want another version, search it in %VERSION_FILE%.
echo.
goto good_exit
:help
echo Download and compiles all the necessary libraries to build CARLA.
echo.
echo Commands:
echo -h, --help -^> Shows this dialog.
echo -j ^<N^> -^> N is the integer number of async jobs while compiling (default=1).
echo --boost-toolset [T] -^> Toolset corresponding to your compiler ^(default=^*^):
echo Visual Studio 2013 -^> msvc-12.0
echo Visual Studio 2015 -^> msvc-14.0
echo Visual Studio 2017 -^> msvc-14.1 *
goto good_exit
:error_cl
echo.
echo %FILE_N% [ERROR] Can't find Visual Studio compiler (cl.exe).
echo [ERROR] Possible causes:
echo [ERROR] - Make sure you use x64 (not x64_x86!)
echo [ERROR] - You are not using "Visual Studio x64 Native Tools Command Prompt".
goto failed
:failed
echo.
echo %FILE_N%
echo Ok, and error ocurred, don't panic!
echo We have different platforms where you can find some help :)
echo.
echo - Make sure you have read the documentation:
echo http://carla.readthedocs.io/en/latest/how_to_build_on_windows/
echo.
echo - If the problem persists, you can ask on our Github's "Building on Windows" issue:
echo https://github.com/carla-simulator/carla/issues/21
echo.
echo - Or just use our Discord channel!
echo We'll be glad to help you there :)
echo https://discord.gg/42KJdRj
endlocal
exit /b %errorlevel%
:good_exit
endlocal
exit /b 0

View File

@ -1,2 +1,57 @@
default:
ARGS=--all
default: help
# root of the project (makefile directory)
export ROOT_PATH=$(CURDIR)/
# dependecy install/build directory (rpclib, gtest, boost)
export INSTALLATION_DIR=$(ROOT_PATH)Build/
help:
@type "${CARLA_BUILD_TOOLS_FOLDER}\Windows.mk.help"
launch: LibCarla
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --build --ue-version 4.19
launch-editor: LibCarla
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --launch-editor
package: PythonAPI
@"${CARLA_BUILD_TOOLS_FOLDER}/Package.bat" --ue-version 4.19
docs:
@doxygen
@echo "Documentation index at ./Doxygen/html/index.html"
clean:
@"${CARLA_BUILD_TOOLS_FOLDER}/Package.bat" --clean --ue-version 4.19
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --clean
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat" --clean
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat" --clean
rebuild: setup
@${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat" --rebuild
@${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat" --rebuild
@${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --rebuild --ue-version 4.19
check: PythonAPI
@echo "Not implemented!"
benchmark: LibCarla
@echo "Not implemented!"
CarlaUE4Editor: LibCarla
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.bat" --build-editor --ue-version 4.19
.PHONY: PythonAPI
PythonAPI: LibCarla
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.bat" --py3
.PHONY: LibCarla
LibCarla: setup
@"${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.bat" --server --client
setup:
@"${CARLA_BUILD_TOOLS_FOLDER}/Setup.bat" --boost-toolset msvc-14.1

View File

@ -0,0 +1,61 @@
Welcome to CARLA Simulator!
===========================
This Makefile will help you building the different CARLA utilities.
Use the following commands:
help:
Display this help message.
launch:
Compile CarlaUE4 project and launch it in Unreal Engine's Editor.
launch-editor:
Launch CarlaUE4 project in Unreal Engine's Editor
package:
Makes a packaged version of CARLA ready for distribution.
docs:
Build CARLA Doxygen documentation.
clean:
Remove intermediate build files.
rebuild:
Remove intermediate build files and rebuild the whole project.
There are also some lower level commands for building individual modules helpful
for developers:
check:
Run unit test suites for LibCarla and PythonAPI.
benchmark:
Run the benchmark tests for LibCarla.
CarlaUE4Editor:
Build CarlaUE4 project, but do not launch the editor.
PythonAPI:
Build and package the Python API module for Python 2 and 3.
LibCarla:
Build the LibCarla library, both "Server" and "Client" configurations.
setup:
Run the setup step only.

View File

@ -1,37 +1,48 @@
@echo off
setlocal
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.
setlocal
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
set NUMBER_OF_ASYNC_JOBS=%~2
shift
)
if "%1"=="--build-dir" (
set BUILD_DIR=%2
set BUILD_DIR=%~2
shift
)
if "%1"=="--toolset" (
set B_TOOLSET=%2
set B_TOOLSET=%~2
shift
)
shift
goto :arg-parse
)
rem If not set set the build dir to the current dir
if [%BUILD_DIR%] == [] set BUILD_DIR=.
rem If not definned use Visual Studio 2017 as tool set
if [%B_TOOLSET%] == [] set B_TOOLSET=msvc-14.1
if [%NUMBER_OF_ASYNC_JOBS%] == [] set NUMBER_OF_ASYNC_JOBS=1
set LOCAL_PATH=%~dp0
set FILE_N=---%~n0%~x0:
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%
set B_VERSION=boost-1.64.0
set B_VERSION=boost-1.67.0
set B_SRC=boost-src
set B_SRC_DIR=%BUILD_DIR%%B_SRC%
set B_INSTALL=boost-install
@ -39,96 +50,90 @@ set B_INSTALL_DIR=%BUILD_DIR%%B_INSTALL%
set B_LIB_DIR=%B_INSTALL_DIR%\lib
if exist "%B_INSTALL_DIR%" (
goto already_build
goto already_build
)
if not exist "%B_SRC_DIR%" (
echo %FILE_N% Cloning Boost - version "%B_VERSION%"...
echo.
call git clone --depth=1 -b %B_VERSION%^
--recurse-submodules -j8^
https://github.com/boostorg/boost.git %B_SRC_DIR%
if errorlevel 1 goto error_git
echo.
echo %FILE_N% Cloning Boost - version "%B_VERSION%"...
call git clone --depth=1 -b %B_VERSION% --recurse-submodules -j%NUMBER_OF_ASYNC_JOBS% https://github.com/boostorg/boost.git %B_SRC_DIR%
if %errorlevel% neq 0 goto error_git
) else (
echo %FILE_N% Not cloning boost because already exists a folder called "%B_SRC%".
echo %FILE_N% Not cloning boost because already exists a folder called "%B_SRC%".
)
cd %B_SRC_DIR%
cd "%B_SRC_DIR%"
if not exist "b2.exe" (
echo %FILE_N% Generating build...
call bootstrap.bat
echo %FILE_N% Generating build...
call bootstrap.bat
)
if errorlevel 1 goto error_bootstrap
if %errorlevel% neq 0 goto error_bootstrap
echo %FILE_N% Packing headers...
b2 headers
b2 headers link=static
echo %FILE_N% Building...
b2 -j8^
headers^
--layout=versioned^
--with-system^
--with-date_time^
--build-dir=./build^
architecture=x86^
address-model=64^
toolset=%B_TOOLSET%^
variant=release^
link=static^
threading=multi^
--prefix=%B_INSTALL_DIR%^
--libdir=%B_LIB_DIR%^
--includedir=%B_INSTALL_DIR%^
install
if errorlevel 1 goto error_install
cd %BUILD_DIR%
rem Remove the downloaded protobuf source because is no more needed
rem if you want to keep the source just delete the following command.
rem @rd /s /q %B_SRC_DIR%
b2 -j%NUMBER_OF_ASYNC_JOBS%^
headers^
--layout=versioned^
--build-dir=./build^
architecture=x86^
address-model=64^
toolset=%B_TOOLSET%^
variant=release^
link=static^
runtime-link=shared^
threading=multi^
--prefix="%B_INSTALL_DIR%"^
--libdir="%B_LIB_DIR%"^
--includedir="%B_INSTALL_DIR%"^
install
if %errorlevel% neq 0 goto error_install
for /d %%i in ("%B_INSTALL_DIR%\boost-*") do rename "%%i" include
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
echo.
echo %FILE_N% Boost has been successfully installed in %B_INSTALL_DIR%!
goto good_exit
echo.
echo %FILE_N% Boost has been successfully installed in "%B_INSTALL_DIR%"!
goto good_exit
:already_build
echo %FILE_N% A Boost installation already exists.
echo %FILE_N% Delete "%B_INSTALL_DIR%" if you want to force a rebuild.
goto good_exit
echo %FILE_N% A Boost installation already exists.
echo %FILE_N% Delete "%B_INSTALL_DIR%" if you want to force a rebuild.
goto good_exit
:error_git
echo.
echo %FILE_N% [GIT ERROR] An error ocurred while executing the git.
echo %FILE_N% [GIT ERROR] Possible causes:
echo %FILE_N% - Make sure "git" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
echo.
echo %FILE_N% [GIT ERROR] An error ocurred while executing the git.
echo %FILE_N% [GIT ERROR] Possible causes:
echo %FILE_N% - Make sure "git" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
:error_bootstrap
echo.
echo %FILE_N% [BOOTSTRAP ERROR] An error ocurred while executing "bootstrap.bat".
goto bad_exit
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
echo.
echo %FILE_N% [B2 ERROR] An error ocurred while installing using "b2.exe".
goto bad_exit
:good_exit
echo %FILE_N% Exiting...
endlocal
set install_boost=done
goto:EOF
echo %FILE_N% Exiting...
endlocal
set install_boost=done
exit /b 0
:bad_exit
if exist "%B_INSTALL_DIR%" rd /s /q "B_INSTALL_DIR"
echo %FILE_N% Exiting with error...
endlocal
goto:EOF
if exist "%B_INSTALL_DIR%" rd /s /q "%B_INSTALL_DIR%"
echo %FILE_N% Exiting with error...
endlocal
exit /b %errorlevel%

View File

@ -0,0 +1,134 @@
@echo off
setlocal
rem BAT script that downloads and installs a ready to use
rem Google Test 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 ============================================================================
set BUILD_DIR=.
set DEL_SRC=false
:arg-parse
if not "%1"=="" (
if "%1"=="--build-dir" (
set BUILD_DIR=%~2
shift
)
if "%1"=="--delete-src" (
set DEL_SRC=true
)
shift
goto :arg-parse
)
set GT_VERSION=release-1.8.0
set GT_SRC=gtest-src
set GT_SRC_DIR=%BUILD_DIR%%GT_SRC%\
set GT_INSTALL=gtest-install
set GT_INSTALL_DIR=%BUILD_DIR%%GT_INSTALL%\
set GT_BUILD_DIR=%GT_SRC_DIR%build
if exist "%GT_INSTALL_DIR%" (
goto already_build
)
if not exist "%GT_SRC_DIR%" (
echo %FILE_N% Cloning Google Test - version "%GT_VERSION%"...
call git clone --depth=1 -b %GT_VERSION% https://github.com/google/googletest.git %GT_SRC_DIR%
if %errorlevel% neq 0 goto error_git
) else (
echo %FILE_N% Not cloning Google Test because already exists a folder called "%GT_SRC%".
)
if not exist "%GT_BUILD_DIR%" (
echo %FILE_N% Creating "%GT_BUILD_DIR%"
mkdir "%GT_BUILD_DIR%"
)
cd "%GT_BUILD_DIR%"
echo %FILE_N% Generating build...
cmake .. -G "Visual Studio 15 2017 Win64"^
-DCMAKE_BUILD_TYPE=Release^
-DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^
-DCMAKE_INSTALL_PREFIX=%GT_INSTALL_DIR%^
-DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING^
%GT_SRC_DIR%
if %errorlevel% neq 0 goto error_cmake
echo %FILE_N% Building...
cmake --build . --config Release --target install
if errorlevel neq 0 goto error_install
rem Remove the downloaded Google Test source because is no more needed
if %DEL_SRC% == true (
rd /s /q "%GT_SRC_DIR%"
)
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
echo.
echo %FILE_N% Google Test has been successfully installed in "%GT_INSTALL_DIR%"!
goto good_exit
:already_build
echo %FILE_N% A Google Test installation already exists.
echo %FILE_N% Delete "%GT_INSTALL_DIR%" if you want to force a rebuild.
goto good_exit
:error_git
echo.
echo %FILE_N% [GIT ERROR] An error ocurred while executing the git.
echo %FILE_N% [GIT ERROR] Possible causes:
echo %FILE_N% - Make sure "git" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
:error_cmake
echo.
echo %FILE_N% [CMAKE ERROR] An error ocurred while executing the cmake.
echo %FILE_N% [CMAKE ERROR] Possible causes:
echo %FILE_N% - Make sure "CMake" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
:error_install
echo.
echo %FILE_N% [Visual Studio 15 2017 Win64 ERROR] An error ocurred while installing using Visual Studio 15 2017 Win64.
echo %FILE_N% [Visual Studio 15 2017 Win64 ERROR] 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
:good_exit
echo %FILE_N% Exiting...
endlocal
set install_gtest=done
exit /b 0
:bad_exit
if exist "%GT_INSTALL_DIR%" rd /s /q "%GT_INSTALL_DIR%"
echo %FILE_N% Exiting with error...
endlocal
exit /b %errorlevel%

View File

@ -1,11 +1,17 @@
@echo off
setlocal
rem BAT script that downloads and installs a ready to use
rem protobuf build for CARLA (carla.org).
rem Just putit in `Util/Build` and run it through a cmd
rem Just putit in `Util/Build` and run it through a cmd
rem with the x64 Visual C++ Toolset enabled.
setlocal
rem Print batch params (debug purpose)
echo %FILE_N% [Batch params]: %*
rem ============================================================================
rem -- Parse arguments ---------------------------------------------------------
rem ============================================================================
:arg-parse
if not "%1"=="" (

View File

@ -0,0 +1,135 @@
@echo off
setlocal
rem BAT script that downloads and installs a ready to use
rem rpclib 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 ============================================================================
set BUILD_DIR=.
set DEL_SRC=false
:arg-parse
if not "%1"=="" (
if "%1"=="--build-dir" (
set BUILD_DIR=%~2
shift
)
if "%1"=="--delete-src" (
set DEL_SRC=true
)
shift
goto :arg-parse
)
set RPC_VERSION=v2.2.1
set RPC_SRC=rpclib-src
set RPC_SRC_DIR=%BUILD_DIR%%RPC_SRC%\
set RPC_INSTALL=rpclib-install
set RPC_INSTALL_DIR=%BUILD_DIR%%RPC_INSTALL%\
set RPC_BUILD_DIR=%RPC_SRC_DIR%build
if exist "%RPC_INSTALL_DIR%" (
goto already_build
)
if not exist "%RPC_SRC_DIR%" (
echo %FILE_N% Cloning rpclib - version "%RPC_VERSION%"...
call git clone --depth=1 -b %RPC_VERSION% https://github.com/rpclib/rpclib.git %RPC_SRC_DIR%
if %errorlevel% neq 0 goto error_git
) else (
echo %FILE_N% Not cloning rpclib because already exists a folder called "%RPC_SRC%".
)
if not exist "%RPC_BUILD_DIR%" (
echo %FILE_N% Creating "%RPC_BUILD_DIR%"
mkdir "%RPC_BUILD_DIR%"
)
cd "%RPC_BUILD_DIR%"
echo %FILE_N% Generating build...
cmake .. -G "Visual Studio 15 2017 Win64"^
-DCMAKE_BUILD_TYPE=Release^
-RPCLIB_BUILD_EXAMPLES=OFF^
-DCMAKE_CXX_FLAGS_RELEASE="/MD /MP"^
-DCMAKE_INSTALL_PREFIX=%RPC_INSTALL_DIR%^
%RPC_SRC_DIR%
if %errorlevel% neq 0 goto error_cmake
echo %FILE_N% Building...
cmake --build . --config Release --target install
if %errorlevel% neq 0 goto error_install
rem Remove the downloaded rpclib source because is no more needed
if %DEL_SRC% == true (
rd /s /q "%RPC_SRC_DIR%"
)
goto success
rem ============================================================================
rem -- Messages and Errors -----------------------------------------------------
rem ============================================================================
:success
echo.
echo %FILE_N% rpclib has been successfully installed in "%RPC_INSTALL_DIR%"!
goto good_exit
:already_build
echo %FILE_N% A rpclib installation already exists.
echo %FILE_N% Delete "%RPC_INSTALL_DIR%" if you want to force a rebuild.
goto good_exit
:error_git
echo.
echo %FILE_N% [GIT ERROR] An error ocurred while executing the git.
echo %FILE_N% [GIT ERROR] Possible causes:
echo %FILE_N% - Make sure "git" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
goto bad_exit
:error_cmake
echo.
echo %FILE_N% [CMAKE ERROR] An error ocurred while executing the cmake.
echo %FILE_N% [CMAKE ERROR] Possible causes:
echo %FILE_N% - Make sure "CMake" is installed.
echo %FILE_N% - Make sure it is available on your Windows "path".
echo %FILE_N% - CMake 3.9.0 or higher is required.
goto bad_exit
:error_install
echo.
echo %FILE_N% [Visual Studio 15 2017 Win64 ERROR] An error ocurred while installing using Visual Studio 15 2017 Win64.
echo %FILE_N% [Visual Studio 15 2017 Win64 ERROR] 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
:good_exit
echo %FILE_N% Exiting...
endlocal
set install_rpclib=done
exit /b 0
:bad_exit
if exist "%RPC_INSTALL_DIR%" rd /s /q "%RPC_INSTALL_DIR%"
echo %FILE_N% Exiting with error...
endlocal
exit /b %errorlevel%