Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .Net #190

Merged
merged 41 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2b791ea
begin to add C# API
csukuangfj Apr 25, 2023
bcdd25c
small fixes
csukuangfj Apr 25, 2023
474fb60
Add example
csukuangfj Apr 25, 2023
5abb169
Add readme
csukuangfj Apr 25, 2023
216801b
Update README
csukuangfj Apr 25, 2023
b4a81eb
add csharp test
csukuangfj Apr 25, 2023
a9819ec
minor fixes
csukuangfj Apr 25, 2023
fc69d88
small fixes
csukuangfj Apr 25, 2023
c99a32b
small fixes
csukuangfj Apr 25, 2023
a73f1e0
small fixes
csukuangfj Apr 26, 2023
be748bd
Use HandleRef
csukuangfj Apr 26, 2023
c661277
more fixes
csukuangfj Apr 26, 2023
c93b800
Fix for macOS
csukuangfj May 2, 2023
512e61d
Rename
csukuangfj May 2, 2023
91c011a
Build Nuget packages on macOS
csukuangfj May 2, 2023
86bb060
add license
csukuangfj May 2, 2023
cc49632
update to 1.8.2
csukuangfj May 2, 2023
e21883d
refactor
csukuangfj May 2, 2023
59f1c00
update notes
csukuangfj May 2, 2023
ff15f09
add CI for linux
csukuangfj May 2, 2023
03408fd
add more CIs
csukuangfj May 2, 2023
3dcd83d
rename
csukuangfj May 2, 2023
5ba1bc1
fix windows
csukuangfj May 2, 2023
88d3ef7
small fixes
csukuangfj May 2, 2023
938bebf
add dotnet examples
csukuangfj May 2, 2023
c5db4a2
remove cshar-api-examples
csukuangfj May 2, 2023
a43eeb0
small fixes
csukuangfj May 2, 2023
8f061eb
small fixes
csukuangfj May 2, 2023
635cbf6
Add dotnet test
csukuangfj May 2, 2023
931d884
Merge remote-tracking branch 'dan/master' into csharp-api
csukuangfj May 2, 2023
b033816
small fixes
csukuangfj May 2, 2023
7c18a45
minor fixes
csukuangfj May 2, 2023
776854f
typo fixes
csukuangfj May 2, 2023
d835b76
minor fixes
csukuangfj May 2, 2023
5de5c0a
fix building nuget packages
csukuangfj May 2, 2023
5e2a9a6
small fixes
csukuangfj May 2, 2023
b2dbf8e
minor fixes
csukuangfj May 3, 2023
8260d69
release v1.8.4
csukuangfj May 3, 2023
61ce837
fix building
csukuangfj May 3, 2023
2f4b376
release v1.8.5
csukuangfj May 3, 2023
3965594
Small fixes
csukuangfj May 3, 2023
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
98 changes: 98 additions & 0 deletions .github/workflows/csharp-api-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: swift-api-test

