Skip to content

Commit 6e2f60c

Browse files
authored
Merge pull request #776 from buttaface/sdk
SR-14796: Don't lose '-sdk /' when dropping the trailing slash
2 parents 0545e1c + 6a125d8 commit 6e2f60c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2115,7 +2115,7 @@ extension Driver {
21152115
}
21162116

21172117
// Delete trailing /.
2118-
sdkPath = sdkPath.map { $0.last == "/" ? String($0.dropLast()) : $0 }
2118+
sdkPath = sdkPath.map { $0.count > 1 && $0.last == "/" ? String($0.dropLast()) : $0 }
21192119

21202120
// Validate the SDK if we found one.
21212121
if let sdkPath = sdkPath {

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,6 +3442,10 @@ final class SwiftDriverTests: XCTestCase {
34423442
func testRegressions() throws {
34433443
var driverWithEmptySDK = try Driver(args: ["swiftc", "-sdk", "", "file.swift"])
34443444
_ = try driverWithEmptySDK.planBuild()
3445+
3446+
var driver = try Driver(args: ["swiftc", "foo.swift", "-sdk", "/"])
3447+
let plannedJobs = try driver.planBuild()
3448+
XCTAssertTrue(plannedJobs[0].commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init("/")))]))
34453449
}
34463450

34473451
func testDumpASTOverride() throws {

0 commit comments

Comments
 (0)