From a1abc933bf102514faf3d30ff6b556c5fe60919e Mon Sep 17 00:00:00 2001 From: Avril Date: Thu, 19 Nov 2020 23:11:15 +0000 Subject: [PATCH] linking is a mistake --- .gitignore | 1 + build.rs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5a472f3..5efdbf5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target/ Cargo.lock *~ +lib/*.* diff --git a/build.rs b/build.rs index 355a8e4..3daec2e 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,7 @@ extern crate rustc_version; use rustc_version::{version, version_meta, Channel}; +use std::borrow::Cow; fn main() { // Assert we haven't travelled back in time @@ -25,5 +26,24 @@ fn main() { // Link to GHOST and required stuffs println!(r"cargo:rustc-link-search=./lib"); - println!("cargo:rustc-link-lib=dylib=stdc++"); // libstdc++ + const LINK_TO: &[&'static str] = + &["dylib=stdc++", //libstdc++ + "X11", //X11 + "OpenGL", "GL", //OpenGL + "GLU", "GLX", "GLEW", //GLEW + "spnav", + "Xxf86vm", "Xext", + "Xi", "Xrender", "Xfixes" + ]; + + for link in LINK_TO.iter().map(|x| Cow::<'static, str>::Borrowed(x)) + .chain(std::fs::read_dir("./lib").unwrap().filter_map(|lib| lib.ok() + .map(|entry| entry.path().file_stem() + .map(|x| x.to_str() + .map(|x| Cow::Owned((&x[3..]).to_owned()))) + .flatten()) + .flatten())) + { + println!("cargo:rustc-link-lib={}", link); + } }