mirror of
https://gitee.com/openharmony/third_party_rust_bindgen
synced 2025-03-04 20:57:21 +00:00
Unify under the bindgen
name.
This commit is contained in:
parent
7373a4258f
commit
b83da2729f
@ -23,8 +23,6 @@ cache:
|
||||
|
||||
before_install: . ./ci/before_install.sh
|
||||
|
||||
before_script: cd libbindgen
|
||||
|
||||
script:
|
||||
- cargo test --features "$BINDGEN_FEATURES assert_no_dangling_items"
|
||||
- cargo test --release --features "$BINDGEN_FEATURES assert_no_dangling_items"
|
||||
@ -34,10 +32,7 @@ script:
|
||||
- cargo build --features "$BINDGEN_FEATURES docs_"
|
||||
- cd tests/expectations
|
||||
- cargo test
|
||||
- cd ../../../bindgen
|
||||
- cargo test --features "$BINDGEN_FEATURES"
|
||||
- cargo test --release --features "$BINDGEN_FEATURES"
|
||||
- cd ../bindgen-integration
|
||||
- cd ../../bindgen-integration
|
||||
- cargo test --features "$BINDGEN_FEATURES"
|
||||
- cargo test --release --features "$BINDGEN_FEATURES"
|
||||
|
||||
|
@ -42,10 +42,9 @@ issue, provide us with:
|
||||
|
||||
## Building
|
||||
|
||||
To build `libbindgen`:
|
||||
To build `bindgen`:
|
||||
|
||||
```
|
||||
$ cd bindgen/libbindgen
|
||||
$ cargo build
|
||||
```
|
||||
|
||||
@ -77,21 +76,21 @@ that you aren't forgetting to document types and functions. CI will catch it if
|
||||
you forget, but the turn around will be a lot slower ;)
|
||||
|
||||
```
|
||||
$ cd libbindgen && cargo build --features "llvm_stable _docs"
|
||||
$ cargo build --features "llvm_stable _docs"
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Code for binding generation and testing thereof is in the `libbindgen` crate.
|
||||
Code for binding generation and testing thereof is in the `bindgen` crate.
|
||||
The following sections assume you are working in that subdirectory.
|
||||
|
||||
### Overview
|
||||
|
||||
Input C/C++ test headers reside in the `libbindgen/tests/headers`
|
||||
directory. Expected output Rust bindings live in
|
||||
`libbindgen/tests/expectations/tests`. For example,
|
||||
`libbindgen/tests/headers/my_header.h`'s expected generated Rust bindings would
|
||||
be `libbindgen/tests/expectations/tests/my_header.rs`.
|
||||
Input C/C++ test headers reside in the `tests/headers` directory. Expected
|
||||
output Rust bindings live in `tests/expectations/tests`.
|
||||
|
||||
For example, `tests/headers/my_header.h`'s expected generated Rust bindings
|
||||
would be `tests/expectations/tests/my_header.rs`.
|
||||
|
||||
Run `cargo test` to compare generated Rust bindings to the expectations.
|
||||
|
||||
@ -144,17 +143,16 @@ And ensure `~/.cargo/bin` is on your path.
|
||||
## Debug Logging
|
||||
|
||||
To help debug what `bindgen` is doing, you can define the environment variable
|
||||
`RUST_LOG=libbindgen` to get a bunch of debugging log spew.
|
||||
`RUST_LOG=bindgen` to get a bunch of debugging log spew.
|
||||
|
||||
```
|
||||
$ RUST_LOG=libbindgen ./target/debug/bindgen [flags...] ~/path/to/some/header.h
|
||||
$ RUST_LOG=bindgen ./target/debug/bindgen [flags...] ~/path/to/some/header.h
|
||||
```
|
||||
|
||||
This logging can also be used when debugging failing tests:
|
||||
|
||||
```
|
||||
$ cd libbindgen
|
||||
$ RUST_LOG=libbindgen cargo test
|
||||
$ RUST_LOG=bindgen cargo test
|
||||
```
|
||||
|
||||
## Using `creduce` to Minimize Test Cases
|
||||
|
71
Cargo.toml
71
Cargo.toml
@ -1,7 +1,66 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"bindgen",
|
||||
"bindgen-integration",
|
||||
"libbindgen",
|
||||
"libbindgen/tests/expectations",
|
||||
[package]
|
||||
authors = [
|
||||
"Jyun-Yan You <jyyou.tw@gmail.com>",
|
||||
"Emilio Cobos Álvarez <emilio@crisal.io>",
|
||||
"The Servo project developers",
|
||||
]
|
||||
description = "A binding generator for Rust"
|
||||
homepage = "https://github.com/servo/rust-bindgen"
|
||||
keywords = ["bindings", "ffi", "code-generation"]
|
||||
license = "BSD-3-Clause"
|
||||
name = "bindgen"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/servo/rust-bindgen"
|
||||
version = "0.1.7"
|
||||
build = "build.rs"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "bindgen"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dev-dependencies]
|
||||
diff = "0.1"
|
||||
clap = "2"
|
||||
shlex = "0.1"
|
||||
|
||||
[build-dependencies]
|
||||
quasi_codegen = "0.26"
|
||||
|
||||
[dependencies]
|
||||
cexpr = "0.2"
|
||||
cfg-if = "0.1.0"
|
||||
clang-sys = { version = "0.12", features = ["runtime", "clang_3_9"] }
|
||||
lazy_static = "0.2.1"
|
||||
rustc-serialize = "0.3.19"
|
||||
syntex_syntax = "0.54"
|
||||
regex = "0.2"
|
||||
# This kinda sucks: https://github.com/rust-lang/cargo/issues/1982
|
||||
clap = "2"
|
||||
|
||||
[dependencies.aster]
|
||||
features = ["with-syntex"]
|
||||
version = "0.38"
|
||||
|
||||
[dependencies.env_logger]
|
||||
optional = true
|
||||
version = "0.4"
|
||||
|
||||
[dependencies.log]
|
||||
optional = true
|
||||
version = "0.3"
|
||||
|
||||
[dependencies.quasi]
|
||||
features = ["with-syntex"]
|
||||
version = "0.29"
|
||||
|
||||
[features]
|
||||
assert_no_dangling_items = []
|
||||
default = ["logging"]
|
||||
llvm_stable = []
|
||||
logging = ["env_logger", "log"]
|
||||
static = []
|
||||
# This feature only exists for CI -- don't use it!
|
||||
docs_ = []
|
||||
|
@ -117,20 +117,20 @@ In `Cargo.toml`:
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
libbindgen = "0.1"
|
||||
bindgen = "0.1"
|
||||
```
|
||||
|
||||
In `build.rs`:
|
||||
|
||||
```rust
|
||||
extern crate libbindgen;
|
||||
extern crate bindgen;
|
||||
|
||||
use std::env;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let _ = libbindgen::builder()
|
||||
let _ = bindgen::builder()
|
||||
.header("example.h")
|
||||
.use_core()
|
||||
.generate().unwrap()
|
||||
|
@ -3,13 +3,12 @@ name = "bindgen-integration"
|
||||
description = "A package to test various bindgen features"
|
||||
version = "0.1.0"
|
||||
authors = ["Emilio Cobos Álvarez <emilio@crisal.io>"]
|
||||
workspace = ".."
|
||||
publish = false
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
libbindgen = { path = "../libbindgen" }
|
||||
bindgen = { path = ".." }
|
||||
gcc = "0.3"
|
||||
|
||||
[features]
|
||||
llvm_stable = ["libbindgen/llvm_stable"]
|
||||
llvm_stable = ["bindgen/llvm_stable"]
|
||||
|
@ -1,9 +1,9 @@
|
||||
extern crate libbindgen;
|
||||
extern crate bindgen;
|
||||
extern crate gcc;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use libbindgen::Builder;
|
||||
use bindgen::Builder;
|
||||
|
||||
fn main() {
|
||||
gcc::Config::new()
|
||||
|
@ -1,26 +0,0 @@
|
||||
[package]
|
||||
authors = [
|
||||
"Jyun-Yan You <jyyou.tw@gmail.com>",
|
||||
"Emilio Cobos Álvarez <ecoal95@gmail.com>",
|
||||
"The Servo project developers",
|
||||
]
|
||||
description = "A binding generator for Rust"
|
||||
homepage = "https://github.com/servo/rust-bindgen"
|
||||
keywords = ["bindings", "ffi", "code-generation"]
|
||||
license = "BSD-3-Clause"
|
||||
name = "bindgen"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/servo/rust-bindgen"
|
||||
version = "0.17.1"
|
||||
workspace = ".."
|
||||
|
||||
[dependencies]
|
||||
clang-sys = "0.12"
|
||||
clap = "2"
|
||||
libbindgen = { path = "../libbindgen" }
|
||||
log = "0.3"
|
||||
env_logger = "0.4"
|
||||
rustc-serialize = "0.3.19"
|
||||
|
||||
[features]
|
||||
llvm_stable = ["libbindgen/llvm_stable"]
|
@ -1,58 +0,0 @@
|
||||
[package]
|
||||
authors = [
|
||||
"Jyun-Yan You <jyyou.tw@gmail.com>",
|
||||
"Emilio Cobos Álvarez <ecoal95@gmail.com>",
|
||||
"The Servo project developers",
|
||||
]
|
||||
build = "build.rs"
|
||||
description = "A binding generator for Rust"
|
||||
homepage = "https://github.com/servo/rust-bindgen"
|
||||
keywords = ["bindings", "ffi", "code-generation"]
|
||||
license = "BSD-3-Clause"
|
||||
name = "libbindgen"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/servo/rust-bindgen"
|
||||
version = "0.1.7"
|
||||
workspace = ".."
|
||||
|
||||
[dev-dependencies]
|
||||
diff = "0.1"
|
||||
clap = "2"
|
||||
shlex = "0.1"
|
||||
|
||||
[build-dependencies]
|
||||
quasi_codegen = "0.26"
|
||||
|
||||
[dependencies]
|
||||
cexpr = "0.2"
|
||||
cfg-if = "0.1.0"
|
||||
clang-sys = { version = "0.12", features = ["runtime", "clang_3_9"] }
|
||||
lazy_static = "0.2.1"
|
||||
rustc-serialize = "0.3.19"
|
||||
syntex_syntax = "0.54"
|
||||
regex = "0.2"
|
||||
|
||||
[dependencies.aster]
|
||||
features = ["with-syntex"]
|
||||
version = "0.38"
|
||||
|
||||
[dependencies.env_logger]
|
||||
optional = true
|
||||
version = "0.4"
|
||||
|
||||
[dependencies.log]
|
||||
optional = true
|
||||
version = "0.3"
|
||||
|
||||
[dependencies.quasi]
|
||||
features = ["with-syntex"]
|
||||
version = "0.29"
|
||||
|
||||
[features]
|
||||
assert_no_dangling_items = []
|
||||
default = ["logging"]
|
||||
llvm_stable = []
|
||||
logging = ["env_logger", "log"]
|
||||
static = []
|
||||
# This feature only exists for CI -- don't use it!
|
||||
docs_ = []
|
@ -1,3 +0,0 @@
|
||||
# `libbindgen`
|
||||
|
||||
Generate Rust FFI bindings from C/C++ header files.
|
@ -1,4 +1,4 @@
|
||||
extern crate libbindgen;
|
||||
extern crate bindgen;
|
||||
extern crate env_logger;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
@ -6,7 +6,7 @@ extern crate clang_sys;
|
||||
extern crate clap;
|
||||
extern crate rustc_serialize;
|
||||
|
||||
use libbindgen::clang_version;
|
||||
use bindgen::clang_version;
|
||||
use std::env;
|
||||
|
||||
mod options;
|
@ -1,5 +1,5 @@
|
||||
use clap::{App, Arg};
|
||||
use libbindgen::{Builder, CodegenConfig, builder};
|
||||
use bindgen::{Builder, CodegenConfig, builder};
|
||||
use std::fs::File;
|
||||
use std::io::{self, Error, ErrorKind};
|
||||
|
@ -4,9 +4,8 @@ description = "bindgen results when ran on ../headers/*"
|
||||
version = "0.1.0"
|
||||
authors = [
|
||||
"Jyun-Yan You <jyyou.tw@gmail.com>",
|
||||
"Emilio Cobos Álvarez <ecoal95@gmail.com>",
|
||||
"Emilio Cobos Álvarez <emilio@crisal.io>",
|
||||
"The Servo project developers",
|
||||
]
|
||||
workspace = "../../.."
|
||||
|
||||
[dependencies]
|
0
tests/expectations/src/lib.rs
Normal file
0
tests/expectations/src/lib.rs
Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user