Skip to content

Commit 274ba53

Browse files
authored
Merge pull request #82254 from hamishknight/open-and-shut-case
[xcodegen] `realpath` Swift target sources
2 parents d733338 + 27ec6e3 commit 274ba53

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

utils/swift-xcodegen/Sources/SwiftXcodeGen/BuildArgs/SwiftTargets.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ struct SwiftTargets {
124124
// A relative path is for a file in the build directory, it's external.
125125
let abs = buildDir.path.appending(r)
126126
guard abs.exists else { continue }
127-
sources.externalSources.append(abs)
127+
sources.externalSources.append(abs.realPath)
128128

129129
case .absolute(let a):
130-
guard a.exists, let rel = a.removingPrefix(buildDir.repoPath) else {
130+
guard a.exists else { continue }
131+
// Symlinks shouldn't really be a concern here, but we need to realpath
132+
// in order to canonicalize the casing.
133+
let a = a.realPath
134+
guard let rel = a.removingPrefix(buildDir.repoPath) else {
131135
sources.externalSources.append(a)
132136
continue
133137
}

utils/swift-xcodegen/Sources/SwiftXcodeGen/Path/AbsolutePath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public extension AbsolutePath {
5252
(try? FileManager.default.destinationOfSymbolicLink(atPath: rawPath)) != nil
5353
}
5454

55-
var resolvingSymlinks: Self {
55+
var realPath: Self {
5656
guard let resolved = realpath(rawPath, nil) else { return self }
5757
defer {
5858
free(resolved)

utils/swift-xcodegen/Sources/swift-xcodegen/SwiftXcodegen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct SwiftXcodegen: AsyncParsableCommand, Sendable {
8484

8585
// Check to see if we have a separate runnable build dir.
8686
let runnableBuildDirPath =
87-
self.runnableBuildDir?.absoluteInWorkingDir.resolvingSymlinks
87+
self.runnableBuildDir?.absoluteInWorkingDir.realPath
8888
let runnableBuildDir = try runnableBuildDirPath.map {
8989
try NinjaBuildDir(at: $0, projectRootDir: ninja.projectRootDir)
9090
.buildDir(for: .swift)
@@ -332,7 +332,7 @@ struct SwiftXcodegen: AsyncParsableCommand, Sendable {
332332
}
333333

334334
func generate() async throws {
335-
let buildDirPath = buildDir.absoluteInWorkingDir.resolvingSymlinks
335+
let buildDirPath = buildDir.absoluteInWorkingDir.realPath
336336
log.info("Generating project for '\(buildDirPath)'...")
337337

338338
let projectRootDir = self.projectRootDir?.absoluteInWorkingDir

0 commit comments

Comments
 (0)