!4 Add README_zh.md

Merge pull request !4 from fangting/readme_zh
This commit is contained in:
openharmony_ci 2023-04-25 03:45:14 +00:00 committed by Gitee
commit d38bf94a83
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

119
README_zh.md Normal file
View File

@ -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)