Skip to content

Commit

Permalink
Add Support for Go Bindings
Browse files Browse the repository at this point in the history
This commit does:
- Downgrade to uniffi 0.25.0 because of Go bindings
- Fix compile error. upgrade macos to 10_15
- fix Swift build path for RustFramework
- Add cdylib type for [lib] so that GoLang can build bindings from
- proc_macros
- Generate Go Bindings
-
- changes `ParticipantIdentifier` to be represented as a hex
-   string instead of bytes, because GoLang can use Bytes as a key
-   for maps [see](NordSecurity/uniffi-bindgen-go#52)
- Go module + tests
- Add GoLang to README and build scripts
- Github action to build and test bindings
- Build and test swift package locally
- Fix target replacement
- remove pipefail because github action does not like it
- fix swift.yml
- fix build go bindings script
- fix go bindings generation
  • Loading branch information
pacu committed Jun 10, 2024
1 parent 779b0ce commit ef18cf8
Show file tree
Hide file tree
Showing 20 changed files with 3,113 additions and 227 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build_and_test_go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Go Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Get directory
run: ls

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.21'

- name: Set up cargo
run: rustup update stable && rustup default stable

- name: Install uniffi-bindgen-go
run: cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.2.1+v0.25.0

- name: Build Rust library
run: cargo build

- name: Generate Go Bindings
run: uniffi-bindgen-go --library './target/debug/libfrost_uniffi_sdk.so' --out-dir .

- name: Get dependencies
run: |
go mod tidy
- name: Test Bindings
run: /bin/bash Scripts/test_bindings.sh
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- "main"

jobs:
release:
release-swift:
if: ${{ startsWith(github.event.pull_request.head.ref, 'release-') }}
runs-on: macos-latest

Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,27 @@ env:
CARGO_TERM_COLOR: always

jobs:
build_and_test_swift:
build_and_test_swift_locally:
if: ${{ ! startsWith(github.event.pull_request.head.ref, 'release-') }}
name: Build and Test Swift Package - latest
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- run: swift test --verbose

- name: Replace line in Package.swift
run: |
sed -i '' -E 's|^[[:space:]]*\.binaryTarget\(name: "RustFramework", url: "https://github.com/pacu/frost-uniffi-sdk/releases/download/[^"]+/RustFramework.xcframework.zip", checksum: "[^"]+"\),| .binaryTarget(name: "RustFramework", path: "FrostSwift/RustFramework.xcframework.zip"),|' Package.swift
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: x86_64-apple-darwin aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim

- name: Install cargo swift 0.7
run: cargo install cargo-swift@=0.7 -f

- name: build swift locally
run: sh Scripts/build_swift.sh

- name: test swift
run: swift test --verbose
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["uniffi-bindgen", "frost-uniffi-sdk"]
resolver = "2"

[workspace.dependencies]
uniffi = "0.27.0"
uniffi = "0.25.0"
async-trait = "0.1.77"
eyre = "0.6.12"
frost-ed25519 = { version = "1.0.0", features = ["serde"] }
Expand Down
Loading

0 comments on commit ef18cf8

Please sign in to comment.