2024-05-28 19:38:43 +02:00
|
|
|
//! Build script generating the C# code needed to call methods from the `servicepoint` C library.
|
|
|
|
|
2024-05-25 11:16:37 +02:00
|
|
|
fn main() {
|
2024-05-30 21:55:55 +02:00
|
|
|
println!("cargo::rerun-if-changed=../servicepoint_binding_c/src");
|
|
|
|
println!("cargo::rerun-if-changed=build.rs");
|
2024-05-25 11:16:37 +02:00
|
|
|
csbindgen::Builder::default()
|
2024-05-26 13:15:11 +02:00
|
|
|
.input_extern_file("../servicepoint_binding_c/src/bit_vec.rs")
|
2024-06-23 15:42:15 +02:00
|
|
|
.input_extern_file("../servicepoint_binding_c/src/brightness_grid.rs")
|
|
|
|
.input_extern_file("../servicepoint_binding_c/src/cp437_grid.rs")
|
2024-05-26 13:15:11 +02:00
|
|
|
.input_extern_file("../servicepoint_binding_c/src/command.rs")
|
|
|
|
.input_extern_file("../servicepoint_binding_c/src/connection.rs")
|
|
|
|
.input_extern_file("../servicepoint_binding_c/src/pixel_grid.rs")
|
|
|
|
.input_extern_file("../servicepoint_binding_c/src/lib.rs")
|
|
|
|
.input_extern_file("../servicepoint_binding_c/src/c_slice.rs")
|
|
|
|
.input_extern_file("../servicepoint_binding_c/src/packet.rs")
|
2024-09-05 21:15:53 +02:00
|
|
|
.input_extern_file("../servicepoint_binding_c/src/constants.rs")
|
2024-05-26 13:15:11 +02:00
|
|
|
.csharp_dll_name("servicepoint_binding_c")
|
2024-05-25 11:16:37 +02:00
|
|
|
.csharp_namespace("ServicePoint.BindGen")
|
|
|
|
.csharp_use_nint_types(true)
|
|
|
|
.csharp_class_accessibility("public")
|
2024-05-26 13:15:11 +02:00
|
|
|
.csharp_generate_const_filter(|_| true)
|
2024-08-29 21:40:33 +02:00
|
|
|
.csharp_type_rename(move |name| {
|
2024-09-05 21:15:53 +02:00
|
|
|
if name.len() > 2
|
|
|
|
&& name.starts_with("SP")
|
|
|
|
&& name.chars().nth(2).unwrap().is_uppercase()
|
2024-08-29 21:40:33 +02:00
|
|
|
{
|
2024-09-05 21:15:53 +02:00
|
|
|
name[2..].to_string()
|
2024-08-29 21:40:33 +02:00
|
|
|
} else {
|
|
|
|
name
|
|
|
|
}
|
|
|
|
})
|
2024-05-26 13:15:11 +02:00
|
|
|
.generate_csharp_file("ServicePoint/BindGen/ServicePoint.g.cs")
|
2024-05-25 11:16:37 +02:00
|
|
|
.unwrap();
|
|
|
|
}
|