@@ -112,6 +112,60 @@ private func checkExplicitModuleBuildJobDependencies(job: Job,
112
112
}
113
113
}
114
114
115
+ internal func getDriverArtifactsForScanning( ) throws -> ( stdLibPath: AbsolutePath ,
116
+ shimsPath: AbsolutePath ,
117
+ toolchain: Toolchain ,
118
+ hostTriple: Triple ) {
119
+ // Just instantiating to get at the toolchain path
120
+ let driver = try Driver ( args: [ " swiftc " , " -explicit-module-build " ,
121
+ " -module-name " , " testDependencyScanning " ,
122
+ " test.swift " ] )
123
+ let ( stdLibPath, shimsPath) = try getStdlibShimsPaths ( driver)
124
+ XCTAssertTrue ( localFileSystem. exists ( stdLibPath) ,
125
+ " expected Swift StdLib at: \( stdLibPath. description) " )
126
+ XCTAssertTrue ( localFileSystem. exists ( shimsPath) ,
127
+ " expected Swift Shims at: \( shimsPath. description) " )
128
+ return ( stdLibPath, shimsPath, driver. toolchain, driver. hostTriple)
129
+ }
130
+
131
+ func getStdlibShimsPaths( _ driver: Driver ) throws -> ( AbsolutePath , AbsolutePath ) {
132
+ let toolchainRootPath : AbsolutePath = try driver. toolchain. getToolPath ( . swiftCompiler)
133
+ . parentDirectory // bin
134
+ . parentDirectory // toolchain root
135
+ if driver. targetTriple. isDarwin {
136
+ let executor = try SwiftDriverExecutor ( diagnosticsEngine: DiagnosticsEngine ( handlers: [ Driver . stderrDiagnosticsHandler] ) ,
137
+ processSet: ProcessSet ( ) ,
138
+ fileSystem: localFileSystem,
139
+ env: ProcessEnv . vars)
140
+ let sdkPath = try executor. checkNonZeroExit (
141
+ args: " xcrun " , " -sdk " , " macosx " , " --show-sdk-path " ) . spm_chomp ( )
142
+ let stdLibPath = try AbsolutePath ( validating: sdkPath) . appending ( component: " usr " )
143
+ . appending ( component: " lib " )
144
+ . appending ( component: " swift " )
145
+ return ( stdLibPath, stdLibPath. appending ( component: " shims " ) )
146
+ } else if driver. targetTriple. isWindows {
147
+ if let sdkroot = try driver. toolchain. defaultSDKPath ( driver. targetTriple) {
148
+ return ( sdkroot. appending ( components: " usr " , " lib " , " swift " , " windows " ) ,
149
+ sdkroot. appending ( components: " usr " , " lib " , " swift " , " shims " ) )
150
+ }
151
+ return ( toolchainRootPath
152
+ . appending ( component: " lib " )
153
+ . appending ( component: " swift " )
154
+ . appending ( component: driver. targetTriple. osNameUnversioned) ,
155
+ toolchainRootPath
156
+ . appending ( component: " lib " )
157
+ . appending ( component: " swift " )
158
+ . appending ( component: " shims " ) )
159
+ } else {
160
+ return ( toolchainRootPath. appending ( component: " lib " )
161
+ . appending ( component: " swift " )
162
+ . appending ( component: driver. targetTriple. osNameUnversioned) ,
163
+ toolchainRootPath. appending ( component: " lib " )
164
+ . appending ( component: " swift " )
165
+ . appending ( component: " shims " ) )
166
+ }
167
+ }
168
+
115
169
/// Test that for the given JSON module dependency graph, valid jobs are generated
116
170
final class ExplicitModuleBuildTests : XCTestCase {
117
171
func testModuleDependencyBuildCommandGeneration( ) throws {
@@ -1337,60 +1391,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
1337
1391
}
1338
1392
}
1339
1393
1340
- func getStdlibShimsPaths( _ driver: Driver ) throws -> ( AbsolutePath , AbsolutePath ) {
1341
- let toolchainRootPath : AbsolutePath = try driver. toolchain. getToolPath ( . swiftCompiler)
1342
- . parentDirectory // bin
1343
- . parentDirectory // toolchain root
1344
- if driver. targetTriple. isDarwin {
1345
- let executor = try SwiftDriverExecutor ( diagnosticsEngine: DiagnosticsEngine ( handlers: [ Driver . stderrDiagnosticsHandler] ) ,
1346
- processSet: ProcessSet ( ) ,
1347
- fileSystem: localFileSystem,
1348
- env: ProcessEnv . vars)
1349
- let sdkPath = try executor. checkNonZeroExit (
1350
- args: " xcrun " , " -sdk " , " macosx " , " --show-sdk-path " ) . spm_chomp ( )
1351
- let stdLibPath = try AbsolutePath ( validating: sdkPath) . appending ( component: " usr " )
1352
- . appending ( component: " lib " )
1353
- . appending ( component: " swift " )
1354
- return ( stdLibPath, stdLibPath. appending ( component: " shims " ) )
1355
- } else if driver. targetTriple. isWindows {
1356
- if let sdkroot = try driver. toolchain. defaultSDKPath ( driver. targetTriple) {
1357
- return ( sdkroot. appending ( components: " usr " , " lib " , " swift " , " windows " ) ,
1358
- sdkroot. appending ( components: " usr " , " lib " , " swift " , " shims " ) )
1359
- }
1360
- return ( toolchainRootPath
1361
- . appending ( component: " lib " )
1362
- . appending ( component: " swift " )
1363
- . appending ( component: driver. targetTriple. osNameUnversioned) ,
1364
- toolchainRootPath
1365
- . appending ( component: " lib " )
1366
- . appending ( component: " swift " )
1367
- . appending ( component: " shims " ) )
1368
- } else {
1369
- return ( toolchainRootPath. appending ( component: " lib " )
1370
- . appending ( component: " swift " )
1371
- . appending ( component: driver. targetTriple. osNameUnversioned) ,
1372
- toolchainRootPath. appending ( component: " lib " )
1373
- . appending ( component: " swift " )
1374
- . appending ( component: " shims " ) )
1375
- }
1376
- }
1377
-
1378
- private func getDriverArtifactsForScanning( ) throws -> ( stdLibPath: AbsolutePath ,
1379
- shimsPath: AbsolutePath ,
1380
- toolchain: Toolchain ,
1381
- hostTriple: Triple ) {
1382
- // Just instantiating to get at the toolchain path
1383
- let driver = try Driver ( args: [ " swiftc " , " -explicit-module-build " ,
1384
- " -module-name " , " testDependencyScanning " ,
1385
- " test.swift " ] )
1386
- let ( stdLibPath, shimsPath) = try getStdlibShimsPaths ( driver)
1387
- XCTAssertTrue ( localFileSystem. exists ( stdLibPath) ,
1388
- " expected Swift StdLib at: \( stdLibPath. description) " )
1389
- XCTAssertTrue ( localFileSystem. exists ( shimsPath) ,
1390
- " expected Swift Shims at: \( shimsPath. description) " )
1391
- return ( stdLibPath, shimsPath, driver. toolchain, driver. hostTriple)
1392
- }
1393
-
1394
1394
/// Test the libSwiftScan dependency scanning (import-prescan).
1395
1395
func testDependencyImportPrescan( ) throws {
1396
1396
let ( stdLibPath, shimsPath, toolchain, _) = try getDriverArtifactsForScanning ( )
0 commit comments