Skip to content

Commit 5b0a78e

Browse files
authored
Merge pull request #1035 from compnerd/relativity
Replace `AbsolutePath.appending(_:)` for deprecations
2 parents aa76a6b + 6c699bb commit 5b0a78e

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

Sources/SwiftDriver/Jobs/PrebuiltModulesJob.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ extension Driver {
529529
// Create directories for each Swift module
530530
try inputMap.forEach {
531531
assert(!$0.value.isEmpty)
532-
let moduleDir = prebuiltModuleDir.appending(RelativePath($0.key + ".swiftmodule"))
532+
let moduleDir = AbsolutePath("\($0.key).swiftmodule", relativeTo: prebuiltModuleDir)
533533
if !localFileSystem.exists(moduleDir) {
534534
try localFileSystem.createDirectory(moduleDir)
535535
}
@@ -539,8 +539,9 @@ extension Driver {
539539
let outputMap: [String: [PrebuiltModuleOutput]] =
540540
Dictionary.init(uniqueKeysWithValues: inputMap.map { key, value in
541541
let outputPaths: [PrebuiltModuleInput] = value.map {
542-
let path = prebuiltModuleDir.appending(RelativePath(key + ".swiftmodule"))
543-
.appending(RelativePath($0.path.file.basenameWithoutExt + ".swiftmodule"))
542+
let path = AbsolutePath("\($0.path.file.basenameWithoutExt).swiftmodule",
543+
relativeTo: AbsolutePath("\(key).swiftmodule",
544+
relativeTo: prebuiltModuleDir))
544545
return PrebuiltModuleOutput(TypedVirtualPath(file: VirtualPath.absolute(path).intern(),
545546
type: .swiftModule), $0.arch)
546547
}

Sources/SwiftDriver/Toolchains/DarwinToolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public final class DarwinToolchain: Toolchain {
9696

9797
/// Path to the StdLib inside the SDK.
9898
public func sdkStdlib(sdk: AbsolutePath) -> AbsolutePath {
99-
sdk.appending(RelativePath("usr/lib/swift"))
99+
AbsolutePath("usr/lib/swift", relativeTo: sdk)
100100
}
101101

102102
public func makeLinkerOutputFilename(moduleName: String, type: LinkOutputType) -> String {

Sources/SwiftDriver/Toolchains/WindowsToolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extension WindowsToolchain.ToolchainValidationError {
9797
}
9898

9999
public func sdkStdlib(sdk: AbsolutePath) -> AbsolutePath {
100-
sdk.appending(RelativePath("usr/lib/swift"))
100+
AbsolutePath("usr/lib/swift", relativeTo: sdk)
101101
}
102102

103103
public func makeLinkerOutputFilename(moduleName: String, type: LinkOutputType) -> String {

Sources/swift-build-sdk-interfaces/main.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ do {
7373
// append the SDK version number so all modules will built into
7474
// the SDK-versioned sub-directory.
7575
if outputDir.basename == "prebuilt-modules" {
76-
outputDir = outputDir.appending(RelativePath(collector.versionString))
76+
outputDir = AbsolutePath(collector.versionString, relativeTo: outputDir)
7777
}
7878
if !localFileSystem.exists(outputDir) {
7979
try localFileSystem.createDirectory(outputDir, recursive: true)
@@ -83,10 +83,12 @@ do {
8383
if let swiftcPathRaw = swiftcPathRaw {
8484
swiftcPath = try VirtualPath(path: swiftcPathRaw).absolutePath!
8585
} else {
86-
swiftcPath = sdkPath.parentDirectory.parentDirectory.parentDirectory
87-
.parentDirectory.parentDirectory.appending(RelativePath("Toolchains"))
88-
.appending(RelativePath("XcodeDefault.xctoolchain")).appending(RelativePath("usr"))
89-
.appending(RelativePath("bin")).appending(RelativePath("swiftc"))
86+
swiftcPath = AbsolutePath("Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc",
87+
relativeTo: sdkPath.parentDirectory
88+
.parentDirectory
89+
.parentDirectory
90+
.parentDirectory
91+
.parentDirectory)
9092
}
9193
if !localFileSystem.exists(swiftcPath) {
9294
diagnosticsEngine.emit(error: "cannot find swift compiler: \(swiftcPath.pathString)")

Tests/SwiftDriverTests/IntegrationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ final class IntegrationTests: IntegrationTestCase {
9595
environment: ProcessEnv.vars.merging(extraEnv) { $1 }
9696
)
9797

98-
XCTAssertTrue(localFileSystem.isExecutableFile(buildPath.appending(RelativePath("debug/swift-driver"))), result)
98+
XCTAssertTrue(localFileSystem.isExecutableFile(AbsolutePath("debug/swift-driver", relativeTo: buildPath)), result)
9999
}
100100
#endif
101101
}

Tests/SwiftDriverTests/JobExecutorTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ extension DarwinToolchain {
7676
/// macOS resource directory, for testing only.
7777
var resourcesDirectory: Result<AbsolutePath, Swift.Error> {
7878
return Result {
79-
try getToolPath(.swiftCompiler).appending(RelativePath("../../lib/swift/macosx"))
79+
try AbsolutePath("../../lib/swift/macosx", relativeTo: getToolPath(.swiftCompiler))
8080
}
8181
}
8282

8383
var clangRT: Result<AbsolutePath, Error> {
84-
resourcesDirectory.map { $0.appending(RelativePath("../clang/lib/darwin/libclang_rt.osx.a")) }
84+
resourcesDirectory.map { AbsolutePath("../clang/lib/darwin/libclang_rt.osx.a", relativeTo: $0) }
8585
}
8686

8787
var compatibility50: Result<AbsolutePath, Error> {

0 commit comments

Comments
 (0)