Skip to content

Commit 755a8eb

Browse files
committed
update code for 31 and 32
1 parent c402eef commit 755a8eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+130534
-0
lines changed

31_ffi/bzlib_sys/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "bzlib-sys"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
anyhow = "1"
8+
9+
[build-dependencies]
10+
bindgen = "0.59"

31_ffi/bzlib_sys/build.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
fn main() {
2+
// 告诉 rustc 需要 link bzip2
3+
println!("cargo:rustc-link-lib=bz2");
4+
5+
// 告诉 cargo 当 wrapper.h 变化时重新运行
6+
println!("cargo:rerun-if-changed=wrapper.h");
7+
8+
// 配置 bindgen,并生成 Bindings 结构
9+
let bindings = bindgen::Builder::default()
10+
.header("wrapper.h")
11+
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
12+
.generate()
13+
.expect("Unable to generate bindings");
14+
15+
// 生成 Rust 代码
16+
bindings
17+
.write_to_file("src/bindings.rs")
18+
.expect("Failed to write bindings");
19+
}

0 commit comments

Comments
 (0)