Add no_includes option
This commit is contained in:
@@ -65,9 +65,7 @@ impl Bindings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write<F: Write>(&self, file: F) {
|
pub fn write_headers<F: Write>(&self, out: &mut SourceWriter<F>) {
|
||||||
let mut out = SourceWriter::new(file, &self.config);
|
|
||||||
|
|
||||||
if let Some(ref f) = self.config.header {
|
if let Some(ref f) = self.config.header {
|
||||||
out.new_line_if_not_start();
|
out.new_line_if_not_start();
|
||||||
write!(out, "{}", f);
|
write!(out, "{}", f);
|
||||||
@@ -119,6 +117,14 @@ impl Bindings {
|
|||||||
write!(out, "#include \"{}\"", include);
|
write!(out, "#include \"{}\"", include);
|
||||||
out.new_line();
|
out.new_line();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write<F: Write>(&self, file: F) {
|
||||||
|
let mut out = SourceWriter::new(file, &self.config);
|
||||||
|
|
||||||
|
if !self.config.no_includes {
|
||||||
|
self.write_headers(&mut out);
|
||||||
|
}
|
||||||
|
|
||||||
for constant in &self.constants {
|
for constant in &self.constants {
|
||||||
if constant.ty.is_primitive_or_ptr_primitive() {
|
if constant.ty.is_primitive_or_ptr_primitive() {
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ impl Builder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
pub fn with_no_includes(mut self) -> Builder {
|
||||||
|
self.config.no_includes = true;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn with_include<S: AsRef<str>>(mut self, include: S) -> Builder {
|
pub fn with_include<S: AsRef<str>>(mut self, include: S) -> Builder {
|
||||||
self.config.includes.push(String::from(include.as_ref()));
|
self.config.includes.push(String::from(include.as_ref()));
|
||||||
|
|||||||
@@ -534,6 +534,11 @@ pub struct Config {
|
|||||||
pub trailer: Option<String>,
|
pub trailer: Option<String>,
|
||||||
/// Optional name to use for an include guard
|
/// Optional name to use for an include guard
|
||||||
pub include_guard: Option<String>,
|
pub include_guard: Option<String>,
|
||||||
|
/// Generates no includes at all. Overrides all other include options
|
||||||
|
///
|
||||||
|
/// This option is useful when using cbindgen with tools such as python's cffi which
|
||||||
|
/// doesn't understand include directives
|
||||||
|
pub no_includes: bool,
|
||||||
/// Optional text to output at major sections to deter manual editing
|
/// Optional text to output at major sections to deter manual editing
|
||||||
pub autogen_warning: Option<String>,
|
pub autogen_warning: Option<String>,
|
||||||
/// Include a comment with the version of cbindgen used to generate the file
|
/// Include a comment with the version of cbindgen used to generate the file
|
||||||
@@ -584,6 +589,7 @@ impl Default for Config {
|
|||||||
include_guard: None,
|
include_guard: None,
|
||||||
autogen_warning: None,
|
autogen_warning: None,
|
||||||
include_version: false,
|
include_version: false,
|
||||||
|
no_includes: false,
|
||||||
namespace: None,
|
namespace: None,
|
||||||
namespaces: None,
|
namespaces: None,
|
||||||
braces: Braces::SameLine,
|
braces: Braces::SameLine,
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
void root(void);
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
void root(void);
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
extern "C" {
|
||||||
|
|
||||||
|
void root();
|
||||||
|
|
||||||
|
} // extern "C"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
void root(void);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn root() {
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
no_includes = true
|
||||||
Reference in New Issue
Block a user