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
11 changes: 9 additions & 2 deletions Runtimes/Overlay/Windows/clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ roots:
contents:
- name: module.modulemap
type: file
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/winsdk.modulemap"
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/winsdk_um.modulemap"
- name: "@WindowsSdkDir@/Include/@WindowsSDKVersion@/shared"
type: directory
contents:
- name: module.modulemap
type: file
external-contents: "@CMAKE_CURRENT_SOURCE_DIR@/winsdk_shared.modulemap"
- name: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/ucrt"
type: directory
contents:
Expand Down Expand Up @@ -47,5 +53,6 @@ install(FILES
ucrt.modulemap
vcruntime.apinotes
vcruntime.modulemap
winsdk.modulemap
winsdk_um.modulemap
winsdk_shared.modulemap
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
3 changes: 2 additions & 1 deletion Runtimes/Resync.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ message(STATUS "Windows modulemaps[${StdlibSources}/Platform] -> ${CMAKE_CURRENT
copy_files(public/Platform Overlay/Windows/clang
FILES
ucrt.modulemap
winsdk.modulemap
winsdk_um.modulemap
winsdk_shared.modulemap
vcruntime.modulemap
vcruntime.apinotes)

Expand Down
17 changes: 13 additions & 4 deletions lib/ClangImporter/ClangIncludePaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,23 @@ void GetWindowsFileMappings(
WindowsSDK.Path, WindowsSDK.MajorVersion,
WindowsSDK.IncludeVersion,
WindowsSDK.LibraryVersion)) {
assert(WindowsSDK.MajorVersion > 8);
llvm::SmallString<261> WinSDKInjection{WindowsSDK.Path};
llvm::sys::path::append(WinSDKInjection, "Include");
if (WindowsSDK.MajorVersion > 8)
llvm::sys::path::append(WinSDKInjection, WindowsSDK.IncludeVersion, "um");
llvm::sys::path::append(WinSDKInjection, WindowsSDK.IncludeVersion, "um");
llvm::sys::path::append(WinSDKInjection, "module.modulemap");

AuxiliaryFile =
GetPlatformAuxiliaryFile("windows", "winsdk.modulemap", SearchPathOpts);
AuxiliaryFile = GetPlatformAuxiliaryFile("windows", "winsdk_um.modulemap",
SearchPathOpts);
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, "shared", "module.modulemap");
AuxiliaryFile = GetPlatformAuxiliaryFile(
"windows", "winsdk_shared.modulemap", SearchPathOpts);
if (!AuxiliaryFile.empty())
fileMapping.redirectedFiles.emplace_back(std::string(WinSDKInjection),
AuxiliaryFile);
Expand Down
8 changes: 7 additions & 1 deletion stdlib/cmake/WindowsVFS.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ roots:
contents:
- name: module.modulemap
type: file
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\winsdk.modulemap"
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\winsdk_um.modulemap"
- name: "@UniversalCRTSdkDir@\\Include\\@UCRTVersion@\\shared"
type: directory
contents:
- name: module.modulemap
type: file
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\winsdk_shared.modulemap"
- name: "@UniversalCRTSdkDir@\\Include\\@UCRTVersion@\\ucrt"
type: directory
contents:
Expand Down
3 changes: 2 additions & 1 deletion stdlib/public/Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ if(WINDOWS IN_LIST SWIFT_SDKS)
ucrt.modulemap
vcruntime.apinotes
vcruntime.modulemap
winsdk.modulemap
winsdk_um.modulemap
winsdk_shared.modulemap
DESTINATION "share"
COMPONENT sdk-overlay)
endif()
Expand Down
16 changes: 16 additions & 0 deletions stdlib/public/Platform/winsdk_shared.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===--- WinSDK_Shared.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 _GUID {
header "guiddef.h"
export *
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- WinSDK.modulemap -------------------------------------------------===//
//===--- WinSDK_UM.modulemap ----------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
Expand Down
1 change: 1 addition & 0 deletions stdlib/public/Windows/WinSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

@_exported import ucrt
@_exported import _GUID
@_exported import WinSDK // Clang module

// WinBase.h
Expand Down
9 changes: 9 additions & 0 deletions test/stdlib/WinSDK_GUID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %target-build-swift %s
// REQUIRES: OS=windows-msvc

// Make sure that importing WinSDK brings in the GUID type, which is declared in
// /shared and not in /um.

import WinSDK

public func usesGUID(_ x: GUID) {}