From d009ef221fd8154b5747ce605118804c20e9e42d Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Wed, 29 Apr 2026 13:55:34 +0100 Subject: [PATCH] More improvements --- .../workflows/reusable-clang-tidy-files.yml | 6 ++++ crates/CMakeLists.txt | 33 +++++++++++++------ crates/Cargo.toml | 4 +++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.github/workflows/reusable-clang-tidy-files.yml b/.github/workflows/reusable-clang-tidy-files.yml index 9b99f418b1..96a9c9989c 100644 --- a/.github/workflows/reusable-clang-tidy-files.yml +++ b/.github/workflows/reusable-clang-tidy-files.yml @@ -74,6 +74,12 @@ jobs: run: | ninja -j ${{ steps.nproc.outputs.nproc }} xrpl.libpb + # clang-tidy needs cxxbridge headers generated from Rust crates + - name: Build xrpl_crates + working-directory: ${{ env.BUILD_DIR }} + run: | + ninja -j ${{ steps.nproc.outputs.nproc }} xrpl_crates + - name: Run clang tidy id: run_clang_tidy continue-on-error: true diff --git a/crates/CMakeLists.txt b/crates/CMakeLists.txt index 3418520757..c2028acc37 100644 --- a/crates/CMakeLists.txt +++ b/crates/CMakeLists.txt @@ -6,18 +6,31 @@ if(NOT Corrosion_FOUND) FetchContent_Declare( Corrosion GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git - GIT_TAG v${CORROSION_VERSION}) + GIT_TAG v${CORROSION_VERSION} + ) FetchContent_MakeAvailable(Corrosion) endif() corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Cargo.toml) -corrosion_add_cxxbridge(rs_hello_world_cxxbridge CRATE rs_hello_world FILES - lib.rs) -# CMake 4.x validates PUBLIC interface sources when target_link_libraries is -# called by a consuming target, but the generated headers don't exist yet at -# configure time. Clear INTERFACE_SOURCES so the existence check is skipped; -# build-time ordering is still enforced by the custom commands inside the target. -if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.0") - set_target_properties(rs_hello_world_cxxbridge PROPERTIES INTERFACE_SOURCES "") -endif() +# Umbrella target that aggregates all crate-generated code (cxxbridge headers, +# etc.). Build this before running clang-tidy so generated headers are present. +add_custom_target(xrpl_crates) + +# add_xrpl_crate( CRATE FILES ...) Creates a cxxbridge +# target _cxxbridge and registers it with xrpl_crates. +function(add_xrpl_crate name) + cmake_parse_arguments(ARG "" "CRATE" "FILES" ${ARGN}) + corrosion_add_cxxbridge(${name}_cxxbridge CRATE ${ARG_CRATE} FILES + ${ARG_FILES} + ) + # CMake 4.x validates INTERFACE_SOURCES at link time, but generated headers + # don't exist at configure time. Clearing skips the check while build-time + # ordering is still enforced by the custom commands inside the target. + if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.0") + set_target_properties(${name}_cxxbridge PROPERTIES INTERFACE_SOURCES "") + endif() + add_dependencies(xrpl_crates ${name}_cxxbridge) +endfunction() + +add_xrpl_crate(rs_hello_world CRATE rs_hello_world FILES lib.rs) diff --git a/crates/Cargo.toml b/crates/Cargo.toml index cdd9a1f467..340e7b2f0d 100644 --- a/crates/Cargo.toml +++ b/crates/Cargo.toml @@ -11,8 +11,12 @@ cxx = { version = "1.0.194", features = ["c++20"] } [workspace.package] edition = "2024" +[profile.dev] +panic = "abort" + [profile.release] opt-level = 3 overflow-checks = true lto = true debug = true +panic = "abort"