Skip to content

Commit 413af2f

Browse files
actions-commit-pr-dekiru-kun[bot]github-actions[bot]yamachu
authored
Update submodule (#152)
* Update submodule * make generate * 別のWorkflowで実体を使いたくなるので、unlinkする * libonnxruntimeもcacheしたりrestoreしたりする * このWorkflowから使いたいし、on: pull_requestにする * voicevox_coreをビルドした時に使われたonnxruntimeを使うようにする * dlopenで使うのはシステムの設定で、明示的にパスを渡さないと参照できないので、Defaultは使わずに使う時に明示する --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: yamachu <[email protected]>
1 parent 130dfd7 commit 413af2f

File tree

9 files changed

+60
-20
lines changed

9 files changed

+60
-20
lines changed

.github/composite/build-dev-rust/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ runs:
2424
shell: bash
2525
working-directory: ./binding
2626
run: make build/dev-library
27+
- if: ${{ steps.restore-dev-library.outputs.cache-hit != 'true' }}
28+
shell: bash
29+
working-directory: ./binding/voicevox_core/target/release
30+
# ライブラリのシンボリックリンクをコピーしてリンクを解除する
31+
run: |
32+
find . -type l | while read link; do
33+
target=$(readlink "$link")
34+
if [ -f "$target" ]; then
35+
cp "$target" "$link".tmp
36+
unlink "$link"
37+
mv "$link".tmp "$link"
38+
fi
39+
done
2740
- if: ${{ steps.restore-dev-library.outputs.cache-hit != 'true' }}
2841
uses: actions/cache/save@v4
2942
with:

.github/workflows/csharp_test.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CI
22

33
on:
4-
push:
4+
pull_request:
55
branches-ignore:
66
- 'auto.**'
77
workflow_call:
@@ -24,7 +24,9 @@ jobs:
2424
ref: ${{ inputs.checkout-ref || github.head_ref }}
2525
- uses: ./.github/composite/build-dev-rust
2626
with:
27-
cache-path: ./binding/voicevox_core/target/release/libvoicevox_core.so
27+
cache-path: |
28+
./binding/voicevox_core/target/release/libvoicevox_core.so
29+
./binding/voicevox_core/target/release/libonnxruntime.so
2830
cache-key: ${{ runner.os }}-dev-library-${{ hashFiles('**/Cargo.lock', '**/VoicevoxCoreSharp.Core.Metas.props') }}
2931

3032
test-dotnet:
@@ -40,9 +42,13 @@ jobs:
4042
dotnet-version: 6
4143
- uses: actions/cache/restore@v4
4244
with:
43-
path: ./binding/voicevox_core/target/release/libvoicevox_core.so
45+
path: |
46+
./binding/voicevox_core/target/release/libvoicevox_core.so
47+
./binding/voicevox_core/target/release/libonnxruntime.so
4448
key: ${{ runner.os }}-dev-library-${{ hashFiles('**/Cargo.lock', '**/VoicevoxCoreSharp.Core.Metas.props') }}
45-
- run: cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./tests/VoicevoxCoreSharp.Core.Tests/resources/libvoicevox_core.so
49+
- run: |
50+
cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./tests/VoicevoxCoreSharp.Core.Tests/resources/libvoicevox_core.so
51+
cp ./binding/voicevox_core/target/release/libonnxruntime.so ./tests/VoicevoxCoreSharp.Core.Tests/resources/libonnxruntime.so
4652
- uses: ./.github/composite/download-openjtalk-dict
4753
with:
4854
cache-path: open_jtalk_dic_utf_8-1.11.tar.gz
@@ -67,10 +73,14 @@ jobs:
6773
dotnet-version: 8
6874
- uses: actions/cache/restore@v4
6975
with:
70-
path: ./binding/voicevox_core/target/release/libvoicevox_core.so
76+
path: |
77+
./binding/voicevox_core/target/release/libvoicevox_core.so
78+
./binding/voicevox_core/target/release/libonnxruntime.so
7179
key: ${{ runner.os }}-dev-library-${{ hashFiles('**/Cargo.lock', '**/VoicevoxCoreSharp.Core.Metas.props') }}
7280
- run: mkdir -p ./examples/cli/voicevox_core
73-
- run: cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./examples/cli/voicevox_core/libvoicevox_core.so
81+
- run: |
82+
cp ./binding/voicevox_core/target/release/libvoicevox_core.so ./examples/cli/voicevox_core/libvoicevox_core.so
83+
cp ./binding/voicevox_core/target/release/libonnxruntime.so ./examples/cli/voicevox_core/libonnxruntime.so
7484
- uses: ./.github/composite/download-openjtalk-dict
7585
with:
7686
cache-path: open_jtalk_dic_utf_8-1.11.tar.gz

binding/voicevox_core

Submodule voicevox_core updated 39 files
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
33
<VoicevoxOnnxRuntimeVersion>1.17.3</VoicevoxOnnxRuntimeVersion>
4-
<VoicevoxCoreCommitHash>66582bd052a17c67ee77833d12ac531a4f1b158b</VoicevoxCoreCommitHash>
4+
<VoicevoxCoreCommitHash>ef66cc2958a143ff45ceb46e8ba84f91898d66bc</VoicevoxCoreCommitHash>
55
</PropertyGroup>
66
</Project>

tests/VoicevoxCoreSharp.Core.Tests/Helper.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.IO;
33
using System.Reflection;
4+
using System.Runtime.InteropServices;
45

56
namespace VoicevoxCoreSharp.Core.Tests
67
{
@@ -27,5 +28,16 @@ public static string GetTestResultsDirectory()
2728
{
2829
return Path.Combine(GetProjectDirectory(), "results");
2930
}
31+
32+
public static string GetOnnxruntimeAssemblyName()
33+
{
34+
return 0 switch
35+
{
36+
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.Windows) => "onnxruntime.dll",
37+
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.Linux) => "libonnxruntime.so",
38+
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.OSX) => "libonnxruntime.dylib",
39+
_ => throw new PlatformNotSupportedException()
40+
};
41+
}
3042
}
3143
}

