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
Copy file name to clipboardExpand all lines: Sources/PackageLoading/ModuleMapGenerator.swift
+24-19Lines changed: 24 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,10 @@
8
8
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9
9
*/
10
10
11
-
import TSCBasic
12
-
import PackageModel
11
+
import Basics
13
12
import Foundation
13
+
import PackageModel
14
+
import TSCBasic
14
15
15
16
/// Name of the module map file recognized by the Clang and Swift compilers.
16
17
publicletmoduleMapFilename="module.modulemap"
@@ -86,8 +87,14 @@ public struct ModuleMapGenerator {
86
87
}
87
88
88
89
/// Inspects the file system at the public-headers directory with which the module map generator was instantiated, and returns the type of module map that applies to that directory. This function contains all of the heuristics that implement module map policy for package targets; other functions just use the results of this determination.
// The following rules are documented at https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md#creating-c-language-targets. To avoid breaking existing packages, do not change the semantics here without making any change conditional on the tools version of the package that defines the target.
@@ -97,7 +104,7 @@ public struct ModuleMapGenerator {
97
104
98
105
// Warn if the public-headers directory is missing. For backward compatibility reasons, this is not an error, we just won't generate a module map in that case.
.error("target '\(targetName)' has invalid header layout: umbrella header found at '\(umbrellaHeader)', but directories exist next to it: \(siblingDirs.map({String(describing: $0)}).sorted().joined(separator:", ")); consider removing them")
233
238
}
234
239
235
240
/// Error emitted if there are other directories next to the parent directory of a nested umbrella header.
.error("target '\(targetName)' has invalid header layout: umbrella header found at '\(umbrellaHeader)', but more than one directory exists next to its parent directory: \(siblingDirs.map({String(describing: $0)}).sorted().joined(separator:", ")); consider reducing them to one")
238
243
}
239
244
240
245
/// Error emitted if there are other headers next to the parent directory of a nested umbrella header.
.error("target '\(targetName)' has invalid header layout: umbrella header found at '\(umbrellaHeader)', but additional header files exist: \((siblingHeaders.map({String(describing: $0)}).sorted().joined(separator:", "))); consider reducing them to one")
Copy file name to clipboardExpand all lines: Tests/PackageLoadingTests/ModuleMapGenerationTests.swift
+31-10Lines changed: 31 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -93,12 +93,17 @@ class ModuleMapGeneration: XCTestCase {
93
93
}
94
94
95
95
func testWarnings()throws{
96
-
varfs=InMemoryFileSystem(emptyFiles:
97
-
"/Foo.c")
96
+
varfs=InMemoryFileSystem(emptyFiles:"/Foo.c")
98
97
ModuleMapTester("Foo", in: fs){ result in
99
98
result.checkNotCreated()
100
99
result.checkDiagnostics{ result in
101
-
result.check(diagnostic:"no include directory found for target \'Foo\'; libraries cannot be imported without public headers", severity:.warning)
100
+
varexpectedMetadata=ObservabilityMetadata()
101
+
expectedMetadata.targetName ="Foo"
102
+
result.check(
103
+
diagnostic:"no include directory found for target \'Foo\'; libraries cannot be imported without public headers",
104
+
severity:.warning,
105
+
metadata: expectedMetadata
106
+
)
102
107
}
103
108
}
104
109
@@ -114,21 +119,31 @@ class ModuleMapGeneration: XCTestCase {
114
119
115
120
""")
116
121
result.checkDiagnostics{ result in
117
-
result.check(diagnostic:"/include/F-o-o.h should be renamed to /include/F_o_o.h to be used as an umbrella header", severity:.warning)
122
+
varexpectedMetadata=ObservabilityMetadata()
123
+
expectedMetadata.targetName ="F-o-o"
124
+
result.check(
125
+
diagnostic:"/include/F-o-o.h should be renamed to /include/F_o_o.h to be used as an umbrella header",
126
+
severity:.warning,
127
+
metadata: expectedMetadata
128
+
)
118
129
}
119
130
}
120
131
}
121
132
122
133
func testUnsupportedLayouts()throws{
123
-
varfs:InMemoryFileSystem
124
-
125
-
fs =InMemoryFileSystem(emptyFiles:
134
+
varfs=InMemoryFileSystem(emptyFiles:
126
135
"/include/Foo/Foo.h",
127
136
"/include/Bar/Foo.h")
128
137
ModuleMapTester("Foo", in: fs){ result in
129
138
result.checkNotCreated()
130
139
result.checkDiagnostics{ result in
131
-
result.check(diagnostic:"target 'Foo' has invalid header layout: umbrella header found at '/include/Foo/Foo.h', but more than one directory exists next to its parent directory: /include/Bar; consider reducing them to one", severity:.error)
140
+
varexpectedMetadata=ObservabilityMetadata()
141
+
expectedMetadata.targetName ="Foo"
142
+
result.check(
143
+
diagnostic:"target 'Foo' has invalid header layout: umbrella header found at '/include/Foo/Foo.h', but more than one directory exists next to its parent directory: /include/Bar; consider reducing them to one",
144
+
severity:.error,
145
+
metadata: expectedMetadata
146
+
)
132
147
}
133
148
}
134
149
@@ -138,7 +153,13 @@ class ModuleMapGeneration: XCTestCase {
138
153
ModuleMapTester("Foo", in: fs){ result in
139
154
result.checkNotCreated()
140
155
result.checkDiagnostics{ result in
141
-
result.check(diagnostic:"target 'Foo' has invalid header layout: umbrella header found at '/include/Foo.h', but directories exist next to it: /include/Bar; consider removing them", severity:.error)
156
+
varexpectedMetadata=ObservabilityMetadata()
157
+
expectedMetadata.targetName ="Foo"
158
+
result.check(
159
+
diagnostic:"target 'Foo' has invalid header layout: umbrella header found at '/include/Foo.h', but directories exist next to it: /include/Bar; consider removing them",
160
+
severity:.error,
161
+
metadata: expectedMetadata
162
+
)
142
163
}
143
164
}
144
165
}
@@ -149,7 +170,7 @@ func ModuleMapTester(_ targetName: String, includeDir: String = "include", in fi
0 commit comments