rippled
|
| :warning: WARNING :warning: |—| | These instructions assume you have a C++ development environment ready with Git, Python, Conan, CMake, and a C++ compiler. For help setting one up on Linux, macOS, or Windows, see this guide. |
These instructions also assume a basic familiarity with Conan and CMake. If you are unfamiliar with Conan, you can read our crash course or the official Getting Started walkthrough.
For a stable release, choose the master
branch or one of the tagged releases.
For the latest release candidate, choose the release
branch.
For the latest set of untested features, or to contribute, choose the develop
branch.
See System Requirements.
Building rippled generally requires git, Python, Conan, CMake, and a C++ compiler. Some guidance on setting up such a C++ development environment can befound here". - <a href="https://www.python.org/downloads/" >Python 3.11</a>, or higher - <a href="https://conan.io/downloads.html" >Conan 2.17</a>[^1], or higher - <a href="https://cmake.org/download/" >CMake 3.22</a>[^2], or higher [^1]: It is possible to build with Conan 1.60+, but the instructions are significantly different, which is why we are not recommending it. [^2]: CMake 4 is not yet supported by all dependencies required by this project. If you are affected by this issue, follow @ref workaround-for-cmake-4 "conan workaround for cmake 4" <tt>rippled</tt> is written in the C++20 dialect and includes the <tt>\<concepts\></tt> header. The <a href="https://en.cppreference.com/w/cpp/compiler_support/20" >minimum compiler versions</a> required are: <table class="markdownTable"> <tr class="markdownTableHead"> <th class="markdownTableHeadNone"> Compiler
Version
GCC
12
Clang
16
Apple Clang
16
MSVC
19.44[^3]
The Ubuntu Linux distribution has received the highest level of quality assurance, testing, and support. We also support Red Hat and use Debian internally.
Here are sample instructions for setting up a C++ development environment on Linux.
Many rippled engineers use macOS for development.
Here are sample instructions for setting up a C++ development environment on macOS.
Windows is used by some engineers for development only.
[^3]: Windows is not recommended for production use.
After you have a C++ development environment ready with Git, Python, Conan, CMake, and a C++ compiler, you may need to set up your Conan profile.
These instructions assume a basic familiarity with Conan and CMake. If you are unfamiliar with Conan, then please read this crash course or the official Getting Started walkthrough.
We recommend that you import the provided conan/profiles/default
profile:
You can check your Conan profile by running:
If the default profile does not work for you and you do not yet have a Conan profile, you can create one by running:
You may need to make changes to the profile to suit your environment. You can refer to the provided conan/profiles/default
profile for inspiration, and you may also need to apply the required tweaks to this default profile.
The recipes in Conan Center occasionally need to be patched for compatibility with the latest version of rippled
. We maintain a fork of the Conan Center here containing the patches.
To ensure our patched recipes are used, you must add our Conan remote at a higher index than the default Conan Center remote, so it is consulted first. You can do this by running:
Alternatively, you can pull the patched recipes into the repository and use them locally:
In the case we switch to a newer version of a dependency that still requires a patch, it will be necessary for you to pull in the changes and re-export the updated dependencies with the newer version. However, if we switch to a newer version that no longer requires a patch, no action is required on your part, as the new recipe will be automatically pulled from the official Conan Center.
If you see an error similar to the following after running conan profile show
:
you need to amend the list of compiler versions in $(conan config home)/settings.yml
, by appending the required version number(s) to the version
array specific for your compiler. For example:
If you have multiple compilers installed, make sure to select the one to use in your default Conan configuration before running conan profile detect
, by setting the CC
and CXX
environment variables.
For example, if you are running MacOS and have homebrew LLVM@18, and want to use it as a compiler in the new Conan profile:
You should also explicitly set the path to the compiler in the profile file, which helps to avoid errors when CC
and/or CXX
are set and disagree with the selected Conan profile. For example:
You can manage multiple Conan profiles in the directory $(conan config home)/profiles
, for example renaming default
to a different name and then creating a new default
profile for a different compiler.
The default profile created by Conan will typically select different C++ dialect than C++20 used by this project. You should set 20
in the profile line starting with compiler.cppstd=
. For example:
Linux developers will commonly have a default Conan profile that compiles with GCC and links with libstdc++. If you are linking with libstdc++ (see profile setting compiler.libcxx
), then you will need to choose the libstdc++11
ABI:
Windows developers may need to use the x64 native build tools. An easy way to do that is to run the shortcut "x64 Native Tools Command Prompt" for the version of Visual Studio that you have installed.
Windows developers must also build rippled
and its dependencies for the x64 architecture:
Windows developers also must select static runtime:
If your system CMake is version 4 rather than 3, you may have to configure Conan profile to use CMake version 3 for dependencies, by adding the following two lines to your profile:
This will force Conan to download and use a locally cached CMake 3 version, and is needed because some of the dependencies used by this project do not support CMake 4.
If your compiler is clang, version 19 or later, or apple-clang, version 17 or later, you may encounter a compilation error while building the grpc
dependency:
The workaround for this error is to add two lines to profile:
If your compiler is gcc, version 12, and you have enabled werr
option, you may encounter a compilation error such as:
The workaround for this error is to add two lines to your profile:
If your compiler is clang, version 16, you may encounter compilation error such as:
The workaround for this error is to add two lines to your profile:
Create a build directory and move into it.
You can use any directory name. Conan treats your working directory as an install folder and generates files with implementation details. You don't need to worry about these files, but make sure to change your working directory to your build directory before calling Conan.
Note: You can specify a directory for the installation files by adding the install-folder
or -if
option to every conan install
command in the next step.
Use conan to generate CMake files for every configuration you want to build:
To build Debug, in the next step, be sure to set -DCMAKE_BUILD_TYPE=Debug
For a single-configuration generator, e.g. Unix Makefiles
or Ninja
, you only need to run this command once. For a multi-configuration generator, e.g. Visual Studio
, you may want to run it more than once.
Each of these commands should also have a different build_type
setting. A second command with the same build_type
setting will overwrite the files generated by the first. You can pass the build type on the command line with --settings build_type=$BUILD_TYPE
or in the profile itself, under the section [settings]
with the key build_type
.
If you are using a Microsoft Visual C++ compiler, then you will need to ensure consistency between the build_type
setting and the compiler.runtime
setting.
When build_type
is Release
, compiler.runtime
should be MT
.
When build_type
is Debug
, compiler.runtime
should be MTd
.
Configure CMake and pass the toolchain file generated by Conan, located at $OUTPUT_FOLDER/build/generators/conan_toolchain.cmake
.
Single-config generators:
Pass the CMake variable CMAKE_BUILD_TYPE
and make sure it matches the one of the build_type
settings you chose in the previous step.
For example, to build Debug, in the next command, replace "Release" with "Debug"
Multi-config generators:
Note: You can pass build options for rippled
in this step.
Build rippled
.
For a single-configuration generator, it will build whatever configuration you passed for CMAKE_BUILD_TYPE
. For a multi-configuration generator, you must pass the option --config
to select the build configuration.
Single-config generators:
Multi-config generators:
Test rippled.
Single-config generators:
Multi-config generators:
Replace the --unittest-jobs
parameter N with the desired unit tests concurrency. Recommended setting is half of the number of available CPU cores.
The location of rippled
binary in your build directory depends on your CMake generator. Pass --help
to see the rest of the command line options.
The coverage report is intended for developers using compilers GCC or Clang (including Apple Clang). It is generated by the build target coverage
, which is only enabled when the coverage
option is set, e.g. with --options coverage=True
in conan
or -Dcoverage=ON
variable in cmake
Prerequisites for the coverage report:
gcov
for GCC (installed with the compiler by default) orllvm-cov
for Clang (installed with the compiler by default)Debug
build typeA coverage report is created when the following steps are completed, in order:
rippled
binary built with instrumentation data, enabled by the coverage
option mentioned abovegcovr
tool (which internally invokes either gcov
or llvm-cov
) to assemble both instrumentation data and the coverage capture data into a coverage reportThe above steps are automated into a single target coverage
. The instrumented rippled
binary can also be used for regular development or testing work, at the cost of extra disk space utilization and a small performance hit (to store coverage capture). In case of a spurious failure of unit tests, it is possible to re-run the coverage
target without rebuilding the rippled
binary (since it is simply a dependency of the coverage report target). It is also possible to select only specific tests for the purpose of the coverage report, by setting the coverage_test
variable in cmake
The default coverage report format is html-details
, but the user can override it to any of the formats listed in Builds/CMake/CodeCoverage.cmake
by setting the coverage_format
variable in cmake
. It is also possible to generate more than one format at a time by setting the coverage_extra_args
variable in cmake
. The specific command line used to run the gcovr
tool will be displayed if the CODE_COVERAGE_VERBOSE
variable is set.
By default, the code coverage tool runs parallel unit tests with --unittest-jobs
set to the number of available CPU cores. This may cause spurious test errors on Apple. Developers can override the number of unit test jobs with the coverage_test_parallelism
variable in cmake
.
Example use with some cmake variables set:
After the coverage
target is completed, the generated coverage report will be stored inside the build directory, as either of:
coverage.
_extension_, with a suitable extension for the report format, orcoverage
, with the index.html
and other files inside, for the html-details
or html-nested
report formats.Option | Default Value | Description |
---|---|---|
assert | OFF | Enable assertions. |
coverage | OFF | Prepare the coverage report. |
san | N/A | Enable a sanitizer with Clang. Choices are thread and address . |
tests | OFF | Build tests. |
unity | OFF | Configure a unity build. |
xrpld | OFF | Build the xrpld (rippled ) application, and not just the libxrpl library. |
werr | OFF | Treat compilation warnings as errors |
wextra | OFF | Enable additional compilation warnings |
Unity builds may be faster for the first build (at the cost of much more memory) since they concatenate sources into fewer translation units. Non-unity builds may be faster for incremental builds, and can be helpful for detecting #include
omissions.
After any updates or changes to dependencies, you may need to do the following:
Remove individual libraries from the Conan cache, e.g.
or
Remove all libraries from Conan cache:
If cmake --build .
results in an error due to a missing a protobuf file, then you might have generated CMake files for a different build_type
than the CMAKE_BUILD_TYPE
you passed to Conan.
For example, if you want to build Debug:
--settings build_type=Debug
-DCMAKE_BUILD_TYPE=Debug
If you want to experiment with a new package, follow these steps:
conanfile.py
:requires
property.default_options
property (with syntax ‘’$package:$option': $value).
Modify [
CMakeLists.txt](./CMakeLists.txt):
- Add a call tofind_package($package REQUIRED)
.
Link a library from the package to the target
ripple_libs (search for the existing call to
target_link_libraries(ripple_libs INTERFACE ...)`).
Start coding! Don't forget to include whatever headers you need from the package.