2 Star 0 Fork 0

mirrors_sfackler/findshlibs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.rs 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
Nick Fitzgerald 提交于 2017-08-20 14:20 . Run cargo fmt
extern crate bindgen;
use std::env;
use std::path::PathBuf;
fn main() {
if cfg!(target_os = "linux") {
generate_linux_bindings();
} else if cfg!(target_os = "macos") {
generate_macos_bindings();
} else {
panic!("`findshlibs` does not support the target OS :(");
}
}
fn generate_linux_bindings() {
let bindings = bindgen::Builder::default()
.header("./src/linux/bindings.h")
.whitelisted_function("dl_iterate_phdr")
.whitelisted_type(r#"Elf\d*.*"#)
.whitelisted_var("PT_.*")
.generate()
.expect("Should generate linux FFI bindings OK");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("linux_bindings.rs"))
.expect("Should write linux_bindings.rs OK");
}
fn generate_macos_bindings() {
let bindings = bindgen::Builder::default()
.header("./src/macos/bindings.h")
.whitelisted_function("_dyld_.*")
.whitelisted_type("mach_header.*")
.whitelisted_type("load_command.*")
.whitelisted_type("segment_command.*")
.whitelisted_var("MH_MAGIC.*")
.whitelisted_var("LC_SEGMENT.*")
.generate()
.expect("Should generate macOS FFI bindings OK");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("macos_bindings.rs"))
.expect("Should write macos_bindings.rs OK");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_sfackler/findshlibs.git
[email protected]:mirrors_sfackler/findshlibs.git
mirrors_sfackler
findshlibs
findshlibs
master

搜索帮助