Skip to content

Commit fa1f7d5

Browse files
authored
Merge pull request #3004 from compnerd/extra-flags
Workspace: allow passing extra swiftc flags via Info.plist
2 parents 0af4d7a + e757df8 commit fa1f7d5

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Sources/Workspace/UserToolchain.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ public final class UserToolchain: Toolchain {
218218
if let SDKROOT = ProcessEnv.vars["SDKROOT"], let root = try? AbsolutePath(validating: SDKROOT) {
219219
var runtime: [String] = []
220220
var xctest: [String] = []
221+
var extraSwiftCFlags: [String] = []
221222

222223
if let settings = WindowsSDKSettings(reading: root.appending(component: "SDKSettings.plist"),
223224
diagnostics: nil, filesystem: localFileSystem) {
@@ -247,10 +248,12 @@ public final class UserToolchain: Toolchain {
247248
"-I", path.appending(RelativePath("usr/lib/swift/windows/\(triple.arch)")).pathString,
248249
"-L", path.appending(RelativePath("usr/lib/swift/windows")).pathString,
249250
]
251+
252+
extraSwiftCFlags = info.defaults.extraSwiftCFlags ?? []
250253
}
251254
}
252255

253-
return [ "-sdk", root.pathString, ] + runtime + xctest
256+
return [ "-sdk", root.pathString, ] + runtime + xctest + extraSwiftCFlags
254257
}
255258
}
256259

Sources/Workspace/WindowsToolchainInfo.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public struct WindowsPlatformInfo {
7474
/// XCTEST_VERSION
7575
/// specifies the version string of the bundled XCTest.
7676
public let xctestVersion: String
77+
78+
/// SWIFTC_FLAGS
79+
/// Specifies extra flags to pass to swiftc from Swift Package Manager.
80+
public let extraSwiftCFlags: [String]?
7781
}
7882

7983
public let defaults: DefaultProperties
@@ -82,6 +86,7 @@ public struct WindowsPlatformInfo {
8286
extension WindowsPlatformInfo.DefaultProperties: Decodable {
8387
enum CodingKeys: String, CodingKey {
8488
case xctestVersion = "XCTEST_VERSION"
89+
case extraSwiftCFlags = "SWIFTC_FLAGS"
8590
}
8691
}
8792

0 commit comments

Comments
 (0)