You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If 'include/ModuleName.h' exists, then use it as the umbrella header (this is case 2 at https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md#creating-c-language-targets).
@@ -117,8 +118,10 @@ public struct ModuleMapGenerator {
117
118
}
118
119
diagnoseInvalidUmbrellaHeader(includeDir)
119
120
121
+
// If 'include/ModuleName/ModuleName.h' exists, then use it as the umbrella header (this is case 1 at Documentation/Usage.md#creating-c-language-targets).
// Otherwise, if 'include' contains only header files and no subdirectories, use it as the umbrella directory (this is case 3 at https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md#creating-c-language-targets).
// Otherwise, the target's public headers are considered to be incompatible with modules. Other C targets can still import them, but Swift won't be able to see them. This is documented as an error, but because SwiftPM has previously allowed it (creating module maps that then cause errors when used), we instead emit a warning and for now, continue to emit what SwiftPM has historically emitted (an umbrella directory include).
147
+
warningStream <<<"warning: the include directory of target '\(target.name)' has "
148
+
warningStream <<<"a layout that is incompatible with modules; consider adding a "
149
+
warningStream <<<"custom module map to the target"
Copy file name to clipboardExpand all lines: Tests/PackageLoadingTests/ModuleMapGenerationTests.swift
+15-8Lines changed: 15 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
/*
2
2
This source file is part of the Swift.org open source project
3
3
4
-
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
4
+
Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5
5
Licensed under Apache License v2.0 with Runtime Library Exception
6
6
7
7
See http://swift.org/LICENSE.txt for license information
@@ -77,13 +77,6 @@ class ModuleMapGeneration: XCTestCase {
77
77
"/Foo.c")
78
78
checkExpected()
79
79
80
-
// FIXME: Should this be allowed?
81
-
fs =InMemoryFileSystem(emptyFiles:
82
-
"/include/Baz/Foo.h",
83
-
"/include/Bar/Bar.h",
84
-
"/Foo.c")
85
-
checkExpected()
86
-
87
80
fs =InMemoryFileSystem(emptyFiles:
88
81
"/include/Baz.h",
89
82
"/include/Bar.h",
@@ -111,6 +104,20 @@ class ModuleMapGeneration: XCTestCase {
111
104
result.check(value: expected.bytes)
112
105
result.checkDiagnostics("warning: /include/F-o-o.h should be renamed to /include/F_o_o.h to be used as an umbrella header")
113
106
}
107
+
108
+
fs =InMemoryFileSystem(emptyFiles:
109
+
"/include/Baz/Foo.h",
110
+
"/include/Bar/Bar.h",
111
+
"/Foo.c")
112
+
letexpected2=BufferedOutputByteStream()
113
+
expected2 <<<"module Foo {\n"
114
+
expected2 <<<" umbrella \"/include\"\n"
115
+
expected2 <<<" export *\n"
116
+
expected2 <<<"}\n"
117
+
ModuleMapTester("Foo", in: fs){ result in
118
+
result.check(value: expected2.bytes)
119
+
result.checkDiagnostics("warning: the include directory of target \'Foo\' has a layout that is incompatible with modules; consider adding a custom module map to the target")
0 commit comments