Skip to content

Commit

Permalink
Modify FFI client methods to avoid task spawning (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
jadamcrain authored May 14, 2024
1 parent f5ae983 commit ccd3c23
Show file tree
Hide file tree
Showing 31 changed files with 1,028 additions and 662 deletions.
57 changes: 35 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ jobs:
- name: Create the FFI modules dir
run: mkdir ffi-modules\${{ matrix.target }}
- name: Build FFI
run: cargo build -p rodbus-ffi --release --target ${{ matrix.target }} --message-format json | Out-File -encoding "UTF8" .\ffi-modules\${{ matrix.target }}\build.ffi.log
run: cargo build -p rodbus-ffi --release --target ${{ matrix.target }}
- name: Build JNI
run: cargo build -p rodbus-ffi-java --release --target ${{ matrix.target }} --message-format json | Out-File -encoding "UTF8" .\ffi-modules\${{ matrix.target }}\build.jni.log
run: cargo build -p rodbus-ffi-java --release --target ${{ matrix.target }}
- name: Copy the FFI and JNI libs
shell: pwsh
run: |
Expand All @@ -144,12 +144,15 @@ jobs:
run: cargo run --bin rodbus-bindings -- --java -r ${{ matrix.target }} -a ./target/${{ matrix.target }}/release
# Build bindings on MacOS [64-bit macOS (10.7+, Lion+) (x86_64-apple-darwin)]
bindings-macos:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
target:
- x86_64-apple-darwin # 64-bit macOS (10.7+, Lion+)
include:
- runner: macos-14
target: aarch64-apple-darwin
- runner: macos-13
target: x86_64-apple-darwin
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -158,9 +161,9 @@ jobs:
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cargo build -p rodbus-ffi --release --message-format json > ffi-modules/${{ matrix.target }}/build.ffi.log
run: cargo build -p rodbus-ffi --release
- name: Build JNI
run: cargo build -p rodbus-ffi-java --release --message-format json > ffi-modules/${{ matrix.target }}/build.jni.log
run: cargo build -p rodbus-ffi-java --release
- name: Copy the FFI and JNI libs
run: |
cp ./target/release/librodbus_ffi.dylib ./ffi-modules/${{ matrix.target }}
Expand Down Expand Up @@ -204,9 +207,9 @@ jobs:
- name: Create ffi-modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cross build -p rodbus-ffi --release --target ${{ matrix.target }} --message-format json > ffi-modules/${{ matrix.target }}/build.ffi.log
run: cross build -p rodbus-ffi --release --target ${{ matrix.target }}
- name: Build JNI
run: cross build -p rodbus-ffi-java --release --target ${{ matrix.target }} --message-format json > ffi-modules/${{ matrix.target }}/build.jni.log
run: cross build -p rodbus-ffi-java --release --target ${{ matrix.target }}
- name: Copy the FFI and JNI libs
run: |
cp ./target/${{ matrix.target }}/release/librodbus_ffi.so ./ffi-modules/${{ matrix.target }}
Expand Down Expand Up @@ -242,26 +245,36 @@ jobs:
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Checkout BOM tools repo
uses: actions/checkout@v3
with:
repository: stepfunc/bom-tools
ref: 0.1.0
path: bom-tools
- name: Install BOM tools
working-directory: bom-tools
run: cargo install --path bom-tools
- name: Install Cargo CycloneDx
run: cargo install cargo-cyclonedx
- name: Install custom allow-list tool
run: cargo install --git https://github.com/stepfunc/bom-tools.git
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Download compiled FFI
uses: actions/download-artifact@v3
with:
name: ffi-modules
path: ffi-modules
- name: Create SBOMs
run: |
for dir in ffi-modules/*; do
echo "processing path: $dir"
target=`basename "${dir}"`
cargo cyclonedx -f json --target $target
mv ./ffi/rodbus-ffi/rodbus-ffi.cdx.json ffi-modules/$target
mv ./ffi/rodbus-ffi-java/rodbus-ffi-java.cdx.json ffi-modules/$target
done
- name: Create FFI third-party-licenses.txt
run: bom-tools gen-licenses-dir ./ffi-modules build.ffi.log ./dep_config.json > third-party-licenses.txt
- name: Package all bindings
run: cargo run --bin rodbus-bindings -- --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
run: allow-list gen-licenses-dir -l ffi-modules -b rodbus-ffi.cdx.json -c allowed.json > third-party-licenses.txt
- name: Create FFI third-party-licenses-java.txt
run: allow-list gen-licenses-dir -l ffi-modules -b rodbus-ffi-java.cdx.json -c allowed.json > third-party-licenses-java.txt
- name: Package C/C++ bindings
run: cargo run --bin rodbus-bindings -- --c --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
- name: Package .NET bindings
run: cargo run --bin rodbus-bindings -- --dotnet --package ./ffi-modules --options ./packaging.json -f third-party-licenses.txt
- name: Package Java bindings
run: cargo run --bin rodbus-bindings -- --java --package ./ffi-modules --options ./packaging.json -f third-party-licenses-java.txt
- name: Upload C/C++ bindings
uses: actions/upload-artifact@v3
with:
Expand Down
Loading

0 comments on commit ccd3c23

Please sign in to comment.