use std::env;
use std::fs;
#[cfg(unix)]
use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::symlink_dir;
use std::path::*;
fn announce_lib() {
#![allow(unreachable_code)] let mut lib_path = PathBuf::new();
lib_path.push(env::var("CARGO_MANIFEST_DIR").expect("Couldn't read manifest dir env var."));
lib_path.push(LIB_DIR);
let mut symlink_path = env::temp_dir();
let mut flag_path = symlink_path.clone();
symlink_path.push("frc-libs");
flag_path.push("frc-flag");
println!("cargo:rerun-if-changed={}", flag_path.display());
fs::write(flag_path, b"flag").expect("Could not write to temp flag file");
fs::remove_file(symlink_path.clone()).ok(); #[cfg(unix)]
{
symlink(lib_path, symlink_path).expect("Could not create lib symlink");
}
#[cfg(windows)]
{
symlink_dir(lib_path, symlink_path).expect("Could not create lib symlink");
}
#[cfg(not(any(windows, unix)))]
{
panic!("Platform is not Windows or UNIX!");
}
}
const LIB_DIR: &'static str = "lib";
const LIB_LIST: &'static [&'static str] = &[
"FRC_NetworkCommunication",
"NiFpga",
"NiFpgaLv",
"niriodevenum",
"niriosession",
"NiRioSrv",
"RoboRIO_FRC_ChipObject",
"visa",
"wpiHal",
"wpiutil",
];
fn link() {
for lib in LIB_LIST.iter() {
println!("cargo:rustc-link-lib=dylib={}", lib);
}
let path = env::current_dir().unwrap();
println!(
"cargo:rustc-link-search=native={}/{}",
path.display(),
LIB_DIR
);
}
fn always_run() {
#[cfg(feature = "dev")]
println!("cargo:rerun-if-changed=*");
}
fn main() {
always_run();
announce_lib();
link();
}