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

feat(java)!: com.microsoft.onnxruntime/onnxruntime{,_gpu}を削除 #860

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
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ jobs:
cp ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/x86_64/

cd crates/voicevox_core_java_api
OS=android DEVICE=cpu gradle publishToMavenLocal
OS=android gradle publishToMavenLocal

- name: Package
run: |
Expand Down
6 changes: 2 additions & 4 deletions crates/voicevox_core_java_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Java プロジェクトを動かすには、
- `lib/src/main/resources/dll/[target]/libvoicevox_core_java_api.so` を作成する(`libvoicevox_core_java_api.so`はプラットフォームによって異なります、詳細は後述)。

必要があります。
また、ハードウェアアクセラレーションを有効にする時は`DEVICE`環境変数を`cuda`または`directml`にし、Android 版をビルドする時は`OS`環境変数を`android`にしてください。
また、Android 版をビルドする時は`OS`環境変数を`android`にしてください。

```console
❯ cargo build
Expand All @@ -53,21 +53,19 @@ Java プロジェクトを動かすには、
# または
❯ cp ../../target/debug/libvoicevox_core_java_api.so lib/src/main/resources/dll/[target]/libvoicevox_core_java_api.so
❯ ./gradlew test
❯ DEVICE=cuda ./gradlew test
❯ OS=android ./gradlew test
```

## ビルド(リリース)

`cargo build --release` で Rust 側を、`./gradlew build` で Java 側をビルドできます。
パッケージ化する時は lib/src/main/resources/dll 内に dll をコピーしてください。
`DEVICE`、`OS`環境変数は開発時と同様です。
`OS`環境変数は開発時と同様です。

```console
❯ cargo build --release
❯ cp ../../target/release/libvoicevox_core_java_api.so lib/src/main/resources/dll/[target]/libvoicevox_core_java_api.so
❯ ./gradlew build
❯ DEVICE=cuda ./gradlew build
❯ OS=android ./gradlew build
```

Expand Down
4 changes: 1 addition & 3 deletions crates/voicevox_core_java_api/lib/build-android.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ dependencies {

// https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: gradle.ext.jakartaAnnotationVersion

implementation group: 'com.microsoft.onnxruntime', name: 'onnxruntime-android', version: gradle.ext.onnxruntimeVersion
}

// Apply a specific Java toolchain to ease working on different environments.
Expand Down Expand Up @@ -65,7 +63,7 @@ publishing {
publications {
maven(MavenPublication) {
groupId = 'jp.hiroshiba.voicevoxcore'
artifactId = gradle.ext.targetDevice == 'cpu' ? 'voicevoxcore-android' : "voicevoxcore-android-${gradle.ext.targetDevice}"
artifactId = 'voicevoxcore-android'
version = gradle.ext.version

afterEvaluate {
Expand Down
10 changes: 1 addition & 9 deletions crates/voicevox_core_java_api/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ plugins {
id "com.diffplug.spotless" version "6.25.0"
}

def boolean isGpu = ['cuda', 'directml'].contains(gradle.ext.targetDevice)

version = gradle.ext.version

repositories {
Expand All @@ -35,12 +33,6 @@ dependencies {

// https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: gradle.ext.jakartaAnnotationVersion

if (isGpu) {
implementation group: 'com.microsoft.onnxruntime', name: 'onnxruntime_gpu', version: gradle.ext.onnxruntimeVersion
} else {
implementation group: 'com.microsoft.onnxruntime', name: 'onnxruntime', version: gradle.ext.onnxruntimeVersion
}
}

// Apply a specific Java toolchain to ease working on different environments.
Expand Down Expand Up @@ -70,7 +62,7 @@ publishing {
publications {
maven(MavenPublication) {
groupId = 'jp.hiroshiba.voicevoxcore'
artifactId = gradle.ext.targetDevice == 'cpu' ? 'voicevoxcore' : "voicevoxcore-${gradle.ext.targetDevice}"
artifactId = 'voicevoxcore'
version = gradle.ext.version
from components.java
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jp.hiroshiba.voicevoxcore;

import ai.onnxruntime.OrtEnvironment;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -42,8 +41,6 @@ abstract class Dll {
}

String target = osName + "-" + osArch;
// ONNX Runtime の DLL を読み込む。
OrtEnvironment.getEnvironment();
try (InputStream in = Dll.class.getResourceAsStream("/dll/" + target + "/" + dllName)) {
if (in == null) {
try {
Expand Down
1 change: 0 additions & 1 deletion crates/voicevox_core_java_api/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ gradle.ext {
version = cargoTomlVersion

targetOs = targetOs
targetDevice = System.getenv('DEVICE') ?: 'cpu'

gsonVersion = '2.10.1'
jakartaValidationVersion = '3.0.2'
Expand Down
Loading