Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to suppress windows-bindgen comment in generated code #2910

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/libs/bindgen/src/rust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/rust/try_format.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
2 changes: 2 additions & 0 deletions crates/libs/bindgen/src/rust/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<metadata::TypeDef, String>,
}
Expand All @@ -36,6 +37,7 @@ impl Writer {
package: false,
minimal: false,
no_inner_attributes: false,
no_bindgen_comment: false,
vtbl: false,
prepend: Default::default(),
}
Expand Down
2 changes: 0 additions & 2 deletions crates/libs/core/src/imp/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)]
::windows_targets::link!("api-ms-win-core-winrt-l1-1-0.dll" "system" fn RoGetActivationFactory(activatableclassid : * mut core::ffi::c_void, iid : *const GUID, factory : *mut *mut core::ffi::c_void) -> HRESULT);
::windows_targets::link!("kernel32.dll" "system" fn CloseHandle(hobject : HANDLE) -> BOOL);
Expand Down
2 changes: 0 additions & 2 deletions crates/libs/core/src/imp/com_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)]
#[inline]
pub unsafe fn CoCreateGuid() -> windows_core::Result<windows_core::GUID> {
Expand Down
2 changes: 0 additions & 2 deletions crates/libs/metadata/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)]
pub type CorElementType = u8;
pub const ELEMENT_TYPE_ARRAY: CorElementType = 20u8;
Expand Down
2 changes: 0 additions & 2 deletions crates/libs/registry/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/registry/tests/bindings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--out src/bindings.rs
--config flatten sys minimal
--config flatten sys minimal no-bindgen-comment

--filter
Windows.Win32.Foundation.ERROR_INVALID_DATA
Expand Down
2 changes: 0 additions & 2 deletions crates/libs/result/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/result/tests/bindings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--out src/bindings.rs
--config flatten sys minimal vtbl
--config flatten sys minimal vtbl no-bindgen-comment

--filter
Windows.Win32.Foundation.E_INVALIDARG
Expand Down
2 changes: 0 additions & 2 deletions crates/libs/version/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
1 change: 1 addition & 0 deletions crates/libs/version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ mod test {
"--config",
"flatten",
"sys",
"no-bindgen-comment",
"--filter",
"Windows.Wdk.System.SystemServices.RtlGetVersion",
"Windows.Win32.System.SystemInformation.OSVERSIONINFOEXW",
Expand Down
1 change: 1 addition & 0 deletions crates/tests/component/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ fn main() {
"test_component",
"--config",
"implement",
"no-bindgen-comment",
]);

if !command.status().unwrap().success() {
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/component/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 2 additions & 0 deletions crates/tests/component_client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ fn main() {
"src/bindings.rs",
"--filter",
"test_component",
"--config",
"no-bindgen-comment",
]);

if !command.status().unwrap().success() {
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/component_client/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/generic_interfaces.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
13 changes: 12 additions & 1 deletion crates/tests/riddle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ pub fn run_riddle(name: &str, dialect: &str, etc: &[&str]) -> Vec<windows_metada
std::fs::remove_file(&rs).expect("Failed to delete output");
let mut command = Command::new("cargo");
command.args([
"run", "-p", "riddle", "--", "--in", &rdl, "--out", &rs, "--filter", "Test",
"run",
"-p",
"riddle",
"--",
"--in",
&rdl,
"--out",
&rs,
"--filter",
"Test",
"--config",
"no-bindgen-comment",
]);
command.args(etc);
assert!(command.status().unwrap().success());
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/module_attributes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/nested_module.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/nested_struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/params.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/win32_struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/riddle/src/winrt_struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/standalone/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ fn riddle(output: &str, filter: &[&str], config: &[&str]) {
]);

command.args(filter);
command.arg("--config");
command.args(["--config", "no-bindgen-comment"]);
command.args(config);

if !command.status().unwrap().success() {
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_arch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_arch_dependencies.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_bstr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_calendar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_constant_types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_depends.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_enumeration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_enumerator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_guid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_hresult.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_hstring.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_include_me.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#[inline]
pub unsafe fn GetVersion() -> u32 {
::windows_targets::link!("kernel32.dll" "system" fn GetVersion() -> u32);
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_inspectable.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_nested.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_none.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_overloads.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_pcstr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_pcwstr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_prepend.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_pstr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_pwstr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_std.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_stringable.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_unknown.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_uri.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_variant.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_vtbl_0.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_vtbl_1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_vtbl_2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_vtbl_3.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_vtbl_4.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
2 changes: 0 additions & 2 deletions crates/tests/standalone/src/b_win_enumerator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Bindings generated by `windows-bindgen` 0.54.0

#![allow(
non_snake_case,
non_upper_case_globals,
Expand Down
Loading