From 0f5dc78e282aed9761bc469a714ed29cf252de76 Mon Sep 17 00:00:00 2001 From: Michael Legleux Date: Tue, 15 Jul 2025 15:17:22 -0700 Subject: [PATCH] chore: Update CI to use Conan 2 (#5556) This is a minimally invasive update to use Conan 2 provided by our new build images. --- .pre-commit-config.yaml | 2 +- conan/profiles/libxrpl | 23 ++++++++++++++ conanfile.py | 20 ++++++++----- tests/conan/CMakeLists.txt | 2 +- tests/conan/conanfile.py | 61 ++++++++++++++------------------------ 5 files changed, 60 insertions(+), 48 deletions(-) create mode 100644 conan/profiles/libxrpl diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f69d4137..abfbd887c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ # .pre-commit-config.yaml repos: - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.3 + rev: v18.1.8 hooks: - id: clang-format diff --git a/conan/profiles/libxrpl b/conan/profiles/libxrpl new file mode 100644 index 000000000..862244536 --- /dev/null +++ b/conan/profiles/libxrpl @@ -0,0 +1,23 @@ +{% set os = detect_api.detect_os() %} +{% set arch = detect_api.detect_arch() %} +{% set compiler, version, compiler_exe = detect_api.detect_default_compiler() %} +{% set compiler_version = version %} +{% if os == "Linux" %} +{% set compiler_version = detect_api.default_compiler_version(compiler, version) %} +{% endif %} + +{% if os == "Linux" %} +include(default) +{% endif %} + +[settings] +os={{ os }} +arch={{ arch }} +compiler={{compiler}} +compiler.version={{ compiler_version }} +compiler.cppstd=20 +{% if os == "Windows" %} +compiler.runtime=static +{% else %} +compiler.libcxx={{detect_api.detect_libcxx(compiler, version, compiler_exe)}} +{% endif %} diff --git a/conanfile.py b/conanfile.py index c5e19a013..b4fb37700 100644 --- a/conanfile.py +++ b/conanfile.py @@ -26,7 +26,6 @@ class Xrpl(ConanFile): } requires = [ - 'doctest/2.4.11', 'grpc/1.50.1', 'libarchive/3.7.6', 'magic_enum/0.9.5', @@ -36,6 +35,10 @@ class Xrpl(ConanFile): 'zlib/1.3.1', ] + test_requires = [ + 'doctest/2.4.11', + ] + tool_requires = [ 'protobuf/3.21.12', ] @@ -91,12 +94,13 @@ class Xrpl(ConanFile): } def set_version(self): - path = f'{self.recipe_folder}/src/libxrpl/protocol/BuildInfo.cpp' - regex = r'versionString\s?=\s?\"(.*)\"' - with open(path, 'r') as file: - matches = (re.search(regex, line) for line in file) - match = next(m for m in matches if m) - self.version = match.group(1) + if self.version is None: + path = f'{self.recipe_folder}/src/libxrpl/protocol/BuildInfo.cpp' + regex = r'versionString\s?=\s?\"(.*)\"' + with open(path, encoding='utf-8') as file: + matches = (re.search(regex, line) for line in file) + match = next(m for m in matches if m) + self.version = match.group(1) def build_requirements(self): # These provide build tools (protoc, grpc plugins) that run during build @@ -157,6 +161,8 @@ class Xrpl(ConanFile): tc.variables['static'] = self.options.static tc.variables['unity'] = self.options.unity tc.variables['xrpld'] = self.options.xrpld + if self.settings.compiler == 'clang' and self.settings.compiler.version == 16: + tc.extra_cxxflags = ["-DBOOST_ASIO_DISABLE_CONCEPTS"] tc.generate() def build(self): diff --git a/tests/conan/CMakeLists.txt b/tests/conan/CMakeLists.txt index 83aa24880..f1b37e7a6 100644 --- a/tests/conan/CMakeLists.txt +++ b/tests/conan/CMakeLists.txt @@ -9,7 +9,7 @@ project( LANGUAGES CXX ) -find_package(xrpl REQUIRED) +find_package(xrpl CONFIG REQUIRED) add_executable(example) target_sources(example PRIVATE src/example.cpp) diff --git a/tests/conan/conanfile.py b/tests/conan/conanfile.py index be3750bf9..1ea1b333f 100644 --- a/tests/conan/conanfile.py +++ b/tests/conan/conanfile.py @@ -1,59 +1,42 @@ -from conan import ConanFile, conan_version +from pathlib import Path + +from conan import ConanFile +from conan.tools.build import can_run from conan.tools.cmake import CMake, cmake_layout class Example(ConanFile): - def set_name(self): - if self.name is None: - self.name = 'example' + name = 'example' + license = 'ISC' + author = 'John Freeman , Michael Legleux