Skip to content

Commit 1791bb5

Browse files
committed
Merge remote-tracking branch 'dan/master' into release-v1.12.4
2 parents 9959a98 + 53a3ad3 commit 1791bb5

8 files changed

Lines changed: 200 additions & 47 deletions

File tree

.github/workflows/release-dart-package.yaml

Lines changed: 152 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17-
sherpa_onnx_linux:
18-
# if: false
19-
permissions:
20-
id-token: write # Required for authentication using OIDC
21-
name: sherpa_onnx_linux
22-
runs-on: ubuntu-latest
17+
build_linux_libs_x64:
18+
name: ${{ matrix.os }}
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [ubuntu-latest]
2324

2425
steps:
2526
- uses: actions/checkout@v4
@@ -30,37 +31,76 @@ jobs:
3031
./new-release.sh
3132
git diff .
3233
33-
- name: Fix version
34-
shell: bash
35-
run: |
36-
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
34+
- name: Build sherpa-onnx
35+
uses: addnab/docker-run-action@v3
36+
with:
37+
image: quay.io/pypa/manylinux2014_x86_64
38+
options: |
39+
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
40+
shell: bash
41+
run: |
42+
uname -a
43+
gcc --version
44+
cmake --version
45+
cat /etc/*release
46+
id
47+
pwd
3748
38-
src_dir=$PWD/flutter/sherpa_onnx_linux
39-
pushd $src_dir
40-
v="version: $SHERPA_ONNX_VERSION"
41-
echo "v: $v"
42-
sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml
43-
rm *.bak
44-
git status
45-
git diff
49+
cd /home/runner/work/sherpa-onnx/sherpa-onnx
4650
47-
- name: Copy extra files
51+
mkdir build
52+
cd build
53+
54+
cmake \
55+
-D SHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
56+
-D SHERPA_ONNX_ENABLE_TTS=ON \
57+
-D CMAKE_BUILD_TYPE=Release \
58+
-D BUILD_SHARED_LIBS=ON \
59+
-D CMAKE_INSTALL_PREFIX=./install \
60+
-D SHERPA_ONNX_ENABLE_JNI=OFF \
61+
-D SHERPA_ONNX_ENABLE_BINARY=OFF \
62+
..
63+
64+
make -j2
65+
make install
66+
67+
ls -lh ./install/lib
68+
69+
- name: Create tar file
4870
shell: bash
4971
run: |
50-
dst=flutter/sherpa_onnx_linux
72+
mkdir x64
73+
dst=x64
74+
cp -v build/install/lib/lib* $dst
75+
tar cjvf $dst.tar.bz2 $dst
76+
ls -lh *.tar.bz2
5177
52-
mkdir $dst/example
78+
- uses: actions/upload-artifact@v4
79+
with:
80+
name: linux-x64
81+
path: ./*.tar.bz2
5382

54-
cp -v flutter/sherpa_onnx/example/* $dst/example
55-
cp -v LICENSE $dst/
56-
cp -v CHANGELOG.md $dst/
83+
build_linux_libs_aarch64:
84+
name: ${{ matrix.os }}
85+
runs-on: ${{ matrix.os }}
86+
strategy:
87+
fail-fast: false
88+
matrix:
89+
os: [ubuntu-22.04-arm]
5790

58-
git status
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: Update version
95+
shell: bash
96+
run: |
97+
./new-release.sh
98+
git diff .
5999
60100
- name: Build sherpa-onnx
61101
uses: addnab/docker-run-action@v3
62102
with:
63-
image: quay.io/pypa/manylinux2014_x86_64
103+
image: quay.io/pypa/manylinux2014_aarch64
64104
options: |
65105
--volume ${{ github.workspace }}/:/home/runner/work/sherpa-onnx/sherpa-onnx
66106
shell: bash
@@ -92,10 +132,93 @@ jobs:
92132
93133
ls -lh ./install/lib
94134
135+
- name: Create tar file
136+
shell: bash
137+
run: |
138+
mkdir aarch64
139+
dst=aarch64
140+
cp -v build/install/lib/lib* $dst
141+
tar cjvf $dst.tar.bz2 $dst
142+
ls -lh *.tar.bz2
143+
144+
- uses: actions/upload-artifact@v4
145+
with:
146+
name: linux-aarch64
147+
path: ./*.tar.bz2
148+
149+
sherpa_onnx_linux:
150+
needs: [build_linux_libs_x64, build_linux_libs_aarch64]
151+
# if: false
152+
permissions:
153+
id-token: write # Required for authentication using OIDC
154+
name: sherpa_onnx_linux
155+
runs-on: ubuntu-latest
156+
157+
steps:
158+
- uses: actions/checkout@v4
159+
160+
- name: Update version
161+
shell: bash
162+
run: |
163+
./new-release.sh
164+
git diff .
165+
166+
- name: Fix version
167+
shell: bash
168+
run: |
169+
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
170+
171+
src_dir=$PWD/flutter/sherpa_onnx_linux
172+
pushd $src_dir
173+
v="version: $SHERPA_ONNX_VERSION"
174+
echo "v: $v"
175+
sed -i.bak s"/^version: .*/$v/" ./pubspec.yaml
176+
rm *.bak
177+
git status
178+
git diff
179+
180+
- name: Retrieve artifact from linux x64
181+
uses: actions/download-artifact@v4
182+
with:
183+
name: linux-x64
184+
path: /tmp
185+
186+
- name: Retrieve artifact from linux aarch64
187+
uses: actions/download-artifact@v4
188+
with:
189+
name: linux-aarch64
190+
path: /tmp
191+
192+
- name: Show files
193+
shell: bash
194+
run: |
195+
cd /tmp
196+
tar xvf x64.tar.bz2
197+
tar xvf aarch64.tar.bz2
198+
199+
echo "----x64---"
200+
ls -lh /tmp/x64/
201+
echo "----aarch64---"
202+
ls -lh /tmp/aarch64/
203+
204+
- name: Copy extra files
205+
shell: bash
206+
run: |
207+
dst=flutter/sherpa_onnx_linux
208+
209+
mkdir $dst/example
210+
211+
cp -v flutter/sherpa_onnx/example/* $dst/example
212+
cp -v LICENSE $dst/
213+
cp -v CHANGELOG.md $dst/
214+
215+
git status
216+
95217
- name: Copy pre-built libs
96218
shell: bash
97219
run: |
98-
cp -v build/install/lib/lib*.so* flutter/sherpa_onnx_linux/linux/
220+
cp -v /tmp/x64/lib*.so* flutter/sherpa_onnx_linux/linux/x64
221+
cp -v /tmp/aarch64/lib*.so* flutter/sherpa_onnx_linux/linux/aarch64
99222
100223
mv -v flutter/sherpa_onnx_linux /tmp/to_be_published
101224
@@ -104,8 +227,8 @@ jobs:
104227
- name: Setup Flutter SDK
105228
uses: flutter-actions/setup-flutter@v3
106229
with:
107-
channel: stable
108-
version: latest
230+
channel: master
231+
version: 3.24.0
109232

110233
- uses: dart-lang/setup-dart@v1
111234

.github/workflows/test-dart-package.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
os: [macos-latest, ubuntu-latest] #, windows-latest]
26+
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm] #, windows-latest]
2727

2828
steps:
2929
- uses: actions/checkout@v4
@@ -36,11 +36,12 @@ jobs:
3636
./new-release.sh
3737
git diff .
3838
39-
- name: Setup Flutter SDK
40-
uses: flutter-actions/setup-flutter@v3
39+
# see https://github.com/subosito/flutter-action/issues/345
40+
- name: Set up Flutter
41+
uses: subosito/flutter-action@v2
4142
with:
42-
channel: stable
43-
version: latest
43+
channel: master
44+
flutter-version: 3.24.0
4445

4546
- name: Display flutter info
4647
shell: bash
@@ -58,7 +59,7 @@ jobs:
5859
cd dart-api-examples/vad
5960
flutter pub get
6061
61-
if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
62+
if [[ ${{ matrix.os }} == ubuntu-latest || ${{ matrix.os }} == ubuntu-24.04-arm ]]; then
6263
echo "-----"
6364
ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev
6465
@@ -75,7 +76,7 @@ jobs:
7576
# sudo touch /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-1.10.7/lib/.gitkeep
7677
7778
echo "-----"
78-
ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-*/linux
79+
ls -lh /home/runner/work/_temp/pub-cache/hosted/pub.dev/sherpa_onnx_linux-*/linux/*
7980
elif [[ ${{ matrix.os }} == macos-latest ]]; then
8081
echo "-----"
8182
ls -lh /Users/runner/work/_temp/pub-cache/hosted/pub.dev

.github/workflows/test-dart.yaml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
os: [ubuntu-latest, macos-latest] #, windows-latest]
35+
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm] #, windows-latest]
3636

3737
steps:
3838
- uses: actions/checkout@v4
@@ -50,11 +50,12 @@ jobs:
5050
with:
5151
key: ${{ matrix.os }}-dart
5252

53-
- name: Setup Flutter SDK
54-
uses: flutter-actions/setup-flutter@v3
53+
# see https://github.com/subosito/flutter-action/issues/345
54+
- name: Set up Flutter
55+
uses: subosito/flutter-action@v2
5556
with:
56-
channel: stable
57-
version: latest
57+
channel: master
58+
flutter-version: 3.24.0
5859

5960
- name: Display flutter info
6061
shell: bash
@@ -91,22 +92,34 @@ jobs:
9192
shell: bash
9293
run: |
9394
if [[ ${{ matrix.os }} == ubuntu-latest ]]; then
94-
os=linux
95+
os=linux-x64
96+
elif [[ ${{ matrix.os }} == ubuntu-24.04-arm ]]; then
97+
os=linux-aarch64
9598
elif [[ ${{ matrix.os }} == macos-latest ]]; then
9699
os=macos
97100
elif [[ ${{ matrix.os }} == windows-latest ]]; then
98101
os=windows
99102
fi
100103
104+
echo "os: $os"
105+
101106
if [[ $os == windows ]]; then
102107
cp -fv build/install/lib/*.dll ./flutter/sherpa_onnx_$os/$os
108+
elif [[ $os == linux-x64 ]]; then
109+
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_linux/linux/x64
110+
elif [[ $os == linux-aarch64 ]]; then
111+
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_linux/linux/aarch64
103112
else
104113
cp -fv build/install/lib/lib* ./flutter/sherpa_onnx_$os/$os
105114
fi
106115
107116
echo "--------------------"
108117
109-
ls -lh ./flutter/sherpa_onnx_$os/$os
118+
if [[ $os == linux-x64 || $os == linux-aarch64 ]]; then
119+
ls -lh ./flutter/sherpa_onnx_linux/linux/*
120+
else
121+
ls -lh ./flutter/sherpa_onnx_$os/$os
122+
fi
110123
111124
- name: Run tests
112125
shell: bash

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Fix VAD+ASR C++ example. (#2335)
77
* Add sherpa-onnx-streaming-zipformer-zh-int8-2025-06-30 to android ASR apk (#2336)
88
* Support non-streaming zipformer CTC ASR models (#2340)
9-
9+
* Support linux aarch64 for Dart and Flutter (#2342)
1010

1111
## 1.12.3
1212

dart-api-examples/vad/bin/init.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ Future<void> initSherpaOnnx() async {
2525
exit(1);
2626
}
2727

28-
final libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform);
28+
var libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform);
29+
if (platform == 'linux') {
30+
final arch = Platform.version.contains('arm64') ||
31+
Platform.version.contains('aarch64')
32+
? 'aarch64'
33+
: 'x64';
34+
libPath = p.join(p.dirname(p.fromUri(uri)), '..', platform, arch);
35+
}
36+
2937
sherpa_onnx.initBindings(libPath);
3038
}

flutter/sherpa_onnx_linux/linux/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ cmake_minimum_required(VERSION 3.10)
77
set(PROJECT_NAME "sherpa_onnx_linux")
88
project(${PROJECT_NAME} LANGUAGES CXX)
99

10+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
11+
set(LIB_ARCH_DIR "x64")
12+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
13+
set(LIB_ARCH_DIR "aarch64")
14+
else()
15+
message(FATAL_ERROR "Unsupported arch: ${CMAKE_SYSTEM_PROCESSOR}")
16+
endif()
17+
1018
# List of absolute paths to libraries that should be bundled with the plugin.
1119
# This list could contain prebuilt libraries, or libraries created by an
1220
# external build triggered from this build file.
1321
set(sherpa_onnx_linux_bundled_libraries
14-
"${CMAKE_CURRENT_SOURCE_DIR}/libsherpa-onnx-c-api.so"
15-
"${CMAKE_CURRENT_SOURCE_DIR}/libonnxruntime.so"
22+
"${CMAKE_CURRENT_SOURCE_DIR}/${LIB_ARCH_DIR}/libsherpa-onnx-c-api.so"
23+
"${CMAKE_CURRENT_SOURCE_DIR}/${LIB_ARCH_DIR}/libonnxruntime.so"
1624
PARENT_SCOPE
1725
)

flutter/sherpa_onnx_linux/linux/aarch64/.gitikeep

Whitespace-only changes.

flutter/sherpa_onnx_linux/linux/x64/.gitikeep

Whitespace-only changes.

0 commit comments

Comments
 (0)