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

Update windows-bindgen dependency #1347

Merged
merged 1 commit into from
Jan 7, 2025
Merged

Update windows-bindgen dependency #1347

merged 1 commit into from
Jan 7, 2025

Conversation

kennykerr
Copy link
Contributor

Updates the cc crate to use the latest version of the windows-bindgen crate.
https://github.com/microsoft/windows-rs/releases/tag/0.61.0

A few notes worth mentioning about this change:

  • The bindgen arguments have been simplified and I've updated them to produce the same form of output.
  • The --etc option can be used to avoid having to parse the filter file yourself.
  • The filters no longer need to include the fully qualified type/function names.
  • The output is now sorted more consistently but is otherwise largely the same.
  • There are a handful of additional types in the output. Those reflect a more complete representation of the requested filters and their dependencies.

Here's more detailed information on the latest version of the windows-bindgen crate:
microsoft/windows-rs#3359

Adding @ChrisDenton as he originally came up with this model for the Rust project. I figure you'll be updating the bindings for the Rust compiler/library yourself so I thought I'd take a stab at this smaller project.

Comment on lines +73 to +90
pub type HINSTANCE = *mut core::ffi::c_void;
pub type HKEY = *mut core::ffi::c_void;
pub const HKEY_LOCAL_MACHINE: HKEY = -2147483646i32 as _;
pub type HMODULE = *mut core::ffi::c_void;
pub type HRESULT = i32;
pub type IMAGE_FILE_MACHINE = u16;
pub const IMAGE_FILE_MACHINE_AMD64: IMAGE_FILE_MACHINE = 34404u16;
pub const IID_IUnknown: GUID = GUID::from_u128(0x00000000_0000_0000_c000_000000000046);
#[repr(C)]
pub struct IUnknown_Vtbl {
pub QueryInterface: unsafe extern "system" fn(
this: *mut core::ffi::c_void,
iid: *const GUID,
interface: *mut *mut core::ffi::c_void,
) -> HRESULT,
pub AddRef: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32,
pub Release: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I wonder why these are added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metadata used to described HMODULE - required by FreeLibrary and friends - actually depends on HINSTANCE.

image

Similarly, CoCreateInstance depends on IUnknown.

This is what I meant by the following in the PR description:

There are a handful of additional types in the output. Those reflect a more complete representation of the requested filters and their dependencies.

The bindgen crate doesn't know whether you actually need these dependencies but it includes them as there are cases where they are definitely required.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for the detailed explanation!

@madsmtm madsmtm added dependencies Pull requests that update a dependency file O-windows Windows targets and toolchains labels Jan 7, 2025
@madsmtm madsmtm merged commit 685a1ef into rust-lang:main Jan 7, 2025
52 checks passed
@github-actions github-actions bot mentioned this pull request Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file O-windows Windows targets and toolchains
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants