From 3ccb35ccbb22599130c66b325b42f5acfbdfd2ca Mon Sep 17 00:00:00 2001 From: fangting Date: Mon, 24 Apr 2023 20:51:14 +0800 Subject: [PATCH] Add RAEDME_zh.md Issue:#I6YAO1 Signed-off-by: fangting --- README_zh.md | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 README_zh.md diff --git a/README_zh.md b/README_zh.md new file mode 100644 index 00000000..5ddd5f32 --- /dev/null +++ b/README_zh.md @@ -0,0 +1,119 @@ +[![crates.io](https://img.shields.io/crates/v/bindgen.svg)](https://crates.io/crates/bindgen) +[![docs.rs](https://docs.rs/bindgen/badge.svg)](https://docs.rs/bindgen/) + +## bindgen + +`bindgen` 自动生成Rust与C(和一些C++)库的FFI绑定。 + +例如,给定C头文件`doggo.h`: + +```c +typedef struct Doggo { + int many; + char wow; +} Doggo; + +void eleven_out_of_ten_majestic_af(Doggo* pupper); +``` + +`bindgen`产生Rust FFI代码,允许调用`doggo`库的函数并使用其类型: + +```rust +/* automatically generated by rust-bindgen 0.99.9 */ + +#[repr(C)] +pub struct Doggo { + pub many: ::std::os::raw::c_int, + pub wow: ::std::os::raw::c_char, +} + +extern "C" { + pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo); +} +``` + +## 目录结构 +bindgen的目录树结构如下: +``` +. +├── appveyor.yml +├── bindgen +│ ├── BUILD.gn +│ ├── build.rs +│ ├── callbacks.rs +│ ├── Cargo.toml +│ ├── codegen +│ ├── deps.rs +│ ├── extra_assertions.rs +│ ├── features.rs +│ ├── ir +│ ├── lib.rs +│ ├── LICENSE -> ../LICENSE +│ ├── log_stubs.rs +│ ├── parse.rs +│ ├── regex_set.rs +│ └── time.rs +├── bindgen-cli +│ ├── BUILD.gn +│ ├── Cargo.toml +│ ├── LICENSE -> ../LICENSE +│ ├── main.rs +│ └── options.rs +├── bindgen-integration +│ ├── build.rs +│ ├── Cargo.toml +│ ├── cpp +│ ├── include +│ └── src +├── bindgen-tests +│ ├── build.rs +│ ├── Cargo.toml +│ ├── src +│ └── tests +├── book +│ ├── book.toml +│ └── src +├── Cargo.lock +├── Cargo.toml +├── CHANGELOG.md +├── ci +│ ├── assert-no-diff.bat +│ ├── no-includes.sh +│ ├── test.bat +│ └── test.sh +├── CONTRIBUTING.md +├── csmith-fuzzing +│ ├── csmith.h +│ ├── driver.py +│ ├── predicate.py +│ └── README.md +├── example-graphviz-ir.png +├── LICENSE +├── OAT.xml +├── README.md +├── README.OpenSource +├── README_zh.md +├── releases +│ ├── friends.sh +│ └── release-announcement-template.md +└── rustfmt.toml +``` + + +## 使用指导 + +建议初学者先阅读[使用指导](https://rust-lang.github.io/rust-bindgen),然后build仓下rust/tests/test_bindgen_test来具体使用该工具加深理解。 + +## MSRV + +Minimum support Rust版本是**1.60.0**。 + +目前还没有制定MSRV提升政策,所以MSRV可能会在任何版本中增加。 + +MSRV是可用于编译`bindgen`的Minimum Rust版本。然而,`bindgen`可以生成与低于当前MSRV的Rust版本兼容的绑定。 + +## API参考 + +[API参考文档在docs.rs上](https://docs.rs/bindgen) + + -- Gitee