Move cxx header search to method of Includes
diff --git a/gen/src/builtin.rs b/gen/src/builtin.rs
index 60bbf43..adcd048 100644
--- a/gen/src/builtin.rs
+++ b/gen/src/builtin.rs
@@ -48,11 +48,6 @@
let builtin = &mut out.builtin;
let out = &mut builtin.content;
- let cxx_header = include
- .custom
- .iter()
- .any(|header| header.path == "rust/cxx.h" || header.path == "rust\\cxx.h");
-
if builtin.rust_string {
include.array = true;
include.cstdint = true;
@@ -132,6 +127,7 @@
out.begin_block(Block::Namespace("rust"));
out.begin_block(Block::InlineNamespace("cxxbridge1"));
+ let cxx_header = include.has_cxx_header();
if !cxx_header {
writeln!(out, "// #include \"rust/cxx.h\"");
diff --git a/gen/src/include.rs b/gen/src/include.rs
index 93ce60b..029b08d 100644
--- a/gen/src/include.rs
+++ b/gen/src/include.rs
@@ -50,6 +50,12 @@
pub fn insert(&mut self, include: impl Into<Include>) {
self.custom.push(include.into());
}
+
+ pub fn has_cxx_header(&self) -> bool {
+ self.custom
+ .iter()
+ .any(|header| header.path == "rust/cxx.h" || header.path == "rust\\cxx.h")
+ }
}
pub(super) fn write(out: &mut OutFile) {