Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ jobs:
- name: Put NDK toolchain on PATH
run: echo "$ANDROID_HOME/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH

- name: Build libsodium
env:
CC: ${{ matrix.cc }}
run: |
dir=$(./build-libsodium.sh ${{ matrix.target }})
echo "SODIUM_LIB_DIR=$dir" >> $GITHUB_ENV

- name: Build
env:
CC: ${{ matrix.cc }}
Expand Down Expand Up @@ -114,11 +121,10 @@ jobs:
subdir: windows-x86_64
target: x86_64-pc-windows-msvc
libfile: etebase_jni.dll
- runner: ubuntu-24.04
- runner: windows-11-arm
subdir: windows-aarch64
target: aarch64-pc-windows-gnullvm
target: aarch64-pc-windows-msvc
libfile: etebase_jni.dll
zig: true
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0

Expand All @@ -129,23 +135,15 @@ jobs:
rustflags: ""
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}

- name: Build
if: ${{ !matrix.zig }}
- name: Build libsodium
shell: bash
run: cargo build --locked --target ${{ matrix.target }} --release --no-default-features --features jvm

- name: Install cargo-zigbuild
if: matrix.zig
run: |
python3 -m venv "$RUNNER_TEMP/zig"
"$RUNNER_TEMP/zig/bin/pip" install --require-hashes -r zig-requirements.txt
echo "$RUNNER_TEMP/zig/bin" >> $GITHUB_PATH
dir=$(./build-libsodium.sh ${{ matrix.target }})
echo "SODIUM_LIB_DIR=$dir" >> $GITHUB_ENV

- name: Build (zig)
if: matrix.zig
env:
ZIG: python3 -m ziglang
run: ./build-windows-aarch64.sh
- name: Build
shell: bash
run: cargo build --locked --target ${{ matrix.target }} --release --no-default-features --features jvm

- name: Upload native lib
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down
68 changes: 68 additions & 0 deletions build-libsodium.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

set -euo pipefail

VERSION=1.0.22
URL=https://github.com/jedisct1/libsodium/releases/download/$VERSION-RELEASE
TARBALL_SHA256=adbdd8f16149e81ac6078a03aca6fc03b592b89ef7b5ed83841c086191be3349
MSVC_SHA256=3e03a726fac4bc09cb61d8f29d658ef7a5eca0811de59082130414f7ca2e4279

target=$1
exec 3>&1 1>&2
cd "$(dirname "$0")"
out="$(pwd)/target/$target/libsodium"
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
rm -rf "$out"
mkdir -p "$out"

verify() {
if command -v shasum >/dev/null; then
actual=$(shasum -a 256 "$2")
else
actual=$(sha256sum "$2")
fi
actual=${actual%% *}
if [ "$actual" != "$1" ]; then
echo "$2: expected sha256 $1, got $actual" >&2
exit 1
fi
}

case $target in
*-pc-windows-msvc)
case $target in
x86_64-*) arch=x64 ;;
aarch64-*) arch=ARM64 ;;
*) echo "unsupported target $target" >&2; exit 1 ;;
esac
curl -fsSL --retry 5 --retry-all-errors -o "$work/libsodium.zip" "$URL/libsodium-$VERSION-msvc.zip"
verify $MSVC_SHA256 "$work/libsodium.zip"
lib="libsodium/$arch/Release/v143/static/libsodium.lib"
(cd "$work" && "$(cygpath "$SYSTEMROOT")/System32/tar.exe" -xf libsodium.zip "$lib")
cp "$work/$lib" "$out/"
out=$(cygpath -m "$out")
;;
*)
curl -fsSL --retry 5 --retry-all-errors -o "$work/libsodium.tar.gz" "$URL/libsodium-$VERSION.tar.gz"
verify $TARBALL_SHA256 "$work/libsodium.tar.gz"
tar -xzf "$work/libsodium.tar.gz" -C "$work"
case $target in
*-apple-darwin)
arch=${target%%-*}
export CC="clang -arch ${arch/aarch64/arm64} -mmacosx-version-min=$(rustc --print deployment-target --target "$target" | cut -d= -f2)"
;;
esac
cd "$work/libsodium-$VERSION"
./configure --host="$target" --prefix="$work/install" --disable-shared --with-pic --disable-dependency-tracking
jobs=$(getconf _NPROCESSORS_ONLN)
make -j"$jobs"
if [ "$target" = "$(rustc -vV | sed -n 's/^host: //p')" ]; then
make -j"$jobs" check
fi
make install
cp "$work/install/lib/libsodium.a" "$out/"
;;
esac

echo "$out" >&3
34 changes: 0 additions & 34 deletions build-windows-aarch64.sh

This file was deleted.

22 changes: 0 additions & 22 deletions zig-requirements.txt

This file was deleted.

Loading