From 8f7818046faffa44a3fd6c6d21f54427458d1854 Mon Sep 17 00:00:00 2001 From: Louis Thiery Date: Sun, 16 Feb 2020 23:14:51 -0800 Subject: [PATCH 1/2] create constructor allowing user to set c_cfg and cxx_cfg --- src/lib.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ae8770f..b47ce5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,6 +77,8 @@ pub struct Config { verbose_cmake: bool, verbose_make: bool, pic: Option, + c_cfg: Option, + cxx_cfg: Option, } /// Builds the native library rooted at `path` with the default cmake options. @@ -103,6 +105,12 @@ impl Config { /// Creates a new blank set of configuration to build the project specified /// at the path `path`. pub fn new>(path: P) -> Config { + Config::new_with_configs(path, None, None) + } + + /// Creates a new blank set of configuration to build the project specified + /// at the path `path`. + pub fn new_with_configs>(path: P, c_cfg: Option, cxx_cfg: Option) -> Config { Config { path: env::current_dir().unwrap().join(path), generator: None, @@ -125,6 +133,8 @@ impl Config { verbose_cmake: false, verbose_make: false, pic: None, + c_cfg, + cxx_cfg, } } @@ -326,7 +336,11 @@ impl Config { let host = self.host.clone().unwrap_or_else(|| getenv_unwrap("HOST")); let msvc = target.contains("msvc"); let ndk = self.uses_android_ndk(); - let mut c_cfg = cc::Build::new(); + let mut c_cfg = if let Some(cfg) = self.c_cfg.take() { + cfg + } else { + cc::Build::new() + }; c_cfg .cargo_metadata(false) .opt_level(0) @@ -337,7 +351,12 @@ impl Config { if !ndk { c_cfg.target(&target); } - let mut cxx_cfg = cc::Build::new(); + + let mut cxx_cfg = if let Some(cfg) = self.cxx_cfg.take() { + cfg + } else { + cc::Build::new() + }; cxx_cfg .cargo_metadata(false) .cpp(true) From f6018fc6c3af7bf3611a2669c4481bf4d2e9f5bf Mon Sep 17 00:00:00 2001 From: Louis Thiery Date: Sun, 16 Feb 2020 23:21:29 -0800 Subject: [PATCH 2/2] fmt --- src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b47ce5e..577c1ad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,9 +108,13 @@ impl Config { Config::new_with_configs(path, None, None) } - /// Creates a new blank set of configuration to build the project specified + /// Creates a new blank set of configuration to build the project specified /// at the path `path`. - pub fn new_with_configs>(path: P, c_cfg: Option, cxx_cfg: Option) -> Config { + pub fn new_with_configs>( + path: P, + c_cfg: Option, + cxx_cfg: Option, + ) -> Config { Config { path: env::current_dir().unwrap().join(path), generator: None,