From 80526eecfd0ee8834ed58ff35282dab523e6fafc Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Thu, 12 Mar 2020 19:08:15 -0400 Subject: [PATCH 1/3] Update build.rs --- rustcord-sys/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustcord-sys/build.rs b/rustcord-sys/build.rs index 9f0f7df..5438711 100644 --- a/rustcord-sys/build.rs +++ b/rustcord-sys/build.rs @@ -11,7 +11,7 @@ fn main() { println!("cargo:rustc-link-search={}", config.join("lib").display()); println!("cargo:rustc-link-search={}", config.join("lib64").display()); - let include_path = format!("discord-rpc-{}/include", LIB_VERSION); + let include_path = "discord-rpc/include".to_string(); let bindings = bindgen::Builder::default() .header("wrapper.h") From c3461dd952b05b42d99c5d4343bfe0d10383022a Mon Sep 17 00:00:00 2001 From: Timothy Cyrus <4201229+tcyrus@users.noreply.github.com> Date: Thu, 12 Mar 2020 19:26:03 -0400 Subject: [PATCH 2/3] Update build.rs --- rustcord-sys/build.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/rustcord-sys/build.rs b/rustcord-sys/build.rs index 5438711..7b12829 100644 --- a/rustcord-sys/build.rs +++ b/rustcord-sys/build.rs @@ -1,8 +1,6 @@ use std::env; use std::path::PathBuf; -const LIB_VERSION: &str = "3.4.0"; - fn main() { let config = cmake::Config::new("discord-rpc".to_string()) .define("BUILD_EXAMPLES", "OFF") From 574f413e8da1951d137ea32781a98edb93f515a2 Mon Sep 17 00:00:00 2001 From: Timothy Cyrus Date: Thu, 12 Mar 2020 19:43:00 -0400 Subject: [PATCH 3/3] Fixed Formatting Rewrote based on cmake crate example and rust-discord-rpc-src crate --- rustcord-sys/build.rs | 21 ++++++++++++++++++--- rustcord-sys/wrapper.h | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/rustcord-sys/build.rs b/rustcord-sys/build.rs index 7b12829..bf6e8b9 100644 --- a/rustcord-sys/build.rs +++ b/rustcord-sys/build.rs @@ -2,12 +2,18 @@ use std::env; use std::path::PathBuf; fn main() { - let config = cmake::Config::new("discord-rpc".to_string()) + let dst = cmake::Config::new("discord-rpc") .define("BUILD_EXAMPLES", "OFF") .build(); - println!("cargo:rustc-link-search={}", config.join("lib").display()); - println!("cargo:rustc-link-search={}", config.join("lib64").display()); + println!( + "cargo:rustc-link-search={}", + dst.join("lib").display() + ); + println!( + "cargo:rustc-link-search={}", + dst.join("lib64").display() + ); let include_path = "discord-rpc/include".to_string(); @@ -23,4 +29,13 @@ fn main() { .expect("Couldn't write bindings!"); println!("cargo:rustc-link-lib=static=discord-rpc"); + + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + + match target_os.as_str() { + "linux" => println!("cargo:rustc-link-lib=dylib=stdc++"), + "macos" => println!("cargo:rustc-link-lib=dylib=c++"), + "windows" => {}, + _ => panic!("Unsupported platform!"), + } } diff --git a/rustcord-sys/wrapper.h b/rustcord-sys/wrapper.h index f7cc8e2..6d88b6c 100644 --- a/rustcord-sys/wrapper.h +++ b/rustcord-sys/wrapper.h @@ -1 +1 @@ -#include "discord-rpc/include/discord_rpc.h" \ No newline at end of file +#include