mirror of
https://github.com/topjohnwu/cxx.git
synced 2024-11-23 03:49:44 +00:00
Support generate from path in cxx-gen
This commit is contained in:
parent
8b34a83f11
commit
7535230afb
@ -51,6 +51,7 @@ pub use crate::gen::include::{Include, HEADER};
|
||||
pub use crate::gen::{CfgEvaluator, CfgResult, GeneratedCode, Opt};
|
||||
pub use crate::syntax::IncludeKind;
|
||||
use proc_macro2::TokenStream;
|
||||
use std::path::Path;
|
||||
|
||||
/// Generate C++ bindings code from a Rust token stream. This should be a Rust
|
||||
/// token stream which somewhere contains a `#[cxx::bridge] mod {}`.
|
||||
@ -60,3 +61,9 @@ pub fn generate_header_and_cc(rust_source: TokenStream, opt: &Opt) -> Result<Gen
|
||||
.map_err(Error::from)?;
|
||||
gen::generate(syntax, opt).map_err(Error::from)
|
||||
}
|
||||
|
||||
/// Generate C++ bindings code from a file.
|
||||
/// This should be a Rust file containing a `#[cxx::bridge] mod {}`.
|
||||
pub fn generate_header_and_cc_with_path<P: AsRef<Path>>(path: P, opt: &Opt) -> GeneratedCode {
|
||||
gen::generate_from_path(path.as_ref(), opt)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user