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 15 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
127 changes: 83 additions & 44 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,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 @@ -289,7 +288,7 @@ jobs:
env:
ORT_USE_CUDA: ${{ matrix.use_cuda }}
- name: build voicevox_core_java_api
if: contains(matrix.target, 'android')
if: ${{ !contains(matrix.target, 'ios') }}
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
run: |
function build() {
cargo build -p voicevox_core_java_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
Expand All @@ -312,18 +311,17 @@ 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 }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
- name: Upload artifact to build XCFramework
if: contains(matrix.target, 'ios')
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: voicevox_core-${{ matrix.target }}
path: artifact/${{ env.ASSET_NAME }}
Expand All @@ -350,8 +348,8 @@ 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')
uses: actions/upload-artifact@v3
if: fromJson(needs.config.outputs.deploy) && !contains(matrix.target, 'ios')
uses: actions/upload-artifact@v4
with:
name: voicevox_core_java_api-${{ matrix.artifact_name }}
path: java_artifact
Expand All @@ -367,23 +365,23 @@ jobs:
ASSET_NAME: voicevox_core-ios-xcframework-cpu-${{ needs.config.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: voicevox_core-x86_64-apple-ios
path: ${{ env.IOS_X86_64_PATH }}
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: voicevox_core-aarch64-apple-ios-sim
path: ${{ env.IOS_AARCH64_SIM_PATH }}
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: voicevox_core-aarch64-apple-ios
path: ${{ env.IOS_AARCH64_PATH }}
- name: Create xcframework
id: create-xcframework
id: create-xcframework
run: |
build_util/make_ios_xcframework.bash
echo "output_asset_path=${OUTPUT_ASSET_PATH}" >> "$GITHUB_OUTPUT"
echo "output_asset_path=${OUTPUT_ASSET_PATH}" >> "$GITHUB_OUTPUT"
env:
OUTPUT_ASSET_PATH: artifact/voicevox_core-ios-xcframework-cpu
- name: Archive artifact
Expand Down Expand Up @@ -414,11 +412,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 @@ -459,40 +456,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

- name: "Download artifact (android-arm64-cpu)"
uses: actions/download-artifact@v3
with:
name: voicevox_core_java_api-android-arm64-cpu
path: artifact/android-arm64-cpu
run: cargo set-version "$VERSION" -p voicevox_core_java_api

- name: "Download artifact (android-x86_64-cpu)"
uses: actions/download-artifact@v3
- name: "Download artifact"
uses: actions/download-artifact@v4
with:
name: voicevox_core_java_api-android-x86_64-cpu
path: artifact/android-x86_64-cpu
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-cpu|arm64-v8a
android-x86_64-cpu|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"
sevenc-nanashi marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p "$dest"
cp -v "../../artifacts/voicevox_core_java_api-$artifact_name"/*.{dll,so,dylib} "$dest" || true
# こうするしかないはず。echoを使わない書き方があるかもしれないが、シンプルに面倒。
# shellcheck disable=SC2086
if [ "$(echo $dest/*)" = "$dest/*" ]; then
echo "No dll found in $artifact_name"
exit 1
else
echo "$artifact_name => $dest"
fi
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
}
function clean_dlls() {
rm -rf lib/src/main/resources/dll
rm -rf lib/src/main/resources/jniLibs
}

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/
# 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