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

cbindgenのinclude_versionを有効化する #519

Merged
merged 3 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 0 additions & 23 deletions .github/actions/cargo-binstall-cbindgen/action.yml

This file was deleted.

6 changes: 2 additions & 4 deletions .github/workflows/generate_document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ jobs:
python-version: "3.8"
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: Create a venv
uses: ./.github/actions/create-venv
- name: pip install
run: pip install -r ./crates/voicevox_core_python_api/requirements.txt
- name: Generate C header file
run: cbindgen --crate voicevox_core_c_api -o ./docs/apis/c_api/doxygen/voicevox_core.h
- name: mkdir public
run: mkdir -p public/apis/c_api
- name: cp docs/apis/index.html
run: cp docs/apis/index.html public/apis/
- name: cp crates/voicevox_core_c_api/include/voicevox_core.h
run: cp crates/voicevox_core_c_api/include/voicevox_core.h docs/apis/c_api/doxygen/
- name: Generate doxygen document
uses: mattnotmitt/[email protected]
with:
Expand Down
33 changes: 23 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,27 @@ jobs:
uses: ./.github/actions/rust-toolchain-from-file
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: Extract the cbindgen version
id: cbindgen-version
run: |
metadata=$(cargo metadata --format-version 1)
version=$(
jq -r '
(.workspace_members[] | select(startswith("xtask "))) as $xtask
| (.resolve.nodes[] | select(.id == $xtask).deps[] | select(.name == "cbindgen").pkg) as $cbindgen
| .packages[] | select(.id == $cbindgen).version
' <<< "$metadata"
)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Install cbindgen v${{ steps.cbindgen-version.outputs.version }}
run: |
cargo binstall \
cbindgen@${{ steps.cbindgen-version.outputs.version }} \
--pkg-url 'https://github.com/alsuren/cargo-quickinstall/releases/download/{ name }-{ version }-{ target }/{ name }-{ version }-{ target }.tar.gz' \
--pkg-fmt tgz \
--bin-dir '{ bin }{ binary-ext }' \
--no-confirm \
--log-level debug
- name: Assert voicevox_core.h is up to date
run: |
cbindgen --crate voicevox_core_c_api -o /tmp/voicevox_core.h
Expand All @@ -140,15 +159,12 @@ jobs:
uses: ./.github/actions/rust-toolchain-from-file
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv
- name: voicevox_core.hを生成
run: cbindgen --crate voicevox_core_c_api -o ./example/cpp/unix/voicevox_core/voicevox_core.h
- name: 必要なfileをunix用exampleのディレクトリに移動させる
run: |
mkdir -p example/cpp/unix/voicevox_core/
cp -v crates/voicevox_core_c_api/include/voicevox_core.h example/cpp/unix/voicevox_core/
cp -v target/debug/libvoicevox_core.{so,dylib} example/cpp/unix/voicevox_core/ || true
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.so.* example/cpp/unix/voicevox_core/ || true
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.*.dylib example/cpp/unix/voicevox_core/ || true
Expand Down Expand Up @@ -184,15 +200,12 @@ jobs:
uses: ./.github/actions/rust-toolchain-from-file
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cbindgen
uses: ./.github/actions/cargo-binstall-cbindgen
- name: build voicevox_core_c_api
run: cargo build -p voicevox_core_c_api -vv
- name: voicevox_core.hを生成
run: cbindgen --crate voicevox_core_c_api -o ./example/cpp/windows/simple_tts/voicevox_core.h
- name: 必要なfileをexampleのディレクトリに移動させる
run: |
mkdir example/cpp/windows/simple_tts/lib/x64
cp -v crates/voicevox_core_c_api/include/voicevox_core.h example/cpp/windows/simple_tts/
cp target/debug/voicevox_core.dll.lib example/cpp/windows/simple_tts/lib/x64/voicevox_core.lib

- name: Add MSBuild to PATH
Expand Down
1 change: 1 addition & 0 deletions crates/voicevox_core_c_api/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ language = "C"
header = "/// @file"
include_guard = "VOICEVOX_CORE_INCLUDE_GUARD"
no_includes = true
include_version = true
cpp_compat = true
after_includes = """
#ifdef __cplusplus
Expand Down
2 changes: 2 additions & 0 deletions crates/voicevox_core_c_api/include/voicevox_core.h

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