-
Notifications
You must be signed in to change notification settings - Fork 451
372 lines (309 loc) · 10.4 KB
/
lazarus.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
name: lazarus
on:
push:
branches:
- master
- lazarus
paths:
- '.github/workflows/lazarus.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'lazarus-examples/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'sherpa-onnx/pascal-api/*'
- 'scripts/lazarus/*'
pull_request:
branches:
- master
paths:
- '.github/workflows/lazarus.yaml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'lazarus-examples/**'
- 'sherpa-onnx/csrc/*'
- 'sherpa-onnx/c-api/*'
- 'sherpa-onnx/pascal-api/*'
- 'scripts/lazarus/*'
workflow_dispatch:
concurrency:
group: lazarus-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest, macos-13, windows-latest]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}
# See https://github.com/gcarreno/setup-lazarus
- uses: gcarreno/setup-lazarus@v3
with:
lazarus-version: "stable"
with-cache: true
- name: Lazarus info
shell: bash
run: |
which lazbuild
lazbuild --help
- name: FPC info
shell: bash
run: |
which fpc
fpc -i
- name: OS info
shell: bash
run: |
uname -a
- name: Install patchelf for ubuntu
if: matrix.os == 'ubuntu-20.04'
shell: bash
run: |
sudo apt-get update -q
sudo apt-get install -q -y patchelf
- name: Show Patchelf version (ubuntu)
if: matrix.os == 'ubuntu-20.04'
shell: bash
run: |
patchelf --version
patchelf --help
which patchelf
- name: Configure CMake
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
mkdir build
cd build
os=${{ matrix.os }}
if [[ $os == 'windows-latest' || $os == 'ubuntu-20.04' ]]; then
BUILD_SHARED_LIBS=ON
else
BUILD_SHARED_LIBS=OFF
fi
cmake \
-DCMAKE_INSTALL_PREFIX=./install \
-D BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS \
-D SHERPA_ONNX_ENABLE_BINARY=OFF \
-D CMAKE_BUILD_TYPE=Release \
..
- name: Build sherpa-onnx
shell: bash
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cd build
cmake --build . --target install --config Release -j 2
ls -lh install/lib/
cp -v install/lib/*.dll ../lazarus-examples/generate_subtitles/ || true
cp -v install/lib/*.so* ../lazarus-examples/generate_subtitles/ || true
- name: Build generating subtitles
shell: bash
run: |
cd lazarus-examples/generate_subtitles
os=${{ matrix.os }}
if [[ $os == macos-13 ]]; then
lazbuild --verbose --build-mode=Release --widgetset=cocoa ./generate_subtitles.lpi
elif [[ $os == macos-latest ]]; then
lazbuild --verbose --build-mode=Release --widgetset=cocoa --cpu=aarch64 ./generate_subtitles.lpi
elif [[ $os == 'ubuntu-20.04' ]]; then
lazbuild --verbose --build-mode=Release-Linux ./generate_subtitles.lpi
else
lazbuild --verbose --build-mode=Release ./generate_subtitles.lpi
fi
- name: Display generating subtitles
shell: bash
run: |
cd lazarus-examples/generate_subtitles
ls -lh
- name: Collect generating subtitles (Ubuntu)
if: matrix.os == 'ubuntu-20.04'
shell: bash
run: |
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
cd lazarus-examples/generate_subtitles
ls -lh
readelf -d ./generate_subtitles
echo '----------'
ldd ./generate_subtitles
d=generate_subtitles-linux-x64-$SHERPA_ONNX_VERSION
echo "---before running patchelf---"
readelf -d ./generate_subtitles
patchelf --set-rpath '$ORIGIN' ./generate_subtitles
echo "---after running patchelf---"
readelf -d ./generate_subtitles
mkdir -p $d
cp -v ./generate_subtitles $d/
cp -v *.so $d/
mv -v $d /tmp/linux-x64
ls -lh /tmp/linux-x64
- name: Collect generating subtitles (windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
cd lazarus-examples/generate_subtitles
ls -lh
d=generate-subtitles-windows-x64-$SHERPA_ONNX_VERSION
mkdir -p $d
cp -v ./generate_subtitles.exe $d/
cp -v onnxruntime.dll $d/
cp -v sherpa-onnx-c-api.dll $d/
mv $d ../../windows-x64
cd ../..
ls -lh windows-x64
- name: Collect generating subtitles (macos)
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
shell: bash
run: |
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
cd lazarus-examples/generate_subtitles
ls -lh
file ./generate_subtitles
echo '----------'
otool -L ./generate_subtitles
rm -v generate_subtitles.app/Contents/MacOS/generate_subtitles
cp -v ./generate_subtitles generate_subtitles.app/Contents/MacOS/generate_subtitles
chmod +x generate_subtitles.app/Contents/MacOS/generate_subtitles
if [[ ${{ matrix.os }} == 'macos-latest' ]]; then
mv generate_subtitles.app /tmp/macos-arm64
else
mv generate_subtitles.app /tmp/macos-x64
d=generate-subtitles-macos-x64-$SHERPA_ONNX_VERSION.app
fi
ls -lh /tmp
echo "---"
ls -lh /tmp/macos-*
- uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-20.04'
with:
name: linux-x64
path: /tmp/linux-x64
- uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: macos-arm64
path: /tmp/macos-arm64
- uses: actions/upload-artifact@v4
if: matrix.os == 'macos-13'
with:
name: macos-x64
path: /tmp/macos-x64
- uses: actions/upload-artifact@v4
if: matrix.os == 'windows-latest'
with:
name: windows-x64
path: ./windows-x64
release:
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
total: ["2"]
index: ["0", "1"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve artifact from windows x64
uses: actions/download-artifact@v4
with:
name: windows-x64
path: /tmp/windows-x64
- name: Retrieve artifact from linux x64
uses: actions/download-artifact@v4
with:
name: linux-x64
path: /tmp/linux-x64
- name: Retrieve artifact from macos x64
uses: actions/download-artifact@v4
with:
name: macos-x64
path: /tmp/macos-x64
- name: Retrieve artifact from macos arm64
uses: actions/download-artifact@v4
with:
name: macos-arm64
path: /tmp/macos-arm64
- name: Display build files
shell: bash
run: |
ls -lh /tmp
echo "---linux-x64---"
ls -lh /tmp/linux-x64/
readelf -d /tmp/linux-x64/generate_subtitles
echo "---"
ldd /tmp/linux-x64/generate_subtitles
echo "---macos-x64---"
ls -lh /tmp/macos-x64/
mkdir -p /tmp/macos-x64/Contents/Resources
chmod +x /tmp/macos-x64/Contents/MacOS/generate_subtitles
echo "---macos-arm64---"
ls -lh /tmp/macos-arm64/
mkdir -p /tmp/macos-arm64/Contents/Resources
chmod +x /tmp/macos-arm64/Contents/MacOS/generate_subtitles
echo "---windows-x64---"
ls -lh /tmp/windows-x64/
- name: Install Python dependencies
shell: bash
run: |
python3 -m pip install --upgrade pip jinja2
- name: Generate build script
shell: bash
run: |
cd scripts/lazarus
total=${{ matrix.total }}
index=${{ matrix.index }}
./generate-subtitles.py --total $total --index $index
chmod +x build-generate-subtitles.sh
mv -v ./build-generate-subtitles.sh ../..
- name: Generate tar files
shell: bash
run: |
./build-generate-subtitles.sh
- name: Display tar files
shell: bash
run: |
ls -lh /tmp/out
- name: Publish to huggingface
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v3
with:
max_attempts: 20
timeout_seconds: 200
shell: bash
command: |
git config --global user.email "[email protected]"
git config --global user.name "Fangjun Kuang"
rm -rf huggingface
export GIT_LFS_SKIP_SMUDGE=1
export GIT_CLONE_PROTECTION_ACTIVE=false
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
echo "SHERPA_ONNX_VERSION $SHERPA_ONNX_VERSION"
git clone https://huggingface.co/csukuangfj/sherpa-onnx-bin huggingface
cd huggingface
git fetch
git pull
git merge -m "merge remote" --ff origin main
d=generate-subtitles/$SHERPA_ONNX_VERSION
mkdir -p $d
cp -v /tmp/out/*.tar.bz2 $d/
git status
git lfs track "*.tar.bz2"
git add .
git commit -m "add more files"
git push https://csukuangfj:[email protected]/csukuangfj/sherpa-onnx-bin main