From ce4a8c56acc8ae0d24f954eae37751eba95ec01d Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Mon, 22 Apr 2019 17:54:37 +0900 Subject: [PATCH] Allow rust_binding to build the C library --- rust_binding/Cargo.toml | 1 + rust_binding/build.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/rust_binding/Cargo.toml b/rust_binding/Cargo.toml index ab94e15..b2d5560 100644 --- a/rust_binding/Cargo.toml +++ b/rust_binding/Cargo.toml @@ -8,3 +8,4 @@ edition = "2018" [build-dependencies] bindgen = "0.42.2" +cmake = "0.1" diff --git a/rust_binding/build.rs b/rust_binding/build.rs index 436f988..745ee57 100644 --- a/rust_binding/build.rs +++ b/rust_binding/build.rs @@ -1,10 +1,18 @@ +use cmake::Config; use bindgen; use std::env; use std::path::PathBuf; fn main() { - println!("cargo:rustc-link-lib=UDPConnection"); + let mut dst = Config::new("../c_impl") + .define("NDEBUG", "true") + .cflag("-O3") + .build(); + dst.push("build"); + + println!("cargo:rustc-link-search=native={}", dst.display()); + println!("cargo:rustc-link-lib=static=UDPConnection"); let bindings = bindgen::Builder::default() .header("wrapper.h")