Introducing the windows-link
crate
#3450
Merged
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.
This update introduces the
windows-link
crate as a simpler alternative to thewindows-targets
crate. It provides the exact samelink
macro but usesraw-dylib
unconditionally and thus has no target-specific dependencies to include import libs. This means that thewindows-link
crate requires Rust 1.71 or later as that was the first version to stabilizeraw-dylib
for all Windows targets.The
windows-bindgen
crate is also updated to default to usewindows-link
for functions. You can opt-out by using the new--link
option and specify a different module for thelink
macro. For example, thewindows-sys
crate continues to usewindows-targets
as it has an older MSRV. It does so by using the following optionbindgen
arguments:--link windows_targets
The
windows-targets
crate is unchanged and will continue to be updated for the time being to supportwindows-sys
. It continues to support thewindows_raw_dylib
cfg option for opting in toraw-dylib
whereas the newwindows-link
crate ignores thewindows_raw_dylib
cfg option and usesraw-dylib
in all cases.As an example, consider the following build script.
This will produce the following output:
Add a dependency on the
windows-link
crate and you're all set!You can then use the new
--link
argument only if you need to change this.This will produce the following altered output to once again use the
windows-targets
crate.