Skip to content

Commit fe23cad

Browse files
committed
[PackageLoading] Fix a regression in target sources builder
For some reason I thought that we ignored symlinked directories and baked that logic in the new sources builder. This fixes that regression. <rdar://problem/58963219>
1 parent 67ef003 commit fe23cad

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

Sources/PackageLoading/TargetSourcesBuilder.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,7 @@ public struct TargetSourcesBuilder {
231231
}
232232

233233
// At this point, curr can only be a directory.
234-
235-
// The path is a symlinked directory. Warn and continue.
236-
if fs.isSymlink(curr) {
237-
// FIXME: Emit warning here.
238-
continue
239-
}
240-
234+
//
241235
// Check if the directory is marked to be copied.
242236
let directoryMarkedToBeCopied = target.resources.contains{ resource in
243237
let resourcePath = self.targetPath.appending(RelativePath(resource.path))

Tests/PackageLoadingTests/PackageBuilderTests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,32 @@ class PackageBuilderTests: XCTestCase {
8787
}
8888
}
8989

90+
func testSymlinkedSourcesDirectory() throws {
91+
mktmpdir { path in
92+
let fs = localFileSystem
93+
94+
let sources = path.appending(components: "Sources")
95+
let foo = sources.appending(components: "foo")
96+
let bar = sources.appending(components: "bar")
97+
try fs.createDirectory(foo, recursive: true)
98+
try fs.writeFileContents(foo.appending(components: "foo.swift"), bytes: "")
99+
100+
// Create a symlink to foo.
101+
try createSymlink(bar, pointingAt: foo)
102+
103+
let manifest = Manifest.createV4Manifest(
104+
name: "pkg",
105+
targets: [
106+
TargetDescription(name: "bar"),
107+
]
108+
)
109+
110+
PackageBuilderTester(manifest, path: path, in: fs) { package, _ in
111+
package.checkModule("bar")
112+
}
113+
}
114+
}
115+
90116
func testCInTests() throws {
91117
let fs = InMemoryFileSystem(emptyFiles:
92118
"/Sources/MyPackage/main.swift",

Tests/PackageLoadingTests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extension PackageBuilderTests {
5252
("testResolvesSystemModulePackage", testResolvesSystemModulePackage),
5353
("testSpecialTargetDir", testSpecialTargetDir),
5454
("testSpecifiedCustomPathDoesNotExist", testSpecifiedCustomPathDoesNotExist),
55+
("testSymlinkedSourcesDirectory", testSymlinkedSourcesDirectory),
5556
("testSystemLibraryTarget", testSystemLibraryTarget),
5657
("testSystemLibraryTargetDiagnostics", testSystemLibraryTargetDiagnostics),
5758
("testSystemPackageDeclaresTargetsDiagnostic", testSystemPackageDeclaresTargetsDiagnostic),

0 commit comments

Comments
 (0)