Skip to content

Commit

Permalink
Add unstable_ir feature flag that makes the ir pub
Browse files Browse the repository at this point in the history
Rename to unstable_ir, add docs

Push omitted file
  • Loading branch information
Heesoo Yang committed Oct 30, 2024
1 parent 89a9faa commit 3d3e702
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
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

0 comments on commit 3d3e702

Please sign in to comment.