More improvements

This commit is contained in:
Sergey Kuznetsov
2026-04-29 13:55:34 +01:00
parent 5fdedd7e99
commit d009ef221f
3 changed files with 33 additions and 10 deletions

View File

@@ -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

View File

@@ -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(<name> CRATE <crate> FILES <file>...) Creates a cxxbridge
# target <name>_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)

View File

@@ -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"