代码拉取完成,页面将自动刷新
extern crate target_build_utils;
use target_build_utils::TargetInfo;
use std::io::Write;
use std::env;
fn main(){
let target = TargetInfo::new().expect("could not get target info");
match target.target_os() {
"linux" | "android" => println!("cargo:rustc-link-lib=dl"),
"freebsd" | "dragonfly" => println!("cargo:rustc-link-lib=c"),
// netbsd claims dl* will be available to any dynamically linked binary, but I haven’t
// found any libraries that have to be linked to on other platforms.
// What happens if the executable is not linked up dynamically?
"openbsd" | "bitrig" | "netbsd" | "macos" | "ios" => {}
// dependencies come with winapi
"windows" => {}
tos => {
writeln!(::std::io::stderr(),
"Building for an unknown target_os=`{}`!\nPlease report an issue ",
tos).expect("could not report the error");
::std::process::exit(0xfc);
}
}
maybe_test_helpers();
}
fn maybe_test_helpers() {
if env::var("OPT_LEVEL").ok().and_then(|v| v.parse().ok()).unwrap_or(0u64) != 0 {
// certainly not for testing, just skip.
return;
}
let mut outpath = if let Some(od) = env::var_os("OUT_DIR") { od } else { return };
let target = if let Some(t) = env::var_os("TARGET") { t } else { return };
let rustc = env::var_os("RUSTC").unwrap_or_else(|| { "rustc".into() });
outpath.push("/libtest_helpers.dll"); // extension for windows required, POSIX does not care.
let _ = ::std::process::Command::new(rustc)
.arg("src/test_helpers.rs")
.arg("-o")
.arg(outpath)
.arg("-O")
.arg("--target")
.arg(target)
.output();
// Ignore the failures here. We do not want failures of this thing to inhibit people from
// building and using the library. Might make it hard to debug why tests fail in case this
// library does not get built, though.
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。