You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
|
|
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
|
|
assert!(version().unwrap().major >= 1);
|
|
|
|
// Set cfg flags depending on release channel
|
|
match version_meta().unwrap().channel {
|
|
Channel::Stable => {
|
|
println!("cargo:rustc-cfg=stable");
|
|
}
|
|
Channel::Beta => {
|
|
println!("cargo:rustc-cfg=beta");
|
|
}
|
|
Channel::Nightly => {
|
|
println!("cargo:rustc-cfg=nightly");
|
|
}
|
|
Channel::Dev => {
|
|
println!("cargo:rustc-cfg=dev");
|
|
}
|
|
}
|
|
|
|
// Link to GHOST and required stuffs
|
|
println!(r"cargo:rustc-link-search=./lib");
|
|
|
|
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);
|
|
}
|
|
}
|