diff --git a/.github/actions/cmake/action.yml b/.github/actions/cmake/action.yml index b40df6a299..b7d5db651f 100644 --- a/.github/actions/cmake/action.yml +++ b/.github/actions/cmake/action.yml @@ -64,6 +64,7 @@ runs: -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ "${SANITIZER_OPTION}" \ + -Dtests=ON \ -Dintegration_tests="${INTEGRATION_TESTS}" \ -Dbenchmark="${BENCHMARK}" \ -Dcoverage="${COVERAGE}" \ diff --git a/.github/actions/conan/action.yml b/.github/actions/conan/action.yml index 52ed03dd70..bd931f7977 100644 --- a/.github/actions/conan/action.yml +++ b/.github/actions/conan/action.yml @@ -17,10 +17,6 @@ inputs: description: Build type for third-party libraries and clio. Could be 'Release', 'Debug' required: true default: "Release" - build_benchmark: - description: Whether to build benchmark tests - required: true - default: "true" runs: using: composite @@ -33,13 +29,10 @@ runs: shell: bash env: CONAN_BUILD_OPTION: "${{ inputs.force_conan_source_build == 'true' && '*' || 'missing' }}" - BUILD_BENCHMARK: "${{ inputs.build_benchmark == 'true' && 'True' || 'False' }}" run: | conan \ install . \ -of build \ -b "$CONAN_BUILD_OPTION" \ -s "build_type=${{ inputs.build_type }}" \ - -o "&:tests=True" \ - -o "&:benchmark=${BUILD_BENCHMARK}" \ --profile:all "${{ inputs.conan_profile }}" diff --git a/.github/workflows/check_libxrpl.yml b/.github/workflows/check_libxrpl.yml index 1f3c965d87..ee1b36c2e9 100644 --- a/.github/workflows/check_libxrpl.yml +++ b/.github/workflows/check_libxrpl.yml @@ -38,7 +38,7 @@ jobs: - name: Update conan lockfile shell: bash run: | - conan lock create . -o '&:tests=True' -o '&:benchmark=True' --profile:all ${{ env.CONAN_PROFILE }} + conan lock create . --profile:all ${{ env.CONAN_PROFILE }} - name: Run conan uses: ./.github/actions/conan diff --git a/conanfile.py b/conanfile.py index 90dfb8ac4d..60bdeb0a96 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,10 +9,7 @@ class ClioConan(ConanFile): url = 'https://github.com/xrplf/clio' description = 'Clio RPC server' settings = 'os', 'compiler', 'build_type', 'arch' - options = { - 'tests': [True, False], - 'benchmark': [True, False], - } + options = {} requires = [ 'boost/1.83.0', @@ -28,9 +25,6 @@ class ClioConan(ConanFile): ] default_options = { - 'tests': False, - 'benchmark': False, - 'xrpl/*:tests': False, 'xrpl/*:rocksdb': False, 'cassandra-cpp-driver/*:shared': False, @@ -51,10 +45,8 @@ class ClioConan(ConanFile): ) def requirements(self): - if self.options.tests or self.options.integration_tests: - self.requires('gtest/1.14.0') - if self.options.benchmark: - self.requires('benchmark/1.9.4') + self.requires('gtest/1.14.0') + self.requires('benchmark/1.9.4') def configure(self): if self.settings.compiler == 'apple-clang': @@ -70,8 +62,6 @@ def layout(self): def generate(self): tc = CMakeToolchain(self) - for option_name, option_value in self.options.items(): - tc.variables[option_name] = option_value tc.generate() def build(self): diff --git a/docs/build-clio.md b/docs/build-clio.md index a5bada311a..00e6944f94 100644 --- a/docs/build-clio.md +++ b/docs/build-clio.md @@ -107,62 +107,72 @@ You have to update this file every time you add a new dependency or change a rev To do that, run the following command in the repository root: ```bash -conan lock create . -o '&:tests=True' -o '&:benchmark=True' +conan lock create . ``` ## Building Clio -Navigate to Clio's root directory and run: +1. Navigate to Clio's root directory and run: -```sh -mkdir build && cd build -# You can also specify profile explicitly by adding `--profile:all ` -conan install .. --output-folder . --build missing --settings build_type=Release -o '&:tests=True' -# You can also add -GNinja to use Ninja build system instead of Make -cmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. -cmake --build . --parallel 8 # or without the number if you feel extra adventurous -``` - -> [!TIP] -> You can omit the `-o '&:tests=True'` if you don't want to build `clio_tests`. - -If successful, `conan install` will find the required packages and `cmake` will do the rest. You should see `clio_server` and `clio_tests` in the `build` directory (the current directory). + ```sh + mkdir build && cd build + ``` -> [!TIP] -> To generate a Code Coverage report, include `-o '&:coverage=True'` in the `conan install` command above, along with `-o '&:tests=True'` to enable tests. -> After running the `cmake` commands, execute `make clio_tests-ccov`. -> The coverage report will be found at `clio_tests-llvm-cov/index.html`. +2. Install dependencies through conan. - + ```sh + conan install .. --output-folder . --build missing --settings build_type=Release + ``` -> [!NOTE] -> If you've built Clio before and the build is now failing, it's likely due to updated dependencies. Try deleting the build folder and then rerunning the Conan and CMake commands mentioned above. + > You can add `--profile:all ` to choose a specific conan profile. -### Generating API docs for Clio +3. Configure and generate build files with CMake. -The API documentation for Clio is generated by [Doxygen](https://www.doxygen.nl/index.html). If you want to generate the API documentation when building Clio, make sure to install Doxygen 1.12.0 on your system. + ```sh + cmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. + ``` -To generate the API docs: + > You can add `-GNinja` to use the Ninja build system (instead of Make). -1. First, include `-o '&:docs=True'` in the conan install command. For example: +4. Now, you can build all targets or specific ones: ```sh - mkdir build && cd build - conan install .. --output-folder . --build missing --settings build_type=Release -o '&:tests=True' -o '&:docs=True' + # builds all targets + cmake --build . --parallel 8 + # builds only clio_server target + cmake --build . --parallel 8 --target clio_server ``` -2. Once that has completed successfully, run the `cmake` command and add the `--target docs` option: + You should see `clio_server` and `clio_tests` in the current directory. - ```sh - cmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. - cmake --build . --parallel 8 --target docs - ``` +> [!NOTE] +> If you've built Clio before and the build is now failing, it's likely due to updated dependencies. Try deleting the build folder and then rerunning the Conan and CMake commands mentioned above. -3. Go to `build/docs/html` to view the generated files. +### CMake options - Open the `index.html` file in your browser to see the documentation pages. +There are several CMake options you can use to customize the build: - ![API index page](./img/doxygen-docs-output.png "API index page") +| CMake Option | Default | CMake Target | Description | +| --------------------- | ------- | -------------------------------------------------------- | ------------------------------------- | +| `-Dcoverage` | OFF | `clio_tests-ccov` | Enables code coverage generation | +| `-Dtests` | OFF | `clio_tests` | Enables unit tests | +| `-Dintegration_tests` | OFF | `clio_integration_tests` | Enables integration tests | +| `-Dbenchmark` | OFF | `clio_benchmark` | Enables benchmark executable | +| `-Ddocs` | OFF | `docs` | Enables API documentation generation | +| `-Dlint` | OFF | See [#clang-tidy](#using-clang-tidy-for-static-analysis) | Enables `clang-tidy` static analysis | +| `-Dsan` | N/A | N/A | Enables Sanitizer (asan, tsan, ubsan) | +| `-Dpackage` | OFF | N/A | Creates a debian package | + +### Generating API docs for Clio + +The API documentation for Clio is generated by [Doxygen](https://www.doxygen.nl/index.html). If you want to generate the API documentation when building Clio, make sure to install Doxygen 1.12.0 on your system. + +To generate the API docs, please use CMake option `-Ddocs=ON` as described above and build the `docs` target. + +To view the generated files, go to `build/docs/html`. +Open the `index.html` file in your browser to see the documentation pages. + +![API index page](./img/doxygen-docs-output.png "API index page") ## Building Clio with Docker @@ -171,12 +181,11 @@ It is also possible to build Clio using [Docker](https://www.docker.com/) if you ```sh docker run -it ghcr.io/xrplf/clio-ci:384e79cd32f5f6c0ab9be3a1122ead41c5a7e67d git clone https://github.com/XRPLF/clio -mkdir build && cd build -conan install .. --output-folder . --build missing --settings build_type=Release -o '&:tests=True' -cmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. -cmake --build . --parallel 8 # or without the number if you feel extra adventurous +cd clio ``` +Follow the same steps in the [Building Clio](#building-clio) section. You can use `--profile:all gcc` or `--profile:all clang` with the `conan install` command to choose the desired compiler. + ## Developing against `rippled` in standalone mode If you wish to develop against a `rippled` instance running in standalone mode there are a few quirks of both Clio and `rippled` that you need to keep in mind. You must: @@ -229,10 +238,10 @@ Sometimes, during development, you need to build against a custom version of `li ## Using `clang-tidy` for static analysis Clang-tidy can be run by CMake when building the project. -To achieve this, you just need to provide the option `-o '&:lint=True'` for the `conan install` command: +To achieve this, you just need to provide the option `-Dlint=ON` when generating CMake files: ```sh -conan install .. --output-folder . --build missing --settings build_type=Release -o '&:tests=True' -o '&:lint=True' --profile:all clang +cmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -Dlint=ON .. ``` By default CMake will try to find `clang-tidy` automatically in your system.