Support linux-arm64 for .Net (#1092)
This commit is contained in:
@@ -34,23 +34,23 @@ def get_dict():
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def process_linux(s):
|
def process_linux(s, rid):
|
||||||
libs = [
|
libs = [
|
||||||
"libonnxruntime.so.1.17.1",
|
"libonnxruntime.so.1.17.1",
|
||||||
"libsherpa-onnx-c-api.so",
|
"libsherpa-onnx-c-api.so",
|
||||||
]
|
]
|
||||||
prefix = f"{src_dir}/linux/"
|
prefix = f"{src_dir}/linux-{rid}/"
|
||||||
libs = [prefix + lib for lib in libs]
|
libs = [prefix + lib for lib in libs]
|
||||||
libs = "\n ;".join(libs)
|
libs = "\n ;".join(libs)
|
||||||
|
|
||||||
d = get_dict()
|
d = get_dict()
|
||||||
d["dotnet_rid"] = "linux-x64"
|
d["dotnet_rid"] = f"linux-{rid}"
|
||||||
d["libs"] = libs
|
d["libs"] = libs
|
||||||
|
|
||||||
environment = jinja2.Environment()
|
environment = jinja2.Environment()
|
||||||
template = environment.from_string(s)
|
template = environment.from_string(s)
|
||||||
s = template.render(**d)
|
s = template.render(**d)
|
||||||
with open("./linux/sherpa-onnx.runtime.csproj", "w") as f:
|
with open(f"./linux-{rid}/sherpa-onnx.runtime.csproj", "w") as f:
|
||||||
f.write(s)
|
f.write(s)
|
||||||
|
|
||||||
|
|
||||||
@@ -101,7 +101,8 @@ def main():
|
|||||||
s = read_proj_file("./sherpa-onnx.csproj.runtime.in")
|
s = read_proj_file("./sherpa-onnx.csproj.runtime.in")
|
||||||
process_macos(s, "x64")
|
process_macos(s, "x64")
|
||||||
process_macos(s, "arm64")
|
process_macos(s, "arm64")
|
||||||
process_linux(s)
|
process_linux(s, "x64")
|
||||||
|
process_linux(s, "arm64")
|
||||||
process_windows(s, "x64")
|
process_windows(s, "x64")
|
||||||
process_windows(s, "x86")
|
process_windows(s, "x86")
|
||||||
process_windows(s, "arm64")
|
process_windows(s, "arm64")
|
||||||
|
|||||||
@@ -24,10 +24,13 @@ export src_dir
|
|||||||
mkdir -p $src_dir
|
mkdir -p $src_dir
|
||||||
pushd $src_dir
|
pushd $src_dir
|
||||||
|
|
||||||
mkdir -p linux macos-x64 macos-arm64 windows-x64 windows-x86 windows-arm64
|
mkdir -p linux-x64 linux-arm64 macos-x64 macos-arm64 windows-x64 windows-x86 windows-arm64
|
||||||
|
|
||||||
linux_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
linux_x64_wheel_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
linux_wheel=$src_dir/$linux_wheel_filename
|
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_filename=sherpa_onnx-${SHERPA_ONNX_VERSION}-cp39-cp39-macosx_11_0_x86_64.whl
|
||||||
macos_x64_wheel=$src_dir/$macos_x64_wheel_filename
|
macos_x64_wheel=$src_dir/$macos_x64_wheel_filename
|
||||||
@@ -44,17 +47,35 @@ 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_filename=sherpa-onnx-${SHERPA_ONNX_VERSION}-win-arm64.tar.bz2
|
||||||
windows_arm64_wheel=$src_dir/$windows_arm64_wheel_filename
|
windows_arm64_wheel=$src_dir/$windows_arm64_wheel_filename
|
||||||
|
|
||||||
if [ ! -f $src_dir/linux/libsherpa-onnx-c-api.so ]; then
|
if [ ! -f $src_dir/linux-x64/libsherpa-onnx-c-api.so ]; then
|
||||||
echo "---linux x86_64---"
|
echo "---linux x86_64---"
|
||||||
cd linux
|
cd linux-x64
|
||||||
mkdir -p wheel
|
mkdir -p wheel
|
||||||
cd wheel
|
cd wheel
|
||||||
if [ -f $linux_wheel ]; then
|
if [ -f $linux_x64_wheel ]; then
|
||||||
cp -v $linux_wheel .
|
cp -v $linux_x64_wheel .
|
||||||
else
|
else
|
||||||
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$linux_wheel_filename
|
curl -OL https://$HF_MIRROR/csukuangfj/sherpa-onnx-wheels/resolve/main/$linux_x64_wheel_filename
|
||||||
fi
|
fi
|
||||||
unzip $linux_wheel_filename
|
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/$linux_arm64_wheel_filename
|
||||||
|
fi
|
||||||
|
unzip $linux_arm64_wheel_filename
|
||||||
cp -v sherpa_onnx/lib/*.so* ../
|
cp -v sherpa_onnx/lib/*.so* ../
|
||||||
cd ..
|
cd ..
|
||||||
rm -rf wheel
|
rm -rf wheel
|
||||||
@@ -161,13 +182,18 @@ fi
|
|||||||
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
mkdir -p macos-x64 macos-arm64 linux windows-x64 windows-x86 windows-arm64 all
|
mkdir -p macos-x64 macos-arm64 linux-x64 linux-arm64 windows-x64 windows-x86 windows-arm64 all
|
||||||
|
|
||||||
cp ./*.cs all
|
cp ./*.cs all
|
||||||
|
|
||||||
./generate.py
|
./generate.py
|
||||||
|
|
||||||
pushd linux
|
pushd linux-x64
|
||||||
|
dotnet build -c Release
|
||||||
|
dotnet pack -c Release -o ../packages
|
||||||
|
popd
|
||||||
|
|
||||||
|
pushd linux-arm64
|
||||||
dotnet build -c Release
|
dotnet build -c Release
|
||||||
dotnet pack -c Release -o ../packages
|
dotnet pack -c Release -o ../packages
|
||||||
popd
|
popd
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
<TargetFrameworks>net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks>
|
||||||
<RuntimeIdentifiers>linux-x64;osx-x64;osx-arm64;win-x64;win-x86;win-arm64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>linux-x64;linux-arm64;osx-x64;osx-arm64;win-x64;win-x86;win-arm64</RuntimeIdentifiers>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<AssemblyName>sherpa-onnx</AssemblyName>
|
<AssemblyName>sherpa-onnx</AssemblyName>
|
||||||
<Version>{{ version }}</Version>
|
<Version>{{ version }}</Version>
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.linux-x64" Version="{{ version }}" />
|
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.linux-x64" Version="{{ version }}" />
|
||||||
|
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.linux-arm64" Version="{{ version }}" />
|
||||||
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.osx-x64" Version="{{ version }}" />
|
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.osx-x64" Version="{{ version }}" />
|
||||||
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.osx-arm64" Version="{{ version }}" />
|
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.osx-arm64" Version="{{ version }}" />
|
||||||
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.win-x64" Version="{{ version }}" />
|
<PackageReference Include="org.k2fsa.sherpa.onnx.runtime.win-x64" Version="{{ version }}" />
|
||||||
|
|||||||
Reference in New Issue
Block a user