Skip to content

Commit 80c50c6

Browse files
Heesoo Yangemilio
Heesoo Yang
authored andcommitted
Add unstable_ir feature flag that makes the ir pub
Rename to unstable_ir, add docs Push omitted file
1 parent e82815e commit 80c50c6

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pretty_assertions = "1.4.0"
4141

4242
[features]
4343
default = ["clap"]
44+
unstable_ir = []
4445

4546
[[bin]]
4647
name = "cbindgen"

docs.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,18 @@ cbindgen = "0.24.0"
9494

9595
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.
9696

97+
## Internal Representation
9798

99+
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:
98100

101+
```
102+
[build-dependencies]
103+
cbindgen = { version = "0.27.0", features = ["unstable_ir"] }
104+
```
105+
106+
This opens up the `cbindgen::bindgen::ir` module.
99107

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

101110
# Writing Your C API
102111

src/bindgen/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ mod config;
4545
mod declarationtyperesolver;
4646
mod dependencies;
4747
mod error;
48+
#[cfg(feature = "unstable_ir")]
49+
pub mod ir;
50+
#[cfg(not(feature = "unstable_ir"))]
4851
mod ir;
4952
mod language_backend;
5053
mod library;

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ extern crate quote;
1414
extern crate syn;
1515
extern crate toml;
1616

17+
#[cfg(feature = "unstable_ir")]
18+
pub mod bindgen;
19+
#[cfg(not(feature = "unstable_ir"))]
1720
mod bindgen;
1821

1922
pub use crate::bindgen::*;

0 commit comments

Comments
 (0)