Skip to content

Commit

Permalink
Migrate to TSC versions of Absolute/RelativePath APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
owenv committed Dec 15, 2020
1 parent 4200941 commit 9e1e6a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"repositoryURL": "https://github.com/apple/swift-llbuild.git",
"state": {
"branch": "main",
"revision": "5b5421a12fea9c5ec63fd9a797c05f7aebd8142b",
"revision": "eb56a00ed9dfd62c2ce4ec86183ff0bc0afda997",
"version": null
}
},
Expand All @@ -24,7 +24,7 @@
"repositoryURL": "https://github.com/apple/swift-tools-support-core.git",
"state": {
"branch": "main",
"revision": "99ae28c10aaf9009d87445d780197d85bc09f0b3",
"revision": "c98cfc216d22798dce7ce7b9cc171565371e967e",
"version": null
}
},
Expand Down
11 changes: 0 additions & 11 deletions Sources/SwiftDriver/Utilities/RelativePathAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@
import TSCBasic

extension RelativePath {
/// Retrieve the basename of the relative path without the extension.
///
/// FIXME: Probably belongs in TSC
var basenameWithoutExt: String {
if let ext = self.extension {
return String(basename.dropLast(ext.count + 1))
}

return basename
}

/// Retrieve the basename of the relative path without any extensions,
/// even if there are several, and without any leading dots. Roughly
/// equivalent to the regex `/[^.]+/`.
Expand Down
20 changes: 14 additions & 6 deletions Sources/SwiftDriver/Utilities/VirtualPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,21 @@ public enum VirtualPath: Hashable {
}

public func appending(components: String...) -> VirtualPath {
// FIXME: TSC should add non-variadic overloads of appending(components:)
// so we can forward arguments here instead of appending components one-by-one.
var result = self
components.forEach {
result = result.appending(component: $0)
switch self {
case .absolute(let path):
return .absolute(path.appending(components: components))
case .relative(let path):
return .relative(path.appending(components: components))
case .temporary(let path):
return .temporary(path.appending(components: components))
case let .temporaryWithKnownContents(path, contents):
return .temporaryWithKnownContents(path.appending(components: components), contents)
case .fileList(let path, let content):
return .fileList(path.appending(components: components), content)
case .standardInput, .standardOutput:
assertionFailure("Can't append path component to standard in/out")
return self
}
return result
}

/// Returns the virtual path with an additional suffix appended to base name.
Expand Down

0 comments on commit 9e1e6a4

Please sign in to comment.