4 Star 0 Fork 9

OpenHarmony/third_party_rust_link-cplusplus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.rs 1016 Bytes
一键复制 编辑 原始数据 按行查看 历史
use std::env;
use std::fs;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let libstdcxx = cfg!(feature = "libstdc++");
let libcxx = cfg!(feature = "libc++");
let nothing = cfg!(feature = "nothing");
if nothing {
return;
}
if libstdcxx && libcxx {
println!(
"cargo:warning=-lstdc++ and -lc++ are both requested, \
using the platform's default"
);
}
match (libstdcxx, libcxx) {
(true, false) => println!("cargo:rustc-link-lib=stdc++"),
(false, true) => println!("cargo:rustc-link-lib=c++"),
(false, false) | (true, true) => {
// The platform's default.
let out_dir = env::var_os("OUT_DIR").expect("missing OUT_DIR");
let path = PathBuf::from(out_dir).join("dummy.cc");
fs::write(&path, "int rust_link_cplusplus;\n").unwrap();
cc::Build::new().cpp(true).file(&path).compile("link-cplusplus");
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_rust_link-cplusplus.git
git@gitee.com:openharmony/third_party_rust_link-cplusplus.git
openharmony
third_party_rust_link-cplusplus
third_party_rust_link-cplusplus
master

搜索帮助