diff --git a/.cargo/config b/.cargo/config new file mode 100644 index 0000000..b800c6d --- /dev/null +++ b/.cargo/config @@ -0,0 +1,2 @@ +[build] +target = "thumbv7m-none-eabi" diff --git a/Cargo.toml b/Cargo.toml index e133cf9..9a0b512 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ name = "rtl8710-sdk" version = "0.1.0" authors = ["David Goodlad "] edition = "2018" +links = "sdk" [dependencies] cty = "0.2" diff --git a/build.rs b/build.rs index f3c2c3d..24010f9 100644 --- a/build.rs +++ b/build.rs @@ -294,7 +294,6 @@ fn main() { .compile("sdk"); println!("cargo:rustc-link-search=native=vendor/sdk/component/soc/realtek/8195a/misc/bsp/lib/common/GCC/"); - println!("cargo:rustc-link-lib=sdk"); println!("cargo:rustc-link-lib=_platform"); println!("cargo:rustc-link-lib=_wlan"); println!("cargo:rustc-link-lib=_http"); @@ -304,4 +303,29 @@ fn main() { println!("cargo:rustc-link-lib=_websocket"); println!("cargo:rustc-link-lib=_xmodem"); println!("cargo:rustc-link-lib=_mdns"); + + let bindings = bindgen::Builder::default() + .header("include/wrapper.h") + .whitelist_function("wifi_manager_init") + .whitelist_function("wifi_off") + .whitelist_function("wifi_on") + .whitelist_function("wifi_scan_networks") + .whitelist_function("vTaskStartScheduler") + .whitelist_function("pvPortMalloc") + .whitelist_function("vPortFree") + .whitelist_type("rtw_mode_t") + .whitelist_type("rtw_scan_result_t") + .whitelist_type("rtw_scan_result_handler_t") + .clang_arg("-Iinclude") + .clang_args(STDLIB_INCLUDE_PATHS.iter().map(|path| format!("-I{}", path))) + .clang_args(SDK_INCLUDE_PATHS.iter().map(|path| format!("-I{}", path))) + .use_core() + .ctypes_prefix("cty") + .rustfmt_bindings(true) + .generate() + .expect("Unable to generate C SDK bindings"); + + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings.rs!"); } diff --git a/src/bindings.rs b/src/bindings.rs new file mode 100644 index 0000000..ba898b9 --- /dev/null +++ b/src/bindings.rs @@ -0,0 +1,8 @@ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] + +use cty; + +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/src/lib.rs b/src/lib.rs index ecc21c6..10b5083 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] +pub mod bindings; + #[cfg(test)] mod tests { #[test]