@@ -151,9 +151,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
151
151
$0 <<< " import G; "
152
152
}
153
153
154
- var pcmArgs9 = [ " -Xcc " , " -target " , " -Xcc " , " x86_64-apple-macosx10.9 " ]
155
- var pcmArgs15 = [ " -Xcc " , " -target " , " -Xcc " , " x86_64-apple-macosx10.15 " ]
156
-
157
154
let packageRootPath = URL ( fileURLWithPath: #file) . pathComponents
158
155
. prefix ( while: { $0 != " Tests " } ) . joined ( separator: " / " ) . dropFirst ( )
159
156
let testInputsPath = packageRootPath + " /TestInputs "
@@ -164,12 +161,19 @@ final class ExplicitModuleBuildTests: XCTestCase {
164
161
" -I " , swiftModuleInterfacesPath,
165
162
" -experimental-explicit-module-build " ,
166
163
main. pathString] )
164
+
165
+ let jobs = try driver. planBuild ( )
166
+ // Figure out which Triples to use.
167
+ let dependencyGraph = driver. explicitModuleBuildHandler!. dependencyGraph
168
+ guard case . swift( let mainModuleSwiftDetails) = dependencyGraph. mainModule. details else {
169
+ XCTFail ( " Main module does not have Swift details field " )
170
+ return
171
+ }
172
+ let pcmArgsCurrent = mainModuleSwiftDetails. extraPcmArgs!
173
+ var pcmArgs9 = [ " -Xcc " , " -target " , " -Xcc " , " x86_64-apple-macosx10.9 " ]
167
174
if driver. targetTriple. isDarwin {
168
175
pcmArgs9. append ( contentsOf: [ " -Xcc " , " -fapinotes-swift-version=5 " ] )
169
- pcmArgs15. append ( contentsOf: [ " -Xcc " , " -fapinotes-swift-version=5 " ] )
170
176
}
171
- let jobs = try driver. planBuild ( )
172
- let dependencyGraph = driver. explicitModuleBuildHandler!. dependencyGraph
173
177
for job in jobs {
174
178
XCTAssertEqual ( job. outputs. count, 1 )
175
179
switch ( job. outputs [ 0 ] . file) {
@@ -188,22 +192,22 @@ final class ExplicitModuleBuildTests: XCTestCase {
188
192
case . relative( RelativePath ( " SwiftOnoneSupport.swiftmodule " ) ) :
189
193
try checkExplicitModuleBuildJob ( job: job, moduleId: . swift( " SwiftOnoneSupport " ) ,
190
194
moduleDependencyGraph: dependencyGraph)
191
- case . relative( try pcmArgsEncodedRelativeModulePath ( for: " A " , with: pcmArgs15 ) ) :
195
+ case . relative( try pcmArgsEncodedRelativeModulePath ( for: " A " , with: pcmArgsCurrent ) ) :
192
196
try checkExplicitModuleBuildJob ( job: job, moduleId: . clang( " A " ) ,
193
197
moduleDependencyGraph: dependencyGraph)
194
- case . relative( try pcmArgsEncodedRelativeModulePath ( for: " B " , with: pcmArgs15 ) ) :
198
+ case . relative( try pcmArgsEncodedRelativeModulePath ( for: " B " , with: pcmArgsCurrent ) ) :
195
199
try checkExplicitModuleBuildJob ( job: job, moduleId: . clang( " B " ) ,
196
200
moduleDependencyGraph: dependencyGraph)
197
- case . relative( try pcmArgsEncodedRelativeModulePath ( for: " C " , with: pcmArgs15 ) ) :
201
+ case . relative( try pcmArgsEncodedRelativeModulePath ( for: " C " , with: pcmArgsCurrent ) ) :
198
202
try checkExplicitModuleBuildJob ( job: job, moduleId: . clang( " C " ) ,
199
203
moduleDependencyGraph: dependencyGraph)
200
- case . relative( try pcmArgsEncodedRelativeModulePath ( for: " G " , with: pcmArgs15 ) ) :
204
+ case . relative( try pcmArgsEncodedRelativeModulePath ( for: " G " , with: pcmArgsCurrent ) ) :
201
205
try checkExplicitModuleBuildJob ( job: job, moduleId: . clang( " G " ) ,
202
206
moduleDependencyGraph: dependencyGraph)
203
207
case . relative( try pcmArgsEncodedRelativeModulePath ( for: " SwiftShims " , with: pcmArgs9) ) :
204
208
try checkExplicitModuleBuildJob ( job: job, moduleId: . clang( " SwiftShims " ) ,
205
209
moduleDependencyGraph: dependencyGraph)
206
- case . relative( try pcmArgsEncodedRelativeModulePath ( for: " SwiftShims " , with: pcmArgs15 ) ) :
210
+ case . relative( try pcmArgsEncodedRelativeModulePath ( for: " SwiftShims " , with: pcmArgsCurrent ) ) :
207
211
try checkExplicitModuleBuildJob ( job: job, moduleId: . clang( " SwiftShims " ) ,
208
212
moduleDependencyGraph: dependencyGraph)
209
213
case . temporary( RelativePath ( " main.o " ) ) :
@@ -223,4 +227,36 @@ final class ExplicitModuleBuildTests: XCTestCase {
223
227
}
224
228
}
225
229
}
230
+
231
+ func testExplicitModuleBuildEndToEnd( ) throws {
232
+ // The macOS-only restriction is temporary while Clang's dependency scanner
233
+ // is gaining the ability to perform name-based module lookup.
234
+ #if os(macOS)
235
+ try withTemporaryDirectory { path in
236
+ try localFileSystem. changeCurrentWorkingDirectory ( to: path)
237
+ let main = path. appending ( component: " main.swift " )
238
+ try localFileSystem. writeFileContents ( main) {
239
+ $0 <<< " import C; "
240
+ $0 <<< " import E; "
241
+ $0 <<< " import G; "
242
+ }
243
+
244
+ let packageRootPath = URL ( fileURLWithPath: #file) . pathComponents
245
+ . prefix ( while: { $0 != " Tests " } ) . joined ( separator: " / " ) . dropFirst ( )
246
+ let testInputsPath = packageRootPath + " /TestInputs "
247
+ let cHeadersPath : String = testInputsPath + " /ExplicitModuleBuilds/CHeaders "
248
+ let swiftModuleInterfacesPath : String = testInputsPath + " /ExplicitModuleBuilds/Swift "
249
+ var driver = try Driver ( args: [ " swiftc " ,
250
+ " -I " , cHeadersPath,
251
+ " -I " , swiftModuleInterfacesPath,
252
+ " -experimental-explicit-module-build " ,
253
+ " -working-directory " , path. pathString,
254
+ main. pathString] )
255
+ let jobs = try driver. planBuild ( )
256
+ let resolver = try ArgsResolver ( fileSystem: localFileSystem)
257
+ try driver. run ( jobs: jobs, resolver: resolver, processSet: ProcessSet ( ) )
258
+ XCTAssertFalse ( driver. diagnosticEngine. hasErrors)
259
+ }
260
+ #endif
261
+ }
226
262
}
0 commit comments