on:
push:
branches:
- master
- csharp-api
paths:
- '.github/workflows/csharp-api-test.yaml'
- '.github/scripts/csharp-api-test.sh'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-ncnn/csrc/*'
- 'sherpa-ncnn/csharp-api/*'
- 'sherpa-ncnn/c-api/*'
- 'sherpa-ncnn/csharp-api-examples/*'
pull_request:
branches:
- master
paths:
- '.github/workflows/swift-api-test.yaml'
- '.github/scripts/swift-api-test.sh'
- 'CMakeLists.txt'
- 'cmake/**'
- 'sherpa-ncnn/csrc/*'
- 'sherpa-ncnn/csharp-api/*'
- 'sherpa-ncnn/c-api/*'
- 'sherpa-ncnn/csharp-api-examples/*'

concurrency:
group: csharp-api-test-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
csharp-api-test:
runs-on: ${{ matrix.os }}
name: ${{ matrix.vs-version }}
strategy:
fail-fast: false
matrix:
include:
- vs-version: vs2015
toolset-version: v140
os: windows-2019

- vs-version: vs2017
toolset-version: v141
os: windows-2019

- vs-version: vs2019
toolset-version: v142
os: windows-2022

- vs-version: vs2022
toolset-version: v143
os: windows-2022

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: true

- name: Configure CMake
shell: bash
run: |
mkdir build
cd build
cmake \
-T ${{ matrix.toolset-version}},host=x64 \
-A x64 \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_SHARED_LIBS=ON \
..

- name: Build sherpa-ncnn for windows
shell: bash
run: |
cd build
cmake --build . --config Release --target sherpa-ncnn-c-api -v

- name: Build C# exe
shell: bash
run: |
export PATH=$PWD/build/bin/Release:$PATH

csc ./csharp-api-examples/WaveReader.cs ./csharp-api-examples/DecodeFile.cs ./sherpa-ncnn/csharp-api/SherpaNcnn.cs
ls -lh ./DecodeFile.exe
./DecodeFile.exe

76 changes: 76 additions & 0 deletions .github/workflows/dot-net-linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: dot-net-linux

on:
push:
branches:
- dot-net
tags:
- '*'

concurrency:
group: dot-net-linux-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
dot-net-linux:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Check dotnet
run: dotnet --info

- name: Configure CMake
shell: bash
run: |
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DSHERPA_NCNN_ENABLE_DOT_NET_API=ON -DSHERPA_NCNN_ENABLE_C_API=ON -DSHERPA_NCNN_ENABLE_PORTAUDIO=OFF ..

- name: Build sherpa-ncnn for ubuntu
run: |
cd build
make sherpa-ncnn-native-dot-net-package

ls -lh packages

- name: Display .Net packages
run: |
cd build
ls -lh packages

- name: Upload .Net packages sherpa-ncnn
uses: actions/upload-artifact@v2
with:
name: sherpa-ncnn-pre-built-dot-net-packages-os-${{ matrix.os }}
path: ./build/packages

- name: publish .Net packages to nuget.org
if: github.repository == 'csukuangfj/sherpa-ncnn' || github.repository == 'k2-fsa/sherpa-ncnn'
shell: bash
env:
API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
# API_KEY is valid until 2024.05.02
cd build/packages
dotnet nuget push ./org.k2fsa.sherpa.ncnn.runtime.*.nupkg --api-key $API_KEY --source https://api.nuget.org/v3/index.json
77 changes: 77 additions & 0 deletions .github/workflows/dot-net-macos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: dot-net-macos

on:
push:
branches:
- dot-net
tags:
- '*'

concurrency:
group: dot-net-macos-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
dot-net-macos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Check dotnet
run: dotnet --info

- name: Configure CMake
shell: bash
run: |
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DSHERPA_NCNN_ENABLE_DOT_NET_API=ON -DSHERPA_NCNN_ENABLE_C_API=ON -DSHERPA_NCNN_ENABLE_PORTAUDIO=OFF ..

- name: Build sherpa-ncnn for macOS
shell: bash
run: |
cd build
make sherpa-ncnn-native-dot-net-package

ls -lh packages

- name: Display .Net packages
run: |
cd build
ls -lh packages

- name: Upload .Net packages sherpa-ncnn
uses: actions/upload-artifact@v2
with:
name: sherpa-ncnn-pre-built-dot-net-packages-os-${{ matrix.os }}
path: ./build/packages

- name: publish .Net packages to nuget.org
if: github.repository == 'csukuangfj/sherpa-ncnn' || github.repository == 'k2-fsa/sherpa-ncnn'
shell: bash
env:
API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
# API_KEY is valid until 2024.05.02
cd build/packages
dotnet nuget push ./org.k2fsa.sherpa.ncnn.runtime.*.nupkg --api-key $API_KEY --source https://api.nuget.org/v3/index.json
82 changes: 82 additions & 0 deletions .github/workflows/dot-net-windows-x64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: dot-net-windows-x64

on:
push:
branches:
- dot-net
tags:
- '*'

concurrency:
group: dot-net-windows-x64-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
dot-net-windows-x64:
runs-on: ${{ matrix.os }}
name: ${{ matrix.vs-version }}
strategy:
fail-fast: false
matrix:
include:
- vs-version: vs2015
toolset-version: v140
os: windows-2019

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x

- name: Setup .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: Check dotnet
run: dotnet --info

- name: Configure CMake
shell: bash
run: |
mkdir build
cd build
cmake -T ${{ matrix.toolset-version}},host=x64 -A x64 -D CMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DSHERPA_NCNN_ENABLE_DOT_NET_API=ON -DSHERPA_NCNN_ENABLE_C_API=ON -DSHERPA_NCNN_ENABLE_PORTAUDIO=OFF ..

- name: Build sherpa-ncnn for windows x64
shell: bash
run: |
cd build
cmake --build . --config Release --target sherpa-ncnn-native-dot-net-package

ls -lh packages

- name: Display .Net packages
shell: bash
run: |
cd build
ls -lh packages

- name: Upload .Net packages sherpa-ncnn
uses: actions/upload-artifact@v2
with:
name: sherpa-ncnn-pre-built-dot-net-packages-os-${{ matrix.os }}
path: ./build/packages

- name: publish .Net packages to nuget.org
if: github.repository == 'csukuangfj/sherpa-ncnn' || github.repository == 'k2-fsa/sherpa-ncnn'
shell: bash
env:
API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
# API_KEY is valid until 2024.05.02
cd build/packages
dotnet nuget push ./org.k2fsa.sherpa.ncnn.runtime.*.nupkg --api-key $API_KEY --source https://api.nuget.org/v3/index.json
2 changes: 1 addition & 1 deletion .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
cd build
cmake -D CMAKE_BUILD_TYPE=Release -DSHERPA_NCNN_ENABLE_FFMPEG_EXAMPLES=OFF ..

- name: Build sherpa for ubuntu
- name: Build sherpa-ncnn for ubuntu
run: |
cd build
make -j2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
cd build
cmake -D CMAKE_BUILD_TYPE=Release ..

- name: Build sherpa for macos
- name: Build sherpa-ncnn for macos
run: |
cd build
make -j2
Expand Down
Loading