From 5b6f54a087854f6567f08f152745907236f67eb6 Mon Sep 17 00:00:00 2001 From: Ryan Hunt <rhunt@eqrion.net> Date: Thu, 14 Dec 2017 11:54:54 -0600 Subject: [PATCH] Add an option to Builder for preprocessor defines --- Cargo.lock | 26 +++++++++++++------------- src/bindgen/builder.rs | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e85add2..fde60a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,16 +1,3 @@ -[root] -name = "cbindgen" -version = "0.3.2" -dependencies = [ - "clap 2.24.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ansi_term" version = "0.9.0" @@ -31,6 +18,19 @@ name = "bitflags" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "cbindgen" +version = "0.3.2" +dependencies = [ + "clap 2.24.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "clap" version = "2.24.2" diff --git a/src/bindgen/builder.rs b/src/bindgen/builder.rs index b1e444a..97bb942 100644 --- a/src/bindgen/builder.rs +++ b/src/bindgen/builder.rs @@ -133,6 +133,24 @@ impl Builder { self } + #[allow(unused)] + pub fn with_target_os_define(mut self, platform: &str, preprocessor_define: &str) -> Builder { + self.config.defines.insert( + format!("target_os = {}", platform), + preprocessor_define.to_owned(), + ); + self + } + + #[allow(unused)] + pub fn with_define(mut self, key: &str, value: &str, preprocessor_define: &str) -> Builder { + self.config.defines.insert( + format!("{} = {}", key, value), + preprocessor_define.to_owned(), + ); + self + } + #[allow(unused)] pub fn with_config(mut self, config: Config) -> Builder { self.config = config; -- GitLab