From c30f5be0cc2d601adb917079e96a2100052bc2b5 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Tue, 5 Mar 2024 09:43:12 -0600 Subject: [PATCH] no-bindgen-comment --- crates/libs/bindgen/src/rust/mod.rs | 1 + crates/libs/bindgen/src/rust/try_format.rs | 2 +- crates/libs/bindgen/src/rust/writer.rs | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/libs/bindgen/src/rust/mod.rs b/crates/libs/bindgen/src/rust/mod.rs index 6c634a22eb..3afe0463d6 100644 --- a/crates/libs/bindgen/src/rust/mod.rs +++ b/crates/libs/bindgen/src/rust/mod.rs @@ -32,6 +32,7 @@ pub fn from_reader(reader: &'static metadata::Reader, mut config: std::collectio writer.implement = config.remove("implement").is_some(); writer.minimal = config.remove("minimal").is_some(); writer.no_inner_attributes = config.remove("no-inner-attributes").is_some(); + writer.no_bindgen_comment = config.remove("no-bindgen-comment").is_some(); writer.vtbl = config.remove("vtbl").is_some(); if writer.package && writer.flatten { diff --git a/crates/libs/bindgen/src/rust/try_format.rs b/crates/libs/bindgen/src/rust/try_format.rs index 0d7047105f..715f9a20ff 100644 --- a/crates/libs/bindgen/src/rust/try_format.rs +++ b/crates/libs/bindgen/src/rust/try_format.rs @@ -1,7 +1,7 @@ use std::io::Write; pub fn try_format(writer: &super::Writer, tokens: &str) -> String { - let preamble = if writer.package { + let preamble = if writer.no_bindgen_comment { String::new() } else { let name = std::env!("CARGO_PKG_NAME"); diff --git a/crates/libs/bindgen/src/rust/writer.rs b/crates/libs/bindgen/src/rust/writer.rs index 64c883d875..6e7a3c418e 100644 --- a/crates/libs/bindgen/src/rust/writer.rs +++ b/crates/libs/bindgen/src/rust/writer.rs @@ -19,6 +19,7 @@ pub struct Writer { pub package: bool, // default is single file with no cfg - implies !flatten pub minimal: bool, // strips out enumerators - in future possibly other helpers as well pub no_inner_attributes: bool, // skips the inner attributes at the start of the file + pub no_bindgen_comment: bool, // skips the bindgen comment at the start of the file pub vtbl: bool, // include minimal vtbl layout support for interfaces pub prepend: std::collections::HashMap, } @@ -36,6 +37,7 @@ impl Writer { package: false, minimal: false, no_inner_attributes: false, + no_bindgen_comment: false, vtbl: false, prepend: Default::default(), }