diff options
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | build.rs | 18 | ||||
| -rw-r--r-- | cbindgen.toml | 14 | ||||
| -rw-r--r-- | dome_key_map.h | 22 | ||||
| -rw-r--r-- | src/lib.rs | 2 |
5 files changed, 58 insertions, 1 deletions
@@ -6,5 +6,8 @@ version = "0.0.1" cocoa = "0.18.0" combine = "3.4.0" +[build-dependencies] +cbindgen = "0.6.2" + [lib] crate-type = ["staticlib"] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d2a0b5d --- /dev/null +++ b/build.rs @@ -0,0 +1,18 @@ +extern crate cbindgen; + +use cbindgen::Language; + +fn main() { + let crate_dir = env!("CARGO_MANIFEST_DIR"); + + let config = cbindgen::Config::from_file("cbindgen.toml") + .expect("Failed to read 'cbindgen.toml'"); + + cbindgen::Builder::new() + .with_crate(crate_dir) + // .with_language(Language::C) + .with_config(config) + .generate() + .expect("Unable to generate bindings") + .write_to_file("dome_key_map.h"); +} diff --git a/cbindgen.toml b/cbindgen.toml new file mode 100644 index 0000000..22e0269 --- /dev/null +++ b/cbindgen.toml @@ -0,0 +1,14 @@ +language = "C" +header = "/* Test */" +include_version = true + +# [parse] +# include = ["dome-key-map"] + +[export] +include = ["KeyActionResult", "HeadphoneButton"] +# item_types = ["enums", "structs", "functions"] +item_types = ["constants", "globals", "enums", "structs", "unions", "typedefs", "opaque", "functions"] + +[export.rename] +"run_key_action" = "hello_run" diff --git a/dome_key_map.h b/dome_key_map.h new file mode 100644 index 0000000..473d2f0 --- /dev/null +++ b/dome_key_map.h @@ -0,0 +1,22 @@ +/* Test */ + +/* Generated with cbindgen:0.6.2 */ + +#include <stdint.h> +#include <stdlib.h> +#include <stdbool.h> + +typedef enum { + Play, + Up, + Down, +} HeadphoneButton; + +typedef struct MapKind MapKind; + +typedef struct Option_CString Option_CString; + +typedef struct { + Option_CString action; + MapKind kind; +} KeyActionResult; @@ -8,4 +8,4 @@ mod parser; use parser::{HeadphoneButton, MapGroup, MapKind}; -pub use cocoa_bridge::run_key_action; +pub use cocoa_bridge::*; |
