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

Add: Java APIのPC用ビルドを追加 #764

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4b691cf
Add: Java APIのPC用ビルドを追加
sevenc-nanashi Mar 21, 2024
df222c8
Change: artifact系をv4に揃える
sevenc-nanashi Mar 21, 2024
a2a6ac6
Fix: name -> pattern
sevenc-nanashi Mar 23, 2024
1dfa267
Fix: cwdを修正
sevenc-nanashi Mar 23, 2024
05fbb49
Fix: パスを修正
sevenc-nanashi Mar 23, 2024
f862b0d
Fix: パスを修正
sevenc-nanashi Mar 23, 2024
86c0ee5
Change: directmlとcudaで分ける
sevenc-nanashi Mar 23, 2024
0d4ac2f
Fix: DEVICE周りを修正
sevenc-nanashi Mar 25, 2024
223d722
Fix: actionlintにひっかかってたので修正
sevenc-nanashi Mar 25, 2024
ba545fa
Fix: 否定の表記を${{ }}のに変える
sevenc-nanashi Mar 30, 2024
c8086ab
Change: setup_dllを解体する
sevenc-nanashi Mar 30, 2024
67677c7
Fix: shellcheckに引っかかっていたのを直す
sevenc-nanashi Mar 30, 2024
da8cf4d
Add: チェックを追加
sevenc-nanashi Mar 30, 2024
29883a8
Fix: -cudaじゃなく-gpuだった
sevenc-nanashi Mar 30, 2024
2966c1f
Apply suggestions from code review
Hiroshiba Apr 14, 2024
2a9f8af
Change: caseで書きかえる
sevenc-nanashi Apr 17, 2024
cb1ae01
Fix: mkdir忘れ
sevenc-nanashi Apr 17, 2024
5db8a70
Merge: upstream/main -> add/java-desktop-build
sevenc-nanashi Apr 17, 2024
8d5633b
Fix: targetじゃなくてartifact_nameだった
sevenc-nanashi Apr 17, 2024
2a648f9
Merge: main -> add/java-desktop-build
sevenc-nanashi May 19, 2024
e479d58
Merge branch 'main' into add/java-desktop-build
sevenc-nanashi Oct 1, 2024
030c36e
Change: javaをmatrixに生やしてそっちを使う
sevenc-nanashi Oct 3, 2024
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
122 changes: 86 additions & 36 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
"artifact_name": "windows-x64",
"c_release_format": "plain-cdylib",
"python_whl": true,
"java": true,
"can_skip_in_simple_test": false
},
{
Expand All @@ -73,6 +74,7 @@ jobs:
"artifact_name": "windows-x86",
"c_release_format": "plain-cdylib",
"python_whl": true,
"java": true,
"can_skip_in_simple_test": true
},
{
Expand All @@ -81,6 +83,7 @@ jobs:
"artifact_name": "linux-x64",
"c_release_format": "plain-cdylib",
"python_whl": true,
"java": true,
"can_skip_in_simple_test": false
},
{
Expand All @@ -89,6 +92,7 @@ jobs:
"artifact_name": "linux-arm64",
"c_release_format": "plain-cdylib",
"python_whl": true,
"java": true,
"can_skip_in_simple_test": true
},
{
Expand All @@ -97,6 +101,7 @@ jobs:
"artifact_name": "android-arm64",
"c_release_format": "plain-cdylib",
"python_whl": false,
"java": true,
"can_skip_in_simple_test": true
},
{
Expand All @@ -105,6 +110,7 @@ jobs:
"artifact_name": "android-x86_64",
"c_release_format": "plain-cdylib",
"python_whl": false,
"java": true,
"can_skip_in_simple_test": true
},
{
Expand All @@ -113,6 +119,7 @@ jobs:
"artifact_name": "osx-arm64",
"c_release_format": "plain-cdylib",
"python_whl": true,
"java": true,
"can_skip_in_simple_test": false
},
{
Expand All @@ -121,6 +128,7 @@ jobs:
"artifact_name": "osx-x64",
"c_release_format": "plain-cdylib",
"python_whl": true,
"java": true,
"can_skip_in_simple_test": true
},
{
Expand All @@ -129,6 +137,7 @@ jobs:
"artifact_name": "ios-arm64-cpu",
"c_release_format": "ios-xcframework",
"python_whl": false,
"java": false,
"can_skip_in_simple_test": true
},
{
Expand All @@ -137,6 +146,7 @@ jobs:
"artifact_name": "ios-arm64-cpu-sim",
"c_release_format": "ios-xcframework",
"python_whl": false,
"java": false,
"can_skip_in_simple_test": true
},
{
Expand All @@ -145,6 +155,7 @@ jobs:
"artifact_name": "ios-x64-cpu",
"c_release_format": "ios-xcframework",
"python_whl": false,
"java": false,
"can_skip_in_simple_test": true
}
]'
Expand Down Expand Up @@ -213,11 +224,10 @@ jobs:
repository: VOICEVOX/voicevox_resource
ref: ${{ env.VOICEVOX_RESOURCE_VERSION }}
path: download/resource
- name: Raplace resource
- name: Replace resource
if: inputs.is_production
shell: bash
run:
mv -f download/resource/core/README.md ./README.md
run: mv -f download/resource/core/README.md ./README.md
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cargo-edit
Expand Down Expand Up @@ -264,7 +274,7 @@ jobs:
fi
echo "whl=$(find ./target/wheels -type f)" >> "$GITHUB_OUTPUT"
- name: build voicevox_core_java_api
if: contains(matrix.target, 'android')
if: ${{ matrix.java }}
run: |
function build() {
cargo build -p voicevox_core_java_api -vv --target ${{ matrix.target }} --release
Expand All @@ -289,11 +299,10 @@ jobs:
echo "${{ env.VERSION }}" > "artifact/${{ env.ASSET_NAME }}/VERSION"

mkdir java_artifact
cp -v target/${{ matrix.target }}/release/libvoicevox_core_java_api.so java_artifact/ || true
cp -v target/${{ matrix.target }}/release/*voicevox_core_java_api.{dll,so,dylib} "java_artifact" || true
- name: Code signing (Windows)
if: startsWith(matrix.os, 'windows') && inputs.code_signing
run:
bash build_util/codesign.bash "artifact/${{ env.ASSET_NAME }}/voicevox_core.dll"
run: bash build_util/codesign.bash "artifact/${{ env.ASSET_NAME }}/voicevox_core.dll"
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
Expand Down Expand Up @@ -327,7 +336,7 @@ jobs:
${{ steps.build-voicevox-core-python-api.outputs.whl }}
target_commitish: ${{ github.sha }}
- name: Upload voicevox_core_java_api artifact
if: fromJson(needs.config.outputs.deploy) && contains(matrix.target, 'android')
if: fromJson(needs.config.outputs.deploy) && matrix.java
uses: actions/upload-artifact@v4
with:
name: voicevox_core_java_api-${{ matrix.artifact_name }}
Expand Down Expand Up @@ -391,11 +400,10 @@ jobs:
repository: VOICEVOX/voicevox_fat_resource
ref: ${{ env.VOICEVOX_FAT_RESOURCE_VERSION }}
path: download/fat_resource
- name: Raplace resource
- name: Replace resource
if: inputs.is_production
shell: bash
run:
rm -r ./model; mv download/fat_resource/core/model ./model
run: rm -r ./model; mv download/fat_resource/core/model ./model
- name: Create artifact
run: |
mkdir "artifact"
Expand Down Expand Up @@ -436,40 +444,82 @@ jobs:
- name: Install cargo-edit
run: cargo binstall cargo-edit@^0.11 --no-confirm
- name: set cargo version
run:
cargo set-version "$VERSION" -p voicevox_core_java_api
run: cargo set-version "$VERSION" -p voicevox_core_java_api

- name: "Download artifact (android-arm64)"
- name: "Download artifact"
uses: actions/download-artifact@v4
with:
name: voicevox_core_java_api-android-arm64
path: artifact/android-arm64

- name: "Download artifact (android-x86_64)"
uses: actions/download-artifact@v4
with:
name: voicevox_core_java_api-android-x86_64
path: artifact/android-x86_64
pattern: voicevox_core_java_api-*
path: artifacts/

- name: Print tree
run: tree artifact
run: tree artifacts

- name: Build voicevoxcore-android
- name: Build voicevoxcore
run: |
rm -rf crates/voicevox_core_java_api/lib/src/main/resources/dll
cat <<EOF | while read -r line; do
android-arm64|arm64-v8a
android-x86_64|x86_64
EOF
IFS='|' read -r artifact_name target <<< "$line"
mkdir "crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/${target}/"
cp -v "artifact/$artifact_name"/* "crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/${target}/"
done
cd crates/voicevox_core_java_api
function copy_dll() {
artifact_name=$1
target=$2
root=$(echo "$1" | grep -q android && echo jniLibs || echo dll)
dest=lib/src/main/resources/$root/$target
case "$artifact_name" in
windows-*) ext=dll ;;
osx-*) ext=dylib ;;
linux-*) ext=so ;;
android-*) ext=so ;;
*) echo "unknown target: $target"; exit 1 ;;
esac

cp ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so crates/voicevox_core_java_api/lib/src/main/resources/jniLibs/arm64-v8a/
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/
mkdir -p "$dest"
cp -v "../../artifacts/voicevox_core_java_api-$artifact_name"/*."$ext" "$dest"
}
function clean_dlls() {
rm -rf lib/src/main/resources/dll
rm -rf lib/src/main/resources/jniLibs
}

# desktop: cpu
clean_dlls
copy_dll windows-x64-cpu windows-x64
copy_dll windows-x86-cpu windows-x86
copy_dll linux-x64-cpu linux-x64
copy_dll linux-arm64-cpu linux-arm64
copy_dll osx-x64-cpu macos-x64
copy_dll osx-arm64-cpu macos-arm64

OS=desktop DEVICE=cpu gradle publishToMavenLocal

# desktop: cuda
clean_dlls
copy_dll windows-x64-cuda windows-x64
copy_dll windows-x86-cpu windows-x86
copy_dll linux-x64-gpu linux-x64
copy_dll linux-arm64-cpu linux-arm64
copy_dll osx-x64-cpu macos-x64
copy_dll osx-arm64-cpu macos-arm64

OS=desktop DEVICE=cuda gradle publishToMavenLocal

# desktop: directml
clean_dlls
copy_dll windows-x64-directml windows-x64
copy_dll windows-x86-cpu windows-x86
copy_dll linux-x64-cpu linux-x64
copy_dll linux-arm64-cpu linux-arm64
copy_dll osx-x64-cpu macos-x64
copy_dll osx-arm64-cpu macos-arm64

OS=desktop DEVICE=directml gradle publishToMavenLocal

# android: cpu
clean_dlls
copy_dll android-arm64-cpu arm64-v8a
copy_dll android-x86_64-cpu x86_64

cp ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so lib/src/main/resources/jniLibs/arm64-v8a/
cp ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so lib/src/main/resources/jniLibs/x86_64/

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

- name: Package
Expand Down
Loading