Skip to content

Commit 2edd936

Browse files
antoniofrighettoartemcm
authored andcommitted
Add support for load-pass-plugin option
`Options.swift` has been regenerated so as to include `load-pass-plugin` option as well.
1 parent d853e50 commit 2edd936

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,11 @@ extension Driver {
528528
if !hasToolchainStdlib {
529529
try addPluginPathArguments(commandLine: &commandLine)
530530
}
531+
532+
if let passPluginPath = parsedOptions.getLastArgument(.loadPassPluginEQ),
533+
isFrontendArgSupported(.loadPassPluginEQ) {
534+
commandLine.appendFlag("-load-pass-plugin=\(passPluginPath.asSingle)")
535+
}
531536
}
532537

533538
mutating func addBridgingHeaderPCHCacheKeyArguments(commandLine: inout [Job.ArgTemplate],

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8275,6 +8275,21 @@ final class SwiftDriverTests: XCTestCase {
82758275
XCTAssertTrue(jobs[0].commandLine.contains(subsequence: featureArgs.map { Job.ArgTemplate.flag($0) }))
82768276
}
82778277
}
8278+
8279+
func testFrontendLoadPassPlugin() throws {
8280+
#if os(Windows)
8281+
throw XCTSkip("'-load-pass-plugin' is not available on Windows.")
8282+
#else
8283+
var driver = try Driver(args: ["swiftc", "foo.swift", "-load-pass-plugin=/path/to/plugin"])
8284+
guard driver.isFrontendArgSupported(.loadPassPluginEQ) else {
8285+
throw XCTSkip("Skipping: compiler does not support '-load-pass-plugin'.")
8286+
}
8287+
let plannedJobs = try driver.planBuild()
8288+
XCTAssertEqual(plannedJobs[0].kind, .compile)
8289+
XCTAssertTrue(plannedJobs[0].tool.name.hasSuffix("swift-frontend"))
8290+
XCTAssertTrue(plannedJobs[0].commandLine.contains(.flag("-load-pass-plugin=/path/to/plugin")))
8291+
#endif
8292+
}
82788293
}
82798294

82808295
func assertString(

0 commit comments

Comments
 (0)