Skip to content

Commit 340d260

Browse files
authored
Merge pull request #1411 from apple/block-list-version
Teach version requests to include the version of the separately installed blocklist
2 parents f07c1f2 + 2a0afce commit 340d260

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Sources/SwiftDriver/Driver/Driver.swift

+15
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,18 @@ public struct Driver {
459459
return results
460460
}
461461

462+
@_spi(Testing)
463+
public static func findCompilerClientsConfigVersion(RelativeTo execDir: AbsolutePath) throws -> String? {
464+
// Expect to find all blocklists in such dir:
465+
// .../XcodeDefault.xctoolchain/usr/local/lib/swift/compilerClientsConfig_version.txt
466+
let versionFilePath = execDir.parentDirectory
467+
.appending(components: "local", "lib", "swift", "compilerClientsConfig_version.txt")
468+
if (localFileSystem.exists(versionFilePath)) {
469+
return try localFileSystem.readFileContents(versionFilePath).cString
470+
}
471+
return nil
472+
}
473+
462474
/// Handler for emitting diagnostics to stderr.
463475
public static let stderrDiagnosticsHandler: DiagnosticsEngine.DiagnosticsHandler = { diagnostic in
464476
stdErrQueue.sync {
@@ -1504,6 +1516,9 @@ extension Driver {
15041516
// versions.
15051517
if inPlaceJob.kind == .versionRequest && !Driver.driverSourceVersion.isEmpty {
15061518
stderrStream <<< "swift-driver version: " <<< Driver.driverSourceVersion <<< " "
1519+
if let blocklistVersion = try Driver.findCompilerClientsConfigVersion(RelativeTo: try toolchain.executableDir) {
1520+
stderrStream <<< blocklistVersion <<< " "
1521+
}
15071522
stderrStream.flush()
15081523
}
15091524
// In verbose mode, print out the job
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
compilerClientsConfig-9999.99.9

Tests/SwiftDriverTests/SwiftDriverTests.swift

+6
Original file line numberDiff line numberDiff line change
@@ -7069,6 +7069,12 @@ final class SwiftDriverTests: XCTestCase {
70697069
XCTAssertTrue(list.allSatisfy { $0.extension! == "yml" || $0.extension! == "yaml"})
70707070
}
70717071

7072+
func testFindingBlockListVersion() throws {
7073+
let execDir = testInputsPath.appending(components: "Dummy.xctoolchain", "usr", "bin")
7074+
let version = try Driver.findCompilerClientsConfigVersion(RelativeTo: execDir)
7075+
XCTAssertEqual(version, "compilerClientsConfig-9999.99.9")
7076+
}
7077+
70727078
func testToolSearching() throws {
70737079
#if os(Windows)
70747080
let PATH = "Path"

0 commit comments

Comments
 (0)