Skip to content

Commit 4cae771

Browse files
committed
build linux libs
1 parent 9e86a89 commit 4cae771

5 files changed

Lines changed: 170 additions & 48 deletions

File tree

.github/scripts/show-rust-binary-info.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,42 @@ if [[ -z "$os_name" ]]; then
1212
esac
1313
fi
1414

15+
show_stripped_size() {
16+
local bin="$1"
17+
local strip_tool=""
18+
19+
if command -v llvm-strip >/dev/null 2>&1; then
20+
strip_tool="llvm-strip"
21+
elif command -v strip >/dev/null 2>&1; then
22+
strip_tool="strip"
23+
fi
24+
25+
if [[ -z "$strip_tool" ]]; then
26+
echo "No strip tool available on PATH"
27+
return 0
28+
fi
29+
30+
local tmp
31+
tmp="$(mktemp "${TMPDIR:-/tmp}/$(basename "$bin").XXXXXX")"
32+
cp "$bin" "$tmp"
33+
34+
if "$strip_tool" "$tmp" >/dev/null 2>&1; then
35+
echo "=== Binary size after strip ($strip_tool) ==="
36+
ls -lh "$tmp"
37+
else
38+
echo "=== Binary size after strip ($strip_tool) ==="
39+
echo "strip failed"
40+
fi
41+
42+
rm -f "$tmp"
43+
}
44+
1545
show_one() {
1646
local bin="$1"
1747

1848
echo "=== Binary info: $bin ==="
1949
ls -lh "$bin"
50+
show_stripped_size "$bin"
2051
echo
2152
echo "=== Binary dependencies ($os_name) ==="
2253

@@ -49,11 +80,19 @@ if [[ "${1:-}" == "--all" ]]; then
4980
case "$os_name" in
5081
Windows)
5182
for bin in target/debug/examples/*.exe; do
83+
base="$(basename "$bin" .exe)"
84+
if [[ "$base" =~ -[0-9a-f]{16}$ ]]; then
85+
continue
86+
fi
5287
bins+=("$bin")
5388
done
5489
;;
5590
*)
5691
for bin in target/debug/examples/*; do
92+
base="$(basename "$bin")"
93+
if [[ "$base" =~ -[0-9a-f]{16}$ ]]; then
94+
continue
95+
fi
5796
if [[ -f "$bin" && -x "$bin" && "$bin" != *.d ]]; then
5897
bins+=("$bin")
5998
fi

.github/workflows/aarch64-linux-gnu-shared.yaml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- rust-static
89
tags:
910
- 'v[0-9]+.[0-9]+.[0-9]+*'
1011
paths:
@@ -199,10 +200,36 @@ jobs:
199200
200201
tar cjvf ${dst}.tar.bz2 $dst
201202
203+
lib_dst=${dst}-lib
204+
mkdir -p ${lib_dst}/lib
205+
cp -av build/install/lib/lib*.so* ${lib_dst}/lib/
206+
rm -f ${lib_dst}/lib/libcargs.so ${lib_dst}/lib/libcargs.so.*
207+
tree ${lib_dst}
208+
tar cjvf ${lib_dst}.tar.bz2 ${lib_dst}
209+
202210
- uses: actions/upload-artifact@v4
203211
with:
204212
name: sherpa-onnx-linux-aarch64-shared-gpu-${{ matrix.gpu }}-onnxruntime-${{ matrix.onnxruntime_version }}
205-
path: sherpa-onnx-*linux-aarch64-shared*.tar.bz2
213+
path: sherpa-onnx-*.tar.bz2
214+
215+
- name: Release pre-compiled binaries and libs for linux aarch64
216+
# if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
217+
uses: svenstaro/upload-release-action@v2
218+
with:
219+
file_glob: true
220+
overwrite: true
221+
file: sherpa-onnx-*.tar.bz2
222+
repo_name: k2-fsa/sherpa-onnx
223+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
224+
tag: v1.12.31
225+
226+
- name: Release pre-compiled binaries and libs for linux aarch64
227+
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
228+
uses: svenstaro/upload-release-action@v2
229+
with:
230+
file_glob: true
231+
overwrite: true
232+
file: sherpa-onnx-*.tar.bz2
206233

207234
# https://huggingface.co/docs/hub/spaces-github-actions
208235
- name: Publish to huggingface
@@ -238,24 +265,7 @@ jobs:
238265
239266
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-libs main
240267
241-
- name: Release pre-compiled binaries and libs for aarch64 linux
242-
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
243-
uses: svenstaro/upload-release-action@v2
244-
with:
245-
file_glob: true
246-
overwrite: true
247-
file: sherpa-onnx-*linux-aarch64*.tar.bz2
248268
249-
- name: Release pre-compiled binaries and libs for aarch64 linux
250-
if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
251-
uses: svenstaro/upload-release-action@v2
252-
with:
253-
file_glob: true
254-
overwrite: true
255-
file: sherpa-onnx-*linux-aarch64*.tar.bz2
256-
# repo_name: k2-fsa/sherpa-onnx
257-
# repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
258-
# tag: v1.12.17
259269
260270
- name: Test offline Moonshine
261271
if: matrix.build_type != 'Debug'

.github/workflows/aarch64-linux-gnu-static.yaml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- master
8+
- rust-static
89
tags:
910
- 'v[0-9]+.[0-9]+.[0-9]+*'
1011
paths:
@@ -128,10 +129,36 @@ jobs:
128129
129130
tar cjvf ${dst}.tar.bz2 $dst
130131
132+
lib_dst=${dst}-lib
133+
mkdir -p ${lib_dst}/lib
134+
cp -av build/install/lib/lib*.a ${lib_dst}/lib/
135+
rm -f ${lib_dst}/lib/libcargs.a
136+
tree ${lib_dst}
137+
tar cjvf ${lib_dst}.tar.bz2 ${lib_dst}
138+
131139
- uses: actions/upload-artifact@v4
132140
with:
133141
name: sherpa-onnx-linux-aarch64-static
134-
path: sherpa-onnx-*linux-aarch64-static.tar.bz2
142+
path: sherpa-onnx-*.tar.bz2
143+
144+
- name: Release pre-compiled binaries and libs for linux aarch64
145+
# if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
146+
uses: svenstaro/upload-release-action@v2
147+
with:
148+
file_glob: true
149+
overwrite: true
150+
file: sherpa-onnx-*.tar.bz2
151+
repo_name: k2-fsa/sherpa-onnx
152+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
153+
tag: v1.12.31
154+
155+
- name: Release pre-compiled binaries and libs for linux aarch64
156+
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
157+
uses: svenstaro/upload-release-action@v2
158+
with:
159+
file_glob: true
160+
overwrite: true
161+
file: sherpa-onnx-*.tar.bz2
135162

136163
# https://huggingface.co/docs/hub/spaces-github-actions
137164
- name: Publish to huggingface
@@ -167,25 +194,6 @@ jobs:
167194
168195
git push https://csukuangfj2:$HF_TOKEN@huggingface.co/csukuangfj2/sherpa-onnx-libs main
169196
170-
- name: Release pre-compiled binaries and libs for aarch64 linux
171-
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
172-
uses: svenstaro/upload-release-action@v2
173-
with:
174-
file_glob: true
175-
overwrite: true
176-
file: sherpa-onnx-*linux-aarch64*.tar.bz2
177-
178-
- name: Release pre-compiled binaries and libs for aarch64 linux
179-
if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
180-
uses: svenstaro/upload-release-action@v2
181-
with:
182-
file_glob: true
183-
overwrite: true
184-
file: sherpa-onnx-*linux-aarch64*.tar.bz2
185-
# repo_name: k2-fsa/sherpa-onnx
186-
# repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
187-
# tag: v1.11.5
188-
189197
- name: Test offline Moonshine
190198
if: matrix.build_type != 'Debug'
191199
shell: bash

.github/workflows/linux.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
- rust-static-2
78
tags:
89
- 'v[0-9]+.[0-9]+.[0-9]+*'
910
paths:
@@ -221,6 +222,19 @@ jobs:
221222
tree $dst
222223
223224
tar cjvf ${dst}.tar.bz2 $dst
225+
226+
lib_dst=${dst}-lib
227+
mkdir -p ${lib_dst}/lib
228+
if [[ ${{ matrix.shared_lib }} == ON ]]; then
229+
cp -av build/install/lib/lib*.so* ${lib_dst}/lib/
230+
rm -f ${lib_dst}/lib/libcargs.so ${lib_dst}/lib/libcargs.so.*
231+
else
232+
cp -av build/install/lib/lib*.a ${lib_dst}/lib/
233+
rm -f ${lib_dst}/lib/libcargs.a
234+
fi
235+
tree ${lib_dst}
236+
tar cjvf ${lib_dst}.tar.bz2 ${lib_dst}
237+
224238
du -h -d1 .
225239
226240
- name: Release pre-compiled binaries and libs for linux x64
@@ -230,9 +244,9 @@ jobs:
230244
file_glob: true
231245
overwrite: true
232246
file: sherpa-onnx-*.tar.bz2
233-
# repo_name: k2-fsa/sherpa-onnx
234-
# repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
235-
# tag: v1.12.25
247+
repo_name: k2-fsa/sherpa-onnx
248+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
249+
tag: v1.12.31
236250

237251
- name: Release pre-compiled binaries and libs for linux x64
238252
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'

.github/workflows/macos.yaml

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
- rust-static-2
78
tags:
89
- 'v[0-9]+.[0-9]+.[0-9]+*'
910
paths:
@@ -140,6 +141,20 @@ jobs:
140141
if: matrix.build_type == 'Release'
141142
shell: bash
142143
run: |
144+
thin_macos_tree() {
145+
src_dir="$1"
146+
dst_dir="$2"
147+
arch="$3"
148+
149+
cp -a "$src_dir" "$dst_dir"
150+
151+
while IFS= read -r -d '' f; do
152+
tmp="${f}.thin"
153+
lipo -thin "$arch" "$f" -output "$tmp"
154+
mv "$tmp" "$f"
155+
done < <(find "$dst_dir" -type f \( -path "$dst_dir/bin/*" -o -path "$dst_dir/lib/*.dylib*" -o -path "$dst_dir/lib/*.a" \) -print0)
156+
}
157+
143158
SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
144159
145160
if [[ ${{ matrix.with_tts }} == ON ]]; then
@@ -163,16 +178,54 @@ jobs:
163178
164179
tar cjvf ${dst}.tar.bz2 $dst
165180
181+
lib_dst=${dst}-lib
182+
mkdir -p ${lib_dst}/lib
183+
if [[ ${{ matrix.lib_type }} == shared ]]; then
184+
cp -av build/install/lib/lib*.dylib* ${lib_dst}/lib/
185+
rm -f ${lib_dst}/lib/libcargs.dylib ${lib_dst}/lib/libcargs*.dylib
186+
else
187+
cp -av build/install/lib/lib*.a ${lib_dst}/lib/
188+
rm -f ${lib_dst}/lib/libcargs.a
189+
fi
190+
tree ${lib_dst}
191+
tar cjvf ${lib_dst}.tar.bz2 ${lib_dst}
192+
193+
for arch in x86_64 arm64; do
194+
if [[ "$arch" == "x86_64" ]]; then
195+
arch_name=x64
196+
else
197+
arch_name=arm64
198+
fi
199+
200+
arch_dst=${dst/osx-universal2/osx-${arch_name}}
201+
thin_macos_tree "$dst" "$arch_dst" "$arch"
202+
tree "$arch_dst"
203+
tar cjvf ${arch_dst}.tar.bz2 ${arch_dst}
204+
205+
arch_lib_dst=${lib_dst/osx-universal2/osx-${arch_name}}
206+
thin_macos_tree "$lib_dst" "$arch_lib_dst" "$arch"
207+
tree "$arch_lib_dst"
208+
tar cjvf ${arch_lib_dst}.tar.bz2 ${arch_lib_dst}
209+
done
210+
166211
- name: Release pre-compiled binaries and libs for macOS
167-
if: matrix.build_type == 'Release' && (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
212+
if: github.repository_owner == 'csukuangfj' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
168213
uses: svenstaro/upload-release-action@v2
169214
with:
170215
file_glob: true
171216
overwrite: true
172-
file: sherpa-onnx-*osx-universal2*.tar.bz2
173-
# repo_name: k2-fsa/sherpa-onnx
174-
# repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
175-
# tag: v1.12.24
217+
file: sherpa-onnx-*.tar.bz2
218+
repo_name: k2-fsa/sherpa-onnx
219+
repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }}
220+
tag: v1.12.31
221+
222+
- name: Release pre-compiled binaries and libs for macOS
223+
if: github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.build_type == 'Release'
224+
uses: svenstaro/upload-release-action@v2
225+
with:
226+
file_glob: true
227+
overwrite: true
228+
file: sherpa-onnx-*.tar.bz2
176229

177230
- name: Test offline FireRedASR
178231
if: matrix.build_type != 'Debug'
@@ -338,5 +391,3 @@ jobs:
338391
export EXE=decode-file-c-api
339392
340393
.github/scripts/test-online-transducer.sh
341-
342-

0 commit comments

Comments
 (0)