csbindgen/csbindgen-tests/build.rs

150 lines
5.6 KiB
Rust
Raw Normal View History

2023-03-06 00:44:48 +00:00
use std::error::Error;
2023-02-27 11:06:18 +00:00
2023-03-06 00:44:48 +00:00
fn main() -> Result<(), Box<dyn Error>> {
//fn main() {
2023-08-30 17:26:06 +01:00
bindgen::Builder::default()
.header("c/lz4/lz4.h")
.header("c/lz4/lz4hc.h")
.header("c/lz4/lz4frame.h")
.header("c/lz4/xxhash.h")
.generate()
.unwrap()
.write_to_file("src/lz4.rs")
.unwrap();
2023-02-26 18:31:44 +00:00
2023-02-28 05:49:04 +00:00
cc::Build::new()
.files([
"c/lz4/lz4.c",
"c/lz4/lz4hc.c",
"c/lz4/lz4frame.c",
"c/lz4/xxhash.c",
])
.compile("lz4");
2023-02-26 18:31:44 +00:00
2023-03-06 20:00:14 +00:00
// bindgen::Builder::default()
// .header("c/zstd/zstd.h")
// .generate()?
// .write_to_file("src/zstd.rs")?;
2023-02-27 11:06:18 +00:00
2023-03-06 20:00:14 +00:00
// bindgen::Builder::default()
// .header("c/quiche/quiche.h")
// .generate()?
// .write_to_file("src/quiche.rs")?;
2023-02-27 22:18:10 +00:00
2023-03-17 08:46:32 +00:00
// bindgen::Builder::default()
// .header("c/sqlite3/sqlite3.h")
// .generate()?
// .write_to_file("src/sqlite3.rs")?;
2023-03-12 22:34:15 +00:00
// bindgen::Builder::default()
// .header("c/bullet3/PhysicsClientC_API.h")
// .header("c/bullet3/PhysicsClientSharedMemory_C_API.h")
// .header("c/bullet3/PhysicsClientSharedMemory2_C_API.h")
// .header("c/bullet3/PhysicsDirectC_API.h")
// .header("c/bullet3/SharedMemoryPublic.h")
// .generate()?
// .write_to_file("src/bullet3.rs")?;
2023-02-27 22:18:10 +00:00
2023-03-04 05:39:45 +00:00
csbindgen::Builder::default()
.input_bindgen_file("src/lz4.rs")
.method_filter(|x| x.starts_with("LZ4"))
2023-03-04 05:39:45 +00:00
.rust_method_prefix("csbindgen_")
.rust_file_header("use super::lz4;")
.rust_method_type_path("lz4")
.csharp_class_name("LibLz4")
.csharp_namespace("CsBindgen")
.csharp_dll_name("csbindgen_tests")
.csharp_dll_name_if("UNITY_IOS && !UNITY_EDITOR", "__Internal")
.csharp_entry_point_prefix("csbindgen_")
.csharp_method_prefix("")
.csharp_class_accessibility("public")
2023-03-06 20:00:14 +00:00
//.csharp_c_long_convert("int")
//.csharp_c_ulong_convert("uint")
// .csharp_use_function_pointer(true)
2023-09-08 08:31:23 +01:00
.csharp_generate_const_filter(|_|true)
2023-03-04 05:39:45 +00:00
.generate_to_file("src/lz4_ffi.rs", "../dotnet-sandbox/lz4_bindgen.cs")
.unwrap();
2023-08-30 17:26:06 +01:00
2023-03-17 08:46:32 +00:00
// csbindgen::Builder::default()
// .input_bindgen_file("src/sqlite3.rs")
// .method_filter(|x| x.starts_with("sqlite3_"))
// .rust_method_prefix("csbindgen_")
// .rust_file_header("use super::sqlite3::*;")
// // .rust_method_type_path("sqlite3")
// .csharp_class_name("LibSqlite3")
// .csharp_namespace("CsBindgen")
// .csharp_dll_name("csbindgen_tests")
// .csharp_dll_name_if("UNITY_IOS && !UNITY_EDITOR", "__Internal")
// .csharp_entry_point_prefix("csbindgen_")
// .csharp_method_prefix("")
// .csharp_class_accessibility("public")
// .generate_to_file("src/sqlite3_ffi.rs", "../dotnet-sandbox/sqlite3_bindgen.cs")
// .unwrap();
2023-03-12 22:34:15 +00:00
2023-02-28 05:49:04 +00:00
csbindgen::Builder::default()
.input_extern_file("src/lib.rs")
.input_extern_file("src/others.rs")
//.input_extern_files(&["src/lib.rs"])
2023-03-08 09:41:46 +00:00
.csharp_class_name("NativeMethods")
2023-02-28 05:49:04 +00:00
.csharp_dll_name("csbindgen_tests")
2023-09-04 12:54:04 +01:00
.csharp_use_function_pointer(true)
//.csharp_use_function_pointer(false)
2023-09-08 08:31:23 +01:00
.csharp_generate_const_filter(|_|true)
2023-03-08 09:41:46 +00:00
.generate_csharp_file("../dotnet-sandbox/NativeMethods.cs")
2023-02-28 09:12:04 +00:00
.unwrap();
2023-02-28 05:49:04 +00:00
csbindgen::Builder::default()
.input_extern_file("src/nested_module_test.rs")
.csharp_class_name("NestedModuleTests")
.csharp_dll_name("csbindgen_tests_nested_module")
.csharp_use_function_pointer(true)
.generate_csharp_file("../dotnet-sandbox/NestedModuleTests.cs")
.unwrap();
2023-08-30 17:26:06 +01:00
2023-04-15 16:36:08 +01:00
csbindgen::Builder::new()
.input_bindgen_file("src/zstd.rs")
.method_filter(|x| x.starts_with("ZSTD_"))
.rust_file_header("use super::zstd::*;")
.csharp_class_name("LibZstd")
.csharp_dll_name("libzsd")
.generate_to_file("src/zstd_ffi.rs", "../dotnet-sandbox/zstd_bindgen.cs")?;
csbindgen::Builder::new()
.input_bindgen_file("src/quiche.rs")
.method_filter(|x| x.starts_with("quiche_"))
.rust_file_header("use super::quiche::*;")
.csharp_class_name("LibQuiche")
.csharp_dll_name("libquiche")
.generate_to_file("src/quiche_ffi.rs", "../dotnet-sandbox/quiche_bindgen.cs")?;
csbindgen::Builder::new()
.input_bindgen_file("src/bullet3.rs")
.method_filter(|x| x.starts_with("b3"))
.rust_file_header("use super::bullet3::*;")
.csharp_class_name("LibBullet3")
.csharp_dll_name("libbullet3")
2023-09-08 08:31:23 +01:00
.csharp_generate_const_filter(|_|true)
2023-04-15 16:36:08 +01:00
.generate_to_file("src/bullet3_ffi.rs", "../dotnet-sandbox/bullet3_bindgen.cs")?;
2023-02-27 11:06:18 +00:00
csbindgen::Builder::new()
.input_bindgen_file("src/libpng16.rs")
//.method_filter(|x| x.starts_with("png_"))
.csharp_namespace("PixivApi.ImageFile")
.csharp_class_name("LibPng16")
.csharp_dll_name("libpng16")
.generate_csharp_file("../dotnet-sandbox/libpng16_csbindgen.cs")?;
2023-04-13 08:28:54 +01:00
csbindgen::Builder::new()
2023-04-15 15:40:50 +01:00
.input_bindgen_file("src/physx/lib.rs")
2023-04-13 08:28:54 +01:00
.input_bindgen_file("src/physx/physx_generated.rs")
.input_bindgen_file("src/physx/x86_64-pc-windows-msvc/structgen.rs")
2023-04-15 15:40:50 +01:00
// .input_bindgen_file("src/physx/unix/structgen.rs")
2023-04-15 15:32:00 +01:00
// .csharp_disable_emit_dll_name(true)
2023-04-13 08:28:54 +01:00
.csharp_namespace("Physx")
2023-04-15 15:32:00 +01:00
.csharp_class_name("LibPhysx")
.csharp_dll_name("libphys")
2023-04-13 08:28:54 +01:00
.generate_csharp_file("../dotnet-sandbox/libphysx_csbindgen.cs")?;
2023-03-06 00:44:48 +00:00
Ok(())
2023-02-26 18:31:44 +00:00
}