tests/VoicevoxCoreSharp.Core.Tests/OnnxruntimeTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Runtime.InteropServices;
34
using VoicevoxCoreSharp.Core.Enum;
45
using VoicevoxCoreSharp.Core.Struct;
@@ -19,7 +20,7 @@ var _ when RuntimeInformation.IsOSPlatform(OSPlatform.Linux) => "libonnxruntime_
1920
var _ when RuntimeInformation.IsOSPlatform(OSPlatform.OSX) => "libonnxruntime_another_path.dylib",
2021
_ => throw new PlatformNotSupportedException()
2122
};
22-
var option = new LoadOnnxruntimeOptions(libraryPath);
23+
var option = new LoadOnnxruntimeOptions(Path.Join(AppContext.BaseDirectory, libraryPath));
2324
var result = Onnxruntime.LoadOnce(option, out var onnruntime);
2425

2526
Assert.Equal(ResultCode.RESULT_OK, result);

tests/VoicevoxCoreSharp.Core.Tests/SynthesizerTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using VoicevoxCoreSharp.Core.Enum;
34
using VoicevoxCoreSharp.Core.Struct;
45
using Xunit;
@@ -12,7 +13,7 @@ public void Tts()
1213
{
1314
OpenJtalk.New(Consts.OpenJTalkDictDir, out var openJtalk);
1415
var initializeOptions = InitializeOptions.Default();
15-
var onnxruntimeOptions = LoadOnnxruntimeOptions.Default();
16+
var onnxruntimeOptions = new LoadOnnxruntimeOptions(Path.Join(AppContext.BaseDirectory, Helper.GetOnnxruntimeAssemblyName()));
1617
if (Onnxruntime.LoadOnce(onnxruntimeOptions, out var onnruntime) != ResultCode.RESULT_OK)
1718
{
1819
Assert.Fail("Failed to initialize onnxruntime");

tests/VoicevoxCoreSharp.Core.Tests/UtilsTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using VoicevoxCoreSharp.Core.Enum;
34
using VoicevoxCoreSharp.Core.Struct;
45
using Xunit;
@@ -10,7 +11,7 @@ public class UtilsTest
1011
[Fact]
1112
public void CreateSupportedDevicesJson()
1213
{
13-
var option = LoadOnnxruntimeOptions.Default();
14+
var option = new LoadOnnxruntimeOptions(Path.Join(AppContext.BaseDirectory, Helper.GetOnnxruntimeAssemblyName()));
1415
if (Onnxruntime.LoadOnce(option, out var onnruntime) != ResultCode.RESULT_OK)
1516
{
1617
Assert.Fail("Failed to initialize onnxruntime");

tests/VoicevoxCoreSharp.Core.Tests/VoicevoxCoreSharp.Core.Tests.csproj

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<Import Project="..\..\src\VoicevoxCoreSharp.Core\VoicevoxCoreSharp.Core.Metas.props" />
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(VoicevoxOnnxRuntimeVersion)" />
1514
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1615
<PackageReference Include="xunit" Version="2.9.3" />
1716
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
@@ -66,18 +65,21 @@
6665
</ItemGroup>
6766

6867
<ItemGroup>
69-
<Content Include="resources\libvoicevox_core.dylib" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libvoicevox_core.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
70-
<Content Include="resources\libvoicevox_core.so" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libvoicevox_core.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
68+
<Content Include="resources\libvoicevox_core.dylib" TargetPath="libvoicevox_core.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
69+
<Content Include="resources\libvoicevox_core.so" TargetPath="libvoicevox_core.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
70+
<!-- CAUTION: Not tested on Windows, need help -->
7171
<Content Include="resources\voicevox_core.dll" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\voicevox_core.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
7272

73-
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.dylib" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.$(VoicevoxOnnxRuntimeVersion).dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
74-
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.so" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.so.$(VoicevoxOnnxRuntimeVersion)" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
75-
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime.dll" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime.$(VoicevoxOnnxRuntimeVersion).dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
73+
<Content Include="resources\libonnxruntime.dylib" TargetPath="libonnxruntime.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
74+
<Content Include="resources\libonnxruntime.so" TargetPath="libonnxruntime.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
75+
<!-- CAUTION: Not tested on Windows, need help -->
76+
<Content Include="resources\onnxruntime.dll" TargetPath="onnxruntime.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
7677

7778
<!-- for load testing -->
78-
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.dylib" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime_another_path.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
79-
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime.so" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\libonnxruntime_another_path.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
80-
<Content Include="$(OutputPath)runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime.dll" TargetPath="runtimes\$(_MyRuntimeIdentifier)\native\onnxruntime_another_path.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
79+
<Content Include="resources\libonnxruntime.dylib" TargetPath="libonnxruntime_another_path.dylib" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
80+
<Content Include="resources\libonnxruntime.so" TargetPath="libonnxruntime_another_path.so" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
81+
<!-- CAUTION: Not tested on Windows, need help -->
82+
<Content Include="resources\onnxruntime.dll" TargetPath="onnxruntime_another_path.dll" Visible="false" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOsPlatform('Windows'))" />
8183
</ItemGroup>
8284

8385
</Project>

0 commit comments

Comments
 (0)