diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9ec65ab1b..3da09d8cd 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,16 +32,11 @@ jobs: cd rust-bindings cargo fuzz list | xargs -I "%" sh -c "cargo +nightly fuzz run % -- -max_total_time=600 || exit 255" - build_crate: - name: Build crate + lint: + name: Lint runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Set up Rust uses: dtolnay/rust-toolchain@stable @@ -54,9 +49,67 @@ jobs: - name: Clippy run: cargo clippy + test: + name: Test (${{ matrix.os.name }} ${{ matrix.arch.name }}) + runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }} + + strategy: + fail-fast: false + matrix: + os: + - name: macOS + matrix: macos + runs-on: + arm: [macos-13-arm64] + intel: [macos-13] + cibw-archs-macos: + arm: arm64 + intel: x86_64 + - name: Ubuntu + matrix: ubuntu + runs-on: + arm: [Linux, ARM64] + intel: [ubuntu-latest] + - name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + + arch: + - name: ARM + matrix: arm + - name: Intel + matrix: intel + + exclude: + - os: + name: Windows + matrix: windows + runs-on: + intel: [windows-latest] + arch: + name: ARM + matrix: arm + + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + - name: Tests run: cargo test && cargo test --release + build_crate: + name: Build crate + runs-on: ubuntu-latest + needs: [lint, test] + steps: + - uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + - name: Build run: cargo build --release diff --git a/CMakeLists.txt b/CMakeLists.txt index d83916c62..145383d89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,8 +156,8 @@ option(BUILD_STATIC_CHIAPOS_LIBRARY "Build chiapos static library (verify-only)" IF (BUILD_STATIC_CHIAPOS_LIBRARY) message("Build chiapos static library (verify-only)") add_library(chiapos_static STATIC src/chacha8.c c-bindings/wrapper.cpp) - target_link_libraries(chiapos_static PUBLIC blake3) - target_include_directories(chiapos_static PUBLIC lib/include) + target_link_libraries(chiapos_static PRIVATE blake3 $<$:uint128>) + target_include_directories(chiapos_static PUBLIC lib/include uint128_t) set_target_properties(chiapos_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib$<0:>") ENDIF() @@ -190,6 +190,7 @@ find_package(Threads REQUIRED) add_library(uint128 STATIC uint128_t/uint128_t.cpp) target_include_directories(uint128 PUBLIC uint128_t) +set_target_properties(uint128 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib$<0:>") target_compile_features(fse PUBLIC cxx_std_17) target_compile_features(chiapos PUBLIC cxx_std_17) @@ -213,6 +214,7 @@ target_link_libraries(RunTests PRIVATE fse Threads::Threads Catch2::Catch2WithMa $<$>:stdc++fs> ) + if (${CP_LINK_BLADEBIT_HARVESTER}) set(bb_defs diff --git a/rust-bindings/build.rs b/rust-bindings/build.rs index 2e0e664ef..019ee7680 100644 --- a/rust-bindings/build.rs +++ b/rust-bindings/build.rs @@ -33,6 +33,10 @@ fn main() { println!("cargo:rustc-link-lib=static=chiapos_static"); println!("cargo:rustc-link-lib=static=blake3"); + if cfg!(target_os = "windows") { + println!("cargo:rustc-link-lib=static=uint128"); + } + let bindings = bindgen::Builder::default() .header( cpp_dir