Skip to content

Commit

Permalink
Fix "cross" configuration for release workflow (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
philss authored Oct 7, 2022
1 parent 1222399 commit fe2f37f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
ELIXIR_VERSION: 1.13
OTP_VERSION: 24.2
MIX_ENV: test
TOKENIZERS_BUILD: "true"

jobs:
test:
Expand Down
27 changes: 11 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ jobs:
os: ubuntu-20.04,
nif: "2.16",
use-cross: true,
features: "static_openssl",
}
- { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.16", use-cross: true }
- { target: aarch64-apple-darwin, os: macos-11, nif: "2.16" }
- { target: x86_64-apple-darwin, os: macos-11, nif: "2.16" }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.16" }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.16", use-cross: true }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.16", use-cross: true, features: "static_openssl" }
- { target: x86_64-pc-windows-gnu, os: windows-2019, nif: "2.16" }
- { target: x86_64-pc-windows-msvc, os: windows-2019, nif: "2.16" }
# NIF version 2.15
Expand All @@ -47,26 +48,28 @@ jobs:
os: ubuntu-20.04,
nif: "2.15",
use-cross: true,
features: "static_openssl",
}
- { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.15", use-cross: true }
- { target: aarch64-apple-darwin, os: macos-11, nif: "2.15" }
- { target: x86_64-apple-darwin, os: macos-11, nif: "2.15" }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.15" }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.15", use-cross: true }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.15", use-cross: true, features: "static_openssl" }
- { target: x86_64-pc-windows-gnu, os: windows-2019, nif: "2.15" }
- { target: x86_64-pc-windows-msvc, os: windows-2019, nif: "2.15" }
# # NIF version 2.14
# NIF version 2.14
- {
target: arm-unknown-linux-gnueabihf,
os: ubuntu-20.04,
nif: "2.14",
use-cross: true,
features: "static_openssl",
}
- { target: aarch64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.14", use-cross: true }
- { target: aarch64-apple-darwin, os: macos-11, nif: "2.14" }
- { target: x86_64-apple-darwin, os: macos-11, nif: "2.14" }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, nif: "2.14" }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.14", use-cross: true }
- { target: x86_64-unknown-linux-musl, os: ubuntu-20.04, nif: "2.14", use-cross: true, features: "static_openssl" }
- { target: x86_64-pc-windows-gnu, os: windows-2019, nif: "2.14" }
- { target: x86_64-pc-windows-msvc, os: windows-2019, nif: "2.14" }

Expand All @@ -76,14 +79,6 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf libssl-dev openssl;;
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu libssl-dev openssl;;
esac
- name: Extract crate information
shell: bash
run: |
Expand Down Expand Up @@ -115,18 +110,18 @@ jobs:
if: ${{ matrix.job.use-cross }}
with:
binary: "cross"
version: "v0.2.1"
download_url: "https://github.com/rust-embedded/cross/releases/download/${version}/cross-${version}-x86_64-unknown-linux-gnu.tar.gz"
version: "v0.2.4"
download_url: "https://github.com/cross-rs/cross/releases/download/${version}/cross-x86_64-unknown-linux-gnu.tar.gz"
tarball_binary_path: "${binary}"
smoke_test: "${binary} --version"

- name: Build
shell: bash
run: |
if [ "${{ matrix.job.use-cross }}" == "true" ]; then
cross build --release --target=${{ matrix.job.target }}
cross build --release --target=${{ matrix.job.target }} --features=${{ matrix.job.features }}
else
cargo build --release --target=${{ matrix.job.target }}
cargo build --release --target=${{ matrix.job.target }} --features=${{ matrix.job.features }}
fi
- name: Rename lib to the final name
Expand Down
11 changes: 11 additions & 0 deletions native/ex_tokenizers/Cargo.lock

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

4 changes: 4 additions & 0 deletions native/ex_tokenizers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ anyhow = "1"
rustler = "0.25.0"
thiserror = "1"
tokenizers = "0.11.3"
openssl = { version = "0.10", optional = true }

[features]
static_openssl = ["openssl/vendored"]
11 changes: 11 additions & 0 deletions native/ex_tokenizers/Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[build.env]
passthrough = [
"RUSTLER_NIF_VERSION"
]

# We need to install some dependencies for specific targets.
[target.arm-unknown-linux-gnueabihf]
pre-build = "./scripts/install-cross-deps"

[target.aarch64-unknown-linux-gnu]
pre-build = "./scripts/install-cross-deps"
8 changes: 8 additions & 0 deletions native/ex_tokenizers/scripts/install-cross-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Script to install dependencies for cross compilation

dpkg --add-architecture $CROSS_DEB_ARCH

apt-get update
apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH openssl:$CROSS_DEB_ARCH

0 comments on commit fe2f37f

Please sign in to comment.