From 5dd42a6e23f71e8c52d77e6e00fd7e463cdc3a79 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 22 Apr 2019 18:18:03 +0900 Subject: [PATCH] rust_binding now builds C lib Release/Debug --- rust_binding/build.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/rust_binding/build.rs b/rust_binding/build.rs index 745ee57..8388d16 100644 --- a/rust_binding/build.rs +++ b/rust_binding/build.rs @@ -5,11 +5,17 @@ use std::env; use std::path::PathBuf; fn main() { - let mut dst = Config::new("../c_impl") - .define("NDEBUG", "true") - .cflag("-O3") - .build(); - dst.push("build"); + let mut config = Config::new("../c_impl"); + let mut dst: PathBuf; + if env::var("PROFILE").unwrap().eq("release") { + config.define("CMAKE_BUILD_TYPE", "Release"); + dst = config.build(); + dst.push("lib"); + } else { + config.define("CMAKE_BUILD_TYPE", "Debug"); + dst = config.build(); + dst.push("build"); + } println!("cargo:rustc-link-search=native={}", dst.display()); println!("cargo:rustc-link-lib=static=UDPConnection");