diff --git a/.github/workflows/unittests-capi.yml b/.github/workflows/unittests-capi.yml index aeee63379..bfea44a7c 100644 --- a/.github/workflows/unittests-capi.yml +++ b/.github/workflows/unittests-capi.yml @@ -4,7 +4,11 @@ on: push jobs: test-capi: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Setup Python diff --git a/.github/workflows/unittests-rust.yml b/.github/workflows/unittests-rust.yml index 65bc707c9..480272cf3 100644 --- a/.github/workflows/unittests-rust.yml +++ b/.github/workflows/unittests-rust.yml @@ -4,7 +4,11 @@ on: push jobs: test: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Get test data @@ -26,8 +30,12 @@ jobs: - name: Run clippy run: | poe clippy - - name: Install gsl - run: sudo apt-get install libgsl0-dev + - name: Install gsl (Linux) + if: runner.os == 'Linux' + run: sudo apt-get update && sudo apt-get install -y libgsl0-dev + - name: Install gsl (macOS) + if: runner.os == 'macOS' + run: brew install gsl - name: Run Rust unit tests run: | poe rtest diff --git a/crates/eko/pyproject.toml b/crates/eko/pyproject.toml index 3c032645c..139adc220 100644 --- a/crates/eko/pyproject.toml +++ b/crates/eko/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "eko-rs" -version = "0.0.0" +dynamic = ["version"] requires-python = ">=3.11" classifiers = [ "Programming Language :: Rust", diff --git a/crates/ekore_capi/Cargo.toml b/crates/ekore_capi/Cargo.toml index 175b1eb7b..26befe099 100644 --- a/crates/ekore_capi/Cargo.toml +++ b/crates/ekore_capi/Cargo.toml @@ -17,7 +17,7 @@ exclude = ["tests"] rustdoc-args = ["--html-in-header", "doc-header.html"] [lib] -crate-type = ["cdylib", "staticlib"] +crate-type = ["cdylib"] [features] capi = [] diff --git a/crates/ekore_capi/tests/run_tests.sh b/crates/ekore_capi/tests/run_tests.sh index 4d6a424a1..f7e15fb88 100755 --- a/crates/ekore_capi/tests/run_tests.sh +++ b/crates/ekore_capi/tests/run_tests.sh @@ -33,6 +33,13 @@ run_section() { echo " Compiling $name.$ext..." "$compiler" "$src" "${extra[@]}" \ -L"$LIB_DIR" -lekore_capi -o "$bin" -Wl,-rpath,"$RPATH" + + # macOS: cargo-c bakes an absolute /lib/... install name; fix it to @rpath + if [ "$(uname)" = "Darwin" ]; then + old="$(otool -L "$bin" | awk '/\/lib\/libekore_capi/{print $1; exit}')" + [ -n "$old" ] && install_name_tool -change "$old" "@rpath/$(basename "$old")" "$bin" + fi + echo " Running $name..." "$bin" rm -f "$bin" diff --git a/pyproject.toml b/pyproject.toml index 22924b260..0d085b03f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -154,7 +154,7 @@ rtest = "cargo test --workspace" fmtcheck = "cargo fmt --all -- --check" clippy = "cargo clippy --no-deps" rbib = { "shell" = "python crates/make_bib.py > crates/ekore/src/bib.rs" } -build-capi = "cargo cinstall --release -p ekore_capi --destdir=./crates/ekore_capi/dist --prefix=/ --libdir=/lib --includedir=/include" +build-capi = "cargo cinstall --release --library-type cdylib -p ekore_capi --destdir=./crates/ekore_capi/dist --prefix=/ --libdir=/lib --includedir=/include" ctest = "./crates/ekore_capi/tests/run_tests.sh" [tool.pytest.ini_options] diff --git a/tests/data/assets.sh b/tests/data/assets.sh index 66007ee98..f2e20eb60 100755 --- a/tests/data/assets.sh +++ b/tests/data/assets.sh @@ -1,4 +1,4 @@ -#!/usr/bin/bash +#!/usr/bin/env bash # This script downloads the test assets to run both Rust and Python unit tests. # The script is to be executed in the root directory of the repository.