@@ -238,6 +238,10 @@ public final class PackageBuilder {
238
238
)
239
239
}
240
240
241
+ private func diagnosticLocation( ) -> DiagnosticLocation {
242
+ return PackageLocation . Local ( name: manifest. name, packagePath: packagePath)
243
+ }
244
+
241
245
/// Computes the special directory where targets are present or should be placed in future.
242
246
private func findTargetSpecialDirs( _ targets: [ Target ] ) -> ( targetDir: String , testTargetDir: String ) {
243
247
let predefinedDirs = findPredefinedTargetDirectory ( )
@@ -277,8 +281,19 @@ public final class PackageBuilder {
277
281
// Ignore linux main.
278
282
if basename == SwiftTarget . linuxMainBasename { return false }
279
283
280
- // Ignore symlinks to non-files.
281
- if !fileSystem. isFile ( path) { return false }
284
+ // Ignore paths which are not valid files.
285
+ if !fileSystem. isFile ( path) {
286
+
287
+ // Diagnose broken symlinks.
288
+ if fileSystem. isSymlink ( path) {
289
+ diagnostics. emit (
290
+ data: PackageBuilderDiagnostics . BorkenSymlinkDiagnostic ( path: path. asString) ,
291
+ location: diagnosticLocation ( )
292
+ )
293
+ }
294
+
295
+ return false
296
+ }
282
297
283
298
// Ignore manifest files.
284
299
if path. parentDirectory == packagePath {
@@ -336,7 +351,7 @@ public final class PackageBuilder {
336
351
if !targets. isEmpty {
337
352
diagnostics. emit (
338
353
data: PackageBuilderDiagnostics . SystemPackageDeclaresTargetsDiagnostic ( targets: targets. map ( { $0. name } ) ) ,
339
- location: PackageLocation . Local ( name : manifest . name , packagePath : packagePath )
354
+ location: diagnosticLocation ( )
340
355
)
341
356
}
342
357
@@ -346,7 +361,7 @@ public final class PackageBuilder {
346
361
case . v4_2:
347
362
diagnostics. emit (
348
363
data: PackageBuilderDiagnostics . SystemPackageDeprecatedDiagnostic ( ) ,
349
- location: PackageLocation . Local ( name : manifest . name , packagePath : packagePath )
364
+ location: diagnosticLocation ( )
350
365
)
351
366
}
352
367
@@ -786,7 +801,7 @@ public final class PackageBuilder {
786
801
if !inserted {
787
802
diagnostics. emit (
788
803
data: PackageBuilderDiagnostics . DuplicateProduct ( product: product) ,
789
- location: PackageLocation . Local ( name : manifest . name , packagePath : packagePath )
804
+ location: diagnosticLocation ( )
790
805
)
791
806
}
792
807
}
@@ -877,7 +892,7 @@ public final class PackageBuilder {
877
892
if product. type != . library( . automatic) || targets. count != 1 {
878
893
diagnostics. emit (
879
894
data: PackageBuilderDiagnostics . SystemPackageProductValidationDiagnostic ( product: product. name) ,
880
- location: PackageLocation . Local ( name : manifest . name , packagePath : packagePath )
895
+ location: diagnosticLocation ( )
881
896
)
882
897
continue
883
898
}
@@ -892,7 +907,7 @@ public final class PackageBuilder {
892
907
if executableTargets. count != 1 {
893
908
diagnostics. emit (
894
909
data: PackageBuilderDiagnostics . InvalidExecutableProductDecl ( product: product. name) ,
895
- location: PackageLocation . Local ( name : manifest . name , packagePath : packagePath )
910
+ location: diagnosticLocation ( )
896
911
)
897
912
continue
898
913
}
0 commit comments