run.sh
5.9 KB
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
#!/usr/bin/env bash
# Copyright (c) 2023 Xiaomi Corporation
set -ex
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd)
echo "SCRIPT_DIR: $SCRIPT_DIR"
echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR"
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" $SHERPA_ONNX_DIR/CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
# You can pre-download the required wheels to $src_dir
if [ $(hostname) == fangjuns-MacBook-Pro.local ]; then
HF_MIRROR=hf-mirror.com
src_dir=/Users/fangjun/open-source/sherpa-onnx/scripts/dotnet/tmp
else
src_dir=/tmp
HF_MIRROR=hf.co
fi
export src_dir
mkdir -p $src_dir
pushd $src_dir
mkdir -p linux-x64 linux-arm64 macos-x64 macos-arm64 windows-x64 windows-x86 windows-arm64
linux_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
linux_x64_wheel=$src_dir/$linux_x64_wheel_filename
linux_arm64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
linux_arm64_wheel=$src_dir/$linux_arm64_wheel_filename
macos_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
macos_x64_wheel=$src_dir/$macos_x64_wheel_filename
macos_arm64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_arm64.whl
macos_arm64_wheel=$src_dir/$macos_arm64_wheel_filename
windows_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-win_amd64.whl
windows_x64_wheel=$src_dir/$windows_x64_wheel_filename
windows_x86_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86.tar.bz2
windows_x86_wheel=$src_dir/$windows_x86_wheel_filename
windows_arm64_wheel_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2
windows_arm64_wheel=$src_dir/$windows_arm64_wheel_filename
if [ ! -f $src_dir/linux-x64/libsherpa-onnx-c-api.so ]; then
echo "---linux x86_64---"
cd linux-x64
mkdir -p wheel
cd wheel
if [ -f $linux_x64_wheel ]; then
cp -v $linux_x64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$linux_x64_wheel_filename
fi
unzip $linux_x64_wheel_filename
cp -v sherpa_onnx/lib/*.so* ../
cd ..
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/linux-arm64/libsherpa-onnx-c-api.so ]; then
echo "---linux arm64---"
cd linux-arm64
mkdir -p wheel
cd wheel
if [ -f $linux_arm64_wheel ]; then
cp -v $linux_arm64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$linux_arm64_wheel_filename
fi
unzip $linux_arm64_wheel_filename
cp -v sherpa_onnx/lib/*.so* ../
cd ..
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/macos-x64/libsherpa-onnx-c-api.dylib ]; then
echo "--- macOS x86_64---"
cd macos-x64
mkdir -p wheel
cd wheel
if [ -f $macos_x64_wheel ]; then
cp -v $macos_x64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$macos_x64_wheel_filename
fi
unzip $macos_x64_wheel_filename
cp -v sherpa_onnx/lib/*.dylib ../
cd ..
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/macos-arm64/libsherpa-onnx-c-api.dylib ]; then
echo "--- macOS arm64---"
cd macos-arm64
mkdir -p wheel
cd wheel
if [ -f $macos_arm64_wheel ]; then
cp -v $macos_arm64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$macos_arm64_wheel_filename
fi
unzip $macos_arm64_wheel_filename
cp -v sherpa_onnx/lib/*.dylib ../
cd ..
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/windows-x64/sherpa-onnx-c-api.dll ]; then
echo "---windows x64---"
cd windows-x64
mkdir -p wheel
cd wheel
if [ -f $windows_x64_wheel ]; then
cp -v $windows_x64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/cpu/$SHERPA_ONNX_VERSION/$windows_x64_wheel_filename
fi
unzip $windows_x64_wheel_filename
cp -v sherpa_onnx-${SHERPA_ONNX_VERSION}.data/data/bin/*.dll ../
cd ..
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/windows-x86/sherpa-onnx-c-api.dll ]; then
echo "---windows x86---"
cd windows-x86
mkdir -p wheel
cd wheel
if [ -f $windows_x86_wheel ]; then
cp -v $windows_x86_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-libs/resolve/main/windows-for-dotnet/$windows_x86_wheel_filename
fi
tar xvf $windows_x86_wheel_filename
cp -v sherpa-onnx-${SHERPA_ONNX_VERSION}-win-x86/*dll ../
cd ..
rm -rf wheel
ls -lh
cd ..
fi
if [ ! -f $src_dir/windows-arm64/sherpa-onnx-c-api.dll ]; then
echo "---windows arm64---"
cd windows-arm64
mkdir -p wheel
cd wheel
if [ -f $windows_arm64_wheel ]; then
cp -v $windows_arm64_wheel .
else
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-libs/resolve/main/windows-for-dotnet/$windows_arm64_wheel_filename
fi
tar xvf $windows_arm64_wheel_filename
cp -v sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64/*dll ../
cd ..
rm -rf wheel
ls -lh
cd ..
fi
popd
mkdir -p macos-x64 macos-arm64 linux-x64 linux-arm64 windows-x64 windows-x86 windows-arm64 all
cp ./*.cs all
./generate.py
pushd linux-x64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd linux-arm64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd macos-x64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd macos-arm64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd windows-x64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd windows-x86
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd windows-arm64
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
pushd all
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
ls -lh packages
mkdir -p /tmp/packages
cp -v packages/*.nupkg /tmp/packages