From b8c1b316203a0963ce3d3aca787fd392cceba930 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Mon, 12 Jun 2023 18:51:16 +0900 Subject: [PATCH] =?UTF-8?q?cbindgen=E3=81=AE`include=5Fversion`=E3=82=92?= =?UTF-8?q?=E6=9C=89=E5=8A=B9=E5=8C=96=E3=81=99=E3=82=8B=20(#519)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * cbindgenの`include_version`を有効化する * jobをリネーム * 誤字 --- .../cargo-binstall-cbindgen/action.yml | 23 ------------- .github/workflows/generate_document.yml | 6 ++-- .github/workflows/test.yml | 33 +++++++++++++------ crates/voicevox_core_c_api/cbindgen.toml | 1 + .../include/voicevox_core.h | 2 ++ 5 files changed, 28 insertions(+), 37 deletions(-) delete mode 100644 .github/actions/cargo-binstall-cbindgen/action.yml diff --git a/.github/actions/cargo-binstall-cbindgen/action.yml b/.github/actions/cargo-binstall-cbindgen/action.yml deleted file mode 100644 index 0eb0f8f5d..000000000 --- a/.github/actions/cargo-binstall-cbindgen/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -inputs: - version: - required: true - default: ^0.24 - -runs: - using: composite - steps: - - name: Install cbindgen - shell: bash - run: | - case "$OS" in - Windows) - cargo install cbindgen --version ${{ inputs.version }};; - macOS | Linux ) - cargo binstall \ - cbindgen@${{ inputs.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;; - esac diff --git a/.github/workflows/generate_document.yml b/.github/workflows/generate_document.yml index ad52529e3..05cc825de 100644 --- a/.github/workflows/generate_document.yml +++ b/.github/workflows/generate_document.yml @@ -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/doxygen-action@v1.9.4 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed26b05c3..4d9c53f04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 version of cbindgen that xtask depends on + 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 @@ -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 @@ -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 diff --git a/crates/voicevox_core_c_api/cbindgen.toml b/crates/voicevox_core_c_api/cbindgen.toml index 5b925c3c6..d038d038d 100644 --- a/crates/voicevox_core_c_api/cbindgen.toml +++ b/crates/voicevox_core_c_api/cbindgen.toml @@ -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 diff --git a/crates/voicevox_core_c_api/include/voicevox_core.h b/crates/voicevox_core_c_api/include/voicevox_core.h index ddb02eece..893c92095 100644 --- a/crates/voicevox_core_c_api/include/voicevox_core.h +++ b/crates/voicevox_core_c_api/include/voicevox_core.h @@ -3,6 +3,8 @@ #ifndef VOICEVOX_CORE_INCLUDE_GUARD #define VOICEVOX_CORE_INCLUDE_GUARD +/* Generated with cbindgen:0.24.3 */ + #ifdef __cplusplus #include #else // __cplusplus