diff --git a/.gitignore b/.gitignore index eeb82282e..d025fb378 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,38 @@ +Build Dist Doxygen PythonClient/dist Util/Build +Install *.VC.db *.VC.opendb +*.a *.egg-info *.kdev4 *.log *.pb.cc *.pb.h +*.o *.pid *.pri *.pro *.py[cod] *.sln +*.so *.stackdump *.sublime-workspace *.workspace *CodeCompletionFolders.txt *CodeLitePreProcessor.txt .codelite +.gdb_history .tags* .vs __pycache__ _benchmarks_results _images* -_out +_out* _site core +profiler.csv diff --git a/.travis.yml b/.travis.yml index 34a70fe9c..3a2830407 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,14 +17,15 @@ script: matrix: include: - - env: TEST="CppCheck" - install: true - addons: - apt: - packages: - - cppcheck - script: - - cppcheck . -iBuild -i.pb.cc --error-exitcode=1 --enable=warning --inline-suppr --quiet + # CppCheck does not support C++17. + # - env: TEST="CppCheck" + # install: true + # addons: + # apt: + # packages: + # - cppcheck + # script: + # - cppcheck . -iBuild -i.pb.cc --error-exitcode=1 --enable=warning --inline-suppr --quiet - env: TEST="MkDocs" install: diff --git a/CARLA.sublime-project b/CARLA.sublime-project deleted file mode 100644 index 2eab9615d..000000000 --- a/CARLA.sublime-project +++ /dev/null @@ -1,149 +0,0 @@ -{ - "folders": - [ - { - "path": ".", - "folder_exclude_patterns": - [ - ".clang", - ".codelite", - ".kdev4", - ".vs", - ".vscode", - "Binaries", - "Build", - "DerivedDataCache", - "Dist", - "Doxygen", - "Intermediate", - "Saved", - "Unreal/CarlaUE4/Content*", - "__pycache__", - "_site" - ], - "file_exclude_patterns": - [ - "*.VC.db", - "*.VC.opendb", - "*.kdev4", - "*.pri", - "*.pro", - "*.py[cod]", - "*.sln", - "*.stackdump", - "*.sublime-workspace", - "*.uasset", - "*.umap", - "*.workspace", - "*CodeCompletionFolders.txt", - "*CodeLitePreProcessor.txt", - ".tags*", - "core" - ] - } - ], - "settings": - { - "ensure_newline_at_eof_on_save": true, - "tab_size": 2, - "translate_tabs_to_spaces": true, - "trim_trailing_white_space_on_save": true - }, - "build_systems": - [ - { - "name": "CARLA - Pylint", - "working_dir": "${project_path}", - "file_regex": "^\\[([^:]*):([0-9]+):?([0-9]+)?\\]:? (.*)$", - "shell_cmd": "pylint --disable=R,C --rcfile=PythonClient/.pylintrc PythonClient/carla PythonClient/*.py --msg-template='[{path}:{line:3d}:{column}]: {msg_id} {msg}'" - }, - { - "name": "CARLA - CppCheck", - "working_dir": "${project_path}", - "file_regex": "^\\[([^:]*):([0-9]+):?([0-9]+)?\\]:? (.*)$", - "shell_cmd": "cppcheck . -iBuild -i.pb.cc --error-exitcode=0 --enable=warning --quiet" - }, - { - "name": "CARLA - Rebuild script", - "working_dir": "${project_path}", - "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", - "linux": - { - "shell_cmd": "./Rebuild.sh" - }, - "windows": - { - "shell_cmd": "start Rebuild.bat" - } - }, - { - "name": "CARLA - make CarlaUE4", - "working_dir": "${project_path}/Unreal/CarlaUE4", - "file_regex": "Unreal\\/CarlaUE4\\/([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", - "syntax": "Packages/Makefile/Make Output.sublime-syntax", - "linux": - { - "shell_cmd": "make CarlaUE4" - } - }, - { - "name": "CARLA - make CarlaUE4 ARGS=-clean", - "working_dir": "${project_path}/Unreal/CarlaUE4", - "file_regex": "Unreal\\/CarlaUE4\\/([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", - "syntax": "Packages/Makefile/Make Output.sublime-syntax", - "linux": - { - "shell_cmd": "make CarlaUE4 ARGS=-clean" - } - }, - { - "name": "CARLA - make CarlaUE4Editor", - "working_dir": "${project_path}/Unreal/CarlaUE4", - "file_regex": "Unreal\\/CarlaUE4\\/([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", - "syntax": "Packages/Makefile/Make Output.sublime-syntax", - "linux": - { - "shell_cmd": "make CarlaUE4Editor" - } - }, - { - "name": "CARLA - make CarlaUE4Editor ARGS=-clean", - "working_dir": "${project_path}/Unreal/CarlaUE4", - "file_regex": "Unreal\\/CarlaUE4\\/([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", - "syntax": "Packages/Makefile/Make Output.sublime-syntax", - "linux": - { - "shell_cmd": "make CarlaUE4Editor ARGS=-clean" - } - }, - { - "name": "CARLA - make CarlaServer", - "working_dir": "${project_path}", - "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", - "syntax": "Packages/Makefile/Make Output.sublime-syntax", - "linux": - { - "shell_cmd": "make" - } - }, - { - "name": "CARLA - check CarlaServer", - "working_dir": "${project_path}", - "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", - "syntax": "Packages/Makefile/Make Output.sublime-syntax", - "linux": - { - "shell_cmd": "make check" - } - }, - { - "name": "CARLA - clean CarlaServer", - "working_dir": "${project_path}", - "syntax": "Packages/Makefile/Make Output.sublime-syntax", - "linux": - { - "shell_cmd": "make clean" - } - } - ] -} diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..4721d53f3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.9.0) +project(CARLA) + +include("Build/CMakeLists.txt.in") + +add_subdirectory("LibCarla/cmake") diff --git a/Docs/build_system.md b/Docs/build_system.md new file mode 100644 index 000000000..a79226d23 --- /dev/null +++ b/Docs/build_system.md @@ -0,0 +1,110 @@ +

Build system

+ +> _This document is a work in progress, only the Linux build system is taken into account here._ + +The most challenging part of the setup is to compile all the dependencies and +modules to be compatible with a) Unreal Engine in the server-side, and b) Python +in the client-side. + +The goal is to be able to call Unreal Engine's functions from a separate Python +process. + +![modules](img/modules.png) + +In Linux, we compile CARLA and all the dependencies with clang-5.0 and C++17 +standard. We however link against different runtime C++ libraries depending on +where the code going to be used, since all the code that is going to be linked +with Unreal Engine needs to be compiled using `libc++`. + +#### Setup + +Command + +```sh +make setup +``` + +Get and compile dependencies + + * llvm-5.0 (libc++ and libc++abi) + * rpclib-2.2.1 (twice, with libstdc++ and libc++) + * boost-1.67 (headers only) + * googletest-1.8.0 (with libc++) + +#### LibCarla + +Compiled with CMake (minimum version required CMake 3.9). + +Command + +```sh +make LibCarla +``` + +Two configurations: + +| | Server | Client | +|-----------------|--------------|-----------| +| **Unit tests** | yes | no | +| **Requires** | rpclib, gtest, boost | rpclib, boost +| **std runtime** | LLVM's `libc++` | Default `libstdc++` | +| **Output** | headers and test exes | `libcarla_client.a` | +| **Required by** | Carla plugin | PythonAPI | + +#### CarlaUE4 and Carla plugin + +Both compiled at the same step with Unreal Engine 4.19 build tool. They require +the `UE4_ROOT` environment variable set. + +Command + +```sh +make CarlaUE4Editor +``` + +To launch Unreal Engine's Editor run + +```sh +make launch +``` + +#### PythonAPI + +Compiled using Python's `setuptools` ("setup.py"). Currently requires the +following to be installed in the machine: Python, libpython-dev, and +libboost-python-dev; both for Python 2.7 and 3.5. + +Command + +```sh +make PythonAPI +``` + +It creates two "egg" packages + + * `PythonAPI/dist/carla-0.9.0-py2.7-linux-x86_64.egg` + * `PythonAPI/dist/carla-0.9.0-py3.5-linux-x86_64.egg` + +This package can be directly imported into a Python script by adding it to the +system path + +```python +#!/usr/bin/env python + +import sys + +sys.path.append( + 'PythonAPI/dist/carla-0.9.0-py%d.%d-linux-x86_64.egg' % (sys.version_info.major, + sys.version_info.minor)) + +import carla + +# ... +``` + +or installed with `easy_install` + +```sh +easy_install2 --user --no-deps PythonAPI/dist/carla-0.9.0-py2.7-linux-x86_64.egg +easy_install3 --user --no-deps PythonAPI/dist/carla-0.9.0-py3.5-linux-x86_64.egg +``` diff --git a/Docs/how_to_build_on_linux.md b/Docs/how_to_build_on_linux.md index 5d880a3fd..360bbfcd6 100644 --- a/Docs/how_to_build_on_linux.md +++ b/Docs/how_to_build_on_linux.md @@ -5,15 +5,23 @@ Install the build tools and dependencies - $ sudo apt-get install build-essential clang-3.9 git cmake ninja-build python3-requests python-dev tzdata sed curl wget unzip autoconf libtool +``` +sudo add-apt-repository ppa:ubuntu-toolchain-r/test +sudo apt-get install build-essential clang-5.0 lld-5.0 g++-7 ninja-build python python-pip python3 python3-pip libboost-python-dev python-dev tzdata sed curl wget unzip autoconf libtool +pip2 install --user setuptools nose2 +pip3 install --user setuptools nose2 +``` To avoid compatibility issues between Unreal Engine and the CARLA dependencies, the best configuration is to compile everything with the same compiler version -and C++ runtime library. We use clang 3.9 and LLVM's libc++. You may need to -change your default clang version to compile Unreal +and C++ runtime library. We use clang 5.0 and LLVM's libc++. We recommend to +change your default clang version to compile Unreal Engine and the CARLA +dependencies - $ sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-3.9/bin/clang++ 100 - $ sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-3.9/bin/clang 100 +```sh +sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-5.0/bin/clang++ 101 +sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-5.0/bin/clang 101 +``` Build Unreal Engine ------------------- @@ -23,13 +31,15 @@ Build Unreal Engine need to add your GitHub username when you sign up at [www.unrealengine.com](https://www.unrealengine.com). -Download and compile Unreal Engine 4.18. Here we will assume you install it at -"~/UnrealEngine_4.18", but you can install it anywhere, just replace the path +Download and compile Unreal Engine 4.19. Here we will assume you install it at +`~/UnrealEngine_4.19", but you can install it anywhere, just replace the path where necessary. - $ git clone --depth=1 -b 4.18 https://github.com/EpicGames/UnrealEngine.git ~/UnrealEngine_4.18 - $ cd ~/UnrealEngine_4.18 - $ ./Setup.sh && ./GenerateProjectFiles.sh && make +```sh +git clone --depth=1 -b 4.19 https://github.com/EpicGames/UnrealEngine.git ~/UnrealEngine_4.19 +cd ~/UnrealEngine_4.19 +./Setup.sh && ./GenerateProjectFiles.sh && make +``` Check Unreal's documentation ["Building On Linux"](https://wiki.unrealengine.com/Building_On_Linux) if any of @@ -41,56 +51,47 @@ Build CARLA Clone or download the project from our [GitHub repository](https://github.com/carla-simulator/carla) - $ git clone https://github.com/carla-simulator/carla +```sh +git clone https://github.com/carla-simulator/carla +``` Note that the `master` branch contains the latest fixes and features, for the latest stable code may be best to switch to the latest release tag. -Run the setup script to download the content and build all dependencies. It -takes a while (you can speed up the process by parallelizing the script with the -`--jobs=8` flag) +Now you need to download the assets package, to do so we provide a handy script +that downloads and extracts the latest version (note that the package is >10GB, +this step might take some time depending on your connection) - $ ./Setup.sh +```sh +./Update.sh +``` -Once it's done it should print "Success" if everything went well. +For CARLA to find your Unreal Engine's installation folder you need to set the +following environment variable -To build CARLA, use the rebuild script. This script deletes all intermediate -files, rebuilds whole CARLA, and launches the editor. Use it too for making a -clean rebuild of CARLA +```sh +export UE4_ROOT=~/UnrealEngine_4.19 +``` - $ UE4_ROOT=~/UnrealEngine_4.18 ./Rebuild.sh +You can also add this variable to your `~/.bashrc` or `~/.profile`. -It looks at the environment variable `UE4_ROOT` to find the right version of -Unreal Engine. You can also add this variable to your "~/.bashrc" or similar. +Now that the environment is set up, you can run make to run different commands -Later, if you need to compile some changes without doing a full rebuild, you can -use the Makefile generated in the Unreal project folder - - $ cd Unreal/CarlaUE4 - $ make CarlaUE4Editor +```sh +make launch # Compiles CARLA and launches Unreal Engine's Editor. +make package # Compiles CARLA and creates a packaged version for distribution. +make help # Print all available commands. +``` Updating CARLA -------------- Every new release of CARLA we release a new package with the latest changes in -the CARLA assets. To download the latest version, run the "Update" script +the CARLA assets. To download the latest version and recompile CARLA, run - $ git pull - $ ./Update.sh - -Launching the editor --------------------- - -To open the editor once the project is already built - - $ cd Unreal/CarlaUE4 - $ ~/UnrealEngine_4.18/Engine/Binaries/Linux/UE4Editor "$PWD/CarlaUE4.uproject" - -Test (Optional) ---------------- - -A set of unit tests is available for testing the CarlaServer library (note that -these tests launch the python client, they require python3 and protobuf for -python3 installed, as well as ports 2000 and 4000 available) - - $ make check +```sh +make clean +git pull +./Update.sh +make launch +``` diff --git a/Docs/img/modules.png b/Docs/img/modules.png new file mode 100644 index 000000000..4e9aff2cf Binary files /dev/null and b/Docs/img/modules.png differ diff --git a/Docs/index.md b/Docs/index.md index 49370fbcf..a7e682caf 100644 --- a/Docs/index.md +++ b/Docs/index.md @@ -21,7 +21,7 @@ * [General Structure](benchmark_structure.md) * [Creating Your Benchmark](benchmark_creating.md) * [Computed Performance Metrics](benchmark_metrics.md) - +

Advanced topics

