mirror of
https://gitee.com/openharmony/third_party_rust_bindgen
synced 2025-03-02 19:55:59 +00:00
commit
d38bf94a83
119
README_zh.md
Normal file
119
README_zh.md
Normal file
@ -0,0 +1,119 @@
|
||||
[](https://crates.io/crates/bindgen)
|
||||
[](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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user