Skip to content

Commit

Permalink
Merge pull request #1411 from apple/block-list-version
Browse files Browse the repository at this point in the history
Teach version requests to include the version of the separately installed blocklist
  • Loading branch information
nkcsgexi committed Aug 10, 2023
2 parents f07c1f2 + 2a0afce commit 340d260
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
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

0 comments on commit 340d260

Please sign in to comment.