From 35c6e62e1c206cc26817f2101eec7b52e0253501 Mon Sep 17 00:00:00 2001 From: yamachu Date: Sat, 5 Aug 2023 17:30:48 +0900 Subject: [PATCH] =?UTF-8?q?ifdef=E3=81=AF=E8=A9=95=E4=BE=A1=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AA=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E3=80=81=5F=5Fcplusplus=E3=81=8Cdefine=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=80=81-x=20c++=E3=83=95?= =?UTF-8?q?=E3=83=A9=E3=82=B0=E3=82=92clang=E3=81=AEargs=E3=81=AB=E8=B6=B3?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/binding/build.rs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/Core/binding/build.rs b/src/Core/binding/build.rs index 5142384..91598f5 100644 --- a/src/Core/binding/build.rs +++ b/src/Core/binding/build.rs @@ -1,34 +1,24 @@ -use std::{error::Error, fs}; +use std::error::Error; fn main() -> Result<(), Box> { - let generated_source = bindgen::Builder::default() + bindgen::Builder::default() + .clang_args(&["-x", "c++"]) .header("voicevox_core/crates/voicevox_core_c_api/include/voicevox_core.h") .default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false, }) - .generate()? - .to_string() - // 同名のenumが存在かつpub typeでaliasを張っているとcsbindgenでi32に置き換えられてしまうことの対策 - .replace( - "pub type VoicevoxAccelerationMode = i32;", - "// pub type VoicevoxAccelerationMode = i32;", - ) - .replace( - "pub type VoicevoxResultCode = i32;", - "// pub type VoicevoxResultCode = i32;", - ) - .replace( - "pub type VoicevoxUserDictWordType = i32", - "// pub type VoicevoxUserDictWordType = i32", - ); - - fs::write("./generated/voicevox_core.g.rs", generated_source)?; + .generate() + .unwrap() + .write_to_file("./generated/voicevox_core.g.rs") + .unwrap(); csbindgen::Builder::default() .input_bindgen_file("generated/voicevox_core.g.rs") .csharp_dll_name("voicevox_core") .csharp_class_name("CoreUnmanaged") .csharp_namespace("VoicevoxEngineSharp.Core.Native") + // abortっていうのが勝手に足されてしまうので、スキップしている + .method_filter(|method| !method.starts_with("abort")) // TODO: MAUI iOS // see: https://github.com/xamarin/xamarin-macios/issues/17418 .csharp_dll_name_if("UNITY_IOS && !UNITY_EDITOR", "__Internal")