mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[WinSDK] Modularize <guiddef.h>
This fixes modularization errors that arise when importing a C++ header that contains `#include <guiddef.h>`, which might hijack this header from the WinSDK module where it belongs.
This commit is contained in:
@@ -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:
|
||||
@@ -47,5 +53,6 @@ install(FILES
|
||||
ucrt.modulemap
|
||||
vcruntime.apinotes
|
||||
vcruntime.modulemap
|
||||
winsdk.modulemap
|
||||
winsdk_um.modulemap
|
||||
winsdk_shared.modulemap
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()
|
||||
|
||||
16
stdlib/public/Platform/winsdk_shared.modulemap
Normal file
16
stdlib/public/Platform/winsdk_shared.modulemap
Normal file
@@ -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 *
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//===--- WinSDK.modulemap -------------------------------------------------===//
|
||||
//===--- WinSDK_UM.modulemap ----------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
@@ -11,6 +11,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_exported import ucrt
|
||||
@_exported import _GUID
|
||||
@_exported import WinSDK // Clang module
|
||||
|
||||
// WinBase.h
|
||||
|
||||
9
test/stdlib/WinSDK_GUID.swift
Normal file
9
test/stdlib/WinSDK_GUID.swift
Normal file
@@ -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) {}
|
||||
Reference in New Issue
Block a user