fix: build.rs add: readmes

This commit is contained in:
2023-04-30 20:47:50 +08:00
parent 3695bba306
commit dc4d89a6b3
Signed by: LuoRain
GPG key ID: 16B4D3D5372966A6
4 changed files with 30 additions and 1 deletions

2
Cargo.lock generated
View file

@ -191,7 +191,7 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "scs-rs-proc-macros"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"quote",
"syn",

4
README.md Normal file
View file

@ -0,0 +1,4 @@
# SCS SDK Bindings for Rust
## How to use
Check out [README.md](scs_rs/README.md) of [scs-sdk-rs](https://crates.io/crates/scs-sdk-rs) crate.

22
scs_rs/README.md Normal file
View file

@ -0,0 +1,22 @@
# SCS SDK Bindings
## Usage Example
```rust
#[no_mangle]
#[scs_sdk_rs::proc_macros::scs_telemetry_init]
// pub extern "C" fn scs_telemetry_init(version: scs_sdk_rs::scs_u32_t, params: *const scs_sdk_rs::scs_telemetry_init_params_t) -> scs_sdk_rs::scs_result_t
pub fn init() {
let version_params_ptr = params as *const scs_sdk_rs::scs_telemetry_init_params_v101_t;
unsafe {
// example for using params
let version_params = *version_params_ptr;
version_params.common.log.unwrap()(scs_sdk_rs::SCS_LOG_TYPE_message, "The Rust telemetry plugin is loaded.".as_ptr() as *const i8);
}
// ...
scs_sdk_rs::SCS_RESULT_ok
}
```

View file

@ -5,6 +5,9 @@ fn main() {
let bindings = bindgen::Builder::default()
.header("wrapper.hpp")
.blocklist_item(r#"(\w+)_(MAX|MIN|WIDTH)"#)
.blocklist_item(r#"some_requirement_failed_at_(\d+)"#)
.blocklist_function(r#"(\w+)_(init|shutdown)(\w*)"#)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");