From 603d5344993fc309f0f5513329350c00de281f3e Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Sun, 11 Jun 2023 21:15:48 -0400 Subject: [PATCH] Cross platform builds in CI (#133) This PR adds a GH workflow that builds across platforms, specifically the android platforms referenced in the cross_build.sh scripts, but can be extended to build for others. It seems like one of the next steps is to hook up version publishing in general for these packages/platforms, but this PR just focuses on getting the builds running in CI for continuous validation/testing and further iteration. The builds are still relatively slow in CI, taking about 15 minutes to complete, but not nearly as slow as when running locally on a mac via qemu. https://github.com/bitcoindevkit/bdk-ffi/blob/master/.github/workflows/publish-android.yaml seems like a good example of the full build + publish workflow that we'd want to evolve this into. Note that the `x86_64-linux-android` build is failing, with some context in https://github.com/xmtp/libxmtp/issues/134. I spent some time trying to figure this out, unsuccessfully, and ultimately decided to spin up an issue to track it separately and get a PR up for the builds that work. --- .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++++++++ Cargo.lock | 11 ++++++++ xmtp/Cargo.toml | 2 +- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..98f538a53 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build +on: + pull_request: + push: + branches: + - main +jobs: + build: + name: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: [ + aarch64-unknown-linux-gnu, + # x86_64-linux-android, + i686-linux-android, + armv7-linux-androideabi, + aarch64-linux-android, + ] + steps: + - name: Checkout + uses: actions/checkout@v1 + + - 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 + with: + use-cross: true + command: build + args: --release --target ${{ matrix.target }} --manifest-path bindings_ffi/Cargo.toml --target-dir bindings_ffi/target diff --git a/Cargo.lock b/Cargo.lock index f474bfde0..0b1877b3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2802,6 +2802,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" dependencies = [ "cc", + "openssl-sys", "pkg-config", "vcpkg", ] @@ -3205,6 +3206,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "111.26.0+1.1.1u" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efc62c9f12b22b8f5208c23a7200a442b2e5999f8bdf80233852122b5a4f6f37" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.87" @@ -3213,6 +3223,7 @@ checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/xmtp/Cargo.toml b/xmtp/Cargo.toml index cdf251e49..59b16082e 100644 --- a/xmtp/Cargo.toml +++ b/xmtp/Cargo.toml @@ -45,4 +45,4 @@ tempfile = "3.5.0" [dependencies.libsqlite3-sys] version = "0.26.0" -features = ["bundled-sqlcipher"] +features = ["bundled-sqlcipher-vendored-openssl"]