Support linux aarch64 for Dart and Flutter (#2342)
Adds support for building and packaging Linux AArch64 (arm64) artifacts alongside x64 for Dart/Flutter plugins. - Detects host architecture in CMake and adjusts library paths - Extends test workflows to run on an ARM runner and handle linux-aarch64 paths - Splits release pipeline into separate x64 and aarch64 build/package jobs
This commit is contained in:
195
.github/workflows/release-dart-package.yaml
vendored
195
.github/workflows/release-dart-package.yaml
vendored
@@ -14,12 +14,13 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
sherpa_onnx_linux:
|
||||
# if: false
|
||||
permissions:
|
||||
id-token: write # Required for authentication using OIDC
|
||||
name: sherpa_onnx_linux
|
||||
runs-on: ubuntu-latest
|
||||
build_linux_libs_x64:
|
||||
name: ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -30,33 +31,6 @@ jobs:
|
||||
./new-release.sh
|
||||
git diff .
|
||||
|
||||
- name: Fix version
|
||||
shell: bash
|
||||
run: |
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
|
||||
src_dir=$PWD/flutter/sherpa_onnx_linux
|
||||
pushd $src_dir
|
||||
v="version: $SHERPA_ONNX_VERSION"
|
||||
echo "v: $v"
|
||||
sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml
|
||||
rm *.bak
|
||||
git status
|
||||
git diff
|
||||
|
||||
- name: Copy extra files
|
||||
shell: bash
|
||||
run: |
|
||||
dst=flutter/sherpa_onnx_linux
|
||||
|
||||
mkdir $dst/example
|
||||
|
||||
cp -v flutter/sherpa_onnx/example/* $dst/example
|
||||
cp -v LICENSE $dst/
|
||||
cp -v CHANGELOG.md $dst/
|
||||
|
||||
git status
|
||||
|
||||
- name: Build sherpa-onnx
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
@@ -92,10 +66,159 @@ jobs:
|
||||
|
||||
ls -lh ./install/lib
|
||||
|
||||
- name: Create tar file
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir x64
|
||||
dst=x64
|
||||
cp -v build/install/lib/lib* $dst
|
||||
tar cjvf $dst.tar.bz2 $dst
|
||||
ls -lh *.tar.bz2
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-x64
|
||||
path: ./*.tar.bz2
|
||||
|
||||
build_linux_libs_aarch64:
|
||||
name: ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-22.04-arm]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Update version
|
||||
shell: bash
|
||||
run: |
|
||||
./new-release.sh
|
||||
git diff .
|
||||
|
||||
- name: Build sherpa-onnx
|
||||
uses: addnab/docker-run-action@v3
|
||||
with:
|
||||
image: quay.io/pypa/manylinux2014_aarch64
|
||||
options: |
|
||||
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
|
||||
shell: bash
|
||||
run: |
|
||||
uname -a
|
||||
gcc --version
|
||||
cmake --version
|
||||
cat /etc/*release
|
||||
id
|
||||
pwd
|
||||
|
||||
cd /home/runner/work/sherpa-onnx/sherpa-onnx
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
cmake \
|
||||
-D SHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
|
||||
-D SHERPA_ONNX_ENABLE_TTS=ON \
|
||||
-D CMAKE_BUILD_TYPE=Release \
|
||||
-D BUILD_SHARED_LIBS=ON \
|
||||
-D CMAKE_INSTALL_PREFIX=./install \
|
||||
-D SHERPA_ONNX_ENABLE_JNI=OFF \
|
||||
-D SHERPA_ONNX_ENABLE_BINARY=OFF \
|
||||
..
|
||||
|
||||
make -j2
|
||||
make install
|
||||
|
||||
ls -lh ./install/lib
|
||||
|
||||
- name: Create tar file
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir aarch64
|
||||
dst=aarch64
|
||||
cp -v build/install/lib/lib* $dst
|
||||
tar cjvf $dst.tar.bz2 $dst
|
||||
ls -lh *.tar.bz2
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux-aarch64
|
||||
path: ./*.tar.bz2
|
||||
|
||||
sherpa_onnx_linux:
|
||||
needs: [build_linux_libs_x64, build_linux_libs_aarch64]
|
||||
# if: false
|
||||
permissions:
|
||||
id-token: write # Required for authentication using OIDC
|
||||
name: sherpa_onnx_linux
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Update version
|
||||
shell: bash
|
||||
run: |
|
||||
./new-release.sh
|
||||
git diff .
|
||||
|
||||
- name: Fix version
|
||||
shell: bash
|
||||
run: |
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
|
||||
src_dir=$PWD/flutter/sherpa_onnx_linux
|
||||
pushd $src_dir
|
||||
v="version: $SHERPA_ONNX_VERSION"
|
||||
echo "v: $v"
|
||||
sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml
|
||||
rm *.bak
|
||||
git status
|
||||
git diff
|
||||
|
||||
- name: Retrieve artifact from linux x64
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-x64
|
||||
path: /tmp
|
||||
|
||||
- name: Retrieve artifact from linux aarch64
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-aarch64
|
||||
path: /tmp
|
||||
|
||||
- name: Show files
|
||||
shell: bash
|
||||
run: |
|
||||
cd /tmp
|
||||
tar xvf x64.tar.bz2
|
||||
tar xvf aarch64.tar.bz2
|
||||
|
||||
echo "----x64---"
|
||||
ls -lh /tmp/x64/
|
||||
echo "----aarch64---"
|
||||
ls -lh /tmp/aarch64/
|
||||
|
||||
- name: Copy extra files
|
||||
shell: bash
|
||||
run: |
|
||||
dst=flutter/sherpa_onnx_linux
|
||||
|
||||
mkdir $dst/example
|
||||
|
||||
cp -v flutter/sherpa_onnx/example/* $dst/example
|
||||
cp -v LICENSE $dst/
|
||||
cp -v CHANGELOG.md $dst/
|
||||
|
||||
git status
|
||||
|
||||
- name: Copy pre-built libs
|
||||
shell: bash
|
||||
run: |
|
||||
cp -v build/install/lib/lib*.so* flutter/sherpa_onnx_linux/linux/
|
||||
cp -v /tmp/x64/lib*.so* flutter/sherpa_onnx_linux/linux/x64
|
||||
cp -v /tmp/aarch64/lib*.so* flutter/sherpa_onnx_linux/linux/aarch64
|
||||
|
||||
mv -v flutter/sherpa_onnx_linux /tmp/to_be_published
|
||||
|
||||
@@ -104,8 +227,8 @@ jobs:
|
||||
- name: Setup Flutter SDK
|
||||
uses: flutter-actions/setup-flutter@v3
|
||||
with:
|
||||
channel: stable
|
||||
version: latest
|
||||
channel: master
|
||||
version: 3.24.0
|
||||
|
||||
- uses: dart-lang/setup-dart@v1
|
||||
|
||||
|
||||
15
.github/workflows/test-dart-package.yaml
vendored
15
.github/workflows/test-dart-package.yaml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest] #, windows-latest]
|
||||
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm] #, windows-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -36,11 +36,12 @@ jobs:
|
||||
./new-release.sh
|
||||
git diff .
|
||||
|
||||
- name: Setup Flutter SDK
|
||||
uses: flutter-actions/setup-flutter@v3
|
||||
# see https://github.com/subosito/flutter-action/issues/345
|
||||
- name: Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
version: latest
|
||||
channel: master
|
||||
flutter-version: 3.24.0
|
||||
|
||||
- name: Display flutter info
|
||||
shell: bash
|
||||
@@ -58,7 +59,7 @@ jobs:
|
||||
cd dart-api-examples/vad
|
||||
flutter pub get
|
||||
|
||||
if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
|
||||
if [[ ${{ matrix.os }} == ubuntu-latest || ${{ matrix.os }} == ubuntu-24.04-arm ]]; then
|
||||
echo "-----"
|
||||
ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev
|
||||
|
||||
@@ -75,7 +76,7 @@ jobs:
|
||||
# sudo touch /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-1.10.7/lib/.gitkeep
|
||||
|
||||
echo "-----"
|
||||
ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-*/linux
|
||||
ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-*/linux/*
|
||||
elif [[ ${{ matrix.os }} == macos-latest ]]; then
|
||||
echo "-----"
|
||||
ls -lh /Users/runner/work/_temp/pub-cache/hosted/pub.dev
|
||||
|
||||
27
.github/workflows/test-dart.yaml
vendored
27
.github/workflows/test-dart.yaml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest] #, windows-latest]
|
||||
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm] #, windows-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -50,11 +50,12 @@ jobs:
|
||||
with:
|
||||
key: ${{ matrix.os }}-dart
|
||||
|
||||
- name: Setup Flutter SDK
|
||||
uses: flutter-actions/setup-flutter@v3
|
||||
# see https://github.com/subosito/flutter-action/issues/345
|
||||
- name: Set up Flutter
|
||||
uses: subosito/flutter-action@v2
|
||||
with:
|
||||
channel: stable
|
||||
version: latest
|
||||
channel: master
|
||||
flutter-version: 3.24.0
|
||||
|
||||
- name: Display flutter info
|
||||
shell: bash
|
||||
@@ -91,22 +92,34 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
|
||||
os=linux
|
||||
os=linux-x64
|
||||
elif [[ ${{ matrix.os }} == ubuntu-24.04-arm ]]; then
|
||||
os=linux-aarch64
|
||||
elif [[ ${{ matrix.os }} == macos-latest ]]; then
|
||||
os=macos
|
||||
elif [[ ${{ matrix.os }} == windows-latest ]]; then
|
||||
os=windows
|
||||
fi
|
||||
|
||||
echo "os: $os"
|
||||
|
||||
if [[ $os == windows ]]; then
|
||||
cp -fv build/install/lib/*.dll ./flutter/sherpa_onnx_$os/$os
|
||||
elif [[ $os == linux-x64 ]]; then
|
||||
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_linux/linux/x64
|
||||
elif [[ $os == linux-aarch64 ]]; then
|
||||
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_linux/linux/aarch64
|
||||
else
|
||||
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_$os/$os
|
||||
fi
|
||||
|
||||
echo "--------------------"
|
||||
|
||||
ls -lh ./flutter/sherpa_onnx_$os/$os
|
||||
if [[ $os == linux-x64 || $os == linux-aarch64 ]]; then
|
||||
ls -lh ./flutter/sherpa_onnx_linux/linux/*
|
||||
else
|
||||
ls -lh ./flutter/sherpa_onnx_$os/$os
|
||||
fi
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
|
||||
@@ -25,6 +25,14 @@ Future<void> initSherpaOnnx() async {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
final libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform);
|
||||
var libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform);
|
||||
if (platform == 'linux') {
|
||||
final arch = Platform.version.contains('arm64') ||
|
||||
Platform.version.contains('aarch64')
|
||||
? 'aarch64'
|
||||
: 'x64';
|
||||
libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform, arch);
|
||||
}
|
||||
|
||||
sherpa_onnx.initBindings(libPath);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,19 @@ cmake_minimum_required(VERSION 3.10)
|
||||
set(PROJECT_NAME "sherpa_onnx_linux")
|
||||
project(${PROJECT_NAME} LANGUAGES CXX)
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
set(LIB_ARCH_DIR "x64")
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
|
||||
set(LIB_ARCH_DIR "aarch64")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported arch: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
# List of absolute paths to libraries that should be bundled with the plugin.
|
||||
# This list could contain prebuilt libraries, or libraries created by an
|
||||
# external build triggered from this build file.
|
||||
set(sherpa_onnx_linux_bundled_libraries
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-c-api.so"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${LIB_ARCH_DIR}/libsherpa-onnx-c-api.so"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${LIB_ARCH_DIR}/libonnxruntime.so"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
0
flutter/sherpa_onnx_linux/linux/aarch64/.gitikeep
Normal file
0
flutter/sherpa_onnx_linux/linux/aarch64/.gitikeep
Normal file
0
flutter/sherpa_onnx_linux/linux/x64/.gitikeep
Normal file
0
flutter/sherpa_onnx_linux/linux/x64/.gitikeep
Normal file
Reference in New Issue
Block a user