@@ -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 {
@@ -1234,60 +1288,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
1234
1288
}
1235
1289
}
1236
1290
1237
- func getStdlibShimsPaths( _ driver: Driver ) throws -> ( AbsolutePath , AbsolutePath ) {
1238
- let toolchainRootPath : AbsolutePath = try driver. toolchain. getToolPath ( . swiftCompiler)
1239
- . parentDirectory // bin
1240
- . parentDirectory // toolchain root
1241
- if driver. targetTriple. isDarwin {
1242
- let executor = try SwiftDriverExecutor ( diagnosticsEngine: DiagnosticsEngine ( handlers: [ Driver . stderrDiagnosticsHandler] ) ,
1243
- processSet: ProcessSet ( ) ,
1244
- fileSystem: localFileSystem,
1245
- env: ProcessEnv . vars)
1246
- let sdkPath = try executor. checkNonZeroExit (
1247
- args: " xcrun " , " -sdk " , " macosx " , " --show-sdk-path " ) . spm_chomp ( )
1248
- let stdLibPath = try AbsolutePath ( validating: sdkPath) . appending ( component: " usr " )
1249
- . appending ( component: " lib " )
1250
- . appending ( component: " swift " )
1251
- return ( stdLibPath, stdLibPath. appending ( component: " shims " ) )
1252
- } else if driver. targetTriple. isWindows {
1253
- if let sdkroot = try driver. toolchain. defaultSDKPath ( driver. targetTriple) {
1254
- return ( sdkroot. appending ( components: " usr " , " lib " , " swift " , " windows " ) ,
1255
- sdkroot. appending ( components: " usr " , " lib " , " swift " , " shims " ) )
1256
- }
1257
- return ( toolchainRootPath
1258
- . appending ( component: " lib " )
1259
- . appending ( component: " swift " )
1260
- . appending ( component: driver. targetTriple. osNameUnversioned) ,
1261
- toolchainRootPath
1262
- . appending ( component: " lib " )
1263
- . appending ( component: " swift " )
1264
- . appending ( component: " shims " ) )
1265
- } else {
1266
- return ( toolchainRootPath. appending ( component: " lib " )
1267
- . appending ( component: " swift " )
1268
- . appending ( component: driver. targetTriple. osNameUnversioned) ,
1269
- toolchainRootPath. appending ( component: " lib " )
1270
- . appending ( component: " swift " )
1271
- . appending ( component: " shims " ) )
1272
- }
1273
- }
1274
-
1275
- private func getDriverArtifactsForScanning( ) throws -> ( stdLibPath: AbsolutePath ,
1276
- shimsPath: AbsolutePath ,
1277
- toolchain: Toolchain ,
1278
- hostTriple: Triple ) {
1279
- // Just instantiating to get at the toolchain path
1280
- let driver = try Driver ( args: [ " swiftc " , " -explicit-module-build " ,
1281
- " -module-name " , " testDependencyScanning " ,
1282
- " test.swift " ] )
1283
- let ( stdLibPath, shimsPath) = try getStdlibShimsPaths ( driver)
1284
- XCTAssertTrue ( localFileSystem. exists ( stdLibPath) ,
1285
- " expected Swift StdLib at: \( stdLibPath. description) " )
1286
- XCTAssertTrue ( localFileSystem. exists ( shimsPath) ,
1287
- " expected Swift Shims at: \( shimsPath. description) " )
1288
- return ( stdLibPath, shimsPath, driver. toolchain, driver. hostTriple)
1289
- }
1290
-
1291
1291
/// Test the libSwiftScan dependency scanning (import-prescan).
1292
1292
func testDependencyImportPrescan( ) throws {
1293
1293
let ( stdLibPath, shimsPath, toolchain, _) = try getDriverArtifactsForScanning ( )
0 commit comments