Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/dotnet/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ macos-arm64
macos-x64
linux-x64
linux-arm64
android-arm64
windows-arm64
windows-x64
windows-x86
Expand Down
20 changes: 20 additions & 0 deletions scripts/dotnet/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ def get_dict():
}


def process_android(s, rid):
libs = [
"libonnxruntime.so",
"libsherpa-onnx-c-api.so",
]
prefix = f"{src_dir}/android-{rid}/"
libs = [prefix + lib for lib in libs]
libs = "\n ;".join(libs)

d = get_dict()
d["dotnet_rid"] = f"android-{rid}"
d["libs"] = libs

environment = jinja2.Environment()
template = environment.from_string(s)
s = template.render(**d)
with open(f"./android-{rid}/sherpa-onnx.runtime.csproj", "w") as f:
f.write(s)

def process_linux(s, rid):
libs = [
"libonnxruntime.so",
Expand Down Expand Up @@ -101,6 +120,7 @@ def main():
process_macos(s, "arm64")
process_linux(s, "x64")
process_linux(s, "arm64")
process_android(s, "arm64")
process_windows(s, "x64")
process_windows(s, "x86")
process_windows(s, "arm64")
Expand Down
69 changes: 33 additions & 36 deletions scripts/dotnet/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ 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
RIDS=(linux-x64 linux-arm64 android-arm64 macos-x64 macos-arm64 windows-x64 windows-x86 windows-arm64)

mkdir -p ${RIDS[@]}

linux_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_x86_64.whl
linux_x64_wheel=$src_dir/$linux_x64_wheel_filename

linux_arm64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-manylinux2014_aarch64.whl
linux_arm64_wheel=$src_dir/$linux_arm64_wheel_filename

android_arm64_tarball_filename=sherpa-onnx-v$SHERPA_ONNX_VERSION-android.tar.bz2
android_arm64_tarball=$src_dir/$android_arm64_tarball_filename

macos_x64_wheel_filename=sherpa_onnx_core-${SHERPA_ONNX_VERSION}-py3-none-macosx_10_15_x86_64.whl
macos_x64_wheel=$src_dir/$macos_x64_wheel_filename

Expand Down Expand Up @@ -83,6 +88,26 @@ if [ ! -f $src_dir/linux-arm64/libsherpa-onnx-c-api.so ]; then
cd ..
fi

if [ ! -f $src_dir/android-arm64/libsherpa-onnx-c-api.so ]; then
echo "---android arm64---"
cd android-arm64
mkdir -p tarball
cd tarball
if [ -f $android_arm64_tarball ]; then
cp -v $android_arm64_tarball .
else
curl -OL "https://github.com/k2-fsa/sherpa-onnx/releases/download/v$SHERPA_ONNX_VERSION/$android_arm64_tarball_filename"
fi
tar xjf $android_arm64_tarball_filename
cp -v jniLibs/arm64-v8a/lib{onnxruntime,sherpa-onnx-c-api}.so ../

cd ..

rm -rf tarball
ls -lh
cd ..
fi

if [ ! -f $src_dir/macos-x64/libsherpa-onnx-c-api.dylib ]; then
echo "--- macOS x86_64---"
cd macos-x64
Expand Down Expand Up @@ -182,46 +207,18 @@ fi

popd

mkdir -p macos-x64 macos-arm64 linux-x64 linux-arm64 windows-x64 windows-x86 windows-arm64 all
mkdir -p ${RIDS[@]} 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
for rid in "${RIDS[@]}"; do
pushd "$rid"
dotnet build -c Release
dotnet pack -c Release -o ../packages
popd
done

pushd all
dotnet build -c Release
Expand Down
5 changes: 3 additions & 2 deletions scripts/dotnet/sherpa-onnx.csproj.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<OutputType>Library</OutputType>
<LangVersion>10.0</LangVersion>
<TargetFrameworks>net8.0;net7.0;net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks>
<RuntimeIdentifiers>linux-x64;linux-arm64;osx-x64;osx-arm64;win-x64;win-x86;win-arm64</RuntimeIdentifiers>
<TargetFrameworks>net10.0;net8.0;net7.0;net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks>
<RuntimeIdentifiers>linux-x64;linux-arm64;android-arm64;osx-x64;osx-arm64;win-x64;win-x86;win-arm64</RuntimeIdentifiers>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>sherpa-onnx</AssemblyName>
<Version>{{ version }}</Version>
Expand Down Expand Up @@ -50,6 +50,7 @@
<ItemGroup>
<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.android-arm64" 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.win-x64" Version="{{ version }}" />
Expand Down
2 changes: 1 addition & 1 deletion scripts/dotnet/sherpa-onnx.csproj.runtime.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net7.0;net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net10.0;net8.0;net7.0;net6.0;net45;net40;net35;net20;netstandard2.0</TargetFrameworks>
<RuntimeIdentifier>{{ dotnet_rid }}</RuntimeIdentifier>
<AssemblyName>sherpa-onnx</AssemblyName>
<Version>{{ version }}</Version>
Expand Down