* [CARLA settings](carla_settings.md) @@ -41,3 +41,4 @@ * [How to add assets](how_to_add_assets.md) * [CARLA design](carla_design.md) * [CarlaServer documentation](carla_server.md) + * [Build system](build_system.md) diff --git a/Doxyfile b/Doxyfile index 3940101b1..36409b425 100644 --- a/Doxyfile +++ b/Doxyfile @@ -11,7 +11,7 @@ CASE_SENSE_NAMES = YES SORT_BRIEF_DOCS = YES WARN_IF_UNDOCUMENTED = NO WARN_LOGFILE = Doxygen/warnings.log -INPUT = Unreal/CarlaUE4/Source Unreal/CarlaUE4/Plugins/Carla/Source Util/CarlaServer/source +INPUT = Unreal/CarlaUE4/Source Unreal/CarlaUE4/Plugins/Carla/Source LibCarla/source FILE_PATTERNS = *.cpp *.h *.hpp *.cc RECURSIVE = YES SOURCE_BROWSER = YES @@ -26,7 +26,7 @@ FORMULA_FONTSIZE = 12 GENERATE_LATEX = NO MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES -INCLUDE_PATH = Unreal/CarlaUE4/Source Unreal/CarlaUE4/Plugins/Carla/Source Util/CarlaServer/source Util/CarlaServer/include +INCLUDE_PATH = Unreal/CarlaUE4/Source Unreal/CarlaUE4/Plugins/Carla/Source LibCarla/source INCLUDE_FILE_PATTERNS = *.h *.hpp HIDE_UNDOC_RELATIONS = NO HAVE_DOT = YES diff --git a/Makefile b/Makefile index 1afd6ab56..5faab3686 100644 --- a/Makefile +++ b/Makefile @@ -1,104 +1,6 @@ -INSTALL_FOLDER=$(CURDIR)/Unreal/CarlaUE4/Plugins/Carla/CarlaServer -PYTHON_CLIENT_FOLDER=$(CURDIR)/PythonClient/test -BASE_BUILD_FOLDER=$(CURDIR)/Util/Build/carlaserver-build -MY_CMAKE_FOLDER=$(CURDIR)/Util/cmake -MY_CMAKE_FLAGS=-B"$(BUILD_FOLDER)" -DCMAKE_INSTALL_PREFIX="$(INSTALL_FOLDER)" - +include Util/BuildTools/Vars.mk ifeq ($(OS),Windows_NT) -BUILD_RULE=build_windows -CLEAN_RULE=clean_windows -CALL_CMAKE_RULE=call_cmake_windows -PROTOC_COMPILE=cmd.exe /k "cd Util & call Protoc.bat & exit" -PROTOC_CLEAN=cmd.exe /k "cd Util & call Protoc.bat --clean & exit" +include Util/BuildTools/Windows.mk else -BUILD_RULE=build_linux -CLEAN_RULE=clean_linux -CALL_CMAKE_RULE=call_cmake_linux -PROTOC_COMPILE=./Util/Protoc.sh -PROTOC_CLEAN=./Util/Protoc.sh --clean +include Util/BuildTools/Linux.mk endif - -default: release - -### Build ###################################################################### - -debug: BUILD_FOLDER=$(BASE_BUILD_FOLDER)/debug -debug: MY_CMAKE_FLAGS+=-DCMAKE_BUILD_TYPE=Debug -debug: $(BUILD_RULE) - -release: BUILD_FOLDER=$(BASE_BUILD_FOLDER)/release -release: MY_CMAKE_FLAGS+=-DCMAKE_BUILD_TYPE=Release -release: $(BUILD_RULE) - -vsproject: BUILD_FOLDER=$(BASE_BUILD_FOLDER)/visualstudio -vsproject: MY_CMAKE_FLAGS+=-DCMAKE_BUILD_TYPE=Release -vsproject: MY_CMAKE_FLAGS+=-G "Visual Studio 14 2015 Win64" -vsproject: call_cmake - -vsproject15: BUILD_FOLDER=$(BASE_BUILD_FOLDER)/visualstudio -vsproject15: MY_CMAKE_FLAGS+=-DCMAKE_BUILD_TYPE=Release -vsproject15: MY_CMAKE_FLAGS+=-G "Visual Studio 15 2017 Win64" -vsproject15: call_cmake - -build_linux: MY_CMAKE_FLAGS+=-G "Ninja" -build_linux: call_cmake - @cd $(BUILD_FOLDER) && ninja && ninja install - -build_windows: MY_CMAKE_FLAGS+=-G "NMake Makefiles" -build_windows: call_cmake - @cd $(BUILD_FOLDER) && nmake && nmake install - -call_cmake: protobuf $(CALL_CMAKE_RULE) - @cd $(BUILD_FOLDER) && cmake $(MY_CMAKE_FLAGS) "$(MY_CMAKE_FOLDER)" - -protobuf: - @$(PROTOC_COMPILE) - -call_cmake_linux: - @mkdir -p $(BUILD_FOLDER) - -call_cmake_windows: - -@mkdir "$(BUILD_FOLDER)" - -### Docs ####################################################################### - -docs: doxygen - -doxygen: - @doxygen - @echo "Documentation index at ./Doxygen/html/index.html" - -### Clean ###################################################################### - -clean: $(CLEAN_RULE) - @$(PROTOC_CLEAN) - -clean_linux: - @rm -Rf $(BASE_BUILD_FOLDER) $(INSTALL_FOLDER) Doxygen - -clean_windows: - -@rd /s /q "$(BASE_BUILD_FOLDER)" "$(INSTALL_FOLDER)" Doxygen - -### Test ####################################################################### - -check: debug launch_test_clients run_test_debug kill_test_clients - -check_release: release launch_test_clients run_test_release kill_test_clients - -run_test_debug: - @-LD_LIBRARY_PATH=$(INSTALL_FOLDER)/shared $(INSTALL_FOLDER)/bin/test_carlaserverd --gtest_shuffle $(GTEST_ARGS) - -run_test_release: - @-LD_LIBRARY_PATH=$(INSTALL_FOLDER)/shared $(INSTALL_FOLDER)/bin/test_carlaserver --gtest_shuffle $(GTEST_ARGS) - -launch_test_clients: - @echo "Launch echo client" - @python3 $(PYTHON_CLIENT_FOLDER)/test_client.py --echo -v -p 4000 --log echo_client.log & echo $$! > echo_client.pid - @echo "Launch carla client" - @python3 $(PYTHON_CLIENT_FOLDER)/test_client.py -v -p 2000 --log carla_client.log & echo $$! > carla_client.pid - -kill_test_clients: - @echo "Kill echo client" - @kill `cat echo_client.pid` && rm echo_client.pid - @echo "Kill carla client" - @kill `cat carla_client.pid` && rm carla_client.pid diff --git a/Rebuild.sh b/Rebuild.sh deleted file mode 100755 index 879e79483..000000000 --- a/Rebuild.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/bash - -################################################################################ -# Updates CARLA content. -################################################################################ - -set -e - -DOC_STRING="Update CARLA content to the latest version, to be run after 'git pull'." - -USAGE_STRING="Usage: $0 [-h|--help] [--no-editor]" - -# ============================================================================== -# -- Parse arguments ----------------------------------------------------------- -# ============================================================================== - -LAUNCH_UE4_EDITOR=true - -OPTS=`getopt -o h --long help,no-editor -n 'parse-options' -- "$@"` - -if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi - -eval set -- "$OPTS" - -while true; do - case "$1" in - --no-editor ) - LAUNCH_UE4_EDITOR=false; - shift ;; - -h | --help ) - echo "$DOC_STRING" - echo "$USAGE_STRING" - exit 1 - ;; - * ) - break ;; - esac -done - -# ============================================================================== -# -- Set up environment -------------------------------------------------------- -# ============================================================================== - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd "$SCRIPT_DIR" >/dev/null - -UNREAL_PROJECT_FOLDER=./Unreal/CarlaUE4 -UE4_INTERMEDIATE_FOLDERS="Binaries Build Intermediate DerivedDataCache" - -function fatal_error { - echo -e "\033[0;31mERROR: $1\033[0m" - exit 1 -} - -function log { - echo -e "\033[0;33m$1\033[0m" -} - -if [ ! -d "${UE4_ROOT}" ]; then - fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable." -else - echo "Using Unreal Engine at '$UE4_ROOT'" -fi - -# ============================================================================== -# -- Make CarlaServer ---------------------------------------------------------- -# ============================================================================== - -log "Making CarlaServer..." -make clean && make debug && make release - -# ============================================================================== -# -- Clean up intermediate Unreal files ---------------------------------------- -# ============================================================================== - -pushd "$UNREAL_PROJECT_FOLDER" >/dev/null - -pushd "Plugins/Carla" >/dev/null - -log "Cleaning up CARLA Plugin..." -rm -Rf ${UE4_INTERMEDIATE_FOLDERS} - -popd > /dev/null - -log "Cleaning up CARLAUE4..." -rm -Rf ${UE4_INTERMEDIATE_FOLDERS} - -popd >/dev/null - -# ============================================================================== -# -- Build and launch Unreal project ------------------------------------------- -# ============================================================================== - -pushd "$UNREAL_PROJECT_FOLDER" >/dev/null - -# This command usually fails but normally we can continue anyway. -set +e -log "Generate Unreal project files..." -${UE4_ROOT}/GenerateProjectFiles.sh -project="${PWD}/CarlaUE4.uproject" -game -engine -makefiles -set -e - -log "Build CarlaUE4 project..." -make CarlaUE4Editor - -if $LAUNCH_UE4_EDITOR ; then - log "Launching UE4Editor..." - ${UE4_ROOT}/Engine/Binaries/Linux/UE4Editor "${PWD}/CarlaUE4.uproject" -else - echo "" - echo "****************" - echo "*** Success! ***" - echo "****************" -fi - -popd >/dev/null - -# ============================================================================== -# -- ...and we are done -------------------------------------------------------- -# ============================================================================== - -popd >/dev/null diff --git a/Setup.sh b/Setup.sh deleted file mode 100755 index 9a6a29e0d..000000000 --- a/Setup.sh +++ /dev/null @@ -1,227 +0,0 @@ -#! /bin/bash - -################################################################################ -# CARLA Setup.sh -# -# This script sets up the environment and dependencies for compiling CARLA on -# Linux. -# -# 1) Download CARLA Content if necessary. -# 2) Download and compile libc++. -# 3) Download other third-party libraries and compile them with libc++. -# -# Thanks to the people at https://github.com/Microsoft/AirSim for providing the -# important parts of this script. -################################################################################ - -set -e - -DOC_STRING="Download and compile CARLA content and dependencies." - -USAGE_STRING="Usage: $0 [-h|--help] [-s|--skip-download] [--jobs=N]" - -# ============================================================================== -# -- Parse arguments ----------------------------------------------------------- -# ============================================================================== - -UPDATE_SCRIPT_FLAGS= -NUMBER_OF_ASYNC_JOBS=1 - -OPTS=`getopt -o hs --long help,skip-download,jobs:: -n 'parse-options' -- "$@"` - -if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi - -eval set -- "$OPTS" - -while true; do - case "$1" in - -s | --skip-download ) - UPDATE_SCRIPT_FLAGS=--skip-download; - shift ;; - --jobs) - case "$2" in - "") NUMBER_OF_ASYNC_JOBS=4 ; shift 2 ;; - *) NUMBER_OF_ASYNC_JOBS=$2 ; shift 2 ;; - esac ;; - -h | --help ) - echo "$DOC_STRING" - echo "$USAGE_STRING" - exit 1 - ;; - * ) - break ;; - esac -done - -# ============================================================================== -# -- Set up environment -------------------------------------------------------- -# ============================================================================== - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd "$SCRIPT_DIR" >/dev/null - -# Require clang 3.9 -command -v clang++-3.9 >/dev/null 2>&1 || { - echo >&2 "clang 3.9 is required, but it's not installed."; - echo >&2 "make sure you build Unreal Engine with clang 3.9 too."; - exit 1; -} - -mkdir -p Util/Build -pushd Util/Build >/dev/null - -# ============================================================================== -# -- Get and compile libc++ ---------------------------------------------------- -# ============================================================================== - -# Get libc++ source -if [[ ! -d "llvm-source" ]]; then - echo "Retrieving libc++..." - git clone --depth=1 -b release_39 https://github.com/llvm-mirror/llvm.git llvm-source - git clone --depth=1 -b release_39 https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx - git clone --depth=1 -b release_39 https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi -else - echo "Folder llvm-source already exists, skipping git clone..." -fi - -# Build libc++ -rm -rf llvm-build -mkdir -p llvm-build - -pushd llvm-build >/dev/null - -export C_COMPILER=clang-3.9 -export COMPILER=clang++-3.9 - -cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \ - -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=OFF \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="../llvm-install" \ - ../llvm-source - -make -j $NUMBER_OF_ASYNC_JOBS cxx - -#install libc++ locally in llvm-install folder -make -j $NUMBER_OF_ASYNC_JOBS install-libcxx install-libcxxabi - -popd >/dev/null - -# ============================================================================== -# -- Get Boost and compile it with libc++ -------------------------------------- -# ============================================================================== - -# Get boost source -if [[ ! -d "boost-source" ]]; then - echo "Retrieving boost..." - wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz - tar -xvzf boost_1_64_0.tar.gz - rm boost_1_64_0.tar.gz - mv boost_1_64_0 boost-source -else - echo "Folder boost-source already exists, skipping download..." -fi - -pushd boost-source >/dev/null - -BOOST_TOOLSET="clang-3.9" -BOOST_CFLAGS="-fPIC -std=c++1y -stdlib=libc++ -I../llvm-install/include/c++/v1" -BOOST_LFLAGS="-stdlib=libc++ -L../llvm-install/lib" - -./bootstrap.sh \ - --with-toolset=clang \ - --prefix=../boost-install \ - --with-libraries=system -./b2 clean -./b2 toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" -j $NUMBER_OF_ASYNC_JOBS stage release -./b2 install toolset="${BOOST_TOOLSET}" cxxflags="${BOOST_CFLAGS}" linkflags="${BOOST_LFLAGS}" --prefix="../boost-install" -j $NUMBER_OF_ASYNC_JOBS - -popd >/dev/null - -# ============================================================================== -# -- Get Protobuf and compile it with libc++ ----------------------------------- -# ============================================================================== - -# Get protobuf source -if [[ ! -d "protobuf-source" ]]; then - echo "Retrieving protobuf..." - git clone --depth=1 -b v3.3.0 --recurse-submodules https://github.com/google/protobuf.git protobuf-source -else - echo "Folder protobuf-source already exists, skipping git clone..." -fi - -pushd protobuf-source >/dev/null - -export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/../llvm-install/lib/" - -./autogen.sh -./configure \ - CC="clang-3.9" \ - CXX="clang++-3.9" \ - CXXFLAGS="-fPIC -stdlib=libc++ -I$PWD/../llvm-install/include/c++/v1" \ - LDFLAGS="-stdlib=libc++ -L$PWD/../llvm-install/lib/" \ - --prefix="$PWD/../protobuf-install" \ - --disable-shared -make -j $NUMBER_OF_ASYNC_JOBS -make -j $NUMBER_OF_ASYNC_JOBS install - -popd >/dev/null - -# ============================================================================== -# -- Get GTest and compile it with libc++ -------------------------------------- -# ============================================================================== - -# Get googletest source -if [[ ! -d "googletest-source" ]]; then - echo "Retrieving googletest..." - git clone --depth=1 -b release-1.8.0 https://github.com/google/googletest.git googletest-source -else - echo "Folder googletest-source already exists, skipping git clone..." -fi - -pushd googletest-source >/dev/null - -cmake -H. -B./build \ - -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \ - -DCMAKE_CXX_FLAGS="-stdlib=libc++ -I$PWD/../llvm-install/include/c++/v1 -Wl,-L$PWD/../llvm-install/lib" \ - -DCMAKE_INSTALL_PREFIX="../googletest-install" \ - -G "Ninja" - -pushd build >/dev/null -ninja -ninja install -popd >/dev/null - -popd >/dev/null - -# ============================================================================== -# -- Other CARLA files --------------------------------------------------------- -# ============================================================================== - -popd >/dev/null - -CARLA_SETTINGS_FILE="./Unreal/CarlaUE4/Config/CarlaSettings.ini" - -if [[ ! -f $CARLA_SETTINGS_FILE ]]; then - echo "Copying CarlaSettings.ini..." - sed -e 's/UseNetworking=true/UseNetworking=false/' ./Docs/Example.CarlaSettings.ini > $CARLA_SETTINGS_FILE -fi - -./Util/Protoc.sh - -# ============================================================================== -# -- Update CARLA Content ------------------------------------------------------ -# ============================================================================== - -echo -./Update.sh $UPDATE_SCRIPT_FLAGS - -# ============================================================================== -# -- ...and we are done -------------------------------------------------------- -# ============================================================================== - -popd >/dev/null - -set +x -echo "" -echo "****************" -echo "*** Success! ***" -echo "****************" diff --git a/Unreal/CarlaUE4/.gitignore b/Unreal/CarlaUE4/.gitignore index 32c3e361e..a8b3ead2a 100644 --- a/Unreal/CarlaUE4/.gitignore +++ b/Unreal/CarlaUE4/.gitignore @@ -7,6 +7,7 @@ Saved Plugins/Carla/Binaries Plugins/Carla/Build Plugins/Carla/CarlaServer +Plugins/Carla/CarlaDependencies Plugins/Carla/Debug Plugins/Carla/DerivedDataCache Plugins/Carla/Intermediate diff --git a/Unreal/CarlaUE4/CarlaUE4.uproject b/Unreal/CarlaUE4/CarlaUE4.uproject index 22c8354fb..c7b4426fb 100644 --- a/Unreal/CarlaUE4/CarlaUE4.uproject +++ b/Unreal/CarlaUE4/CarlaUE4.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "4.18", + "EngineAssociation": "4.19", "Category": "", "Description": "", "Modules": [ diff --git a/Unreal/CarlaUE4/Config/DefaultGame.ini b/Unreal/CarlaUE4/Config/DefaultGame.ini index 8bb2e6084..72d4d8855 100644 --- a/Unreal/CarlaUE4/Config/DefaultGame.ini +++ b/Unreal/CarlaUE4/Config/DefaultGame.ini @@ -3,7 +3,7 @@ ProjectID=675BF8694238308FA9368292CC440350 ProjectName=CARLA UE4 CompanyName=CVC CopyrightNotice="Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see ." -ProjectVersion=0.8.4 +ProjectVersion=0.9.0 [/Script/UnrealEd.ProjectPackagingSettings] BuildConfiguration=PPBC_Development diff --git a/Unreal/CarlaUE4/Plugins/Carla/Carla.uplugin b/Unreal/CarlaUE4/Plugins/Carla/Carla.uplugin index 5db0a836f..83ccb0f10 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Carla.uplugin +++ b/Unreal/CarlaUE4/Plugins/Carla/Carla.uplugin @@ -1,7 +1,7 @@ { "FileVersion": 3, "Version": 1, - "VersionName": "0.8.4", + "VersionName": "0.9.0", "FriendlyName": "CARLA", "Description": "Open-source simulator for autonomous driving research.", "Category": "Science", diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Carla.Build.cs b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Carla.Build.cs index 16bc6715f..f9c74b603 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Carla.Build.cs +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Carla.Build.cs @@ -1,5 +1,6 @@ // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. +using System; using System.IO; using UnrealBuildTool; @@ -78,17 +79,7 @@ public class Carla : ModuleRules private void AddCarlaServerDependency(ReadOnlyTargetRules Target) { - string CarlaServerInstallPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "../../CarlaServer")); - - string CarlaServerLib; - if (UseDebugLibs(Target)) - { - CarlaServerLib = "carlaserverd"; - } - else - { - CarlaServerLib = "carlaserver"; - } + string LibCarlaInstallPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "../../CarlaDependencies")); ADelegate GetLibName = (string BaseName) => { if (IsWindows(Target)) @@ -104,23 +95,17 @@ public class Carla : ModuleRules // Link dependencies. if (IsWindows(Target)) { - // Auto-links boost libraries in folder. - PublicLibraryPaths.Add(Path.Combine(CarlaServerInstallPath, "lib")); - - PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("libprotobuf"))); - PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName(CarlaServerLib))); + throw new NotImplementedException(); } else { - PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("c++abi"))); - PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("boost_system"))); - PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName("protobuf"))); - PublicAdditionalLibraries.Add(Path.Combine(CarlaServerInstallPath, "lib", GetLibName(CarlaServerLib))); + PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("c++abi"))); + PublicAdditionalLibraries.Add(Path.Combine(LibCarlaInstallPath, "lib", GetLibName("rpc"))); } // Include path. - string CarlaServerIncludePath = Path.Combine(CarlaServerInstallPath, "include"); - PublicIncludePaths.Add(CarlaServerIncludePath); - PrivateIncludePaths.Add(CarlaServerIncludePath); + string LibCarlaIncludePath = Path.Combine(LibCarlaInstallPath, "include"); + PublicIncludePaths.Add(LibCarlaIncludePath); + PrivateIncludePaths.Add(LibCarlaIncludePath); } } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.cpp index 77578cae0..751a9a44e 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.cpp @@ -4,6 +4,8 @@ // This work is licensed under the terms of the MIT license. // For a copy, see . +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + #include "Carla.h" #include "CarlaEncoder.h" @@ -221,3 +223,5 @@ void FCarlaEncoder::Visit(const UWalkerAgentComponent &Agent) ::Encode(Agent.GetBoundingBoxTransform(), Data.bounding_box.transform); ::Encode(Agent.GetBoundingBoxExtent() * TO_METERS, Data.bounding_box.extent); } + +#endif // CARLA_COMPILE_CARLASERVER_LEGACY diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.h index 0c523029c..659d32658 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaEncoder.h @@ -6,6 +6,8 @@ #pragma once +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + #include "Agent/AgentComponentVisitor.h" #include "Sensor/SensorDataView.h" @@ -74,3 +76,5 @@ private: carla_agent &Data; }; + +#endif // CARLA_COMPILE_CARLASERVER_LEGACY diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp index 8488d31a6..879274281 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp @@ -9,12 +9,15 @@ #include "Server/CarlaEncoder.h" -#include +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY +# include +#endif // CARLA_COMPILE_CARLASERVER_LEGACY // ============================================================================= // -- Static local methods ----------------------------------------------------- // ============================================================================= +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY static FCarlaServer::ErrorCode ParseErrorCode(const uint32 ErrorCode) { if (ErrorCode == CARLA_SERVER_SUCCESS) { @@ -25,6 +28,7 @@ static FCarlaServer::ErrorCode ParseErrorCode(const uint32 ErrorCode) return FCarlaServer::Error; } } +#endif // CARLA_COMPILE_CARLASERVER_LEGACY static int32 GetTimeOut(uint32 TimeOut, const bool bBlocking) { @@ -38,7 +42,12 @@ static int32 GetTimeOut(uint32 TimeOut, const bool bBlocking) FCarlaServer::FCarlaServer(const uint32 InWorldPort, const uint32 InTimeOut) : WorldPort(InWorldPort), TimeOut(InTimeOut), - Server(carla_make_server()) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + Server(carla_make_server()) +#else + Server(nullptr) +#endif // CARLA_COMPILE_CARLASERVER_LEGACY +{ check(Server != nullptr); } @@ -47,17 +56,26 @@ FCarlaServer::~FCarlaServer() #ifdef CARLA_SERVER_EXTRA_LOG UE_LOG(LogCarlaServer, Warning, TEXT("Destroying CarlaServer")); #endif // CARLA_SERVER_EXTRA_LOG +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY carla_free_server(Server); +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::Connect() { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY UE_LOG(LogCarlaServer, Log, TEXT("Waiting for the client to connect...")); return ParseErrorCode(carla_server_connect(Server, WorldPort, TimeOut)); +#else + UE_LOG(LogCarlaServer, Error, TEXT("CarlaServer no longer supported!!")); + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::ReadNewEpisode(FString &IniFile, const bool bBlocking) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + carla_request_new_episode values; auto ec = ParseErrorCode(carla_read_request_new_episode(Server, values, GetTimeOut(TimeOut, bBlocking))); if (Success == ec) { @@ -68,6 +86,10 @@ FCarlaServer::ErrorCode FCarlaServer::ReadNewEpisode(FString &IniFile, const boo #endif // CARLA_SERVER_EXTRA_LOG } return ec; + +#else + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::SendSceneDescription( @@ -76,6 +98,8 @@ FCarlaServer::ErrorCode FCarlaServer::SendSceneDescription( const TArray &SensorDescriptions, const bool bBlocking) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + carla_scene_description scene; // Encode map name. const auto MapNameBuffer = FCarlaEncoder::Encode(MapName); @@ -95,10 +119,16 @@ FCarlaServer::ErrorCode FCarlaServer::SendSceneDescription( UE_LOG(LogCarlaServer, Log, TEXT("Sending %d available start positions"), scene.number_of_player_start_spots); UE_LOG(LogCarlaServer, Log, TEXT("Sending %d sensor descriptions"), scene.number_of_sensors); return ParseErrorCode(carla_write_scene_description(Server, scene, GetTimeOut(TimeOut, bBlocking))); + +#else + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::ReadEpisodeStart(uint32 &StartPositionIndex, const bool bBlocking) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + carla_episode_start values; auto ec = ParseErrorCode(carla_read_episode_start(Server, values, GetTimeOut(TimeOut, bBlocking))); if (Success == ec) { @@ -106,17 +136,29 @@ FCarlaServer::ErrorCode FCarlaServer::ReadEpisodeStart(uint32 &StartPositionInde UE_LOG(LogCarlaServer, Log, TEXT("Episode start received: { StartIndex = %d }"), StartPositionIndex); } return ec; + +#else + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::SendEpisodeReady(const bool bBlocking) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + UE_LOG(LogCarlaServer, Log, TEXT("Ready to play, notifying client")); const carla_episode_ready values = {true}; return ParseErrorCode(carla_write_episode_ready(Server, values, GetTimeOut(TimeOut, bBlocking))); + +#else + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::ReadControl(FVehicleControl &Control, const bool bBlocking) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + carla_control values; auto ec = ParseErrorCode(carla_read_control(Server, values, GetTimeOut(TimeOut, bBlocking))); if (Success == ec) { @@ -137,13 +179,23 @@ FCarlaServer::ErrorCode FCarlaServer::ReadControl(FVehicleControl &Control, cons UE_LOG(LogCarlaServer, Warning, TEXT("No control received from the client this frame!")); } return ec; + +#else + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::SendSensorData(const FSensorDataView &Data) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + carla_sensor_data values; FCarlaEncoder::Encode(Data, values); return ParseErrorCode(carla_write_sensor_data(Server, values)); + +#else + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } FCarlaServer::ErrorCode FCarlaServer::SendMeasurements( @@ -151,6 +203,8 @@ FCarlaServer::ErrorCode FCarlaServer::SendMeasurements( const TArray &Agents, const bool bSendNonPlayerAgentsInfo) { +#ifdef CARLA_COMPILE_CARLASERVER_LEGACY + // Encode measurements. carla_measurements values; FCarlaEncoder::Encode(PlayerState, values); @@ -166,4 +220,8 @@ FCarlaServer::ErrorCode FCarlaServer::SendMeasurements( UE_LOG(LogCarlaServer, Log, TEXT("Sending data of %d agents"), values.number_of_non_player_agents); #endif // CARLA_SERVER_EXTRA_LOG return ParseErrorCode(carla_write_measurements(Server, values)); + +#else + return ErrorCode::Error; +#endif // CARLA_COMPILE_CARLASERVER_LEGACY } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/RPCServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/RPCServer.cpp new file mode 100644 index 000000000..5871ec9aa --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/RPCServer.cpp @@ -0,0 +1,91 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#include "Carla.h" +#include "Server.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +static FVehicleControl MakeControl(const carla::rpc::VehicleControl &cControl) +{ + FVehicleControl Control; + Control.Throttle = cControl.throttle; + Control.Steer = cControl.steer; + Control.Brake = cControl.brake; + Control.bHandBrake = cControl.hand_brake; + Control.bReverse = cControl.reverse; + return Control; +} + +class FRPCServer::Pimpl +{ +public: + Pimpl(uint16_t port) : Server(port) {} + carla::rpc::Server Server; +}; + +FRPCServer::FRPCServer() : _Pimpl(nullptr) {} + +FRPCServer::~FRPCServer() {} + +void FRPCServer::Initialize(AServer &Server, uint16_t Port) +{ + UE_LOG(LogTemp, Error, TEXT("Initializing rpc-server at port %d"), Port); + + _Pimpl = std::make_unique(Port); + + namespace cr = carla::rpc; + + auto &srv = _Pimpl->Server; + + srv.BindAsync("ping", []() { return true; }); + + srv.BindAsync("version", []() { return std::string(carla::version()); }); + + srv.BindAsync("get_blueprints", []() { + return std::vector{ + cr::ActorBlueprint{"vehicle.mustang.red"}, + cr::ActorBlueprint{"vehicle.mustang.also_red"}, + cr::ActorBlueprint{"vehicle.mustang.still_red"} + }; + }); + + srv.BindSync("spawn_actor", [&]( + const cr::ActorBlueprint &blueprint, + const cr::Transform &transform) { + auto id = Server.SpawnAgent(transform); + return cr::Actor{static_cast(id), blueprint}; + }); + + srv.BindSync("apply_control_to_actor", [&]( + const cr::Actor &actor, + const cr::VehicleControl &control) { + Server.ApplyControl(actor.id, MakeControl(control)); + }); +} + +void FRPCServer::Run() +{ + _Pimpl->Server.AsyncRun(4); +} + +void FRPCServer::RunSome() +{ + using namespace std::chrono_literals; + _Pimpl->Server.SyncRunFor(20ms); +} + +void FRPCServer::Stop() +{ + _Pimpl->Server.Stop(); +} diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/RPCServer.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/RPCServer.h new file mode 100644 index 000000000..2ec8c71b6 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/RPCServer.h @@ -0,0 +1,35 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "CoreMinimal.h" + +#include + +class AServer; + +class FRPCServer +{ +public: + + FRPCServer(); + + ~FRPCServer(); + + void Initialize(AServer &Server, uint16_t Port = 8080u); + + void Run(); + + void RunSome(); + + void Stop(); + +private: + + class Pimpl; + std::unique_ptr _Pimpl; +}; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/Server.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/Server.cpp new file mode 100644 index 000000000..2a1ab6d95 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/Server.cpp @@ -0,0 +1,72 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#include "Carla.h" +#include "Server.h" + + +// Sets default values +AServer::AServer() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + +} + +// Called when the game starts or when spawned +void AServer::BeginPlay() +{ + Super::BeginPlay(); + + _Server.Initialize(*this); + _Server.Run(); +} + +void AServer::EndPlay(EEndPlayReason::Type EndPlayReason) +{ + _Server.Stop(); +} + +// Called every frame +void AServer::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + + _Server.RunSome(); +} + +int32 AServer::SpawnAgent(const FTransform &Transform) +{ + check(IsInGameThread()); + UE_LOG(LogTemp, Warning, TEXT("Spawning vehicle at %s"), *Transform.ToString()); + + static int32 COUNT = 0u; + ++COUNT; + + ACarlaWheeledVehicle *Vehicle; + SpawnVehicle(Transform, Vehicle); + if ((Vehicle != nullptr) && !Vehicle->IsPendingKill()) + { + // Vehicle->AIControllerClass = AWheeledVehicleAIController::StaticClass(); + Vehicle->SpawnDefaultController(); + _Agents.Add(COUNT, Vehicle); + return COUNT; + } + return -1; +} + +bool AServer::ApplyControl(int32 AgentId, const FVehicleControl &Control) +{ + UE_LOG(LogTemp, Log, TEXT("Applying control to vehicle %d: throttle = %f, steer = %f"), AgentId, Control.Throttle, Control.Steer); + if (!_Agents.Contains(AgentId)) + { + UE_LOG(LogTemp, Error, TEXT("Vehicle %d does not exist!"), AgentId); + return false; + } + auto *Vehicle = _Agents[AgentId]; + Vehicle->ApplyVehicleControl(Control); + return true; +} diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/Server.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/Server.h new file mode 100644 index 000000000..e8cd23755 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/Server.h @@ -0,0 +1,52 @@ +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "Vehicle/CarlaWheeledVehicle.h" +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "RPCServer.h" +#include "Vehicle/VehicleControl.h" +#include +#include +#include +#include "Server.generated.h" + +UCLASS() +class CARLA_API AServer : public AActor +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + AServer(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + virtual void EndPlay(EEndPlayReason::Type EndPlayReason) override; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + + UFUNCTION(BlueprintCallable) + int32 SpawnAgent(const FTransform &Transform); + + UFUNCTION(BlueprintCallable) + bool ApplyControl(int32 AgentId, const FVehicleControl &Control); + + UFUNCTION(BlueprintImplementableEvent) + void SpawnVehicle(const FTransform &SpawnTransform, ACarlaWheeledVehicle *&SpawnedCharacter); + +private: + + FRPCServer _Server; + + UPROPERTY(VisibleAnywhere) + TMap _Agents; +}; diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.cpp index 31f8aa246..69f0279f0 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.cpp @@ -155,7 +155,7 @@ AWalkerAIController::AWalkerAIController(const FObjectInitializer& ObjectInitial SightConfiguration->DetectionByAffiliation.bDetectEnemies = true; SightConfiguration->DetectionByAffiliation.bDetectNeutrals = true; SightConfiguration->DetectionByAffiliation.bDetectFriendlies = true; - + Perception->ConfigureSense(*SightConfiguration); Perception->SetDominantSense(SightConfiguration->GetSenseImplementation()); Perception->OnPerceptionUpdated.AddDynamic(this, &AWalkerAIController::SenseActors); @@ -163,7 +163,6 @@ AWalkerAIController::AWalkerAIController(const FObjectInitializer& ObjectInitial TimeInState=0.0f; } - void AWalkerAIController::Possess(APawn *aPawn) { Super::Possess(aPawn); @@ -175,12 +174,12 @@ void AWalkerAIController::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); TimeInState+=DeltaSeconds; - if (Status != EWalkerStatus::RunOver) + if (Status != EWalkerStatus::RunOver) { - switch (GetMoveStatus()) + switch (GetMoveStatus()) { default: break; - case EPathFollowingStatus::Idle: + case EPathFollowingStatus::Idle: //case EPathFollowingStatus::Waiting: //<-- incomplete path LOG_AI_WALKER(Warning, "is stuck!"); ChangeStatus(EWalkerStatus::Stuck); @@ -191,7 +190,7 @@ void AWalkerAIController::Tick(float DeltaSeconds) TryResumeMovement(); } break; - + }; } } @@ -208,7 +207,7 @@ FPathFollowingRequestResult AWalkerAIController::MoveTo( ; #endif // CARLA_AI_WALKERS_EXTRA_LOG - + ChangeStatus(EWalkerStatus::Moving); return Super::MoveTo(MoveRequest, OutPath); } @@ -221,13 +220,12 @@ void AWalkerAIController::OnMoveCompleted( #ifdef CARLA_AI_WALKERS_EXTRA_LOG UE_LOG(LogCarla, Log, TEXT("Walker %s completed move at (%s)"), *GetPawn()->GetName(), - *GetPawn()->GetActorLocation().ToString()) -; + *GetPawn()->GetActorLocation().ToString()); #endif // CARLA_AI_WALKERS_EXTRA_LOG ChangeStatus(EWalkerStatus::MoveCompleted); } -void AWalkerAIController::SenseActors(TArray Actors) +void AWalkerAIController::SenseActors(const TArray &Actors) { const auto *aPawn = GetPawn(); if ((Status == EWalkerStatus::Moving) && diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.h index 986d22fde..5db79ee81 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Walker/WalkerAIController.h @@ -35,16 +35,17 @@ public: virtual void Tick(float DeltaSeconds) override; - + virtual FPathFollowingRequestResult MoveTo( const FAIMoveRequest& MoveRequest, FNavPathSharedPtr* OutPath = nullptr) override; - virtual void OnMoveCompleted(FAIRequestID RequestID, const FPathFollowingResult &Result) override; - + virtual void OnMoveCompleted( + FAIRequestID RequestID, + const FPathFollowingResult &Result) override; UFUNCTION(BlueprintCallable) - void SenseActors(TArray Actors); + void SenseActors(const TArray &Actors); EWalkerStatus GetWalkerStatus() const { @@ -58,19 +59,27 @@ public: float GetTimeInState() const { return TimeInState; } private: + void ChangeStatus(EWalkerStatus status); + void TryResumeMovement(); - + void TryPauseMovement(bool bItWasRunOver = false); UFUNCTION() - void OnPawnTookDamage(AActor *DamagedActor, float Damage, const UDamageType *DamageType, AController *InstigatedBy, AActor *DamageCauser); + void OnPawnTookDamage( + AActor *DamagedActor, + float Damage, + const UDamageType *DamageType, + AController *InstigatedBy, + AActor *DamageCauser); UPROPERTY(Category = "Walker AI Controller", VisibleAnywhere) UAISenseConfig_Sight *SightConfiguration; UPROPERTY(VisibleAnywhere) EWalkerStatus Status = EWalkerStatus::Unknown; + /** Continous time in the same EWalkerStatus */ float TimeInState=0.0f; }; diff --git a/Util/BuildTools/BuildCarlaUE4.sh b/Util/BuildTools/BuildCarlaUE4.sh new file mode 100755 index 000000000..950aed19f --- /dev/null +++ b/Util/BuildTools/BuildCarlaUE4.sh @@ -0,0 +1,147 @@ +#! /bin/bash + +# ============================================================================== +# -- Set up environment -------------------------------------------------------- +# ============================================================================== + +source $(dirname "$0")/Environment.sh + +if [ ! -d "${UE4_ROOT}" ]; then + fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable." +else + log "Using Unreal Engine at '$UE4_ROOT'" +fi + +# ============================================================================== +# -- Parse arguments ----------------------------------------------------------- +# ============================================================================== + +DOC_STRING="Build and launch CarlaUE4." + +USAGE_STRING="Usage: $0 [-h|--help] [--build] [--rebuild] [--launch] [--clean] [--hard-clean]" + +REMOVE_INTERMEDIATE=false +HARD_CLEAN=false +BUILD_CARLAUE4=false +LAUNCH_UE4_EDITOR=false + +OPTS=`getopt -o h --long help,build,rebuild,launch,clean,hard-clean -n 'parse-options' -- "$@"` + +if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi + +eval set -- "$OPTS" + +while true; do + case "$1" in + --build ) + BUILD_CARLAUE4=true; + shift ;; + --rebuild ) + REMOVE_INTERMEDIATE=true; + BUILD_CARLAUE4=true; + shift ;; + --launch ) + LAUNCH_UE4_EDITOR=true; + shift ;; + --clean ) + REMOVE_INTERMEDIATE=true; + shift ;; + --hard-clean ) + REMOVE_INTERMEDIATE=true; + HARD_CLEAN=true; + shift ;; + -h | --help ) + echo "$DOC_STRING" + echo "$USAGE_STRING" + exit 1 + ;; + * ) + break ;; + esac +done + +if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_CARLAUE4} || ${LAUNCH_UE4_EDITOR}; }; then + fatal_error "Nothing selected to be done." +fi + +pushd "${CARLAUE4_ROOT_FOLDER}" >/dev/null + +# ============================================================================== +# -- Clean CarlaUE4 ------------------------------------------------------------ +# ============================================================================== + +if ${REMOVE_INTERMEDIATE} ; then + + log "Cleaning intermediate files and folders." + + UE4_INTERMEDIATE_FOLDERS="Binaries Build Intermediate DerivedDataCache" + + rm -Rf ${UE4_INTERMEDIATE_FOLDERS} + + pushd "${CARLAUE4_PLUGIN_ROOT_FOLDER}" >/dev/null + + rm -Rf ${UE4_INTERMEDIATE_FOLDERS} + + popd >/dev/null + +fi + +if ${HARD_CLEAN} ; then + + if [ ! -f Makefile ]; then + fatal_error "The project wasn't built before!" + fi + + log "Doing a \"hard\" clean of the Unreal Engine project." + + make CarlaUE4Editor ARGS=-clean + +fi + +if ${REMOVE_INTERMEDIATE} ; then + + rm -f Makefile + +fi + +# ============================================================================== +# -- Build CarlaUE4 ------------------------------------------------------------ +# ============================================================================== + +if ${BUILD_CARLAUE4} ; then + + if [ ! -f Makefile ]; then + + # This command fails sometimes but normally we can continue anyway. + set +e + log "Generate Unreal project files." + ${UE4_ROOT}/GenerateProjectFiles.sh -project="${PWD}/CarlaUE4.uproject" -game -engine -makefiles + set -e + + fi + + log "Build CarlaUE4 project." + make CarlaUE4Editor + +fi + +# ============================================================================== +# -- Launch UE4Editor ---------------------------------------------------------- +# ============================================================================== + +if ${LAUNCH_UE4_EDITOR} ; then + + log "Launching UE4Editor..." + ${UE4_ROOT}/Engine/Binaries/Linux/UE4Editor "${PWD}/CarlaUE4.uproject" + +else + + log "Success!" + +fi + +# ============================================================================== +# -- ...and we are done -------------------------------------------------------- +# ============================================================================== + +popd >/dev/null diff --git a/Util/BuildTools/BuildLibCarla.sh b/Util/BuildTools/BuildLibCarla.sh new file mode 100755 index 000000000..49b73fcb3 --- /dev/null +++ b/Util/BuildTools/BuildLibCarla.sh @@ -0,0 +1,131 @@ +#! /bin/bash + +source $(dirname "$0")/Environment.sh + +# ============================================================================== +# -- Parse arguments ----------------------------------------------------------- +# ============================================================================== + +DOC_STRING="Build LibCarla." + +USAGE_STRING="Usage: $0 [-h|--help] [--rebuild] [--server] [--client] [--clean]" + +REMOVE_INTERMEDIATE=false +BUILD_SERVER=false +BUILD_CLIENT=false + +OPTS=`getopt -o h --long help,rebuild,server,client,clean -n 'parse-options' -- "$@"` + +if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi + +eval set -- "$OPTS" + +while true; do + case "$1" in + --rebuild ) + REMOVE_INTERMEDIATE=true; + BUILD_SERVER=true; + BUILD_CLIENT=true; + shift ;; + --server ) + BUILD_SERVER=true; + shift ;; + --client ) + BUILD_CLIENT=true; + shift ;; + --clean ) + REMOVE_INTERMEDIATE=true; + shift ;; + -h | --help ) + echo "$DOC_STRING" + echo "$USAGE_STRING" + exit 1 + ;; + * ) + break ;; + esac +done + +if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_SERVER} || ${BUILD_CLIENT}; }; then + fatal_error "Nothing selected to be done." +fi + +# ============================================================================== +# -- Clean intermediate files -------------------------------------------------- +# ============================================================================== + +if ${REMOVE_INTERMEDIATE} ; then + + log "Cleaning intermediate files and folders." + + rm -Rf ${LIBCARLA_BUILD_SERVER_FOLDER} ${LIBCARLA_BUILD_CLIENT_FOLDER} + rm -Rf ${LIBCARLA_INSTALL_SERVER_FOLDER} ${LIBCARLA_INSTALL_CLIENT_FOLDER} + rm -f ${LIBCARLA_ROOT_FOLDER}/source/carla/Version.h + +fi + +# ============================================================================== +# -- Build Server configuration ------------------------------------------------ +# ============================================================================== + +if ${BUILD_SERVER} ; then + + log "Building LibCarla \"Server\" configuration." + + mkdir -p ${LIBCARLA_BUILD_SERVER_FOLDER} + pushd "${LIBCARLA_BUILD_SERVER_FOLDER}" >/dev/null + + if [ ! -f "build.ninja" ]; then + + cmake \ + -G "Ninja" \ + -DCMAKE_BUILD_TYPE=Server \ + -DCMAKE_TOOLCHAIN_FILE=${LIBCPP_TOOLCHAIN_FILE} \ + -DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_SERVER_FOLDER} \ + ${CARLA_ROOT_FOLDER} + + fi + + ninja + + ninja install | grep -v "Up-to-date:" + + popd >/dev/null + +fi + +# ============================================================================== +# -- Build Client configuration ------------------------------------------------ +# ============================================================================== + +if ${BUILD_CLIENT} ; then + + log "Building LibCarla \"Client\" configuration." + + mkdir -p ${LIBCARLA_BUILD_CLIENT_FOLDER} + pushd "${LIBCARLA_BUILD_CLIENT_FOLDER}" >/dev/null + + if [ ! -f "build.ninja" ]; then + + cmake \ + -G "Ninja" \ + -DCMAKE_BUILD_TYPE=Client \ + -DCMAKE_TOOLCHAIN_FILE=${LIBSTDCPP_TOOLCHAIN_FILE} \ + -DCMAKE_INSTALL_PREFIX=${LIBCARLA_INSTALL_CLIENT_FOLDER} \ + ${CARLA_ROOT_FOLDER} + + fi + + ninja + + ninja install | grep -v "Up-to-date:" + + popd >/dev/null + +fi + +# ============================================================================== +# -- ...and we are done -------------------------------------------------------- +# ============================================================================== + +log "Success!" diff --git a/Util/BuildTools/BuildPythonAPI.sh b/Util/BuildTools/BuildPythonAPI.sh new file mode 100755 index 000000000..89671c58a --- /dev/null +++ b/Util/BuildTools/BuildPythonAPI.sh @@ -0,0 +1,99 @@ +#! /bin/bash + +source $(dirname "$0")/Environment.sh + +export CC=clang-5.0 +export CXX=clang++-5.0 + +# ============================================================================== +# -- Parse arguments ----------------------------------------------------------- +# ============================================================================== + +DOC_STRING="Build and package CARLA Python API." + +USAGE_STRING="Usage: $0 [-h|--help] [--rebuild] [--py2] [--py3] [--clean]" + +REMOVE_INTERMEDIATE=false +BUILD_FOR_PYTHON2=false +BUILD_FOR_PYTHON3=false + +OPTS=`getopt -o h --long help,rebuild,py2,py3,clean -n 'parse-options' -- "$@"` + +if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi + +eval set -- "$OPTS" + +while true; do + case "$1" in + --rebuild ) + REMOVE_INTERMEDIATE=true; + BUILD_FOR_PYTHON2=true; + BUILD_FOR_PYTHON3=true; + shift ;; + --py2 ) + BUILD_FOR_PYTHON2=true; + shift ;; + --py3 ) + BUILD_FOR_PYTHON3=true; + shift ;; + --clean ) + REMOVE_INTERMEDIATE=true; + shift ;; + -h | --help ) + echo "$DOC_STRING" + echo "$USAGE_STRING" + exit 1 + ;; + * ) + break ;; + esac +done + +if ! { ${REMOVE_INTERMEDIATE} || ${BUILD_FOR_PYTHON2} || ${BUILD_FOR_PYTHON3}; }; then + fatal_error "Nothing selected to be done." +fi + +pushd "${CARLA_PYTHONAPI_ROOT_FOLDER}" >/dev/null + +# ============================================================================== +# -- Clean intermediate files -------------------------------------------------- +# ============================================================================== + +if ${REMOVE_INTERMEDIATE} ; then + + log "Cleaning intermediate files and folders." + + rm -Rf build dist carla.egg-info source/carla.egg-info + + find source -name "*.so" -delete + find source -name "__pycache__" -type d -exec rm -r "{}" \; + +fi + +# ============================================================================== +# -- Build API ----------------------------------------------------------------- +# ============================================================================== + +if ${BUILD_FOR_PYTHON2} ; then + + log "Building Python API for Python 2." + + /usr/bin/env python2 setup.py bdist_egg + +fi + +if ${BUILD_FOR_PYTHON3} ; then + + log "Building Python API for Python 3." + + /usr/bin/env python3 setup.py bdist_egg + +fi + +# ============================================================================== +# -- ...and we are done -------------------------------------------------------- +# ============================================================================== + +popd >/dev/null + +log "Success!" diff --git a/Util/BuildTools/Check.sh b/Util/BuildTools/Check.sh new file mode 100755 index 000000000..db3609226 --- /dev/null +++ b/Util/BuildTools/Check.sh @@ -0,0 +1,131 @@ +#! /bin/bash + +source $(dirname "$0")/Environment.sh + +# ============================================================================== +# -- Parse arguments ----------------------------------------------------------- +# ============================================================================== + +DOC_STRING="Run unit tests." + +USAGE_STRING=$(cat <<- END +Usage: $0 [-h|--help] [--gdb] [--gtest_args=ARGS] + +Then either ran all the tests + + [--all] + +Or choose one or more of the following + + [--libcarla-release] [--libcarla-debug] + [--python-api-2] [--python-api-3] + [--benchmark] +END +) + +GDB= +GTEST_ARGS= +LIBCARLA_RELEASE=false +LIBCARLA_DEBUG=false +PYTHON_API_2=false +PYTHON_API_3=false + +OPTS=`getopt -o h --long help,gdb,gtest_args:,all,libcarla-release,libcarla-debug,python-api-2,python-api-3,benchmark -n 'parse-options' -- "$@"` + +if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi + +eval set -- "$OPTS" + +while true; do + case "$1" in + --gdb ) + GDB="gdb --args"; + shift ;; + --gtest_args ) + GTEST_ARGS="$2"; + shift ;; + --all ) + LIBCARLA_RELEASE=true; + LIBCARLA_DEBUG=true; + PYTHON_API_2=true; + PYTHON_API_3=true; + shift ;; + --libcarla-release ) + LIBCARLA_RELEASE=true; + shift ;; + --libcarla-debug ) + LIBCARLA_DEBUG=true; + shift ;; + --python-api-2 ) + PYTHON_API_2=true; + shift ;; + --python-api-3 ) + PYTHON_API_3=true; + shift ;; + --benchmark ) + LIBCARLA_RELEASE=true; + GTEST_ARGS="--gtest_filter=benchmark*"; + shift ;; + -h | --help ) + echo "$DOC_STRING" + echo -e "$USAGE_STRING" + exit 1 + ;; + * ) + break ;; + esac +done + +if ! { ${LIBCARLA_RELEASE} || ${LIBCARLA_DEBUG} || ${PYTHON_API_2} || ${PYTHON_API_3}; }; then + fatal_error "Nothing selected to be done." +fi + +# ============================================================================== +# -- Run LibCarla tests -------------------------------------------------------- +# ============================================================================== + +if ${LIBCARLA_DEBUG} ; then + + log "Running LibCarla unit tests debug." + + LD_LIBRARY_PATH=${LIBCARLA_INSTALL_SERVER_FOLDER}/lib ${GDB} ${LIBCARLA_INSTALL_SERVER_FOLDER}/test/libcarla_test_debug ${GTEST_ARGS} + +fi + +if ${LIBCARLA_RELEASE} ; then + + log "Running LibCarla unit tests release." + + LD_LIBRARY_PATH=${LIBCARLA_INSTALL_SERVER_FOLDER}/lib ${GDB} ${LIBCARLA_INSTALL_SERVER_FOLDER}/test/libcarla_test_release ${GTEST_ARGS} + +fi + +# ============================================================================== +# -- Run Python API tests ------------------------------------------------------ +# ============================================================================== + +pushd "${CARLA_PYTHONAPI_ROOT_FOLDER}/test" >/dev/null + +if ${PYTHON_API_2} ; then + + log "Running Python API for Python 2 unit tests." + + /usr/bin/env python2 -m nose2 + +fi + +if ${PYTHON_API_3} ; then + + log "Running Python API for Python 3 unit tests." + + /usr/bin/env python3 -m nose2 + +fi + +popd >/dev/null + +# ============================================================================== +# -- ...and we are done -------------------------------------------------------- +# ============================================================================== + +log "Success!" diff --git a/Util/BuildTools/Environment.sh b/Util/BuildTools/Environment.sh new file mode 100644 index 000000000..03a334009 --- /dev/null +++ b/Util/BuildTools/Environment.sh @@ -0,0 +1,47 @@ +#! /bin/bash + +# Sets the environment for other shell scripts. + +set -e + +CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" +source $(dirname "$0")/Vars.mk +unset CURDIR + +if [ -n "${CARLA_BUILD_NO_COLOR}" ]; then + + function log { + echo "`basename "$0"`: $1" + } + + function fatal_error { + echo -e >&2 "`basename "$0"`: ERROR: $1" + exit 2 + } + +else + + function log { + echo -e "\033[1;35m`basename "$0"`: $1\033[0m" + } + + function fatal_error { + echo -e >&2 "\033[0;31m`basename "$0"`: ERROR: $1\033[0m" + exit 2 + } + +fi + +function get_carla_version { + git describe --tags --dirty --always +} + +function copy_if_changed { + mkdir -p $(dirname $2) + rsync -cI --out-format="%n" $1 $2 +} + +function move_if_changed { + copy_if_changed $1 $2 + rm -f $1 +} diff --git a/Util/BuildTools/Linux.mk b/Util/BuildTools/Linux.mk new file mode 100644 index 000000000..a1100969e --- /dev/null +++ b/Util/BuildTools/Linux.mk @@ -0,0 +1,57 @@ +ARGS=--all + +default: help + +help: + @less ${CARLA_BUILD_TOOLS_FOLDER}/Linux.mk.help + +launch: LibCarla + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --build --launch + +launch-only: + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --launch + +package: CarlaUE4Editor PythonAPI + @${CARLA_BUILD_TOOLS_FOLDER}/Package.sh + +docs: + @doxygen + @echo "Documentation index at ./Doxygen/html/index.html" + +clean: + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --clean + @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --clean + @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --clean + +rebuild: setup + @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --rebuild + @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --rebuild + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --rebuild + +hard-clean: clean + @rm -Rf ${CARLA_BUILD_FOLDER} + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --hard-clean + +check: PythonAPI + @${CARLA_BUILD_TOOLS_FOLDER}/Check.sh $(ARGS) + +benchmark: LibCarla + @${CARLA_BUILD_TOOLS_FOLDER}/Check.sh --benchmark + @cat profiler.csv + +CarlaUE4Editor: LibCarla + @${CARLA_BUILD_TOOLS_FOLDER}/BuildCarlaUE4.sh --build + +.PHONY: PythonAPI +PythonAPI: LibCarla + @${CARLA_BUILD_TOOLS_FOLDER}/BuildPythonAPI.sh --py2 --py3 + +.PHONY: LibCarla +LibCarla: setup + @${CARLA_BUILD_TOOLS_FOLDER}/BuildLibCarla.sh --server --client + +setup: + @${CARLA_BUILD_TOOLS_FOLDER}/Setup.sh + +pretty: + @${CARLA_BUILD_TOOLS_FOLDER}/Prettify.sh $(ARGS) diff --git a/Util/BuildTools/Linux.mk.help b/Util/BuildTools/Linux.mk.help new file mode 100644 index 000000000..28f4d7627 --- /dev/null +++ b/Util/BuildTools/Linux.mk.help @@ -0,0 +1,77 @@ +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-only: + + Launch CarlaUE4 project in Unreal Engine's Editor, but skip building + step (assume the project is already built). + + 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. + + hard-clean: + + Remove intermediate build files and dependencies, and force a + recompilation of Unreal Engine's pre-compiled headers. Useful for + fixing "version.h has been modified since the precompiled header" + errors. Beware, recompilation takes a long time! + + +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. + + pretty: + + Prettify code files. Run uncrustify on C++ files or AutoPEP8 on Python + files. To prettify a single file, use: make pretty ARGS=-f/path/to/file. + + diff --git a/Package.sh b/Util/BuildTools/Package.sh similarity index 59% rename from Package.sh rename to Util/BuildTools/Package.sh index 155fd65d9..92155640d 100755 --- a/Package.sh +++ b/Util/BuildTools/Package.sh @@ -1,20 +1,15 @@ #! /bin/bash -################################################################################ -# Packages a CARLA build. -################################################################################ - -set -e - -DOC_STRING="Makes a packaged version of CARLA for distribution. -Please make sure to run Rebuild.sh before!" - -USAGE_STRING="Usage: $0 [-h|--help] [--no-packaging] [--no-zip] [--clean-intermediate]" +source $(dirname "$0")/Environment.sh # ============================================================================== # -- Parse arguments ----------------------------------------------------------- # ============================================================================== +DOC_STRING="Makes a packaged version of CARLA for distribution." + +USAGE_STRING="Usage: $0 [-h|--help] [--no-packaging] [--no-zip] [--clean-intermediate]" + DO_PACKAGE=true DO_COPY_FILES=true DO_TARBALL=true @@ -47,39 +42,21 @@ while true; do esac done -# ============================================================================== -# -- Set up environment -------------------------------------------------------- -# ============================================================================== - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd "$SCRIPT_DIR" >/dev/null - -REPOSITORY_TAG=`git describe --tags --dirty --always` - -echo "Packaging version '$REPOSITORY_TAG'." - -UNREAL_PROJECT_FOLDER=${PWD}/Unreal/CarlaUE4 -DIST_FOLDER=${PWD}/Dist -BUILD_FOLDER=${DIST_FOLDER}/${REPOSITORY_TAG} - -function fatal_error { - echo -e "\033[0;31mERROR: $1\033[0m" - exit 1 -} - -function log { - echo -e "\033[0;33m$1\033[0m" -} - # ============================================================================== # -- Package project ----------------------------------------------------------- # ============================================================================== +REPOSITORY_TAG=$(get_carla_version) + +BUILD_FOLDER=${CARLA_DIST_FOLDER}/${REPOSITORY_TAG} + +log "Packaging version '$REPOSITORY_TAG'." + if $DO_PACKAGE ; then - pushd "$UNREAL_PROJECT_FOLDER" >/dev/null + pushd "${CARLAUE4_ROOT_FOLDER}" >/dev/null - log "Packaging the project..." + log "Packaging the project." if [ ! -d "${UE4_ROOT}" ]; then fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable." @@ -105,34 +82,25 @@ if [[ ! -d ${BUILD_FOLDER}/LinuxNoEditor ]] ; then fi # ============================================================================== -# -- Copy files (Python server, README, etc) ----------------------------------- +# -- Copy files (Python API, README, etc) -------------------------------------- # ============================================================================== if $DO_COPY_FILES ; then DESTINATION=${BUILD_FOLDER}/LinuxNoEditor - log "Copying extra files..." + log "Adding extra files to package." - cp -v ./LICENSE ${DESTINATION}/LICENSE - cp -v ./CHANGELOG.md ${DESTINATION}/CHANGELOG - cp -v ./Docs/release_readme.md ${DESTINATION}/README - cp -v ./Docs/Example.CarlaSettings.ini ${DESTINATION}/Example.CarlaSettings.ini - cp -v ./Util/Docker/Release.Dockerfile ${DESTINATION}/Dockerfile + pushd ${CARLA_ROOT_FOLDER} >/dev/null - rsync -vhr --delete --delete-excluded \ - --exclude "*.egg-info" \ - --exclude "*.log" \ - --exclude "*.pyc" \ - --exclude ".*" \ - --exclude ".tags*" \ - --exclude "__pycache__" \ - --exclude "_benchmarks_results*" \ - --exclude "_images*" \ - --exclude "_out*" \ - PythonClient/ ${DESTINATION}/PythonClient + copy_if_changed "./LICENSE" "${DESTINATION}/LICENSE" + copy_if_changed "./CHANGELOG.md" "${DESTINATION}/CHANGELOG" + copy_if_changed "./Docs/release_readme.md" "${DESTINATION}/README" + copy_if_changed "./Docs/Example.CarlaSettings.ini" "${DESTINATION}/Example.CarlaSettings.ini" + copy_if_changed "./Util/Docker/Release.Dockerfile" "${DESTINATION}/Dockerfile" + copy_if_changed "./PythonAPI/dist/*.egg" "${DESTINATION}/PythonAPI" - echo + popd >/dev/null fi @@ -142,12 +110,12 @@ fi if $DO_TARBALL ; then - DESTINATION=${DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz + DESTINATION=${CARLA_DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz SOURCE=${BUILD_FOLDER}/LinuxNoEditor - pushd "$SOURCE" >/dev/null + pushd "${SOURCE}" >/dev/null - log "Packaging build..." + log "Packaging build." rm -f ./Manifest_NonUFSFiles_Linux.txt rm -Rf ./CarlaUE4/Saved @@ -165,7 +133,7 @@ fi if $DO_CLEAN_INTERMEDIATE ; then - log "Removing intermediate build..." + log "Removing intermediate build." rm -Rf ${BUILD_FOLDER} @@ -176,16 +144,10 @@ fi # ============================================================================== if $DO_TARBALL ; then - FINAL_PACKAGE=Dist/CARLA_${REPOSITORY_TAG}.tar.gz + FINAL_PACKAGE=${CARLA_DIST_FOLDER}/CARLA_${REPOSITORY_TAG}.tar.gz else - FINAL_PACKAGE=Dist/${REPOSITORY_TAG} + FINAL_PACKAGE=${BUILD_FOLDER} fi -echo -echo "Packaged version created at ${FINAL_PACKAGE}" -echo -echo "****************" -echo "*** Success! ***" -echo "****************" - -popd >/dev/null +log "Packaged version created at ${FINAL_PACKAGE}" +log "Success!" diff --git a/Util/BuildTools/Prettify.sh b/Util/BuildTools/Prettify.sh new file mode 100755 index 000000000..631e6e909 --- /dev/null +++ b/Util/BuildTools/Prettify.sh @@ -0,0 +1,137 @@ +#! /bin/bash + +# ============================================================================== +# -- Set up environment -------------------------------------------------------- +# ============================================================================== + +source $(dirname "$0")/Environment.sh + +# ============================================================================== +# -- Parse arguments ----------------------------------------------------------- +# ============================================================================== + +DOC_STRING="Prettify code files." + +USAGE_STRING="Usage: $0 [-h|--help] [--all] [-f path|--file=path]" + +PRETTIFY_ALL=false +PRETTIFY_FILE=false + +OPTS=`getopt -o hf: --long help,all,file: -n 'parse-options' -- "$@"` + +if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2 ; fi + +eval set -- "$OPTS" + +while true; do + case "$1" in + --all ) + PRETTIFY_ALL=true; + shift ;; + -f | --file ) + PRETTIFY_FILE="$2"; + shift ;; + -h | --help ) + echo "$DOC_STRING" + echo "$USAGE_STRING" + exit 1 + ;; + * ) + break ;; + esac +done + +if ! { ${PRETTIFY_ALL} || [ -n "${PRETTIFY_FILE}" ]; } ; then + fatal_error "Nothing selected to be done." +fi + +if ${PRETTIFY_ALL} ; then + PRETTIFY_FILE=false +elif [[ ! -f ${PRETTIFY_FILE} ]] ; then + pwd + fatal_error "\"${PRETTIFY_FILE}\" no such file." +fi + +# ============================================================================== +# -- Get latest version of uncrustify ------------------------------------------ +# ============================================================================== + +mkdir -p ${CARLA_BUILD_FOLDER} +pushd ${CARLA_BUILD_FOLDER} >/dev/null + +UNCRUSTIFY_BASENAME=uncrustify-0.67 + +UNCRUSTIFY=${PWD}/${UNCRUSTIFY_BASENAME}-install/bin/uncrustify + +if [[ -d "${UNCRUSTIFY_BASENAME}-install" ]] ; then + log "${UNCRUSTIFY_BASENAME} already installed." +else + rm -Rf ${UNCRUSTIFY_BASENAME}-source ${UNCRUSTIFY_BASENAME}-build + + log "Retrieving Uncrustify." + + git clone --depth=1 -b uncrustify-0.67 https://github.com/uncrustify/uncrustify.git ${UNCRUSTIFY_BASENAME}-source + + log "Building Uncrustify." + + mkdir -p ${UNCRUSTIFY_BASENAME}-build + + pushd ${UNCRUSTIFY_BASENAME}-build >/dev/null + + cmake -G "Ninja" \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="../${UNCRUSTIFY_BASENAME}-install" \ + ../${UNCRUSTIFY_BASENAME}-source + + ninja + + ninja install + + popd >/dev/null + + rm -Rf ${UNCRUSTIFY_BASENAME}-source ${UNCRUSTIFY_BASENAME}-build + +fi + +command -v ${UNCRUSTIFY} >/dev/null 2>&1 || { + fatal_error "Failed to install Uncrustify!"; +} + +popd >/dev/null + +command -v autopep8 >/dev/null 2>&1 || { + log "Installing autopep8 for this user." + pip3 install --user autopep8 +} + +# ============================================================================== +# -- Run uncrustify and/or autopep8 -------------------------------------------- +# ============================================================================== + +UNCRUSTIFY_CONFIG=${CARLA_BUILD_TOOLS_FOLDER}/uncrustify.cfg +UNCRUSTIFY_COMMAND="${UNCRUSTIFY} -c ${UNCRUSTIFY_CONFIG} --no-backup --replace" + +AUTOPEP8_COMMAND="autopep8 --jobs 0 --in-place -a" + +if ${PRETTIFY_ALL} ; then + + find ${CARLA_ROOT_FOLDER} -iregex '.*\.\(py\)$' -exec ${AUTOPEP8_COMMAND} {} + + # find ${LIBCARLA_ROOT_FOLDER} -iregex '.*\.\(h\|cpp\)$' -exec ${UNCRUSTIFY_COMMAND} {} \; + +elif [[ -f ${PRETTIFY_FILE} ]] ; then + + if [[ ${PRETTIFY_FILE} == *.py ]] ; then + log "autopep8 ${PRETTIFY_FILE}" + ${AUTOPEP8_COMMAND} ${PRETTIFY_FILE} + else + log "uncrustify ${PRETTIFY_FILE}" + ${UNCRUSTIFY_COMMAND} ${PRETTIFY_FILE} + fi + +fi + +# ============================================================================== +# -- ...and we are done -------------------------------------------------------- +# ============================================================================== + +log "Success!" diff --git a/Util/BuildTools/Setup.sh b/Util/BuildTools/Setup.sh new file mode 100755 index 000000000..214e7daf0 --- /dev/null +++ b/Util/BuildTools/Setup.sh @@ -0,0 +1,267 @@ +#! /bin/bash + +# ============================================================================== +# -- Set up environment -------------------------------------------------------- +# ============================================================================== + +command -v /usr/bin/clang++-5.0 >/dev/null 2>&1 || { + echo >&2 "clang 5.0 is required, but it's not installed."; + echo >&2 "make sure you build Unreal Engine with clang 5.0 too."; + exit 1; +} + +export CC=/usr/bin/clang-5.0 +export CXX=/usr/bin/clang++-5.0 + +source $(dirname "$0")/Environment.sh + +mkdir -p ${CARLA_BUILD_FOLDER} +pushd ${CARLA_BUILD_FOLDER} >/dev/null + +# ============================================================================== +# -- Get and compile libc++ ---------------------------------------------------- +# ============================================================================== + +LLVM_BASENAME=llvm-5.0 + +LLVM_INCLUDE=${PWD}/${LLVM_BASENAME}-install/include/c++/v1 +LLVM_LIBPATH=${PWD}/${LLVM_BASENAME}-install/lib + +if [[ -d "${LLVM_BASENAME}-install" ]] ; then + log "${LLVM_BASENAME} already installed." +else + rm -Rf ${LLVM_BASENAME}-source ${LLVM_BASENAME}-build + + log "Retrieving libc++." + + git clone --depth=1 -b release_50 https://github.com/llvm-mirror/llvm.git ${LLVM_BASENAME}-source + git clone --depth=1 -b release_50 https://github.com/llvm-mirror/libcxx.git ${LLVM_BASENAME}-source/projects/libcxx + git clone --depth=1 -b release_50 https://github.com/llvm-mirror/libcxxabi.git ${LLVM_BASENAME}-source/projects/libcxxabi + + log "Compiling libc++." + + mkdir -p ${LLVM_BASENAME}-build + + pushd ${LLVM_BASENAME}-build >/dev/null + + cmake -G "Ninja" \ + -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=OFF \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="../${LLVM_BASENAME}-install" \ + ../${LLVM_BASENAME}-source + + ninja cxx + + ninja install-libcxx + + ninja install-libcxxabi + + popd >/dev/null + + # Workaround, it seems LLVM 5.0 does not install these files. + cp -v ${LLVM_BASENAME}-build/include/c++/v1/cxxabi.h ${LLVM_INCLUDE} + cp -v ${LLVM_BASENAME}-build/include/c++/v1/__cxxabi_config.h ${LLVM_INCLUDE} + + rm -Rf ${LLVM_BASENAME}-source ${LLVM_BASENAME}-build + +fi + +unset LLVM_BASENAME + +# ============================================================================== +# -- Get boost includes -------------------------------------------------------- +# ============================================================================== + +BOOST_BASENAME=boost-1.67.0 + +BOOST_INCLUDE=${PWD}/${BOOST_BASENAME}-install/include + +if [[ -d "${BOOST_BASENAME}-install" ]] ; then + log "${BOOST_BASENAME} already installed." +else + + log "Retrieving boost." + wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.gz + log "Extracting boost." + tar -xzf boost_1_67_0.tar.gz + rm boost_1_67_0.tar.gz + mkdir -p ${BOOST_BASENAME}-install/include + mv boost_1_67_0/boost ${BOOST_BASENAME}-install/include/ + rm -Rf boost_1_67_0 + +fi + +unset BOOST_BASENAME + +# ============================================================================== +# -- Get rpclib and compile it with libc++ and libstdc++ ----------------------- +# ============================================================================== + +RPCLIB_BASENAME=rpclib-2.2.1 + +RPCLIB_LIBCXX_INCLUDE=${PWD}/${RPCLIB_BASENAME}-libcxx-install/include +RPCLIB_LIBCXX_LIBPATH=${PWD}/${RPCLIB_BASENAME}-libcxx-install/lib +RPCLIB_LIBSTDCXX_INCLUDE=${PWD}/${RPCLIB_BASENAME}-libstdcxx-install/include +RPCLIB_LIBSTDCXX_LIBPATH=${PWD}/${RPCLIB_BASENAME}-libstdcxx-install/lib + +if [[ -d "${RPCLIB_BASENAME}-libcxx-install" && -d "${RPCLIB_BASENAME}-libstdcxx-install" ]] ; then + log "${RPCLIB_BASENAME} already installed." +else + rm -Rf \ + ${RPCLIB_BASENAME}-source \ + ${RPCLIB_BASENAME}-libcxx-build ${RPCLIB_BASENAME}-libstdcxx-build \ + ${RPCLIB_BASENAME}-libcxx-install ${RPCLIB_BASENAME}-libstdcxx-install + + log "Retrieving rpclib." + + git clone --depth=1 -b v2.2.1 https://github.com/rpclib/rpclib.git ${RPCLIB_BASENAME}-source + + log "Building rpclib with libc++." + + mkdir -p ${RPCLIB_BASENAME}-libcxx-build + + pushd ${RPCLIB_BASENAME}-libcxx-build >/dev/null + + cmake -G "Ninja" \ + -DCMAKE_CXX_FLAGS="-fPIC -std=c++17 -stdlib=libc++ -I${LLVM_INCLUDE} -Wl,-L${LLVM_LIBPATH}" \ + -DCMAKE_INSTALL_PREFIX="../${RPCLIB_BASENAME}-libcxx-install" \ + ../${RPCLIB_BASENAME}-source + + ninja + + ninja install + + popd >/dev/null + + log "Building rpclib with libstdc++." + + mkdir -p ${RPCLIB_BASENAME}-libstdcxx-build + + pushd ${RPCLIB_BASENAME}-libstdcxx-build >/dev/null + + cmake -G "Ninja" \ + -DCMAKE_CXX_FLAGS="-fPIC -std=c++17" \ + -DCMAKE_INSTALL_PREFIX="../${RPCLIB_BASENAME}-libstdcxx-install" \ + ../${RPCLIB_BASENAME}-source + + ninja + + ninja install + + popd >/dev/null + + rm -Rf ${RPCLIB_BASENAME}-source ${RPCLIB_BASENAME}-libcxx-build ${RPCLIB_BASENAME}-libstdcxx-build + +fi + +unset RPCLIB_BASENAME + +# ============================================================================== +# -- Get GTest and compile it with libc++ -------------------------------------- +# ============================================================================== + +GTEST_BASENAME=googletest-1.8.0 + +GTEST_INCLUDE=${PWD}/${GTEST_BASENAME}-install/include +GTEST_LIBPATH=${PWD}/${GTEST_BASENAME}-install/lib + +if [[ -d "${GTEST_BASENAME}-install" ]] ; then + log "${GTEST_BASENAME} already installed." +else + rm -Rf ${GTEST_BASENAME}-source ${GTEST_BASENAME}-build + + log "Retrieving Google Test." + + git clone --depth=1 -b release-1.8.0 https://github.com/google/googletest.git ${GTEST_BASENAME}-source + + log "Building Google Test." + + mkdir -p ${GTEST_BASENAME}-build + + pushd ${GTEST_BASENAME}-build >/dev/null + + cmake -G "Ninja" \ + -DCMAKE_CXX_FLAGS="-std=c++17 -stdlib=libc++ -I${LLVM_INCLUDE} -Wl,-L${LLVM_LIBPATH}" \ + -DCMAKE_INSTALL_PREFIX="../${GTEST_BASENAME}-install" \ + ../${GTEST_BASENAME}-source + + ninja + + ninja install + + popd >/dev/null + + rm -Rf ${GTEST_BASENAME}-source ${GTEST_BASENAME}-build + +fi + +# ============================================================================== +# -- Generate CMake toolchains and config -------------------------------------- +# ============================================================================== + +log "Generating CMake configuration files." + +# -- LIBSTDCPP_TOOLCHAIN_FILE -------------------------------------------------- + +cat >${LIBSTDCPP_TOOLCHAIN_FILE}.gen <>${LIBCPP_TOOLCHAIN_FILE}.gen <${CMAKE_CONFIG_FILE}.gen </dev/null + +log "Success!" diff --git a/Util/BuildTools/Vars.mk b/Util/BuildTools/Vars.mk new file mode 100644 index 000000000..997f4ab8e --- /dev/null +++ b/Util/BuildTools/Vars.mk @@ -0,0 +1,22 @@ +# Here CURDIR is assumed to be the root folder of the project. + +CARLA_ROOT_FOLDER=${CURDIR} +CARLA_BUILD_FOLDER=${CURDIR}/Build +CARLA_DIST_FOLDER=${CURDIR}/Dist +CARLA_BUILD_TOOLS_FOLDER=${CURDIR}/Util/BuildTools + +CARLAUE4_ROOT_FOLDER=${CURDIR}/Unreal/CarlaUE4 +CARLAUE4_PLUGIN_ROOT_FOLDER=${CURDIR}/Unreal/CarlaUE4/Plugins/Carla +CARLA_PYTHONAPI_ROOT_FOLDER=${CURDIR}/PythonAPI + +LIBCARLA_ROOT_FOLDER=${CURDIR}/LibCarla +LIBCARLA_BUILD_SERVER_FOLDER=${CARLA_BUILD_FOLDER}/libcarla-server-build +LIBCARLA_BUILD_CLIENT_FOLDER=${CARLA_BUILD_FOLDER}/libcarla-client-build +LIBCARLA_INSTALL_SERVER_FOLDER=${CARLAUE4_PLUGIN_ROOT_FOLDER}/CarlaDependencies +LIBCARLA_INSTALL_CLIENT_FOLDER=${CARLA_PYTHONAPI_ROOT_FOLDER}/dependencies + +CARLAUE4_PLUGIN_DEPS_FOLDER=${CARLAUE4_PLUGIN_ROOT_FOLDER}/CarlaDependencies + +LIBSTDCPP_TOOLCHAIN_FILE=${CARLA_BUILD_FOLDER}/LibStdCppToolChain.cmake +LIBCPP_TOOLCHAIN_FILE=${CARLA_BUILD_FOLDER}/LibCppToolChain.cmake +CMAKE_CONFIG_FILE=${CARLA_BUILD_FOLDER}/CMakeLists.txt.in diff --git a/Util/BuildTools/Windows.mk b/Util/BuildTools/Windows.mk new file mode 100644 index 000000000..6fdd66328 --- /dev/null +++ b/Util/BuildTools/Windows.mk @@ -0,0 +1,2 @@ +default: + @echo "Not implemented!" diff --git a/Util/BuildTools/uncrustify.cfg b/Util/BuildTools/uncrustify.cfg new file mode 100644 index 000000000..926933119 --- /dev/null +++ b/Util/BuildTools/uncrustify.cfg @@ -0,0 +1,2239 @@ +# Uncrustify-0.67 + +# +# General options +# + +# The type of line endings. Default=Auto. +newlines = auto # auto/lf/crlf/cr + +# The original size of tabs in the input. Default=8. +input_tab_size = 2 # unsigned number + +# The size of tabs in the output (only used if align_with_tabs=true). Default=8. +output_tab_size = 2 # unsigned number + +# The ASCII value of the string escape char, usually 92 (\) or 94 (^). (Pawn). +string_escape_char = 92 # unsigned number + +# Alternate string escape char for Pawn. Only works right before the quote char. +string_escape_char2 = 0 # unsigned number + +# Replace tab characters found in string literals with the escape sequence \t instead. +string_replace_tab_chars = true # false/true + +# Allow interpreting '>=' and '>>=' as part of a template in 'void f(list>=val);'. +# If True, 'assert(x<0 && y>=3)' will be broken. Default=False +# Improvements to template detection may make this option obsolete. +tok_split_gte = false # false/true + +# Override the default ' *INDENT-OFF*' in comments for disabling processing of part of the file. +disable_processing_cmt = "" # string + +# Override the default ' *INDENT-ON*' in comments for enabling processing of part of the file. +enable_processing_cmt = "" # string + +# Enable parsing of digraphs. Default=False. +enable_digraphs = false # false/true + +# Control what to do with the UTF-8 BOM (recommend 'remove'). +utf8_bom = ignore # ignore/add/remove/force + +# If the file contains bytes with values between 128 and 255, but is not UTF-8, then output as UTF-8. +utf8_byte = false # false/true + +# Force the output encoding to UTF-8. +utf8_force = false # false/true + +# +# Spacing options +# + +# Add or remove space around arithmetic operator '+', '-', '/', '*', etc +# also '>>>' '<<' '>>' '%' '|'. +sp_arith = add # ignore/add/remove/force + +# Add or remove space around arithmetic operator '+' and '-'. Overrides sp_arith +sp_arith_additive = add # ignore/add/remove/force + +# Add or remove space around assignment operator '=', '+=', etc. +sp_assign = add # ignore/add/remove/force + +# Add or remove space around '=' in C++11 lambda capture specifications. Overrides sp_assign. +sp_cpp_lambda_assign = remove # ignore/add/remove/force + +# Add or remove space after the capture specification in C++11 lambda. +sp_cpp_lambda_paren = ignore # ignore/add/remove/force + +# Add or remove space around assignment operator '=' in a prototype. +sp_assign_default = ignore # ignore/add/remove/force + +# Add or remove space before assignment operator '=', '+=', etc. Overrides sp_assign. +sp_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment operator '=', '+=', etc. Overrides sp_assign. +sp_after_assign = ignore # ignore/add/remove/force + +# Add or remove space in 'NS_ENUM ('. +sp_enum_paren = ignore # ignore/add/remove/force + +# Add or remove space around assignment '=' in enum. +sp_enum_assign = add # ignore/add/remove/force + +# Add or remove space before assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_before_assign = ignore # ignore/add/remove/force + +# Add or remove space after assignment '=' in enum. Overrides sp_enum_assign. +sp_enum_after_assign = ignore # ignore/add/remove/force + +# Add or remove space around assignment ':' in enum. +sp_enum_colon = ignore # ignore/add/remove/force + +# Add or remove space around preprocessor '##' concatenation operator. Default=Add. +sp_pp_concat = add # ignore/add/remove/force + +# Add or remove space after preprocessor '#' stringify operator. Also affects the '#@' charizing operator. +sp_pp_stringify = add # ignore/add/remove/force + +# Add or remove space before preprocessor '#' stringify operator as in '#define x(y) L#y'. +sp_before_pp_stringify = ignore # ignore/add/remove/force + +# Add or remove space around boolean operators '&&' and '||'. +sp_bool = force # ignore/add/remove/force + +# Add or remove space around compare operator '<', '>', '==', etc. +sp_compare = add # ignore/add/remove/force + +# Add or remove space inside '(' and ')'. +sp_inside_paren = remove # ignore/add/remove/force + +# Add or remove space between nested parens: '((' vs ') )'. +sp_paren_paren = remove # ignore/add/remove/force + +# Add or remove space between back-to-back parens: ')(' vs ') ('. +sp_cparen_oparen = ignore # ignore/add/remove/force + +# Whether to balance spaces inside nested parens. +sp_balance_nested_parens = false # false/true + +# Add or remove space between ')' and '{'. +sp_paren_brace = force # ignore/add/remove/force + +# Add or remove space before pointer star '*'. +sp_before_ptr_star = force # ignore/add/remove/force + +# Add or remove space before pointer star '*' that isn't followed by a variable name +# If set to 'ignore', sp_before_ptr_star is used instead. +sp_before_unnamed_ptr_star = force # ignore/add/remove/force + +# Add or remove space between pointer stars '*'. +sp_between_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a word. +sp_after_ptr_star = remove # ignore/add/remove/force + +# Add or remove space after pointer caret '^', if followed by a word. +sp_after_ptr_block_caret = ignore # ignore/add/remove/force + +# Add or remove space after pointer star '*', if followed by a qualifier. +sp_after_ptr_star_qualifier = ignore # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by a func proto/def. +sp_after_ptr_star_func = ignore # ignore/add/remove/force + +# Add or remove space after a pointer star '*', if followed by an open paren (function types). +sp_ptr_star_paren = ignore # ignore/add/remove/force + +# Add or remove space before a pointer star '*', if followed by a func proto/def. +sp_before_ptr_star_func = force # ignore/add/remove/force + +# Add or remove space before a reference sign '&'. +sp_before_byref = force # ignore/add/remove/force + +# Add or remove space before a reference sign '&' that isn't followed by a variable name. +# If set to 'ignore', sp_before_byref is used instead. +sp_before_unnamed_byref = force # ignore/add/remove/force + +# Add or remove space after reference sign '&', if followed by a word. +sp_after_byref = remove # ignore/add/remove/force + +# Add or remove space after a reference sign '&', if followed by a func proto/def. +sp_after_byref_func = remove # ignore/add/remove/force + +# Add or remove space before a reference sign '&', if followed by a func proto/def. +sp_before_byref_func = force # ignore/add/remove/force + +# Add or remove space between type and word. Default=Force. +sp_after_type = force # ignore/add/remove/force + +# Add or remove space before the paren in the D constructs 'template Foo(' and 'class Foo('. +sp_before_template_paren = ignore # ignore/add/remove/force + +# Add or remove space in 'template <' vs 'template<'. +# If set to ignore, sp_before_angle is used. +sp_template_angle = force # ignore/add/remove/force + +# Add or remove space before '<>'. +sp_before_angle = remove # ignore/add/remove/force + +# Add or remove space inside '<' and '>'. +sp_inside_angle = remove # ignore/add/remove/force + +# Add or remove space between '<>' and ':'. +sp_angle_colon = ignore # ignore/add/remove/force + +# Add or remove space after '<>'. +sp_after_angle = ignore # ignore/add/remove/force + +# Add or remove space between '<>' and '(' as found in 'new List(foo);'. +sp_angle_paren = remove # ignore/add/remove/force + +# Add or remove space between '<>' and '()' as found in 'new List();'. +sp_angle_paren_empty = remove # ignore/add/remove/force + +# Add or remove space between '<>' and a word as in 'List m;' or 'template static ...'. +sp_angle_word = force # ignore/add/remove/force + +# Add or remove space between '>' and '>' in '>>' (template stuff). Default=Add. +sp_angle_shift = remove # ignore/add/remove/force + +# Permit removal of the space between '>>' in 'foo >' (C++11 only). Default=False. +# sp_angle_shift cannot remove the space without this option. +sp_permit_cpp11_shift = true # false/true + +# Add or remove space before '(' of 'if', 'for', 'switch', 'while', etc. +sp_before_sparen = force # ignore/add/remove/force + +# Add or remove space inside if-condition '(' and ')'. +sp_inside_sparen = remove # ignore/add/remove/force + +# Add or remove space before if-condition ')'. Overrides sp_inside_sparen. +sp_inside_sparen_close = ignore # ignore/add/remove/force + +# Add or remove space after if-condition '('. Overrides sp_inside_sparen. +sp_inside_sparen_open = ignore # ignore/add/remove/force + +# Add or remove space after ')' of 'if', 'for', 'switch', and 'while', etc. +sp_after_sparen = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of 'if', 'for', 'switch', and 'while', etc. +sp_sparen_brace = force # ignore/add/remove/force + +# Add or remove space between 'invariant' and '(' in the D language. +sp_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space after the ')' in 'invariant (C) c' in the D language. +sp_after_invariant_paren = ignore # ignore/add/remove/force + +# Add or remove space before empty statement ';' on 'if', 'for' and 'while'. +sp_special_semi = ignore # ignore/add/remove/force + +# Add or remove space before ';'. Default=Remove. +sp_before_semi = remove # ignore/add/remove/force + +# Add or remove space before ';' in non-empty 'for' statements. +sp_before_semi_for = ignore # ignore/add/remove/force + +# Add or remove space before a semicolon of an empty part of a for statement. +sp_before_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space after ';', except when followed by a comment. Default=Add. +sp_after_semi = add # ignore/add/remove/force + +# Add or remove space after ';' in non-empty 'for' statements. Default=Force. +sp_after_semi_for = force # ignore/add/remove/force + +# Add or remove space after the final semicolon of an empty part of a for statement: for ( ; ; ). +sp_after_semi_for_empty = ignore # ignore/add/remove/force + +# Add or remove space before '[' (except '[]'). +sp_before_square = remove # ignore/add/remove/force + +# Add or remove space before '[]'. +sp_before_squares = remove # ignore/add/remove/force + +# Add or remove space before structured bindings. Only for C++17. +sp_cpp_before_struct_binding = ignore # ignore/add/remove/force + +# Add or remove space inside a non-empty '[' and ']'. +sp_inside_square = remove # ignore/add/remove/force + +# Add or remove space inside a non-empty OC boxed array '@[' and ']'. +# If set to ignore, sp_inside_square is used. +sp_inside_square_oc_array = ignore # ignore/add/remove/force + +# Add or remove space after ',', 'a,b' vs 'a, b'. +sp_after_comma = add # ignore/add/remove/force + +# Add or remove space before ','. Default=Remove. +sp_before_comma = remove # ignore/add/remove/force + +# Add or remove space between ',' and ']' in multidimensional array type 'int[,,]'. Only for C#. +sp_after_mdatype_commas = ignore # ignore/add/remove/force + +# Add or remove space between '[' and ',' in multidimensional array type 'int[,,]'. Only for C#. +sp_before_mdatype_commas = ignore # ignore/add/remove/force + +# Add or remove space between ',' in multidimensional array type 'int[,,]'. Only for C#. +sp_between_mdatype_commas = ignore # ignore/add/remove/force + +# Add or remove space between an open paren and comma: '(,' vs '( ,'. Default=Force. +sp_paren_comma = force # ignore/add/remove/force + +# Add or remove space before the variadic '...' when preceded by a non-punctuator. +sp_before_ellipsis = ignore # ignore/add/remove/force + +# Add or remove space after class ':'. +sp_after_class_colon = ignore # ignore/add/remove/force + +# Add or remove space before class ':'. +sp_before_class_colon = ignore # ignore/add/remove/force + +# Add or remove space after class constructor ':'. +sp_after_constr_colon = ignore # ignore/add/remove/force + +# Add or remove space before class constructor ':'. +sp_before_constr_colon = ignore # ignore/add/remove/force + +# Add or remove space before case ':'. Default=Remove. +sp_before_case_colon = remove # ignore/add/remove/force + +# Add or remove space between 'operator' and operator sign. +sp_after_operator = remove # ignore/add/remove/force + +# Add or remove space between the operator symbol and the open paren, as in 'operator ++('. +sp_after_operator_sym = remove # ignore/add/remove/force + +# Overrides sp_after_operator_sym when the operator has no arguments, as in 'operator *()'. +sp_after_operator_sym_empty = ignore # ignore/add/remove/force + +# Add or remove space after C/D cast, i.e. 'cast(int)a' vs 'cast(int) a' or '(int)a' vs '(int) a'. +sp_after_cast = force # ignore/add/remove/force + +# Add or remove spaces inside cast parens. +sp_inside_paren_cast = remove # ignore/add/remove/force + +# Add or remove space between the type and open paren in a C++ cast, i.e. 'int(exp)' vs 'int (exp)'. +sp_cpp_cast_paren = remove # ignore/add/remove/force + +# Add or remove space between 'sizeof' and '('. +sp_sizeof_paren = remove # ignore/add/remove/force + +# Add or remove space after the tag keyword (Pawn). +sp_after_tag = ignore # ignore/add/remove/force + +# Add or remove space inside enum '{' and '}'. +sp_inside_braces_enum = force # ignore/add/remove/force + +# Add or remove space inside struct/union '{' and '}'. +sp_inside_braces_struct = force # ignore/add/remove/force + +# Add or remove space inside OC boxed dictionary @'{' and '}' +sp_inside_braces_oc_dict = ignore # ignore/add/remove/force + +# Add or remove space after open brace in an unnamed temporary direct-list-initialization. +sp_after_type_brace_init_lst_open = ignore # ignore/add/remove/force + +# Add or remove space before close brace in an unnamed temporary direct-list-initialization. +sp_before_type_brace_init_lst_close = ignore # ignore/add/remove/force + +# Add or remove space inside an unnamed temporary direct-list-initialization. +sp_inside_type_brace_init_lst = ignore # ignore/add/remove/force + +# Add or remove space inside '{' and '}'. +sp_inside_braces = ignore # ignore/add/remove/force + +# Add or remove space inside '{}'. +sp_inside_braces_empty = remove # ignore/add/remove/force + +# Add or remove space between return type and function name +# A minimum of 1 is forced except for pointer return types. +sp_type_func = force # ignore/add/remove/force + +# Add or remove space between type and open brace of an unnamed temporary direct-list-initialization. +sp_type_brace_init_lst = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function declaration. +sp_func_proto_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '()' on function declaration without parameters. +sp_func_proto_paren_empty = remove # ignore/add/remove/force + +# Add or remove space between function name and '(' on function definition. +sp_func_def_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '()' on function definition without parameters. +sp_func_def_paren_empty = remove # ignore/add/remove/force + +# Add or remove space inside empty function '()'. +sp_inside_fparens = remove # ignore/add/remove/force + +# Add or remove space inside function '(' and ')'. +sp_inside_fparen = remove # ignore/add/remove/force + +# Add or remove space inside the first parens in the function type: 'void (*x)(...)'. +sp_inside_tparen = ignore # ignore/add/remove/force + +# Add or remove between the parens in the function type: 'void (*x)(...)'. +sp_after_tparen_close = ignore # ignore/add/remove/force + +# Add or remove space between ']' and '(' when part of a function call. +sp_square_fparen = remove # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function. +sp_fparen_brace = force # ignore/add/remove/force + +# Add or remove space between ')' and '{' of function call in object initialization. Overrides sp_fparen_brace. +sp_fparen_brace_initializer = ignore # ignore/add/remove/force + +# Java: Add or remove space between ')' and '{{' of double brace initializer. +sp_fparen_dbrace = ignore # ignore/add/remove/force + +# Add or remove space between function name and '(' on function calls. +sp_func_call_paren = remove # ignore/add/remove/force + +# Add or remove space between function name and '()' on function calls without parameters. +# If set to 'ignore' (the default), sp_func_call_paren is used. +sp_func_call_paren_empty = ignore # ignore/add/remove/force + +# Add or remove space between the user function name and '(' on function calls +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren = ignore # ignore/add/remove/force + +# Add or remove space inside user function '(' and ')' +# You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_inside_fparen = ignore # ignore/add/remove/force + +# Add or remove space between nested parens with user functions: '((' vs ') )'You need to set a keyword to be a user function, like this: 'set func_call_user _' in the config file. +sp_func_call_user_paren_paren = ignore # ignore/add/remove/force + +# Add or remove space between a constructor/destructor and the open paren. +sp_func_class_paren = remove # ignore/add/remove/force + +# Add or remove space between a constructor without parameters or destructor and '()'. +sp_func_class_paren_empty = remove # ignore/add/remove/force + +# Add or remove space between 'return' and '('. +sp_return_paren = force # ignore/add/remove/force + +# Add or remove space between '__attribute__' and '('. +sp_attribute_paren = remove # ignore/add/remove/force + +# Add or remove space between 'defined' and '(' in '#if defined (FOO)'. +sp_defined_paren = remove # ignore/add/remove/force + +# Add or remove space between 'throw' and '(' in 'throw (something)'. +sp_throw_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'throw' and anything other than '(' as in '@throw [...];'. +sp_after_throw = ignore # ignore/add/remove/force + +# Add or remove space between 'catch' and '(' in 'catch (something) { }' +# If set to ignore, sp_before_sparen is used. +sp_catch_paren = force # ignore/add/remove/force + +# Add or remove space between '@catch' and '(' in '@catch (something) { }' +# If set to ignore, sp_catch_paren is used. +sp_oc_catch_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'version' and '(' in 'version (something) { }' (D language) +# If set to ignore, sp_before_sparen is used. +sp_version_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'scope' and '(' in 'scope (something) { }' (D language) +# If set to ignore, sp_before_sparen is used. +sp_scope_paren = ignore # ignore/add/remove/force + +# Add or remove space between 'super' and '(' in 'super (something)'. Default=Remove. +sp_super_paren = remove # ignore/add/remove/force + +# Add or remove space between 'this' and '(' in 'this (something)'. Default=Remove. +sp_this_paren = remove # ignore/add/remove/force + +# Add or remove space between macro and value. +sp_macro = force # ignore/add/remove/force + +# Add or remove space between macro function ')' and value. +sp_macro_func = force # ignore/add/remove/force + +# Add or remove space between 'else' and '{' if on the same line. +sp_else_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'else' if on the same line. +sp_brace_else = force # ignore/add/remove/force + +# Add or remove space between '}' and the name of a typedef on the same line. +sp_brace_typedef = force # ignore/add/remove/force + +# Add or remove space between 'catch' and '{' if on the same line. +sp_catch_brace = force # ignore/add/remove/force + +# Add or remove space between '@catch' and '{' if on the same line. +# If set to ignore, sp_catch_brace is used. +sp_oc_catch_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'catch' if on the same line. +sp_brace_catch = force # ignore/add/remove/force + +# Add or remove space between '}' and '@catch' if on the same line. +# If set to ignore, sp_brace_catch is used. +sp_oc_brace_catch = force # ignore/add/remove/force + +# Add or remove space between 'finally' and '{' if on the same line. +sp_finally_brace = force # ignore/add/remove/force + +# Add or remove space between '}' and 'finally' if on the same line. +sp_brace_finally = force # ignore/add/remove/force + +# Add or remove space between 'try' and '{' if on the same line. +sp_try_brace = force # ignore/add/remove/force + +# Add or remove space between get/set and '{' if on the same line. +sp_getset_brace = force # ignore/add/remove/force + +# Add or remove space between a variable and '{' for C++ uniform initialization. Default=Add. +sp_word_brace = add # ignore/add/remove/force + +# Add or remove space between a variable and '{' for a namespace. Default=Add. +sp_word_brace_ns = add # ignore/add/remove/force + +# Add or remove space before the '::' operator. +sp_before_dc = remove # ignore/add/remove/force + +# Add or remove space after the '::' operator. +sp_after_dc = remove # ignore/add/remove/force + +# Add or remove around the D named array initializer ':' operator. +sp_d_array_colon = ignore # ignore/add/remove/force + +# Add or remove space after the '!' (not) operator. Default=Remove. +sp_not = remove # ignore/add/remove/force + +# Add or remove space after the '~' (invert) operator. Default=Remove. +sp_inv = remove # ignore/add/remove/force + +# Add or remove space after the '&' (address-of) operator. Default=Remove +# This does not affect the spacing after a '&' that is part of a type. +sp_addr = remove # ignore/add/remove/force + +# Add or remove space around the '.' or '->' operators. Default=Remove. +sp_member = remove # ignore/add/remove/force + +# Add or remove space after the '*' (dereference) operator. Default=Remove +# This does not affect the spacing after a '*' that is part of a type. +sp_deref = remove # ignore/add/remove/force + +# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. Default=Remove. +sp_sign = remove # ignore/add/remove/force + +# Add or remove space before or after '++' and '--', as in '(--x)' or 'y++;'. Default=Remove. +sp_incdec = remove # ignore/add/remove/force + +# Add or remove space before a backslash-newline at the end of a line. Default=Add. +sp_before_nl_cont = force # ignore/add/remove/force + +# Add or remove space after the scope '+' or '-', as in '-(void) foo;' or '+(int) bar;'. +sp_after_oc_scope = remove # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '-(int) f:(int) x;' vs '-(int) f: (int) x;'. +sp_after_oc_colon = force # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '-(int) f: (int) x;' vs '-(int) f : (int) x;'. +sp_before_oc_colon = remove # ignore/add/remove/force + +# Add or remove space after the colon in immutable dictionary expression +# 'NSDictionary *test = @{@"foo" :@"bar"};'. +sp_after_oc_dict_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in immutable dictionary expression +# 'NSDictionary *test = @{@"foo" :@"bar"};'. +sp_before_oc_dict_colon = ignore # ignore/add/remove/force + +# Add or remove space after the colon in message specs +# '[object setValue:1];' vs '[object setValue: 1];'. +sp_after_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space before the colon in message specs +# '[object setValue:1];' vs '[object setValue :1];'. +sp_before_send_oc_colon = ignore # ignore/add/remove/force + +# Add or remove space after the (type) in message specs +# '-(int)f: (int) x;' vs '-(int)f: (int)x;'. +sp_after_oc_type = ignore # ignore/add/remove/force + +# Add or remove space after the first (type) in message specs +# '-(int) f:(int)x;' vs '-(int)f:(int)x;'. +sp_after_oc_return_type = ignore # ignore/add/remove/force + +# Add or remove space between '@selector' and '(' +# '@selector(msgName)' vs '@selector (msgName)' +# Also applies to @protocol() constructs. +sp_after_oc_at_sel = ignore # ignore/add/remove/force + +# Add or remove space between '@selector(x)' and the following word +# '@selector(foo) a:' vs '@selector(foo)a:'. +sp_after_oc_at_sel_parens = ignore # ignore/add/remove/force + +# Add or remove space inside '@selector' parens +# '@selector(foo)' vs '@selector( foo )' +# Also applies to @protocol() constructs. +sp_inside_oc_at_sel_parens = ignore # ignore/add/remove/force + +# Add or remove space before a block pointer caret +# '^int (int arg){...}' vs. ' ^int (int arg){...}'. +sp_before_oc_block_caret = ignore # ignore/add/remove/force + +# Add or remove space after a block pointer caret +# '^int (int arg){...}' vs. '^ int (int arg){...}'. +sp_after_oc_block_caret = ignore # ignore/add/remove/force + +# Add or remove space between the receiver and selector in a message. +# '[receiver selector ...]'. +sp_after_oc_msg_receiver = ignore # ignore/add/remove/force + +# Add or remove space after @property. +sp_after_oc_property = ignore # ignore/add/remove/force + +# Add or remove space between '@synchronized' and the parenthesis +# '@synchronized(foo)' vs '@synchronized (foo)'. +sp_after_oc_synchronized = ignore # ignore/add/remove/force + +# Add or remove space around the ':' in 'b ? t : f'. +sp_cond_colon = force # ignore/add/remove/force + +# Add or remove space before the ':' in 'b ? t : f'. Overrides sp_cond_colon. +sp_cond_colon_before = ignore # ignore/add/remove/force + +# Add or remove space after the ':' in 'b ? t : f'. Overrides sp_cond_colon. +sp_cond_colon_after = ignore # ignore/add/remove/force + +# Add or remove space around the '?' in 'b ? t : f'. +sp_cond_question = force # ignore/add/remove/force + +# Add or remove space before the '?' in 'b ? t : f'. Overrides sp_cond_question. +sp_cond_question_before = ignore # ignore/add/remove/force + +# Add or remove space after the '?' in 'b ? t : f'. Overrides sp_cond_question. +sp_cond_question_after = ignore # ignore/add/remove/force + +# In the abbreviated ternary form (a ?: b), add/remove space between ? and :.'. Overrides all other sp_cond_* options. +sp_cond_ternary_short = ignore # ignore/add/remove/force + +# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make sense here. +sp_case_label = force # ignore/add/remove/force + +# Control the space around the D '..' operator. +sp_range = ignore # ignore/add/remove/force + +# Control the spacing after ':' in 'for (TYPE VAR : EXPR)'. Only JAVA. +sp_after_for_colon = ignore # ignore/add/remove/force + +# Control the spacing before ':' in 'for (TYPE VAR : EXPR)'. Only JAVA. +sp_before_for_colon = ignore # ignore/add/remove/force + +# Control the spacing in 'extern (C)' (D). +sp_extern_paren = ignore # ignore/add/remove/force + +# Control the space after the opening of a C++ comment '// A' vs '//A'. +sp_cmt_cpp_start = add # ignore/add/remove/force + +# True: If space is added with sp_cmt_cpp_start, do it after doxygen sequences like '///', '///<', '//!' and '//!<'. +sp_cmt_cpp_doxygen = true # false/true + +# True: If space is added with sp_cmt_cpp_start, do it after Qt translator or meta-data comments like '//:', '//=', and '//~'. +sp_cmt_cpp_qttr = false # false/true + +# Controls the spaces between #else or #endif and a trailing comment. +sp_endif_cmt = ignore # ignore/add/remove/force + +# Controls the spaces after 'new', 'delete' and 'delete[]'. +sp_after_new = force # ignore/add/remove/force + +# Controls the spaces between new and '(' in 'new()'. +sp_between_new_paren = remove # ignore/add/remove/force + +# Controls the spaces between ')' and 'type' in 'new(foo) BAR'. +sp_after_newop_paren = ignore # ignore/add/remove/force + +# Controls the spaces inside paren of the new operator: 'new(foo) BAR'. +sp_inside_newop_paren = ignore # ignore/add/remove/force + +# Controls the space after open paren of the new operator: 'new(foo) BAR'. +# Overrides sp_inside_newop_paren. +sp_inside_newop_paren_open = ignore # ignore/add/remove/force + +# Controls the space before close paren of the new operator: 'new(foo) BAR'. +# Overrides sp_inside_newop_paren. +sp_inside_newop_paren_close = ignore # ignore/add/remove/force + +# Controls the spaces before a trailing or embedded comment. +sp_before_tr_emb_cmt = add # ignore/add/remove/force + +# Number of spaces before a trailing or embedded comment. +sp_num_before_tr_emb_cmt = 0 # unsigned number + +# Control space between a Java annotation and the open paren. +sp_annotation_paren = ignore # ignore/add/remove/force + +# If True, vbrace tokens are dropped to the previous token and skipped. +sp_skip_vbrace_tokens = false # false/true + +# Controls the space after 'noexcept'. +sp_after_noexcept = force # ignore/add/remove/force + +# If True, a is inserted after #define. +force_tab_after_define = false # false/true + +# +# Indenting +# + +# The number of columns to indent per level. +# Usually 2, 3, 4, or 8. Default=8. +indent_columns = 2 # unsigned number + +# The continuation indent. If non-zero, this overrides the indent of '(' and '=' continuation indents. +# For FreeBSD, this is set to 4. Negative value is absolute and not increased for each '(' level. +indent_continue = 4 # number + +# Indent empty lines - lines which contain only spaces before newline character +indent_single_newlines = false # false/true + +# The continuation indent for func_*_param if they are true. +# If non-zero, this overrides the indent. +indent_param = 0 # unsigned number + +# How to use tabs when indenting code +# 0=spaces only +# 1=indent with tabs to brace level, align with spaces (default) +# 2=indent and align with tabs, using spaces when not on a tabstop +indent_with_tabs = 0 # unsigned number + +# Comments that are not a brace level are indented with tabs on a tabstop. +# Requires indent_with_tabs=2. If false, will use spaces. +indent_cmt_with_tabs = false # false/true + +# Whether to indent strings broken by '\' so that they line up. +indent_align_string = true # false/true + +# The number of spaces to indent multi-line XML strings. +# Requires indent_align_string=True. +indent_xml_string = 0 # unsigned number + +# Spaces to indent '{' from level. +indent_brace = 0 # unsigned number + +# Whether braces are indented to the body level. +indent_braces = false # false/true + +# Disabled indenting function braces if indent_braces is True. +indent_braces_no_func = false # false/true + +# Disabled indenting class braces if indent_braces is True. +indent_braces_no_class = false # false/true + +# Disabled indenting struct braces if indent_braces is True. +indent_braces_no_struct = false # false/true + +# Indent based on the size of the brace parent, i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc. +indent_brace_parent = false # false/true + +# Indent based on the paren open instead of the brace open in '({\n', default is to indent by brace. +indent_paren_open_brace = false # false/true + +# indent a C# delegate by another level, default is to not indent by another level. +indent_cs_delegate_brace = false # false/true + +# indent a C# delegate(To hanndle delegates with no brace) by another level. default: false +indent_cs_delegate_body = false # false/true + +# Whether the 'namespace' body is indented. +indent_namespace = true # false/true + +# Only indent one namespace and no sub-namespaces. +# Requires indent_namespace=True. +indent_namespace_single_indent = true # false/true + +# The number of spaces to indent a namespace block. +indent_namespace_level = 2 # unsigned number + +# If the body of the namespace is longer than this number, it won't be indented. +# Requires indent_namespace=True. Default=0 (no limit) +indent_namespace_limit = 0 # unsigned number + +# Whether the 'extern "C"' body is indented. +indent_extern = true # false/true + +# Whether the 'class' body is indented. +indent_class = true # false/true + +# Whether to indent the stuff after a leading base class colon. +indent_class_colon = true # false/true + +# Indent based on a class colon instead of the stuff after the colon. +# Requires indent_class_colon=True. Default=False. +indent_class_on_colon = false # false/true + +# Whether to indent the stuff after a leading class initializer colon. +indent_constr_colon = true # false/true + +# Virtual indent from the ':' for member initializers. Default=2. +indent_ctor_init_leading = 2 # unsigned number + +# Additional indent for constructor initializer list. +# Negative values decrease indent down to the first column. Default=0. +indent_ctor_init = 0 # number + +# False=treat 'else\nif' as 'else if' for indenting purposes +# True=indent the 'if' one level. +indent_else_if = false # false/true + +# Amount to indent variable declarations after a open brace. neg=relative, pos=absolute. +indent_var_def_blk = 0 # number + +# Indent continued variable declarations instead of aligning. +indent_var_def_cont = false # false/true + +# Indent continued shift expressions ('<<' and '>>') instead of aligning. +# Turn align_left_shift off when enabling this. +indent_shift = false # false/true + +# True: force indentation of function definition to start in column 1 +# False: use the default behavior. +indent_func_def_force_col1 = false # false/true + +# True: indent continued function call parameters one indent level +# False: align parameters under the open paren. +indent_func_call_param = true # false/true + +# Same as indent_func_call_param, but for function defs. +indent_func_def_param = true # false/true + +# Same as indent_func_call_param, but for function protos. +indent_func_proto_param = true # false/true + +# Same as indent_func_call_param, but for class declarations. +indent_func_class_param = true # false/true + +# Same as indent_func_call_param, but for class variable constructors. +indent_func_ctor_var_param = true # false/true + +# Same as indent_func_call_param, but for templates. +indent_template_param = true # false/true + +# Double the indent for indent_func_xxx_param options. +# Use both values of the options indent_columns and indent_param. +indent_func_param_double = true # false/true + +# Indentation column for standalone 'const' function decl/proto qualifier. +indent_func_const = 0 # unsigned number + +# Indentation column for standalone 'throw' function decl/proto qualifier. +indent_func_throw = 0 # unsigned number + +# The number of spaces to indent a continued '->' or '.' +# Usually set to 0, 1, or indent_columns. +indent_member = 4 # unsigned number + +# setting to true will indent lines broken at '.' or '->' by a single indent +# UO_indent_member option will not be effective if this is set to true. +indent_member_single = false # false/true + +# Spaces to indent single line ('//') comments on lines before code. +indent_sing_line_comments = 0 # unsigned number + +# If set, will indent trailing single line ('//') comments relative +# to the code instead of trying to keep the same absolute column. +indent_relative_single_line_comments = false # false/true + +# Spaces to indent 'case' from 'switch' +# Usually 0 or indent_columns. +indent_switch_case = 2 # unsigned number + +# Whether to indent preprocessor statements inside of switch statements. +indent_switch_pp = true # false/true + +# Spaces to shift the 'case' line, without affecting any other lines +# Usually 0. +indent_case_shift = 0 # unsigned number + +# Spaces to indent '{' from 'case'. +# By default, the brace will appear under the 'c' in case. +# Usually set to 0 or indent_columns. +# negative value are OK. +indent_case_brace = 0 # number + +# Whether to indent comments found in first column. +indent_col1_comment = false # false/true + +# How to indent goto labels +# >0: absolute column where 1 is the leftmost column +# <=0: subtract from brace indent +# Default=1 +indent_label = 1 # number + +# Same as indent_label, but for access specifiers that are followed by a colon. Default=1 +indent_access_spec = 3 # number + +# Indent the code after an access specifier by one level. +# If set, this option forces 'indent_access_spec=0'. +indent_access_spec_body = false # false/true + +# If an open paren is followed by a newline, indent the next line so that it lines up after the open paren (not recommended). +indent_paren_nl = false # false/true + +# Controls the indent of a close paren after a newline. +# 0: Indent to body level +# 1: Align under the open paren +# 2: Indent to the brace level +indent_paren_close = 0 # unsigned number + +# Controls the indent of the open paren of a function definition, if on it's own line.If True, indents the open paren +indent_paren_after_func_def = false # false/true + +# Controls the indent of the open paren of a function declaration, if on it's own line.If True, indents the open paren +indent_paren_after_func_decl = false # false/true + +# Controls the indent of the open paren of a function call, if on it's own line.If True, indents the open paren +indent_paren_after_func_call = false # false/true + +# Controls the indent of a comma when inside a paren.If True, aligns under the open paren. +indent_comma_paren = false # false/true + +# Controls the indent of a BOOL operator when inside a paren.If True, aligns under the open paren. +indent_bool_paren = false # false/true + +# Controls the indent of a semicolon when inside a for paren.If True, aligns under the open for paren. +indent_semicolon_for_paren = false # false/true + +# If 'indent_bool_paren' is True, controls the indent of the first expression. If True, aligns the first expression to the following ones. +indent_first_bool_expr = false # false/true + +# If 'indent_semicolon_for_paren' is True, controls the indent of the first expression. If True, aligns the first expression to the following ones. +indent_first_for_expr = false # false/true + +# If an open square is followed by a newline, indent the next line so that it lines up after the open square (not recommended). +indent_square_nl = false # false/true + +# Don't change the relative indent of ESQL/C 'EXEC SQL' bodies. +indent_preserve_sql = false # false/true + +# Align continued statements at the '='. Default=True +# If False or the '=' is followed by a newline, the next line is indent one tab. +indent_align_assign = false # false/true + +# Align continued statements at the '('. Default=True +# If FALSE or the '(' is not followed by a newline, the next line indent is one tab. +indent_align_paren = true # false/true + +# Indent OC blocks at brace level instead of usual rules. +indent_oc_block = false # false/true + +# Indent OC blocks in a message relative to the parameter name. +# 0=use indent_oc_block rules, 1+=spaces to indent +indent_oc_block_msg = 0 # unsigned number + +# Minimum indent for subsequent parameters +indent_oc_msg_colon = 0 # unsigned number + +# If True, prioritize aligning with initial colon (and stripping spaces from lines, if necessary). +# Default=True. +indent_oc_msg_prioritize_first_colon = true # false/true + +# If indent_oc_block_msg and this option are on, blocks will be indented the way that Xcode does by default (from keyword if the parameter is on its own line; otherwise, from the previous indentation level). +indent_oc_block_msg_xcode_style = false # false/true + +# If indent_oc_block_msg and this option are on, blocks will be indented from where the brace is relative to a msg keyword. +indent_oc_block_msg_from_keyword = false # false/true + +# If indent_oc_block_msg and this option are on, blocks will be indented from where the brace is relative to a msg colon. +indent_oc_block_msg_from_colon = false # false/true + +# If indent_oc_block_msg and this option are on, blocks will be indented from where the block caret is. +indent_oc_block_msg_from_caret = false # false/true + +# If indent_oc_block_msg and this option are on, blocks will be indented from where the brace is. +indent_oc_block_msg_from_brace = false # false/true + +# When indenting after virtual brace open and newline add further spaces to reach this min. indent. +indent_min_vbrace_open = 0 # unsigned number + +# True: When identing after virtual brace open and newline add further spaces after regular indent to reach next tabstop. +indent_vbrace_open_on_tabstop = false # false/true + +# If True, a brace followed by another token (not a newline) will indent all contained lines to match the token.Default=True. +indent_token_after_brace = true # false/true + +# If True, cpp lambda body will be indentedDefault=False. +indent_cpp_lambda_body = false # false/true + +# indent (or not) an using block if no braces are used. Only for C#.Default=True. +indent_using_block = true # false/true + +# indent the continuation of ternary operator. +# 0: (Default) off +# 1: When the `if_false` is a continuation, indent it under `if_false` +# 2: When the `:` is a continuation, indent it under `?` +indent_ternary_operator = 0 # unsigned number + +# If true, the indentation of the chunks after a `return new` sequence will be set at return indentation column. +indent_off_after_return_new = false # false/true + +# If true, the tokens after return are indented with regular single indentation.By default (false) the indentation is after the return token. +indent_single_after_return = false # false/true + +# If true, ignore indent and align for asm blocks as they have their own indentation. +indent_ignore_asm_block = false # false/true + +# +# Newline adding and removing options +# + +# Whether to collapse empty blocks between '{' and '}'. +nl_collapse_empty_body = true # false/true + +# Don't split one-line braced assignments - 'foo_t f = { 1, 2 };'. +nl_assign_leave_one_liners = true # false/true + +# Don't split one-line braced statements inside a class xx { } body. +nl_class_leave_one_liners = false # false/true + +# Don't split one-line enums: 'enum foo { BAR = 15 };' +nl_enum_leave_one_liners = false # false/true + +# Don't split one-line get or set functions. +nl_getset_leave_one_liners = false # false/true + +# Don't split one-line get or set functions. +nl_cs_property_leave_one_liners = false # false/true + +# Don't split one-line function definitions - 'int foo() { return 0; }'. +nl_func_leave_one_liners = false # false/true + +# Don't split one-line C++11 lambdas - '[]() { return 0; }'. +nl_cpp_lambda_leave_one_liners = true # false/true + +# Don't split one-line if/else statements - 'if(a) b++;'. +nl_if_leave_one_liners = false # false/true + +# Don't split one-line while statements - 'while(a) b++;'. +nl_while_leave_one_liners = false # false/true + +# Don't split one-line OC messages. +nl_oc_msg_leave_one_liner = false # false/true + +# Add or remove newline between Objective-C block signature and '{'. +nl_oc_block_brace = ignore # ignore/add/remove/force + +# Add or remove newline between @interface and '{'. +nl_oc_interface_brace = ignore # ignore/add/remove/force + +# Add or remove newline between @implementation and '{'. +nl_oc_implementation_brace = ignore # ignore/add/remove/force + +# Add or remove newlines at the start of the file. +nl_start_of_file = remove # ignore/add/remove/force + +# The number of newlines at the start of the file (only used if nl_start_of_file is 'add' or 'force'. +nl_start_of_file_min = 0 # unsigned number + +# Add or remove newline at the end of the file. +nl_end_of_file = force # ignore/add/remove/force + +# The number of newlines at the end of the file (only used if nl_end_of_file is 'add' or 'force'). +nl_end_of_file_min = 1 # unsigned number + +# Add or remove newline between '=' and '{'. +nl_assign_brace = ignore # ignore/add/remove/force + +# Add or remove newline between '=' and '[' (D only). +nl_assign_square = ignore # ignore/add/remove/force + +# Add or remove newline between '[]' and '{'. +nl_tsquare_brace = ignore # ignore/add/remove/force + +# Add or remove newline after '= [' (D only). Will also affect the newline before the ']'. +nl_after_square_assign = ignore # ignore/add/remove/force + +# The number of blank lines after a block of variable definitions at the top of a function body +# 0 = No change (default). +nl_func_var_def_blk = 0 # unsigned number + +# The number of newlines before a block of typedefs +# 0 = No change (default) +# is overridden by the option 'nl_after_access_spec'. +nl_typedef_blk_start = 0 # unsigned number + +# The number of newlines after a block of typedefs +# 0 = No change (default). +nl_typedef_blk_end = 0 # unsigned number + +# The maximum consecutive newlines within a block of typedefs +# 0 = No change (default). +nl_typedef_blk_in = 0 # unsigned number + +# The number of newlines before a block of variable definitions not at the top of a function body +# 0 = No change (default) +# is overridden by the option 'nl_after_access_spec'. +nl_var_def_blk_start = 0 # unsigned number + +# The number of newlines after a block of variable definitions not at the top of a function body +# 0 = No change (default). +nl_var_def_blk_end = 0 # unsigned number + +# The maximum consecutive newlines within a block of variable definitions +# 0 = No change (default). +nl_var_def_blk_in = 0 # unsigned number + +# Add or remove newline between a function call's ')' and '{', as in: +# list_for_each(item, &list) { }. +nl_fcall_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'enum' and '{'. +nl_enum_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'enum' and 'class'. +nl_enum_class = remove # ignore/add/remove/force + +# Add or remove newline between 'enum class' and the identifier. +nl_enum_class_identifier = remove # ignore/add/remove/force + +# Add or remove newline between 'enum class' type and ':'. +nl_enum_identifier_colon = remove # ignore/add/remove/force + +# Add or remove newline between 'enum class identifier :' and 'type' and/or 'type'. +nl_enum_colon_type = remove # ignore/add/remove/force + +# Add or remove newline between 'struct and '{'. +nl_struct_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'union' and '{'. +nl_union_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'if' and '{'. +nl_if_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'else'. +nl_brace_else = remove # ignore/add/remove/force + +# Add or remove newline between 'else if' and '{' +# If set to ignore, nl_if_brace is used instead. +nl_elseif_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'else' and '{'. +nl_else_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'else' and 'if'. +nl_else_if = remove # ignore/add/remove/force + +# Add or remove newline before 'if'/'else if' closing parenthesis. +nl_before_if_closing_paren = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'finally'. +nl_brace_finally = remove # ignore/add/remove/force + +# Add or remove newline between 'finally' and '{'. +nl_finally_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'try' and '{'. +nl_try_brace = remove # ignore/add/remove/force + +# Add or remove newline between get/set and '{'. +nl_getset_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'for' and '{'. +nl_for_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'catch' and '{'. +nl_catch_brace = remove # ignore/add/remove/force + +# Add or remove newline between '@catch' and '{'. +# If set to ignore, nl_catch_brace is used. +nl_oc_catch_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch'. +nl_brace_catch = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'catch'. +# If set to ignore, nl_brace_catch is used. +nl_oc_brace_catch = remove # ignore/add/remove/force + +# Add or remove newline between '}' and ']'. +nl_brace_square = remove # ignore/add/remove/force + +# Add or remove newline between '}' and ')' in a function invocation. +nl_brace_fparen = remove # ignore/add/remove/force + +# Add or remove newline between 'while' and '{'. +nl_while_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'scope (x)' and '{' (D). +nl_scope_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'unittest' and '{' (D). +nl_unittest_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'version (x)' and '{' (D). +nl_version_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'using' and '{'. +nl_using_brace = remove # ignore/add/remove/force + +# Add or remove newline between two open or close braces. +# Due to general newline/brace handling, REMOVE may not work. +nl_brace_brace = ignore # ignore/add/remove/force + +# Add or remove newline between 'do' and '{'. +nl_do_brace = remove # ignore/add/remove/force + +# Add or remove newline between '}' and 'while' of 'do' statement. +nl_brace_while = remove # ignore/add/remove/force + +# Add or remove newline between 'switch' and '{'. +nl_switch_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'synchronized' and '{'. +nl_synchronized_brace = remove # ignore/add/remove/force + +# Add a newline between ')' and '{' if the ')' is on a different line than the if/for/etc. +# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch and nl_catch_brace. +nl_multi_line_cond = false # false/true + +# Force a newline in a define after the macro name for multi-line defines. +nl_multi_line_define = false # false/true + +# Whether to put a newline before 'case' statement, not after the first 'case'. +nl_before_case = false # false/true + +# Add or remove newline between ')' and 'throw'. +nl_before_throw = ignore # ignore/add/remove/force + +# Whether to put a newline after 'case' statement. +nl_after_case = false # false/true + +# Add or remove a newline between a case ':' and '{'. Overrides nl_after_case. +nl_case_colon_brace = remove # ignore/add/remove/force + +# Newline between namespace and {. +nl_namespace_brace = remove # ignore/add/remove/force + +# Add or remove newline between 'template<>' and whatever follows. +nl_template_class = ignore # ignore/add/remove/force + +# Add or remove newline between 'class' and '{'. +nl_class_brace = remove # ignore/add/remove/force + +# Add or remove newline before/after each ',' in the base class list, +# (tied to pos_class_comma). +nl_class_init_args = add # ignore/add/remove/force + +# Add or remove newline after each ',' in the constructor member initialization. +# Related to nl_constr_colon, pos_constr_colon and pos_constr_comma. +nl_constr_init_args = add # ignore/add/remove/force + +# Add or remove newline before first element, after comma, and after last element in enum. +nl_enum_own_lines = add # ignore/add/remove/force + +# Add or remove newline between return type and function name in a function definition. +nl_func_type_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name inside a class {} +# Uses nl_func_type_name or nl_func_proto_type_name if set to ignore. +nl_func_type_name_class = ignore # ignore/add/remove/force + +# Add or remove newline between class specification and '::' in 'void A::f() { }' +# Only appears in separate member implementation (does not appear with in-line implmementation). +nl_func_class_scope = ignore # ignore/add/remove/force + +# Add or remove newline between function scope and name +# Controls the newline after '::' in 'void A::f() { }'. +nl_func_scope_name = ignore # ignore/add/remove/force + +# Add or remove newline between return type and function name in a prototype. +nl_func_proto_type_name = remove # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' in the declaration. +nl_func_paren = remove # ignore/add/remove/force + +# Overrides nl_func_paren for functions with no parameters. +nl_func_paren_empty = remove # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' in the definition. +nl_func_def_paren = remove # ignore/add/remove/force + +# Overrides nl_func_def_paren for functions with no parameters. +nl_func_def_paren_empty = remove # ignore/add/remove/force + +# Add or remove newline between a function name and the opening '(' in the call +nl_func_call_paren = remove # ignore/add/remove/force + +# Overrides nl_func_call_paren for functions with no parameters. +nl_func_call_paren_empty = remove # ignore/add/remove/force + +# Add or remove newline after '(' in a function declaration. +nl_func_decl_start = ignore # ignore/add/remove/force + +# Add or remove newline after '(' in a function definition. +nl_func_def_start = ignore # ignore/add/remove/force + +# Overrides nl_func_decl_start when there is only one parameter. +nl_func_decl_start_single = ignore # ignore/add/remove/force + +# Overrides nl_func_def_start when there is only one parameter. +nl_func_def_start_single = ignore # ignore/add/remove/force + +# Whether to add newline after '(' in a function declaration if '(' and ')' are in different lines. +nl_func_decl_start_multi_line = true # false/true + +# Whether to add newline after '(' in a function definition if '(' and ')' are in different lines. +nl_func_def_start_multi_line = true # false/true + +# Add or remove newline after each ',' in a function declaration. +nl_func_decl_args = ignore # ignore/add/remove/force + +# Add or remove newline after each ',' in a function definition. +nl_func_def_args = ignore # ignore/add/remove/force + +# Whether to add newline after each ',' in a function declaration if '(' and ')' are in different lines. +nl_func_decl_args_multi_line = true # false/true + +# Whether to add newline after each ',' in a function definition if '(' and ')' are in different lines. +nl_func_def_args_multi_line = true # false/true + +# Add or remove newline before the ')' in a function declaration. +nl_func_decl_end = remove # ignore/add/remove/force + +# Add or remove newline before the ')' in a function definition. +nl_func_def_end = remove # ignore/add/remove/force + +# Overrides nl_func_decl_end when there is only one parameter. +nl_func_decl_end_single = ignore # ignore/add/remove/force + +# Overrides nl_func_def_end when there is only one parameter. +nl_func_def_end_single = ignore # ignore/add/remove/force + +# Whether to add newline before ')' in a function declaration if '(' and ')' are in different lines. +nl_func_decl_end_multi_line = false # false/true + +# Whether to add newline before ')' in a function definition if '(' and ')' are in different lines. +nl_func_def_end_multi_line = false # false/true + +# Add or remove newline between '()' in a function declaration. +nl_func_decl_empty = remove # ignore/add/remove/force + +# Add or remove newline between '()' in a function definition. +nl_func_def_empty = remove # ignore/add/remove/force + +# Add or remove newline between '()' in a function call. +nl_func_call_empty = remove # ignore/add/remove/force + +# Whether to add newline after '(' in a function call if '(' and ')' are in different lines. +nl_func_call_start_multi_line = false # false/true + +# Whether to add newline after each ',' in a function call if '(' and ')' are in different lines. +nl_func_call_args_multi_line = false # false/true + +# Whether to add newline before ')' in a function call if '(' and ')' are in different lines. +nl_func_call_end_multi_line = false # false/true + +# Whether to put each OC message parameter on a separate line +# See nl_oc_msg_leave_one_liner. +nl_oc_msg_args = false # false/true + +# Add or remove newline between function signature and '{'. +nl_fdef_brace = remove # ignore/add/remove/force + +# Add or remove newline between C++11 lambda signature and '{'. +nl_cpp_ldef_brace = remove # ignore/add/remove/force + +# Add or remove a newline between the return keyword and return expression. +nl_return_expr = ignore # ignore/add/remove/force + +# Whether to put a newline after semicolons, except in 'for' statements. +nl_after_semicolon = true # false/true + +# Java: Control the newline between the ')' and '{{' of the double brace initializer. +nl_paren_dbrace_open = ignore # ignore/add/remove/force + +# Whether to put a newline after the type in an unnamed temporary direct-list-initialization. +nl_type_brace_init_lst = ignore # ignore/add/remove/force + +# Whether to put a newline after open brace in an unnamed temporary direct-list-initialization. +nl_type_brace_init_lst_open = ignore # ignore/add/remove/force + +# Whether to put a newline before close brace in an unnamed temporary direct-list-initialization. +nl_type_brace_init_lst_close = ignore # ignore/add/remove/force + +# Whether to put a newline after brace open. +# This also adds a newline before the matching brace close. +nl_after_brace_open = false # false/true + +# If nl_after_brace_open and nl_after_brace_open_cmt are True, a newline is +# placed between the open brace and a trailing single-line comment. +nl_after_brace_open_cmt = false # false/true + +# Whether to put a newline after a virtual brace open with a non-empty body. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open = false # false/true + +# Whether to put a newline after a virtual brace open with an empty body. +# These occur in un-braced if/while/do/for statement bodies. +nl_after_vbrace_open_empty = false # false/true + +# Whether to put a newline after a brace close. +# Does not apply if followed by a necessary ';'. +nl_after_brace_close = false # false/true + +# Whether to put a newline after a virtual brace close. +# Would add a newline before return in: 'if (foo) a++; return;'. +nl_after_vbrace_close = false # false/true + +# Control the newline between the close brace and 'b' in: 'struct { int a; } b;' +# Affects enums, unions and structures. If set to ignore, uses nl_after_brace_close. +nl_brace_struct_var = ignore # ignore/add/remove/force + +# Whether to alter newlines in '#define' macros. +nl_define_macro = false # false/true + +# Whether to alter newlines between consecutive paren closes, +# The number of closing paren in a line will depend on respective open paren lines +nl_squeeze_paren_close = false # false/true + +# Whether to remove blanks after '#ifxx' and '#elxx', or before '#elxx' and '#endif'. Does not affect top-level #ifdefs. +nl_squeeze_ifdef = false # false/true + +# Makes the nl_squeeze_ifdef option affect the top-level #ifdefs as well. +nl_squeeze_ifdef_top_level = false # false/true + +# Add or remove blank line before 'if'. +nl_before_if = ignore # ignore/add/remove/force + +# Add or remove blank line after 'if' statement. +# Add/Force work only if the next token is not a closing brace. +nl_after_if = ignore # ignore/add/remove/force + +# Add or remove blank line before 'for'. +nl_before_for = ignore # ignore/add/remove/force + +# Add or remove blank line after 'for' statement. +nl_after_for = ignore # ignore/add/remove/force + +# Add or remove blank line before 'while'. +nl_before_while = ignore # ignore/add/remove/force + +# Add or remove blank line after 'while' statement. +nl_after_while = ignore # ignore/add/remove/force + +# Add or remove blank line before 'switch'. +nl_before_switch = ignore # ignore/add/remove/force + +# Add or remove blank line after 'switch' statement. +nl_after_switch = ignore # ignore/add/remove/force + +# Add or remove blank line before 'synchronized'. +nl_before_synchronized = ignore # ignore/add/remove/force + +# Add or remove blank line after 'synchronized' statement. +nl_after_synchronized = ignore # ignore/add/remove/force + +# Add or remove blank line before 'do'. +nl_before_do = ignore # ignore/add/remove/force + +# Add or remove blank line after 'do/while' statement. +nl_after_do = ignore # ignore/add/remove/force + +# Whether to double-space commented-entries in struct/union/enum. +nl_ds_struct_enum_cmt = false # false/true + +# force nl before } of a struct/union/enum +# (lower priority than 'eat_blanks_before_close_brace'). +nl_ds_struct_enum_close_brace = false # false/true + +# Add or remove blank line before 'func_class_def'. +nl_before_func_class_def = 0 # unsigned number + +# Add or remove blank line before 'func_class_proto'. +nl_before_func_class_proto = 0 # unsigned number + +# Add or remove a newline before/after a class colon, +# (tied to pos_class_colon). +nl_class_colon = ignore # ignore/add/remove/force + +# Add or remove a newline around a class constructor colon. +# Related to nl_constr_init_args, pos_constr_colon and pos_constr_comma. +nl_constr_colon = ignore # ignore/add/remove/force + +# If true turns two liner namespace to one liner,else will make then four liners +nl_namespace_two_to_one_liner = false # false/true + +# Change simple unbraced if statements into a one-liner +# 'if(b)\n i++;' => 'if(b) i++;'. +nl_create_if_one_liner = false # false/true + +# Change simple unbraced for statements into a one-liner +# 'for (i=0;i<5;i++)\n foo(i);' => 'for (i=0;i<5;i++) foo(i);'. +nl_create_for_one_liner = false # false/true + +# Change simple unbraced while statements into a one-liner +# 'while (i<5)\n foo(i++);' => 'while (i<5) foo(i++);'. +nl_create_while_one_liner = false # false/true + +# Change simple 4,3,2 liner function def statements into a one-liner +nl_create_func_def_one_liner = false # false/true + +# Change a one-liner if statement into simple unbraced if +# 'if(b) i++;' => 'if(b)\n i++;'. +nl_split_if_one_liner = false # false/true + +# Change a one-liner for statement into simple unbraced for +# 'for (i=0;<5;i++) foo(i);' => 'for (i=0;<5;i++)\n foo(i);'. +nl_split_for_one_liner = false # false/true + +# Change a one-liner while statement into simple unbraced while +# 'while (i<5) foo(i++);' => 'while (i<5)\n foo(i++);'. +nl_split_while_one_liner = false # false/true + +# +# Blank line options +# + +# The maximum consecutive newlines (3 = 2 blank lines). +nl_max = 2 # unsigned number + +# The maximum consecutive newlines in function. +nl_max_blank_in_func = 0 # unsigned number + +# The number of newlines after a function prototype, if followed by another function prototype. +nl_after_func_proto = 2 # unsigned number + +# The number of newlines after a function prototype, if not followed by another function prototype. +nl_after_func_proto_group = 0 # unsigned number + +# The number of newlines after a function class prototype, if followed by another function class prototype. +nl_after_func_class_proto = 0 # unsigned number + +# The number of newlines after a function class prototype, if not followed by another function class prototype. +nl_after_func_class_proto_group = 0 # unsigned number + +# The number of newlines before a multi-line function def body. +nl_before_func_body_def = 0 # unsigned number + +# The number of newlines before a multi-line function prototype body. +nl_before_func_body_proto = 0 # unsigned number + +# The number of newlines after '}' of a multi-line function body. +nl_after_func_body = 0 # unsigned number + +# The number of newlines after '}' of a multi-line function body in a class declaration. +nl_after_func_body_class = 0 # unsigned number + +# The number of newlines after '}' of a single line function body. +nl_after_func_body_one_liner = 0 # unsigned number + +# The minimum number of newlines before a multi-line comment. +# Doesn't apply if after a brace open or another multi-line comment. +nl_before_block_comment = 0 # unsigned number + +# The minimum number of newlines before a single-line C comment. +# Doesn't apply if after a brace open or other single-line C comments. +nl_before_c_comment = 0 # unsigned number + +# The minimum number of newlines before a CPP comment. +# Doesn't apply if after a brace open or other CPP comments. +nl_before_cpp_comment = 0 # unsigned number + +# Whether to force a newline after a multi-line comment. +nl_after_multiline_comment = false # false/true + +# Whether to force a newline after a label's colon. +nl_after_label_colon = false # false/true + +# The number of newlines after '}' or ';' of a struct/enum/union definition. +nl_after_struct = 2 # unsigned number + +# The number of newlines before a class definition. +nl_before_class = 0 # unsigned number + +# The number of newlines after '}' or ';' of a class definition. +nl_after_class = 2 # unsigned number + +# The number of newlines before a 'private:', 'public:', 'protected:', 'signals:', or 'slots:' label. +# Will not change the newline count if after a brace open. +# 0 = No change. +nl_before_access_spec = 2 # unsigned number + +# The number of newlines after a 'private:', 'public:', 'protected:', 'signals:' or 'slots:' label. +# 0 = No change. +# Overrides 'nl_typedef_blk_start' and 'nl_var_def_blk_start'. +nl_after_access_spec = 2 # unsigned number + +# The number of newlines between a function def and the function comment. +# 0 = No change. +nl_comment_func_def = 0 # unsigned number + +# The number of newlines after a try-catch-finally block that isn't followed by a brace close. +# 0 = No change. +nl_after_try_catch_finally = 0 # unsigned number + +# The number of newlines before and after a property, indexer or event decl. +# 0 = No change. +nl_around_cs_property = 0 # unsigned number + +# The number of newlines between the get/set/add/remove handlers in C#. +# 0 = No change. +nl_between_get_set = 0 # unsigned number + +# Add or remove newline between C# property and the '{'. +nl_property_brace = ignore # ignore/add/remove/force + +# Whether to remove blank lines after '{'. +eat_blanks_after_open_brace = false # false/true + +# Whether to remove blank lines before '}'. +eat_blanks_before_close_brace = false # false/true + +# How aggressively to remove extra newlines not in preproc. +# 0: No change +# 1: Remove most newlines not handled by other config +# 2: Remove all newlines and reformat completely by config +nl_remove_extra_newlines = 0 # unsigned number + +# Whether to put a blank line before 'return' statements, unless after an open brace. +nl_before_return = false # false/true + +# Whether to put a blank line after 'return' statements, unless followed by a close brace. +nl_after_return = false # false/true + +# Whether to put a newline after a Java annotation statement. +# Only affects annotations that are after a newline. +nl_after_annotation = ignore # ignore/add/remove/force + +# Controls the newline between two annotations. +nl_between_annotation = ignore # ignore/add/remove/force + +# +# Positioning options +# + +# The position of arithmetic operators in wrapped expressions. +pos_arith = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of assignment in wrapped expressions. +# Do not affect '=' followed by '{'. +pos_assign = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of boolean operators in wrapped expressions. +pos_bool = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of comparison operators in wrapped expressions. +pos_compare = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of conditional (b ? t : f) operators in wrapped expressions. +pos_conditional = ignore # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of the comma in wrapped expressions. +pos_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of the comma in enum entries. +pos_enum_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of the comma in the base class list if there are more than one line, +# (tied to nl_class_init_args). +pos_class_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of the comma in the constructor initialization list. +# Related to nl_constr_colon, nl_constr_init_args and pos_constr_colon. +pos_constr_comma = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of trailing/leading class colon, between class and base class list +# (tied to nl_class_colon). +pos_class_colon = lead # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# The position of colons between constructor and member initialization, +# (tied to nl_constr_colon). +# Related to nl_constr_colon, nl_constr_init_args and pos_constr_comma. +pos_constr_colon = lead # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force + +# +# Line Splitting options +# + +# Try to limit code width to N number of columns +code_width = 110 # unsigned number + +# Whether to fully split long 'for' statements at semi-colons. +ls_for_split_full = true # false/true + +# Whether to fully split long function protos/calls at commas. +ls_func_split_full = true # false/true + +# Whether to split lines as close to code_width as possible and ignore some groupings. +ls_code_width = false # false/true + +# +# Code alignment (not left column spaces/tabs) +# + +# Whether to keep non-indenting tabs. +align_keep_tabs = false # false/true + +# Whether to use tabs for aligning. +align_with_tabs = false # false/true + +# Whether to bump out to the next tab when aligning. +align_on_tabstop = true # false/true + +# Whether to right-align numbers. +align_number_right = true # false/true + +# Whether to keep whitespace not required for alignment. +align_keep_extra_space = true # false/true + +# Align variable definitions in prototypes and functions. +align_func_params = false # false/true + +# The span for aligning parameter definitions in function on parameter name (0=don't align). +align_func_params_span = 0 # unsigned number + +# The threshold for aligning function parameter definitions (0=no limit). +align_func_params_thresh = 0 # unsigned number + +# The gap for aligning function parameter definitions. +align_func_params_gap = 0 # unsigned number + +# Align parameters in single-line functions that have the same name. +# The function names must already be aligned with each other. +align_same_func_call_params = false # false/true + +# The span for aligning variable definitions (0=don't align) +align_var_def_span = 0 # unsigned number + +# How to align the star in variable definitions. +# 0=Part of the type 'void * foo;' +# 1=Part of the variable 'void *foo;' +# 2=Dangling 'void *foo;' +align_var_def_star_style = 0 # unsigned number + +# How to align the '&' in variable definitions. +# 0=Part of the type +# 1=Part of the variable +# 2=Dangling +align_var_def_amp_style = 0 # unsigned number + +# The threshold for aligning variable definitions (0=no limit) +align_var_def_thresh = 0 # unsigned number + +# The gap for aligning variable definitions. +align_var_def_gap = 0 # unsigned number + +# Whether to align the colon in struct bit fields. +align_var_def_colon = false # false/true + +# align variable defs gap for bit colons. +align_var_def_colon_gap = 0 # unsigned number + +# Whether to align any attribute after the variable name. +align_var_def_attribute = false # false/true + +# Whether to align inline struct/enum/union variable definitions. +align_var_def_inline = false # false/true + +# The span for aligning on '=' in assignments (0=don't align) +align_assign_span = 0 # unsigned number + +# The threshold for aligning on '=' in assignments (0=no limit) +align_assign_thresh = 0 # unsigned number + +# The span for aligning on '=' in enums (0=don't align) +align_enum_equ_span = 1 # unsigned number + +# The threshold for aligning on '=' in enums (0=no limit) +align_enum_equ_thresh = 0 # unsigned number + +# The span for aligning class (0=don't align) +align_var_class_span = 0 # unsigned number + +# The threshold for aligning class member definitions (0=no limit). +align_var_class_thresh = 0 # unsigned number + +# The gap for aligning class member definitions. +align_var_class_gap = 0 # unsigned number + +# The span for aligning struct/union (0=don't align) +align_var_struct_span = 0 # unsigned number + +# The threshold for aligning struct/union member definitions (0=no limit) +align_var_struct_thresh = 0 # unsigned number + +# The gap for aligning struct/union member definitions. +align_var_struct_gap = 0 # unsigned number + +# The span for aligning struct initializer values (0=don't align) +align_struct_init_span = 0 # unsigned number + +# The minimum space between the type and the synonym of a typedef. +align_typedef_gap = 0 # unsigned number + +# The span for aligning single-line typedefs (0=don't align). +align_typedef_span = 0 # unsigned number + +# How to align typedef'd functions with other typedefs +# 0: Don't mix them at all +# 1: align the open paren with the types +# 2: align the function type name with the other type names +align_typedef_func = 0 # unsigned number + +# Controls the positioning of the '*' in typedefs. Just try it. +# 0: Align on typedef type, ignore '*' +# 1: The '*' is part of type name: typedef int *pint; +# 2: The '*' is part of the type, but dangling: typedef int *pint; +align_typedef_star_style = 0 # unsigned number + +# Controls the positioning of the '&' in typedefs. Just try it. +# 0: Align on typedef type, ignore '&' +# 1: The '&' is part of type name: typedef int &pint; +# 2: The '&' is part of the type, but dangling: typedef int &pint; +align_typedef_amp_style = 0 # unsigned number + +# The span for aligning comments that end lines (0=don't align) +align_right_cmt_span = 0 # unsigned number + +# If aligning comments, mix with comments after '}' and #endif with less than 3 spaces before the comment. +align_right_cmt_mix = false # false/true + +# If a trailing comment is more than this number of columns away from the text it follows, +# it will qualify for being aligned. This has to be > 0 to do anything. +align_right_cmt_gap = 0 # unsigned number + +# Align trailing comment at or beyond column N; 'pulls in' comments as a bonus side effect (0=ignore) +align_right_cmt_at_col = 0 # unsigned number + +# The span for aligning function prototypes (0=don't align). +align_func_proto_span = 0 # unsigned number + +# Minimum gap between the return type and the function name. +align_func_proto_gap = 0 # unsigned number + +# Align function protos on the 'operator' keyword instead of what follows. +align_on_operator = false # false/true + +# Whether to mix aligning prototype and variable declarations. +# If True, align_var_def_XXX options are used instead of align_func_proto_XXX options. +align_mix_var_proto = false # false/true + +# Align single-line functions with function prototypes, uses align_func_proto_span. +align_single_line_func = false # false/true + +# Aligning the open brace of single-line functions. +# Requires align_single_line_func=True, uses align_func_proto_span. +align_single_line_brace = false # false/true + +# Gap for align_single_line_brace. +align_single_line_brace_gap = 0 # unsigned number + +# The span for aligning ObjC msg spec (0=don't align) +align_oc_msg_spec_span = 0 # unsigned number + +# Whether to align macros wrapped with a backslash and a newline. +# This will not work right if the macro contains a multi-line comment. +align_nl_cont = true # false/true + +# # Align macro functions and variables together. +align_pp_define_together = false # false/true + +# The minimum space between label and value of a preprocessor define. +align_pp_define_gap = 1 # unsigned number + +# The span for aligning on '#define' bodies (0=don't align, other=number of lines including comments between blocks) +align_pp_define_span = 1 # unsigned number + +# Align lines that start with '<<' with previous '<<'. Default=True. +align_left_shift = true # false/true + +# Align text after asm volatile () colons. +align_asm_colon = false # false/true + +# Span for aligning parameters in an Obj-C message call on the ':' (0=don't align) +align_oc_msg_colon_span = 0 # unsigned number + +# If True, always align with the first parameter, even if it is too short. +align_oc_msg_colon_first = false # false/true + +# Aligning parameters in an Obj-C '+' or '-' declaration on the ':'. +align_oc_decl_colon = false # false/true + +# +# Comment modifications +# + +# Try to wrap comments at cmt_width columns +cmt_width = 80 # unsigned number + +# Set the comment reflow mode (Default=0) +# 0: no reflowing (apart from the line wrapping due to cmt_width) +# 1: no touching at all +# 2: full reflow +cmt_reflow_mode = 0 # unsigned number + +# Whether to convert all tabs to spaces in comments. Default is to leave tabs inside comments alone, unless used for indenting. +cmt_convert_tab_to_spaces = true # false/true + +# If False, disable all multi-line comment changes, including cmt_width. keyword substitution and leading chars. +# Default=True. +cmt_indent_multi = true # false/true + +# Whether to group c-comments that look like they are in a block. +cmt_c_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined c-comment. +cmt_c_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined c-comment. +cmt_c_nl_end = false # false/true + +# Whether to group cpp-comments that look like they are in a block. +cmt_cpp_group = false # false/true + +# Whether to put an empty '/*' on the first line of the combined cpp-comment. +cmt_cpp_nl_start = false # false/true + +# Whether to put a newline before the closing '*/' of the combined cpp-comment. +cmt_cpp_nl_end = false # false/true + +# Whether to change cpp-comments into c-comments. +cmt_cpp_to_c = false # false/true + +# Whether to put a star on subsequent comment lines. +cmt_star_cont = false # false/true + +# The number of spaces to insert at the start of subsequent comment lines. +cmt_sp_before_star_cont = 0 # unsigned number + +# The number of spaces to insert after the star on subsequent comment lines. +cmt_sp_after_star_cont = 0 # number + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length. Default=True. +cmt_multi_check_last = true # false/true + +# For multi-line comments with a '*' lead, remove leading spaces if the first and last lines of +# the comment are the same length AND if the length is bigger as the first_len minimum. Default=4 +cmt_multi_first_len_minimum = 4 # unsigned number + +# The filename that contains text to insert at the head of a file if the file doesn't start with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_header = "" # string + +# The filename that contains text to insert at the end of a file if the file doesn't end with a C/C++ comment. +# Will substitute $(filename) with the current file's name. +cmt_insert_file_footer = "" # string + +# The filename that contains text to insert before a function implementation if the function isn't preceded with a C/C++ comment. +# Will substitute $(function) with the function name and $(javaparam) with the javadoc @param and @return stuff. +# Will also substitute $(fclass) with the class name: void CFoo::Bar() { ... }. +cmt_insert_func_header = "" # string + +# The filename that contains text to insert before a class if the class isn't preceded with a C/C++ comment. +# Will substitute $(class) with the class name. +cmt_insert_class_header = "" # string + +# The filename that contains text to insert before a Obj-C message specification if the method isn't preceded with a C/C++ comment. +# Will substitute $(message) with the function name and $(javaparam) with the javadoc @param and @return stuff. +cmt_insert_oc_msg_header = "" # string + +# If a preprocessor is encountered when stepping backwards from a function name, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_oc_msg_header, cmt_insert_func_header and cmt_insert_class_header. +cmt_insert_before_preproc = false # false/true + +# If a function is declared inline to a class definition, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header. +cmt_insert_before_inlines = true # false/true + +# If the function is a constructor/destructor, then +# this option decides whether the comment should be inserted. +# Affects cmt_insert_func_header. +cmt_insert_before_ctor_dtor = false # false/true + +# +# Code modifying options (non-whitespace) +# + +# Add or remove braces on single-line 'do' statement. +mod_full_brace_do = add # ignore/add/remove/force + +# Add or remove braces on single-line 'for' statement. +mod_full_brace_for = add # ignore/add/remove/force + +# Add or remove braces on single-line function definitions. (Pawn). +mod_full_brace_function = add # ignore/add/remove/force + +# Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'. +mod_full_brace_if = add # ignore/add/remove/force + +# Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if. +# If any must be braced, they are all braced. If all can be unbraced, then the braces are removed. +mod_full_brace_if_chain = false # false/true + +# Make all if/elseif/else statements with at least one 'else' or 'else if' fully braced. +# If mod_full_brace_if_chain is used together with this option, all if-else chains will get braces, +# and simple 'if' statements will lose them (if possible). +mod_full_brace_if_chain_only = false # false/true + +# Don't remove braces around statements that span N newlines +mod_full_brace_nl = 0 # unsigned number + +# Blocks removal of braces if the parenthesis of if/for/while/.. span multiple lines. +mod_full_brace_nl_block_rem_mlcond = false # false/true + +# Add or remove braces on single-line 'while' statement. +mod_full_brace_while = add # ignore/add/remove/force + +# Add or remove braces on single-line 'using ()' statement. +mod_full_brace_using = ignore # ignore/add/remove/force + +# Add or remove unnecessary paren on 'return' statement. +mod_paren_on_return = ignore # ignore/add/remove/force + +# Whether to change optional semicolons to real semicolons. +mod_pawn_semicolon = false # false/true + +# Add parens on 'while' and 'if' statement around bools. +mod_full_paren_if_bool = false # false/true + +# Whether to remove superfluous semicolons. +mod_remove_extra_semicolon = true # false/true + +# If a function body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_function_closebrace_comment = 0 # unsigned number + +# If a namespace body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_namespace_closebrace_comment = 0 # unsigned number + +# If a class body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_class_closebrace_comment = 0 # unsigned number + +# If a switch body exceeds the specified number of newlines and doesn't have a comment after +# the close brace, a comment will be added. +mod_add_long_switch_closebrace_comment = 0 # unsigned number + +# If an #ifdef body exceeds the specified number of newlines and doesn't have a comment after +# the #endif, a comment will be added. +mod_add_long_ifdef_endif_comment = 0 # unsigned number + +# If an #ifdef or #else body exceeds the specified number of newlines and doesn't have a comment after +# the #else, a comment will be added. +mod_add_long_ifdef_else_comment = 0 # unsigned number + +# If True, will sort consecutive single-line 'import' statements [Java, D]. +mod_sort_import = false # false/true + +# If True, will sort consecutive single-line 'using' statements [C#]. +mod_sort_using = false # false/true + +# If True, will sort consecutive single-line '#include' statements [C/C++] and '#import' statements [Obj-C] +# This is generally a bad idea, as it may break your code. +mod_sort_include = false # false/true + +# If True, it will move a 'break' that appears after a fully braced 'case' before the close brace. +mod_move_case_break = true # false/true + +# Will add or remove the braces around a fully braced case statement. +# Will only remove the braces if there are no variable declarations in the block. +mod_case_brace = ignore # ignore/add/remove/force + +# If True, it will remove a void 'return;' that appears as the last statement in a function. +mod_remove_empty_return = true # false/true + +# If True, it will organize the properties (Obj-C). +mod_sort_oc_properties = false # false/true + +# Determines weight of class property modifier (Obj-C). +mod_sort_oc_property_class_weight = 0 # number + +# Determines weight of atomic, nonatomic (Obj-C). +mod_sort_oc_property_thread_safe_weight = 0 # number + +# Determines weight of readwrite (Obj-C). +mod_sort_oc_property_readwrite_weight = 0 # number + +# Determines weight of reference type (retain, copy, assign, weak, strong) (Obj-C). +mod_sort_oc_property_reference_weight = 0 # number + +# Determines weight of getter type (getter=) (Obj-C). +mod_sort_oc_property_getter_weight = 0 # number + +# Determines weight of setter type (setter=) (Obj-C). +mod_sort_oc_property_setter_weight = 0 # number + +# Determines weight of nullability type (nullable, nonnull, null_unspecified, null_resettable) (Obj-C). +mod_sort_oc_property_nullability_weight = 0 # number + +# +# Preprocessor options +# + +# Control indent of preprocessors inside #if blocks at brace level 0 (file-level). +pp_indent = force # ignore/add/remove/force + +# Whether to indent #if/#else/#endif at the brace level (True) or from column 1 (False). +pp_indent_at_level = false # false/true + +# Specifies the number of columns to indent preprocessors per level at brace level 0 (file-level). +# If pp_indent_at_level=False, specifies the number of columns to indent preprocessors per level at brace level > 0 (function-level). +# Default=1. +pp_indent_count = 0 # unsigned number + +# Add or remove space after # based on pp_level of #if blocks. +pp_space = ignore # ignore/add/remove/force + +# Sets the number of spaces added with pp_space. +pp_space_count = 0 # unsigned number + +# The indent for #region and #endregion in C# and '#pragma region' in C/C++. +pp_indent_region = 0 # number + +# Whether to indent the code between #region and #endregion. +pp_region_indent_code = false # false/true + +# If pp_indent_at_level=True, sets the indent for #if, #else and #endif when not at file-level. +# 0: indent preprocessors using output_tab_size. +# >0: column at which all preprocessors will be indented. +pp_indent_if = 0 # number + +# Control whether to indent the code between #if, #else and #endif. +pp_if_indent_code = false # false/true + +# Whether to indent '#define' at the brace level (True) or from column 1 (false). +pp_define_at_level = false # false/true + +# Whether to ignore the '#define' body while formatting. +pp_ignore_define_body = false # false/true + +# Whether to indent case statements between #if, #else, and #endif. +# Only applies to the indent of the preprocesser that the case statements directly inside of. +pp_indent_case = true # false/true + +# Whether to indent whole function definitions between #if, #else, and #endif. +# Only applies to the indent of the preprocesser that the function definition is directly inside of. +pp_indent_func_def = true # false/true + +# Whether to indent extern C blocks between #if, #else, and #endif. +# Only applies to the indent of the preprocesser that the extern block is directly inside of. +pp_indent_extern = true # false/true + +# Whether to indent braces directly inside #if, #else, and #endif. +# Only applies to the indent of the preprocesser that the braces are directly inside of. +pp_indent_brace = true # false/true + +# +# Sort includes options +# + +# The regex for include category with priority 0. +include_category_0 = "" # string + +# The regex for include category with priority 1. +include_category_1 = "" # string + +# The regex for include category with priority 2. +include_category_2 = "" # string + +# +# Use or Do not Use options +# + +# True: indent_func_call_param will be used (default) +# False: indent_func_call_param will NOT be used. +use_indent_func_call_param = true # false/true + +# The value of the indentation for a continuation line is calculate differently if the statement is: +# a declaration: your case with QString fileName ... +# an assignment: your case with pSettings = new QSettings( ... +# At the second case the indentation value might be used twice: +# at the assignment +# at the function call (if present) +# To prevent the double use of the indentation value, use this option with the value 'True'. +# True: indent_continue will be used only once +# False: indent_continue will be used every time (default). +use_indent_continue_only_once = false # false/true + +# the value might be used twice: +# at the assignment +# at the opening brace +# To prevent the double use of the indentation value, use this option with the value 'True'. +# True: indentation will be used only once +# False: indentation will be used every time (default). +indent_cpp_lambda_only_once = true # false/true + +# SIGNAL/SLOT Qt macros have special formatting options. See options_for_QT.cpp for details. +# Default=True. +use_options_overriding_for_qt_macros = true # false/true + +# +# Warn levels - 1: error, 2: warning (default), 3: note +# + +# Warning is given if doing tab-to-\t replacement and we have found one in a C# verbatim string literal. +warn_level_tabs_found_in_verbatim_string_literals = 2 # unsigned number + +# Meaning of the settings: +# Ignore - do not do any changes +# Add - makes sure there is 1 or more space/brace/newline/etc +# Force - makes sure there is exactly 1 space/brace/newline/etc, +# behaves like Add in some contexts +# Remove - removes space/brace/newline/etc +# +# +# - Token(s) can be treated as specific type(s) with the 'set' option: +# `set tokenType tokenString [tokenString...]` +# +# Example: +# `set BOOL __AND__ __OR__` +# +# tokenTypes are defined in src/token_enum.h, use them without the +# 'CT_' prefix: 'CT_BOOL' -> 'BOOL' +# +# +# - Token(s) can be treated as type(s) with the 'type' option. +# `type tokenString [tokenString...]` +# +# Example: +# `type int c_uint_8 Rectangle` +# +# This can also be achieved with `set TYPE int c_uint_8 Rectangle` +# +# +# To embed whitespace in tokenStrings use the '\' escape character, or quote +# the tokenStrings. These quotes are supported: "'` +# +# +# - Support for the auto detection of languages through the file ending can be +# added using the 'file_ext' command. +# `file_ext langType langString [langString..]` +# +# Example: +# `file_ext CPP .ch .cxx .cpp.in` +# +# langTypes are defined in uncrusify_types.h in the lang_flag_e enum, use +# them without the 'LANG_' prefix: 'LANG_CPP' -> 'CPP' +# +# +# - Custom macro-based indentation can be set up using 'macro-open', +# 'macro-else' and 'macro-close'. +# `(macro-open | macro-else | macro-close) tokenString` +# +# Example: +# `macro-open BEGIN_TEMPLATE_MESSAGE_MAP` +# `macro-open BEGIN_MESSAGE_MAP` +# `macro-close END_MESSAGE_MAP` +# +# +# option(s) with 'not default' value: 0 +# diff --git a/Util/CARLA.sublime-project b/Util/CARLA.sublime-project new file mode 100644 index 000000000..aa8975f8c --- /dev/null +++ b/Util/CARLA.sublime-project @@ -0,0 +1,138 @@ +{ + "folders": + [ + { + "path": "..", + "file_exclude_patterns": + [ + "*.VC.db", + "*.VC.opendb", + "*.gdb_history", + "*.kdev4", + "*.pri", + "*.pro", + "*.py[cod]", + "*.sln", + "*.stackdump", + "*.sublime-workspace", + "*.uasset", + "*.umap", + "*.workspace", + "*CodeCompletionFolders.txt", + "*CodeLitePreProcessor.txt", + ".tags*", + "core" + ], + "folder_exclude_patterns": + [ + ".clang", + ".codelite", + ".kdev4", + ".vs", + ".vscode", + "Binaries", + "DerivedDataCache", + "Dist", + "Doxygen", + "Intermediate", + "PythonAPI/build", + "PythonAPI/dependencies", + "PythonAPI/dist", + "Saved", + "Unreal/CarlaUE4/Content*", + "Unreal/CarlaUE4/Plugins/Carla/CarlaDependencies", + "__pycache__", + "_site" + ], + } + ], + "settings": + { + "ensure_newline_at_eof_on_save": true, + "tab_size": 2, + "translate_tabs_to_spaces": true, + "trim_trailing_white_space_on_save": true + }, + "build_systems": + [ + { + "name": "CARLA - make CarlaUE4Editor", + "working_dir": "${project_path}/..", + "file_regex": "(Unreal\\/CarlaUE4\\/[^:]*):([0-9]+):?([0-9]+)?:? (.*)$", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "CARLA_BUILD_NO_COLOR=true make CarlaUE4Editor" + } + }, + { + "name": "CARLA - make LibCarla", + "working_dir": "${project_path}/..", + "file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "CARLA_BUILD_NO_COLOR=true make LibCarla" + } + }, + { + "name": "CARLA - make PythonAPI", + "working_dir": "${project_path}/..", + "file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "CARLA_BUILD_NO_COLOR=true make PythonAPI" + } + }, + { + "name": "CARLA - make check", + "working_dir": "${project_path}/..", + "file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "CARLA_BUILD_NO_COLOR=true make check" + } + }, + { + "name": "CARLA - make check LibCarla", + "working_dir": "${project_path}/..", + "file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "CARLA_BUILD_NO_COLOR=true make check ARGS=\"--carlalib-debug\"" + } + }, + { + "name": "CARLA - make check LibCarla (launch GDB)", + "working_dir": "${project_path}/..", + "file_regex": "^../../([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "gnome-terminal --maximize -e 'make check ARGS=\"--gdb --carlalib-debug\"'" + } + }, + { + "name": "CARLA - make clean", + "working_dir": "${project_path}/..", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "CARLA_BUILD_NO_COLOR=true make clean" + } + }, + { + "name": "CARLA - Prettify this file", + "working_dir": "${project_path}/..", + "file_regex": "^([^:]*):([0-9]+):?([0-9]+)?:? (.*)$", + "syntax": "Packages/Makefile/Make Output.sublime-syntax", + "linux": + { + "shell_cmd": "CARLA_BUILD_NO_COLOR=true make pretty ARGS=-f${file}" + } + } + ] +} diff --git a/mkdocs.yml b/mkdocs.yml index 964c8132d..3a366e59b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -35,6 +35,7 @@ pages: - 'How to add assets': 'how_to_add_assets.md' - 'CARLA design': 'carla_design.md' - 'CarlaServer documentation': 'carla_server.md' + - 'Build system': 'build_system.md' - Appendix: - 'Driving Benchmark Sample Results Town01': 'benchmark_basic_results_town01.md' - 'Driving Benchmark Sample Results Town02': 'benchmark_basic_results_town02.md'