Skip to content
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

Add unstable_ir feature flag that makes the ir pub #1011

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pretty_assertions = "1.4.0"

[features]
default = ["clap"]
unstable_ir = []

[[bin]]
name = "cbindgen"
Expand Down
9 changes: 9 additions & 0 deletions docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,18 @@ cbindgen = "0.24.0"

If you'd like to use a `build.rs` script with a `cbindgen.toml`, consider using [`cbindgen::generate()`](https://docs.rs/cbindgen/*/cbindgen/fn.generate.html) instead.

## Internal Representation

Some users may find it useful to access the **unstable** internal representation (IR) that cbindgen uses to parse and generate code. By default, the IR is private, but you can access it by enabling the `"unstable_ir"` feature flag like so:

```
[build-dependencies]
cbindgen = { version = "0.27.0", features = ["unstable_ir"] }
```

This opens up the `cbindgen::bindgen::ir` module.

Please remember that the IR is **not stable**, so if you use this feature, you will need to pin cbindgen to avoid breakages.

# Writing Your C API

Expand Down
3 changes: 3 additions & 0 deletions src/bindgen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ mod config;
mod declarationtyperesolver;
mod dependencies;
mod error;
#[cfg(feature = "unstable_ir")]
pub mod ir;
#[cfg(not(feature = "unstable_ir"))]
mod ir;
mod language_backend;
mod library;
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ extern crate quote;
extern crate syn;
extern crate toml;

#[cfg(feature = "unstable_ir")]
pub mod bindgen;
#[cfg(not(feature = "unstable_ir"))]
mod bindgen;

pub use crate::bindgen::*;
Expand Down