feat: Use Conan 2 (#2179)

Merge right after: https://github.com/XRPLF/clio/pull/2178
Waits for: https://github.com/XRPLF/rippled/pull/5462
This commit is contained in:
Ayaz Salikhov
2025-06-06 19:55:46 +01:00
committed by GitHub
parent cec8b29998
commit a68229e9d7
9 changed files with 62 additions and 66 deletions

View File

@@ -49,7 +49,7 @@ runs:
- name: Run conan - name: Run conan
shell: bash shell: bash
env: env:
BUILD_OPTION: "${{ inputs.conan_cache_hit == 'true' && 'missing' || '' }}" BUILD_OPTION: "${{ inputs.conan_cache_hit == 'true' && 'missing' || '*' }}"
CODE_COVERAGE: "${{ inputs.code_coverage == 'true' && 'True' || 'False' }}" CODE_COVERAGE: "${{ inputs.code_coverage == 'true' && 'True' || 'False' }}"
STATIC_OPTION: "${{ inputs.static == 'true' && 'True' || 'False' }}" STATIC_OPTION: "${{ inputs.static == 'true' && 'True' || 'False' }}"
INTEGRATION_TESTS_OPTION: "${{ inputs.build_integration_tests == 'true' && 'True' || 'False' }}" INTEGRATION_TESTS_OPTION: "${{ inputs.build_integration_tests == 'true' && 'True' || 'False' }}"
@@ -59,15 +59,15 @@ runs:
conan \ conan \
install .. \ install .. \
-of . \ -of . \
-b $BUILD_OPTION \ -b "$BUILD_OPTION" \
-s build_type="${{ inputs.build_type }}" \ -s "build_type=${{ inputs.build_type }}" \
-o clio:static="${STATIC_OPTION}" \ -o "&:static=${STATIC_OPTION}" \
-o clio:tests=True \ -o "&:tests=True" \
-o clio:integration_tests="${INTEGRATION_TESTS_OPTION}" \ -o "&:integration_tests=${INTEGRATION_TESTS_OPTION}" \
-o clio:lint=False \ -o "&:lint=False" \
-o clio:coverage="${CODE_COVERAGE}" \ -o "&:coverage=${CODE_COVERAGE}" \
-o clio:time_trace="${TIME_TRACE}" \ -o "&:time_trace=${TIME_TRACE}" \
--profile "${{ inputs.conan_profile }}" --profile:all "${{ inputs.conan_profile }}"
- name: Run cmake - name: Run cmake
shell: bash shell: bash

View File

@@ -18,13 +18,13 @@ runs:
ca-certificates \ ca-certificates \
ccache \ ccache \
clang-build-analyzer \ clang-build-analyzer \
conan@1 \ conan \
gh \ gh \
jq \ jq \
llvm@14 \ llvm@14 \
ninja \ ninja \
pkg-config pkg-config
echo "/opt/homebrew/opt/conan@1/bin" >> $GITHUB_PATH echo "/opt/homebrew/opt/conan@2/bin" >> $GITHUB_PATH
- name: Install CMake 3.31.6 on mac - name: Install CMake 3.31.6 on mac
if: ${{ runner.os == 'macOS' }} if: ${{ runner.os == 'macOS' }}
@@ -55,14 +55,14 @@ runs:
shell: bash shell: bash
run: | run: |
echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> $GITHUB_ENV echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> $GITHUB_ENV
echo "CONAN_USER_HOME=${{ github.workspace }}" >> $GITHUB_ENV echo "CONAN_HOME=${{ github.workspace }}/.conan2" >> $GITHUB_ENV
- name: Set env variables for Linux - name: Set env variables for Linux
if: ${{ runner.os == 'Linux' }} if: ${{ runner.os == 'Linux' }}
shell: bash shell: bash
run: | run: |
echo "CCACHE_DIR=/root/.ccache" >> $GITHUB_ENV echo "CCACHE_DIR=/root/.ccache" >> $GITHUB_ENV
echo "CONAN_USER_HOME=/root/" >> $GITHUB_ENV echo "CONAN_HOME=/root/.conan2" >> $GITHUB_ENV
- name: Set CCACHE_DISABLE=1 - name: Set CCACHE_DISABLE=1
if: ${{ inputs.disable_ccache == 'true' }} if: ${{ inputs.disable_ccache == 'true' }}
@@ -74,4 +74,4 @@ runs:
shell: bash shell: bash
run: | run: |
mkdir -p "$CCACHE_DIR" mkdir -p "$CCACHE_DIR"
mkdir -p "$CONAN_USER_HOME/.conan" mkdir -p "$CONAN_HOME"

View File

@@ -3,7 +3,7 @@ description: Find and restores conan and ccache cache
inputs: inputs:
conan_dir: conan_dir:
description: Path to .conan directory description: Path to Conan directory
required: true required: true
conan_profile: conan_profile:
description: Conan profile name description: Conan profile name
@@ -41,8 +41,8 @@ runs:
id: conan_hash id: conan_hash
shell: bash shell: bash
run: | run: |
conan info . -j info.json -o clio:tests=True conan graph info . --format json --out-file info.json -o '&:tests=True' --profile:all ${{ inputs.conan_profile }}
packages_info="$(cat info.json | jq '.[] | "\(.display_name): \(.id)"' | grep -v 'clio')" packages_info="$(cat info.json | jq -r '.graph.nodes[]?.ref' | grep -v 'clio')"
echo "$packages_info" echo "$packages_info"
hash="$(echo "$packages_info" | shasum -a 256 | cut -d ' ' -f 1)" hash="$(echo "$packages_info" | shasum -a 256 | cut -d ' ' -f 1)"
rm info.json rm info.json
@@ -52,7 +52,7 @@ runs:
uses: actions/cache/restore@v4 uses: actions/cache/restore@v4
id: conan_cache id: conan_cache
with: with:
path: ${{ inputs.conan_dir }}/data path: ${{ inputs.conan_dir }}/p
key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-${{ inputs.conan_profile }}-develop-${{ steps.conan_hash.outputs.hash }} key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-${{ inputs.conan_profile }}-develop-${{ steps.conan_hash.outputs.hash }}
- name: Restore ccache cache - name: Restore ccache cache

View File

@@ -42,13 +42,13 @@ runs:
if: ${{ inputs.conan_cache_hit != 'true' }} if: ${{ inputs.conan_cache_hit != 'true' }}
shell: bash shell: bash
run: | run: |
conan remove "*" -s -b -f conan cache clean --source --build --temp
- name: Save conan cache - name: Save conan cache
if: ${{ inputs.conan_cache_hit != 'true' }} if: ${{ inputs.conan_cache_hit != 'true' }}
uses: actions/cache/save@v4 uses: actions/cache/save@v4
with: with:
path: ${{ inputs.conan_dir }}/data path: ${{ inputs.conan_dir }}/p
key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-${{ inputs.conan_profile }}-develop-${{ inputs.conan_hash }} key: clio-conan_data-${{ runner.os }}-${{ inputs.build_type }}-${{ inputs.conan_profile }}-develop-${{ inputs.conan_hash }}
- name: Save ccache cache - name: Save ccache cache

View File

@@ -12,22 +12,11 @@ runs:
- name: Create conan profile on macOS - name: Create conan profile on macOS
if: ${{ runner.os == 'macOS' }} if: ${{ runner.os == 'macOS' }}
shell: bash shell: bash
env:
CONAN_PROFILE: ${{ inputs.conan_profile }}
run: | run: |
echo "Creating \"$CONAN_PROFILE\" conan profile" conan profile detect --name "${{ inputs.conan_profile }}" --force
conan profile new "$CONAN_PROFILE" --detect --force sed -i '' 's/compiler.cppstd=[^ ]*/compiler.cppstd=20/' "${{ env.CONAN_HOME }}/profiles/${{ inputs.conan_profile }}"
conan profile update settings.compiler.libcxx=libc++ "$CONAN_PROFILE"
conan profile update settings.compiler.cppstd=20 "$CONAN_PROFILE"
conan profile update env.CXXFLAGS=-DBOOST_ASIO_DISABLE_CONCEPTS "$CONAN_PROFILE"
conan profile update "conf.tools.build:cxxflags+=[\"-DBOOST_ASIO_DISABLE_CONCEPTS\"]" "$CONAN_PROFILE"
- name: Add conan-non-prod artifactory - name: Add artifactory remote
shell: bash shell: bash
run: | run: |
if [[ -z "$(conan remote list | grep conan-non-prod)" ]]; then conan remote add --index 0 --force ripple http://18.143.149.228:8081/artifactory/api/conan/dev
echo "Adding conan-non-prod"
conan remote add --insert 0 conan-non-prod http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod
else
echo "Conan-non-prod is available"
fi

View File

@@ -92,7 +92,7 @@ jobs:
uses: ./.github/actions/restore_cache uses: ./.github/actions/restore_cache
id: restore_cache id: restore_cache
with: with:
conan_dir: ${{ env.CONAN_USER_HOME }}/.conan conan_dir: ${{ env.CONAN_HOME }}
conan_profile: ${{ inputs.conan_profile }} conan_profile: ${{ inputs.conan_profile }}
ccache_dir: ${{ env.CCACHE_DIR }} ccache_dir: ${{ env.CCACHE_DIR }}
build_type: ${{ inputs.build_type }} build_type: ${{ inputs.build_type }}
@@ -172,7 +172,7 @@ jobs:
if: ${{ !inputs.disable_cache && github.ref == 'refs/heads/develop' }} if: ${{ !inputs.disable_cache && github.ref == 'refs/heads/develop' }}
uses: ./.github/actions/save_cache uses: ./.github/actions/save_cache
with: with:
conan_dir: ${{ env.CONAN_USER_HOME }}/.conan conan_dir: ${{ env.CONAN_HOME }}
conan_hash: ${{ steps.restore_cache.outputs.conan_hash }} conan_hash: ${{ steps.restore_cache.outputs.conan_hash }}
conan_cache_hit: ${{ steps.restore_cache.outputs.conan_cache_hit }} conan_cache_hit: ${{ steps.restore_cache.outputs.conan_cache_hit }}
ccache_dir: ${{ env.CCACHE_DIR }} ccache_dir: ${{ env.CCACHE_DIR }}

View File

@@ -49,7 +49,7 @@ jobs:
uses: ./.github/actions/restore_cache uses: ./.github/actions/restore_cache
id: restore_cache id: restore_cache
with: with:
conan_dir: ${{ env.CONAN_USER_HOME }}/.conan conan_dir: ${{ env.CONAN_HOME }}
ccache_dir: ${{ env.CCACHE_DIR }} ccache_dir: ${{ env.CCACHE_DIR }}
conan_profile: ${{ env.CONAN_PROFILE }} conan_profile: ${{ env.CONAN_PROFILE }}

View File

@@ -2,10 +2,10 @@ from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
class Clio(ConanFile): class ClioConan(ConanFile):
name = 'clio' name = 'clio'
license = 'ISC' license = 'ISC'
author = 'Alex Kremer <akremer@ripple.com>, John Freeman <jfreeman@ripple.com>' author = 'Alex Kremer <akremer@ripple.com>, John Freeman <jfreeman@ripple.com>, Ayaz Salikhov <asalikhov@ripple.com>'
url = 'https://github.com/xrplf/clio' url = 'https://github.com/xrplf/clio'
description = 'Clio RPC server' description = 'Clio RPC server'
settings = 'os', 'compiler', 'build_type', 'arch' settings = 'os', 'compiler', 'build_type', 'arch'
@@ -28,7 +28,7 @@ class Clio(ConanFile):
'boost/1.83.0', 'boost/1.83.0',
'cassandra-cpp-driver/2.17.0', 'cassandra-cpp-driver/2.17.0',
'fmt/10.1.1', 'fmt/10.1.1',
'protobuf/3.21.9', 'protobuf/3.21.12',
'grpc/1.50.1', 'grpc/1.50.1',
'openssl/1.1.1v', 'openssl/1.1.1v',
'xrpl/2.5.0-rc1', 'xrpl/2.5.0-rc1',
@@ -100,6 +100,10 @@ class Clio(ConanFile):
tc.variables['benchmark'] = self.options.benchmark tc.variables['benchmark'] = self.options.benchmark
tc.variables['snapshot'] = self.options.snapshot tc.variables['snapshot'] = self.options.snapshot
tc.variables['time_trace'] = self.options.time_trace tc.variables['time_trace'] = self.options.time_trace
if self.settings.compiler == 'clang' and self.settings.compiler.version == 16:
tc.extra_cxxflags = ["-DBOOST_ASIO_DISABLE_CONCEPTS"]
tc.generate() tc.generate()
def build(self): def build(self):

View File

@@ -24,36 +24,36 @@ Clio requires `compiler.cppstd=20` in your Conan profile (`~/.conan/profiles/def
> [!NOTE] > [!NOTE]
> Although Clio is built using C++23, it's required to set `compiler.cppstd=20` for the time being as some of Clio's dependencies are not yet capable of building under C++23. > Although Clio is built using C++23, it's required to set `compiler.cppstd=20` for the time being as some of Clio's dependencies are not yet capable of building under C++23.
**Mac example**: **Mac apple-clang 16 example**:
```text ```text
[settings] [settings]
os=Macos
os_build=Macos
arch=armv8 arch=armv8
arch_build=armv8
compiler=apple-clang
compiler.version=15
compiler.libcxx=libc++
build_type=Release build_type=Release
compiler=apple-clang
compiler.cppstd=20 compiler.cppstd=20
compiler.libcxx=libc++
compiler.version=16
os=Macos
[conf] [conf]
tools.build:cxxflags+=["-DBOOST_ASIO_DISABLE_CONCEPTS"] tools.build:cxxflags+=["-Wno-missing-template-arg-list-after-template-kw"]
``` ```
**Linux example**: **Linux gcc-12 example**:
```text ```text
[settings] [settings]
os=Linux
os_build=Linux
arch=x86_64 arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
build_type=Release build_type=Release
compiler=gcc
compiler.cppstd=20 compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux
[conf]
tools.build:compiler_executables={'c': '/usr/bin/gcc-12', 'cpp': '/usr/bin/g++-12'}
``` ```
#### Artifactory #### Artifactory
@@ -61,7 +61,7 @@ compiler.cppstd=20
Make sure artifactory is setup with Conan. Make sure artifactory is setup with Conan.
```sh ```sh
conan remote add --insert 0 conan-non-prod http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod conan remote add --index 0 ripple http://18.143.149.228:8081/artifactory/api/conan/dev
``` ```
Now you should be able to download the prebuilt `xrpl` package on some platforms. Now you should be able to download the prebuilt `xrpl` package on some platforms.
@@ -81,19 +81,21 @@ Navigate to Clio's root directory and run:
```sh ```sh
mkdir build && cd build mkdir build && cd build
conan install .. --output-folder . --build missing --settings build_type=Release -o tests=True 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 # 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 -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 cmake --build . --parallel 8 # or without the number if you feel extra adventurous
``` ```
> [!TIP] > [!TIP]
> You can omit the `-o tests=True` if you don't want to build `clio_tests`. > 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). 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).
> [!TIP] > [!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`. > 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`.
<!-- markdownlint-disable-line MD028 --> <!-- markdownlint-disable-line MD028 -->
@@ -106,11 +108,11 @@ The API documentation for Clio is generated by [Doxygen](https://www.doxygen.nl/
To generate the API docs: To generate the API docs:
1. First, include `-o docs=True` in the conan install command. For example: 1. First, include `-o '&:docs=True'` in the conan install command. For example:
```sh ```sh
mkdir build && cd build mkdir build && cd build
conan install .. --output-folder . --build missing --settings build_type=Release -o tests=True -o docs=True conan install .. --output-folder . --build missing --settings build_type=Release -o '&:tests=True' -o '&:docs=True'
``` ```
2. Once that has completed successfully, run the `cmake` command and add the `--target docs` option: 2. Once that has completed successfully, run the `cmake` command and add the `--target docs` option:
@@ -134,7 +136,7 @@ It is also possible to build Clio using [Docker](https://www.docker.com/) if you
docker run -it ghcr.io/xrplf/clio-ci:latest docker run -it ghcr.io/xrplf/clio-ci:latest
git clone https://github.com/XRPLF/clio git clone https://github.com/XRPLF/clio
mkdir build && cd build mkdir build && cd build
conan install .. --output-folder . --build missing --settings build_type=Release -o tests=True 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 -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 cmake --build . --parallel 8 # or without the number if you feel extra adventurous
``` ```
@@ -192,10 +194,11 @@ Sometimes, during development, you need to build against a custom version of `li
The minimum [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) version required is 19.0. The minimum [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) version required is 19.0.
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: 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:
```sh ```sh
conan install .. --output-folder . --build missing --settings build_type=Release -o tests=True -o lint=True conan install .. --output-folder . --build missing --settings build_type=Release -o '&:tests=True' -o '&:lint=True'
``` ```
By default CMake will try to find `clang-tidy` automatically in your system. By default CMake will try to find `clang-tidy` automatically in your system.