Skip to content

Reorganize the crate and rename to bindgen. #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
24 changes: 11 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ issue, provide us with:

## Building

To build `libbindgen`:
To build `bindgen`:

```
$ cd bindgen/libbindgen
$ cargo build
```

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
71 changes: 65 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,66 @@
[workspace]
members = [
"bindgen",
"bindgen-integration",
"libbindgen",
"libbindgen/tests/expectations",
[package]
authors = [
"Jyun-Yan You <[email protected]>",
"Emilio Cobos Álvarez <[email protected]>",
"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.20.0"
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_ = []
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ In `Cargo.toml`:
build = "build.rs"

[build-dependencies]
libbindgen = "0.1"
bindgen = "0.20"
```

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()
Expand Down
5 changes: 2 additions & 3 deletions bindgen-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ name = "bindgen-integration"
description = "A package to test various bindgen features"
version = "0.1.0"
authors = ["Emilio Cobos Álvarez <[email protected]>"]
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"]
4 changes: 2 additions & 2 deletions bindgen-integration/build.rs
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
26 changes: 0 additions & 26 deletions bindgen/Cargo.toml

This file was deleted.

File renamed without changes.
58 changes: 0 additions & 58 deletions libbindgen/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions libbindgen/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions bindgen/src/main.rs → src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
extern crate libbindgen;
extern crate bindgen;
extern crate env_logger;
#[macro_use]
extern crate log;
extern crate clang_sys;
extern crate clap;
extern crate rustc_serialize;

use libbindgen::clang_version;
use bindgen::clang_version;
use std::env;

mod options;
Expand Down
2 changes: 1 addition & 1 deletion bindgen/src/options.rs → src/options.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ description = "bindgen results when ran on ../headers/*"
version = "0.1.0"
authors = [
"Jyun-Yan You <[email protected]>",
"Emilio Cobos Álvarez <[email protected]>",
"Emilio Cobos Álvarez <[email protected]>",
"The Servo project developers",
]
workspace = "../../.."

[dependencies]
File renamed without changes.
Empty file added tests/expectations/src/lib.rs
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading