Skip to content

Commit 81e4399

Browse files
committed
Assert include directory exists in Clang target
1 parent c1afc88 commit 81e4399

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Sources/PackageModel/Target.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import TSCBasic
1212
import TSCUtility
13+
import Foundation
1314

1415
public class Target: ObjectIdentifierProtocol, PolymorphicCodableProtocol {
1516
public static var implementations: [PolymorphicCodableProtocol.Type] = [
@@ -427,7 +428,8 @@ public final class ClangTarget: Target {
427428
dependencies: [Target.Dependency] = [],
428429
buildSettings: BuildSettings.AssignmentTable = .init()
429430
) {
430-
assert(includeDir.contains(sources.root), "\(includeDir) should be contained in the source root \(sources.root)")
431+
432+
assert(includeDir.isDirectory && includeDir.contains(sources.root), "\(includeDir) should be contained in the source root \(sources.root)")
431433
self.isCXX = sources.containsCXXFiles
432434
self.cLanguageStandard = cLanguageStandard
433435
self.cxxLanguageStandard = cxxLanguageStandard
@@ -666,3 +668,12 @@ public enum PluginCapability: Equatable, Codable {
666668
}
667669
}
668670
}
671+
672+
673+
fileprivate extension AbsolutePath {
674+
var isDirectory: Bool {
675+
var isDir: ObjCBool = false
676+
let exists = FileManager.default.fileExists(atPath: self.pathString, isDirectory: &isDir)
677+
return exists && isDir.boolValue
678+
}
679+
}

0 commit comments

Comments
 (0)