Skip to content
Open
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
7 changes: 7 additions & 0 deletions Runtimes/Overlay/Windows/clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ roots:
- name: module.modulemap
type: file
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/winsdk_shared.modulemap"
- name: "@WindowsSdkDir@/Include/@WindowsSDKVersion@/winrt"
type: directory
contents:
- name: module.modulemap
type: file
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/WinRT.modulemap"
- name: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/ucrt"
type: directory
contents:
Expand Down Expand Up @@ -55,4 +61,5 @@ install(FILES
vcruntime.modulemap
winsdk_um.modulemap
winsdk_shared.modulemap
WinRT.modulemap
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
1 change: 1 addition & 0 deletions Runtimes/Resync.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ copy_files(public/Platform Overlay/Windows/clang
ucrt.modulemap
winsdk_um.modulemap
winsdk_shared.modulemap
WinRT.modulemap
vcruntime.modulemap
vcruntime.apinotes)

Expand Down
9 changes: 9 additions & 0 deletions lib/ClangImporter/ClangIncludePaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,15 @@ void GetWindowsFileMappings(
if (!AuxiliaryFile.empty())
fileMapping.redirectedFiles.emplace_back(std::string(WinSDKInjection),
AuxiliaryFile);

llvm::sys::path::remove_filename(WinSDKInjection);
llvm::sys::path::remove_filename(WinSDKInjection);
llvm::sys::path::append(WinSDKInjection, "winrt", "module.modulemap");
AuxiliaryFile =
GetPlatformAuxiliaryFile("windows", "WinRT.modulemap", SearchPathOpts);
if (!AuxiliaryFile.empty())
fileMapping.redirectedFiles.emplace_back(std::string(WinSDKInjection),
AuxiliaryFile);
}

struct {
Expand Down
6 changes: 6 additions & 0 deletions stdlib/cmake/WindowsVFS.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ roots:
- name: module.modulemap
type: file
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\winsdk_shared.modulemap"
- name: "@UniversalCRTSdkDir@\\Include\\@UCRTVersion@\\winrt"
type: directory
contents:
- name: module.modulemap
type: file
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\WinRT.modulemap"
- name: "@UniversalCRTSdkDir@\\Include\\@UCRTVersion@\\ucrt"
type: directory
contents:
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ if(WINDOWS IN_LIST SWIFT_SDKS)
vcruntime.modulemap
winsdk_um.modulemap
winsdk_shared.modulemap
WinRT.modulemap
DESTINATION "share"
COMPONENT sdk-overlay)
endif()
Expand Down
31 changes: 31 additions & 0 deletions stdlib/public/Platform/WinRT.modulemap
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 *
}

module hstring {
header "hstring.h"
export *
}

module RoAPI {
header "roapi.h"
export *
}
}
8 changes: 8 additions & 0 deletions test/stdlib/WinRT_HSTRING.swift
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) {}