Skip to content

Commit

Permalink
Merge branch 'main' of github.com:xmtp/libxmtp into insipx/async-call…
Browse files Browse the repository at this point in the history
…back
  • Loading branch information
insipx committed Jun 27, 2024
2 parents a0e53fd + feb4864 commit 5fb9717
Show file tree
Hide file tree
Showing 21 changed files with 505 additions and 138 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/release-kotlin-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Release Kotlin Bindings

on:
workflow_dispatch:

jobs:
build-linux:
runs-on: warp-ubuntu-latest-x64-8x
strategy:
fail-fast: false
matrix:
target:
- x86_64-linux-android
- i686-linux-android
- armv7-linux-androideabi
- aarch64-linux-android
include:
- target: x86_64-linux-android
output_target: x86_64
- target: i686-linux-android
output_target: x86
- target: armv7-linux-androideabi
output_target: armeabi-v7a
- target: aarch64-linux-android
output_target: arm64-v8a
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "Cache"
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
./target/${{ matrix.target }}
key: ${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}

# Install latest cross to mitigate unwind linking issue on android builds.
# See https://github.com/cross-rs/cross/issues/1222
- name: Install rust cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Build target
uses: actions-rs/cargo@v1
env:
CROSS_NO_WARNINGS: "0"
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target

- name: Prepare JNI libs
run: |
mkdir -p bindings_ffi/jniLibs/${{ matrix.output_target }}/ && \
cp bindings_ffi/target/${{ matrix.target }}/release/libxmtpv3.so bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.output_target }}
path: bindings_ffi/jniLibs/${{ matrix.output_target }}/libuniffi_xmtpv3.so
retention-days: 1

package-kotlin:
needs: [build-linux]
runs-on: warp-ubuntu-latest-x64-8x
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: bindings_ffi/jniLibs

- name: Build archive
working-directory: bindings_ffi
run: |
zip -r LibXMTPKotlinFFI.zip jniLibs
- name: Get short SHA
id: slug
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: kotlin-bindings-${{ steps.slug.outputs.sha7 }}
release_name: Kotlin-Bindings-${{ steps.slug.outputs.sha7 }}
draft: false
prerelease: true

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bindings_ffi/LibXMTPKotlinFFI.zip
asset_name: LibXMTPKotlinFFI.zip
asset_content_type: application/zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ wasm-pack.log
# generated
bindings_swift/Sources
bindings_swift/xmtp-rust-swift.zip
bindings_ffi/jniLibs

# Logs
logs
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ futures = "0.3.30"
futures-core = "0.3.30"
hex = "0.4.3"
log = { version = "0.4", features = ["release_max_level_debug"] }
openmls = { git = "https://github.com/xmtp/openmls", rev = "9cb3207" }
openmls = { git = "https://github.com/xmtp/openmls", rev = "9cb3207", default_features = false }
openmls_basic_credential = { git = "https://github.com/xmtp/openmls", rev = "9cb3207" }
openmls_rust_crypto = { git = "https://github.com/xmtp/openmls", rev = "9cb3207" }
openmls_traits = { git = "https://github.com/xmtp/openmls", rev = "9cb3207" }
Expand Down
40 changes: 12 additions & 28 deletions bindings_ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindings_ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ name = "ffi-uniffi-bindgen"
path = "src/bin.rs"

[dev-dependencies]
async-barrier = "1.1"
ethers = "2.0.13"
ethers-core = "2.0.13"
tempfile = "3.5.0"
tokio = { version = "1.28.1", features = ["full"] }
tokio-test = "0.4"
uniffi = { version = "0.27.2", features = ["bindgen-tests"] }
tracing-subscriber = "0.3"
uuid = { version = "1.9", features = ["v4", "fast-rng" ] }

# NOTE: The release profile reduces bundle size from 230M to 41M - may have performance impliciations
# https://stackoverflow.com/a/54842093
Expand Down
4 changes: 4 additions & 0 deletions bindings_ffi/gen_kotlin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ bindings_ffi/target/release/ffi-uniffi-bindgen generate \
popd > /dev/null
make libxmtp-version
cp libxmtp-version.txt src/uniffi/$PROJECT_NAME/

# Assumes libxmtp is in a peer directory of xmtp-android
cp src/uniffi/xmtpv3/xmtpv3.kt ../../xmtp-android/library/src/main/java/xmtpv3.kt
cp src/uniffi/xmtpv3/libxmtp-version.txt ../../xmtp-android/library/src/main/java/libxmtp-version.txt
Binary file removed bindings_ffi/jniLibs/arm64-v8a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file removed bindings_ffi/jniLibs/armeabi-v7a/libuniffi_xmtpv3.so
Binary file not shown.
Binary file removed bindings_ffi/jniLibs/x86/libuniffi_xmtpv3.so
Binary file not shown.
Binary file removed bindings_ffi/jniLibs/x86_64/libuniffi_xmtpv3.so
Binary file not shown.
Loading

0 comments on commit 5fb9717

Please sign in to comment.