Skip to content

Commit 7720d82

Browse files
committed
add a module map for swift/bridging header
1 parent 30d0c17 commit 7720d82

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

lib/ClangImporter/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ add_custom_target("copy_cxxInterop_support_header"
5757
DEPENDS "${SWIFTINC_DIR}/bridging"
5858
COMMENT "Copying C++ interop support header to ${SWIFTINC_DIR}")
5959

60-
swift_install_in_component(FILES "${CMAKE_CURRENT_SOURCE_DIR}/bridging"
60+
swift_install_in_component(FILES
61+
"${CMAKE_CURRENT_SOURCE_DIR}/bridging"
62+
"${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap"
6163
DESTINATION "include/swift"
6264
COMPONENT compiler)
6365

lib/ClangImporter/module.modulemap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===------------------ module.modulemap - C++ and Swift module -*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
module SwiftBridging {
14+
header "bridging"
15+
16+
export *
17+
}

test/Interop/Cxx/ergonomics/swift-bridging-annotations.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
// RUN: %target-swift-ide-test -print-module -module-to-print=SwiftMod -module-to-print=CxxModule -I %t -I %t/Inputs -I %swift_src_root/lib/ClangImporter -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
77

8+
// RUN: %target-swift-ide-test -print-module -module-to-print=SwiftMod -module-to-print=CxxModule -I %t -I %t/Inputs -I %swift_src_root/lib/ClangImporter -source-filename=x -enable-experimental-cxx-interop -Xcc -DINCMOD | %FileCheck %s
9+
810
//--- SwiftMod.swift
911

1012
public protocol Proto {
@@ -21,7 +23,11 @@ module CxxModule {
2123
// Note: in actuality, this will be included
2224
// as <swift/bridging>, but in this test we include
2325
// it directly.
26+
#ifndef INCMOD
2427
#include "bridging"
28+
#else
29+
#pragma clang module import SwiftBridging
30+
#endif
2531

2632
class SELF_CONTAINED SelfContained {
2733
public:

0 commit comments

Comments
 (0)