@@ -30,13 +30,11 @@ public final class UserToolchain: Toolchain {
30
30
/// Path of the `swiftc` compiler.
31
31
public let swiftCompiler : AbsolutePath
32
32
33
- public let extraCCFlags : [ String ]
33
+ public var extraCCFlags : [ String ]
34
34
35
35
public let extraSwiftCFlags : [ String ]
36
36
37
- public var extraCPPFlags : [ String ] {
38
- return destination. extraCPPFlags
39
- }
37
+ public var extraCPPFlags : [ String ]
40
38
41
39
/// Path of the `swift` interpreter.
42
40
public var swiftInterpreter : AbsolutePath {
@@ -213,13 +211,21 @@ public final class UserToolchain: Toolchain {
213
211
// the SDK. This is not the same value as the SDKROOT parameter
214
212
// in Xcode, however, the value represents a similar concept.
215
213
if let SDKROOT = ProcessEnv . vars [ " SDKROOT " ] , let root = try ? AbsolutePath ( validating: SDKROOT) {
216
-
217
214
var runtime : [ String ] = [ ]
218
215
var xctest : [ String ] = [ ]
219
216
220
217
if let settings = WindowsSDKSettings ( reading: root. appending ( component: " SDKSettings.plist " ) ,
221
218
diagnostics: nil , filesystem: localFileSystem) {
222
- runtime = [ " -libc " , settings. defaults. runtime. rawValue ]
219
+ switch settings. defaults. runtime {
220
+ case . multithreadedDebugDLL:
221
+ runtime = [ " -libc " , " MDd " ]
222
+ case . multithreadedDLL:
223
+ runtime = [ " -libc " , " MD " ]
224
+ case . multithreadedDebug:
225
+ runtime = [ " -libc " , " MTd " ]
226
+ case . multithreaded:
227
+ runtime = [ " -libc " , " MT " ]
228
+ }
223
229
}
224
230
225
231
if let DEVELOPER_DIR = ProcessEnv . vars [ " DEVELOPER_DIR " ] ,
@@ -308,8 +314,40 @@ public final class UserToolchain: Toolchain {
308
314
self . extraCCFlags = [
309
315
triple. isDarwin ( ) ? " -isysroot " : " --sysroot " , sdk. pathString
310
316
] + destination. extraCCFlags
317
+
318
+ self . extraCPPFlags = destination. extraCPPFlags
311
319
} else {
312
320
self . extraCCFlags = destination. extraCCFlags
321
+ self . extraCPPFlags = destination. extraCPPFlags
322
+ }
323
+
324
+ if triple. isWindows ( ) {
325
+ if let SDKROOT = ProcessEnv . vars [ " SDKROOT " ] , let root = try ? AbsolutePath ( validating: SDKROOT) {
326
+ if let settings = WindowsSDKSettings ( reading: root. appending ( component: " SDKSettings.plist " ) ,
327
+ diagnostics: nil , filesystem: localFileSystem) {
328
+ switch settings. defaults. runtime {
329
+ case . multithreadedDebugDLL:
330
+ // Defines _DEBUG, _MT, and _DLL
331
+ // Linker uses MSVCRTD.lib
332
+ self . extraCCFlags += [ " -D_DEBUG " , " -D_MT " , " -D_DLL " , " -Xclang " , " --dependent-lib=msvcrtd " ]
333
+
334
+ case . multithreadedDLL:
335
+ // Defines _MT, and _DLL
336
+ // Linker uses MSVCRT.lib
337
+ self . extraCCFlags += [ " -D_MT " , " -D_DLL " , " -Xclang " , " --dependent-lib=msvcrt " ]
338
+
339
+ case . multithreadedDebug:
340
+ // Defines _DEBUG, and _MT
341
+ // Linker uses LIBCMTD.lib
342
+ self . extraCCFlags += [ " -D_DEBUG " , " -D_MT " , " -Xclang " , " --dependent-lib=libcmtd " ]
343
+
344
+ case . multithreaded:
345
+ // Defines _MT
346
+ // Linker uses LIBCMT.lib
347
+ self . extraCCFlags += [ " -D_MT " , " -Xclang " , " --dependent-lib=libcmt " ]
348
+ }
349
+ }
350
+ }
313
351
}
314
352
315
353
// Compute the path of directory containing the PackageDescription libraries.
0 commit comments