-
Notifications
You must be signed in to change notification settings - Fork 585
Improve windows-bindgen dependency targeting consistency and flexibility
#3763
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
Merged
+21,235
−20,971
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Thanks for the detailed outline! I haven't tried this out yet but will keep a list of crates to test this out on when the next update lands on crates.io. Two things:
|
This was referenced Sep 22, 2025
Merged
This was referenced Sep 26, 2025
MarijnS95
added a commit
to MarijnS95/generator-rs
that referenced
this pull request
Sep 26, 2025
…indows-result` https://github.com/Microsoft/windows-rs/releases/70 As highlighted in Xudong-Huang#76 we couldn't use the non-`sys` bindings without pulling in `windows-core` with all its COM support (that this crate doesn't need) and significant version-churn cadence like the `windows` crate itself. Fortunately since then `windows-bindgen` was updated with a new `--specific-deps` configuration option in microsoft/windows-rs#3763 that allows it to prefer using the "special crates" like `windows-link` and `windows-result` over their relative reexports from `windows-core`.
Xudong-Huang
pushed a commit
to Xudong-Huang/generator-rs
that referenced
this pull request
Sep 29, 2025
…indows-result` https://github.com/Microsoft/windows-rs/releases/70 As highlighted in #76 we couldn't use the non-`sys` bindings without pulling in `windows-core` with all its COM support (that this crate doesn't need) and significant version-churn cadence like the `windows` crate itself. Fortunately since then `windows-bindgen` was updated with a new `--specific-deps` configuration option in microsoft/windows-rs#3763 that allows it to prefer using the "special crates" like `windows-link` and `windows-result` over their relative reexports from `windows-core`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today it can be a little hard to manage your dependencies when
windows-bindgenintroduces dependencies in generated code. Although--no-depsis useful for raw or sys-style bindings to limit or eliminate dependencies, it is not so easy to limit or eliminate dependencies for the default richer bindings generated bywindows-bindgenand required for more convenient access to COM and WinRT APIs.This update does two things:
Improve consistency and convenience by default when
windows-coreis required to avoid a growing set of dependencies by usingwindows-coreuniformly for most dependencies where feasible.Allow for more granular and specific dependency targeting and avoid the
windows-coredependency unless required with the new--specific-depsoption.Let's say for example you generate bindings for the
IsCharLowerAfunctionToday the resulting bindings look something like this:
Here you'll need to add dependencies for both the
windows-coreandwindows-linkcrates.Following this change, the generated bindings will use
windows-coreexclusively to avoid the need for the extra explicit dependency:As you can see, only the
windows-corecrate is assumed by the generated bindings. Note that this is merely a convenience to simplify dependency and version management. You will still get a dependency on thewindows-linkcrate in both cases. You just don't need to manage this dependency yourself in the latter case.On the other hand, you may want to avoid a dependency on the
windows-corecrate entirely because it is non-trivial and only really required for COM support. In such cases, you can opt in to manage your dependencies more directly with the new--specific-depsoption that will instructwindows-bindgento use the most specific crate dependencies where feasible.Take for example the
WindowsStringHasEmbeddedNullfunction. As before, this would previously require a dependency on both thewindows-coreandwindows-linkcrates:Following this change, it will by default only require the
windows-corecrate:To avoid a dependency on the
windows-corecrate entirely and instead target the specific - and much smaller - crates directly you only need to add the new--specific-depsoption to produce the following:As you can see, the bindings now directly reference the
windows-strings,windows-result, andwindows-linkcrates. This option is not the default because this level of control is not for everyone but if that's you then enjoy!