Skip to content

Commit c386bf5

Browse files
committed
[DNM] Test Logging
1 parent 36ec39e commit c386bf5

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Sources/Basics/FileSystem/TSCAdapters.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ public func getEnvSearchPaths(
108108
pathString: String?,
109109
currentWorkingDirectory: AbsolutePath?
110110
) -> [AbsolutePath] {
111-
TSCBasic.getEnvSearchPaths(
111+
print("Getting env search paths for PATH=\(pathString), CWD=\(currentWorkingDirectory)")
112+
return TSCBasic.getEnvSearchPaths(
112113
pathString: pathString,
113114
currentWorkingDirectory: currentWorkingDirectory?.underlying
114115
).map { AbsolutePath($0) }

Sources/PackageModel/UserToolchain.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,16 @@ public final class UserToolchain: Toolchain {
126126
fileSystem: any FileSystem
127127
) throws -> AbsolutePath {
128128
let executableName = "\(name)\(hostExecutableSuffix)"
129+
print("getTool: \(executableName) in \(binDirectories)")
129130
var toolPath: AbsolutePath?
130131

131132
for dir in binDirectories {
132133
let path = dir.appending(component: executableName)
133134
guard fileSystem.isExecutableFile(path) else {
135+
print("Trying \(path)... not executable file")
134136
continue
135137
}
138+
print("Trying \(path)... SUCCESS")
136139
toolPath = path
137140
// Take the first match.
138141
break
@@ -230,19 +233,25 @@ public final class UserToolchain: Toolchain {
230233
searchPaths: [AbsolutePath],
231234
fileSystem: any FileSystem
232235
) throws -> SwiftCompilers {
236+
print("Determining swift compilers with binDirectories: \(binDirectories), searchPaths: \(searchPaths)")
233237
func validateCompiler(at path: AbsolutePath?) throws {
238+
print("Validating compiler at \(path)")
234239
guard let path else { return }
235240
guard fileSystem.isExecutableFile(path) else {
236241
throw InvalidToolchainDiagnostic(
237242
"could not find the `swiftc\(hostExecutableSuffix)` at expected path \(path)"
238243
)
239244
}
245+
print("VALID")
240246
}
241247

242248
let lookup = { UserToolchain.lookup(variable: $0, searchPaths: searchPaths, environment: environment) }
243249
// Get overrides.
244250
let SWIFT_EXEC_MANIFEST = lookup("SWIFT_EXEC_MANIFEST")
245251
let SWIFT_EXEC = lookup("SWIFT_EXEC")
252+
253+
print("SWIFT_EXEC: \(SWIFT_EXEC)")
254+
print("SWIFT_EXEC_MANIFEST: \(SWIFT_EXEC_MANIFEST)")
246255

247256
// Validate the overrides.
248257
try validateCompiler(at: SWIFT_EXEC)
@@ -254,6 +263,7 @@ public final class UserToolchain: Toolchain {
254263
if let SWIFT_EXEC {
255264
resolvedBinDirCompiler = SWIFT_EXEC
256265
} else if let binDirCompiler = try? UserToolchain.getTool("swiftc", binDirectories: binDirectories, fileSystem: fileSystem) {
266+
print("Resolved directly to \(binDirCompiler)")
257267
resolvedBinDirCompiler = binDirCompiler
258268
} else {
259269
// Try to lookup swift compiler on the system which is possible when
@@ -264,6 +274,7 @@ public final class UserToolchain: Toolchain {
264274
useXcrun: useXcrun,
265275
fileSystem: fileSystem
266276
)
277+
print("Resolved eventually to \(resolvedBinDirCompiler)")
267278
}
268279

269280
// The compiler for compilation tasks is SWIFT_EXEC or the bin dir compiler.
@@ -541,12 +552,14 @@ public final class UserToolchain: Toolchain {
541552
pathString: environment[.path],
542553
currentWorkingDirectory: fileSystem.currentWorkingDirectory
543554
)
555+
print("Default search strategy envSearchPaths=\(envSearchPaths)")
544556
self.useXcrun = true
545557
case .custom(let searchPaths, let useXcrun):
546558
self.envSearchPaths = searchPaths
559+
print("Custom search strategy envSearchPaths=\(envSearchPaths)")
547560
self.useXcrun = useXcrun
548561
}
549-
562+
print("Toolset known tools: \(swiftSDK.toolset.knownTools)")
550563
let swiftCompilers = try UserToolchain.determineSwiftCompilers(
551564
binDirectories: swiftSDK.toolset.rootPaths,
552565
useXcrun: self.useXcrun,

0 commit comments

Comments
 (0)