Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach version requests to include the version of the separately installed blocklist #1411

Merged
merged 1 commit into from Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions Sources/SwiftDriver/Driver/Driver.swift
Expand Up @@ -459,6 +459,18 @@ public struct Driver {
return results
}

@_spi(Testing)
public static func findCompilerClientsConfigVersion(RelativeTo execDir: AbsolutePath) throws -> String? {
// Expect to find all blocklists in such dir:
// .../XcodeDefault.xctoolchain/usr/local/lib/swift/compilerClientsConfig_version.txt
let versionFilePath = execDir.parentDirectory
.appending(components: "local", "lib", "swift", "compilerClientsConfig_version.txt")
if (localFileSystem.exists(versionFilePath)) {
return try localFileSystem.readFileContents(versionFilePath).cString
}
return nil
}

/// Handler for emitting diagnostics to stderr.
public static let stderrDiagnosticsHandler: DiagnosticsEngine.DiagnosticsHandler = { diagnostic in
stdErrQueue.sync {
Expand Down Expand Up @@ -1504,6 +1516,9 @@ extension Driver {
// versions.
if inPlaceJob.kind == .versionRequest && !Driver.driverSourceVersion.isEmpty {
stderrStream <<< "swift-driver version: " <<< Driver.driverSourceVersion <<< " "
if let blocklistVersion = try Driver.findCompilerClientsConfigVersion(RelativeTo: try toolchain.executableDir) {
stderrStream <<< blocklistVersion <<< " "
}
stderrStream.flush()
}
// In verbose mode, print out the job
Expand Down
@@ -0,0 +1 @@
compilerClientsConfig-9999.99.9
6 changes: 6 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Expand Up @@ -7069,6 +7069,12 @@ final class SwiftDriverTests: XCTestCase {
XCTAssertTrue(list.allSatisfy { $0.extension! == "yml" || $0.extension! == "yaml"})
}

func testFindingBlockListVersion() throws {
let execDir = testInputsPath.appending(components: "Dummy.xctoolchain", "usr", "bin")
let version = try Driver.findCompilerClientsConfigVersion(RelativeTo: execDir)
XCTAssertEqual(version, "compilerClientsConfig-9999.99.9")
}

func testToolSearching() throws {
#if os(Windows)
let PATH = "Path"
Expand Down