@@ -8,14 +8,32 @@ let hasFreeTDS: Bool = {
88 // Manual override for local testing
99 if ProcessInfo . processInfo. environment [ " SKIP_FREETDS " ] != nil { return false }
1010
11+ // 1. Check if the header exists in standard paths.
1112 let standardPaths = [
1213 " /opt/homebrew/include/sybdb.h " , // macOS Apple Silicon
1314 " /usr/local/include/sybdb.h " , // macOS Intel
1415 " /usr/include/sybdb.h " , // Linux (Standard)
1516 " /usr/include/freetds/sybdb.h " , // Linux (Alternative)
1617 " /opt/homebrew/opt/freetds/include/sybdb.h " // Brew opt path
1718 ]
18- return standardPaths. contains { FileManager . default. fileExists ( atPath: $0) }
19+ let headerExists = standardPaths. contains { FileManager . default. fileExists ( atPath: $0) }
20+ guard headerExists else { return false }
21+
22+ // 2. Check if pkg-config can actually find it.
23+ // If headers exist but pkg-config fails, the systemLibrary target will cause a build failure.
24+ let process = Process ( )
25+ process. executableURL = URL ( fileURLWithPath: " /usr/bin/env " )
26+ process. arguments = [ " pkg-config " , " --exists " , " freetds " ]
27+ process. standardOutput = Pipe ( )
28+ process. standardError = Pipe ( )
29+
30+ do {
31+ try process. run ( )
32+ process. waitUntilExit ( )
33+ return process. terminationStatus == 0
34+ } catch {
35+ return false
36+ }
1937} ( )
2038
2139var packageTargets : [ Target ] = [
0 commit comments