-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[WinRT] Start exposing Windows Runtime headers to Swift #84669
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
Open
egorzhdan
wants to merge
1
commit into
swiftlang:main
Choose a base branch
from
egorzhdan:egorzhdan/winrt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//===--- WinRT.modulemap --------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
module WinRT [system] { | ||
link "WindowsApp.lib" | ||
export * | ||
|
||
module Base { | ||
header "WinRTBase.h" | ||
export * | ||
compnerd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
module hstring { | ||
header "hstring.h" | ||
export * | ||
} | ||
|
||
module RoAPI { | ||
header "roapi.h" | ||
export * | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// RUN: %target-build-swift %s | ||
// REQUIRES: OS=windows-msvc | ||
|
||
// Make sure that importing WinRT brings in the HSTRING type. | ||
|
||
import WinRT | ||
|
||
public func usesHSTRING(_ x: HSTRING) {} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
winsdk_winrt
seems like a more consistent name? it would be ideal toimport WinSDK.WinRT
as opposed toimport WinRT
. the latter can cause lots of collisions with other WINMD based projection tools which will generate code in theWinRT
moduleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is WinRT considered part of the Win32 SDK? I thought it was a separate parallel piece. The submodule support isn't sufficient to support that in Swift I think? So this will need to be a top-level module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is just the "Windows SDK" . the distinction between Win32 and WinRT are the APIs used. but since the module is called
WinSDK
it seems appropriate to keep them all together? ifWinSDK
was namedWin32
i would feel differentlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are other submodules in
WinSDK
, so that should be fine?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WinRT can't be a submodule of WinSDK mostly for build performance reasons. WinRT headers are huge, for instance for WinUI headers alone Clang produces a .pcm that is 300MB+ and takes over 10 minutes to precompile on my machine (with weak specs). Clang builds .pcms per top-level module, so all submodules are effectively merged into one. Similarly, Swift merges all submodules into a single module when importing them. That means that for a project that only uses Win32, clang would spend significant time prebuilding WinRT headers, and then Swift would spend time importing WinRT decls into Swift.
For this reason, I'm going to propose splitting WinRT headers into many top-level modules, e.g. having a top-level
module WindowsXyz
perwindows.xyz.*.h
. But that is out of scope of this PR ;)Is
WinRT
a conventional name for some of the modules that are generated by other tools?