Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Multiarch CI #12

Closed
wants to merge 2 commits into from
Closed
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
69 changes: 64 additions & 5 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,77 @@
name: Compile secp256k1 native code
name: Compile secp256k1 native library

on:
push:
pull_request:
branches:
- master
push:
branches:
- trying
- staging

jobs:
compile:
name: Compile secp256k1 native code
name: Compile secp256k1
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-11]
include:
# Linux
- name: linux
os: ubuntu-22.04
arch: amd64
- name: linux
os: ubuntu-22.04
arch: aarch64
# MacOS
- name: macos
os: macos-13
arch: amd64
- name: macos
os: macos-13
arch: aarch64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install dependencies ubuntu
if: matrix.name == 'linux'
run: |
uname -a
sudo apt-get update
sudo apt-get install -y build-essential libtool
sudo apt-get install -y gcc-aarch64-linux-gnu
export DEBIAN_FRONTEND=noninteractive
sudo apt-get install -y openjdk-17-jdk-headless

# TODO: add release job
- name: Install dependencies macos
if: matrix.name == 'macos'
run: |
uname -a
brew install autoconf automake
brew install openjdk@17
echo 'export JAVA_PATH="/usr/local/opt/openjdk@17/libexec/openjdk.jdk:$PATH"' >> /Users/runner/.bash_profile
export CFLAGS="-I$JAVA_PATH/include -I$JAVA_PATH/include/darwin"

- name: Build native code
run: |
./compile.sh

- name: Export artifacts linux
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}-${{ matrix.arch }}
path: ./secp256k1-tmp/.libs/

# Job to notify bors when run is successful. Skipped and cancelled job is considered
# as failure. More info https://github.com/bors-ng/bors-ng/issues/1115.
bors_success:
name: bors build finished
if: ${{ success() }}
needs:
- compile
runs-on: ubuntu-latest
steps:
- run: exit 0
68 changes: 0 additions & 68 deletions .github/workflows/test-compile.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
secp256k1-tmp/
Dockerfile
.idea/
23 changes: 21 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

set -e

# To cross compile to aarch64 use "arm" as a first argument
# Example:
# ./compile.sh arm
ARCH_HOST="$1"
echo "Arch host = '$ARCH_HOST'"

rm -Rf secp256k1-tmp/
cp -r secp256k1/ secp256k1-tmp/

pushd secp256k1-tmp/
Expand All @@ -16,8 +23,20 @@ cp ../jni/configure.ac configure.ac

# Compile secp256k1 native code
./autogen.sh
./configure --enable-jni --enable-module-ecdh --enable-experimental --enable-module-schnorrsig --enable-module-ecdsa-adaptor

if [[ "$ARCH_HOST" ]]; then
echo "Cross compiling for ARM CPU... $ARCH_HOST"
# ./configure --enable-jni --enable-module-ecdh --host=aarch64-linux-gnu
# ./configure --enable-jni --enable-module-ecdh --host=aarch64-linux-gnu --enable-experimental --with-asm=arm
# ./configure --enable-jni --enable-module-ecdh --host=aarch64-linux-gnu --with-asm=no
./configure --enable-jni --enable-module-ecdh --host=$ARCH_HOST --with-asm=no
else
./configure --enable-jni --enable-module-ecdh
fi
# ./configure --enable-jni --enable-module-ecdh --enable-experimental --enable-module-schnorrsig
# ./configure --enable-jni --enable-module-ecdh
make CFLAGS="-std=c99"
make
make check
if [[ ! "$ARCH_HOST" ]]; then
make check
fi
20 changes: 12 additions & 8 deletions jni/build-aux/m4/ax_jni_include_dir.m4
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,26 @@ _AS_ECHO_LOG([_JINC=$_JINC])
# -> ../../CurrentJDK/Headers/jni.h.
AC_CACHE_CHECK(jni headers, ac_cv_jni_header_path,
[
if test -f "$_JINC/jni.h"; then
if test -f "$JAVA_HOME/include/jni.h"; then
ac_cv_jni_header_path="$JAVA_HOME/include \
$JAVA_HOME/include/darwin"
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
elif test -f "$_JINC/jni.h"; then
echo _JINC/jni.h: "$_JINC/jni.h"

ac_cv_jni_header_path="$_JINC"
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
else
_JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'`
if test -f "$_JTOPDIR/include/jni.h"; then
echo _JTOPDIR/include/jni.h: "$_JTOPDIR/include/jni.h"

ac_cv_jni_header_path="$_JTOPDIR/include"
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"

echo JNI_INCLUDE_DIRS: "$JNI_INCLUDE_DIRS"
else
if test -f "/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/include/jni.h"; then
ac_cv_jni_header_path="/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/include \
/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/include/darwin"
JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $ac_cv_jni_header_path"
else
ac_cv_jni_header_path=none
fi
ac_cv_jni_header_path=none
fi
fi
])
Expand Down