Skip to content

Commit

Permalink
cbindgenが生成するvoicevox_core.hをこのリポジトリに追加する (VOICEVOX#493)
Browse files Browse the repository at this point in the history
* cbindgenが生成するvoicevox_core.hをこのリポジトリに追加する

* ビルド時にはcbindgenは不要

* `linguist-generated`に指定
  • Loading branch information
qryxip authored May 19, 2023
1 parent 546e173 commit babce87
Show file tree
Hide file tree
Showing 11 changed files with 689 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/crates/voicevox_core_c_api/include/voicevox_core.h linguist-generated=true
7 changes: 1 addition & 6 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ jobs:
echo "AR_${{ matrix.target }}=llvm-ar" >> "$GITHUB_ENV"
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: Install cargo-edit
shell: bash
run: cargo binstall cargo-edit@^0.11 --no-confirm --log-level debug
Expand All @@ -150,9 +148,6 @@ jobs:
run: |
cargo set-version "$VERSION" --exclude voicevox_core_python_api --exclude download --exclude xtask
if ${{ !!matrix.whl_local_version }}; then cargo set-version "$VERSION+"${{ matrix.whl_local_version }} -p voicevox_core_python_api; fi
- name: generate voicevox_core.h
shell: bash
run: cbindgen --crate voicevox_core_c_api -o ./voicevox_core.h
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv --features ${{ matrix.features }}, --target ${{ matrix.target }} --release
env:
Expand All @@ -174,7 +169,7 @@ jobs:
shell: bash
run: |
mkdir -p "artifact/${{ env.ASSET_NAME }}"
cp -v voicevox_core.h "artifact/${{ env.ASSET_NAME }}"
cp -v crates/voicevox_core_c_api/include/voicevox_core.h "artifact/${{ env.ASSET_NAME }}"
cp -v target/${{ matrix.target }}/release/*voicevox_core.{dll,so,dylib} "artifact/${{ env.ASSET_NAME }}" || true
cp -v target/${{ matrix.target }}/release/voicevox_core.dll.lib "artifact/${{ env.ASSET_NAME }}/voicevox_core.lib" || true
cp -v -n target/${{ matrix.target }}/release/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/*.{dll,so.*,so,dylib} "artifact/${{ env.ASSET_NAME }}" || true
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
shell: bash
run: cargo test -vv --features ,${{ matrix.features }} -- --include-ignored

xtask-generate-c-header:
c-header:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -115,12 +115,14 @@ jobs:
uses: taiki-e/install-action@cargo-binstall
- name: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: Generate voicevox_core_1.h
run: cbindgen --crate voicevox_core_c_api -o ./voicevox_core_1.h
- name: Generate voicevox_core_2.h
run: cargo xtask generate-c-header -o ./voicevox_core_2.h
- name: Assert these header files are same
run: diff -u --color=always ./voicevox_core_{1,2}.h
- name: Assert voicevox_core.h is up to date
run: |
cbindgen --crate voicevox_core_c_api -o /tmp/voicevox_core.h
diff -u --color=always {/tmp,./crates/voicevox_core_c_api/include}/voicevox_core.h
- name: Assert `cargo xtask update-c-header --verify` succeeds
run: |
cargo xtask update-c-header --verify
git diff
build-unix-cpp-example:
strategy:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,22 @@ model フォルダにある onnx モデルはダミーのため、ノイズの
cargo build --release -p voicevox_core_c_api
```

```bash
# DLL用のヘッダファイルvoicevox_core.hを生成
# cbindgenが手元にインストールされているのならそちらでも可
cargo xtask generate-c-header
```
DLL用のヘッダファイルは [crates/voicevox\_core\_c\_api/include/voicevox\_core.h](https://github.com/VOICEVOX/voicevox_core/tree/main/crates/voicevox_core_c_api/include/voicevox_core.h) にあります。

## コアライブラリのテスト

```bash
cargo test
```

## ヘッダファイルの更新

```bash
cargo xtask update-c-header
```

[cbindgen](https://crates.io/crates/cbindgen) が手元にインストールされているなら、それを使いヘッダファイルを生成することもできます。

## タイポチェック

[typos](https://github.com/crate-ci/typos) を使ってタイポのチェックを行っています。
Expand Down
Loading

0 comments on commit babce87

Please sign in to comment.