Skip to content

Commit 8126c2f

Browse files
authored
Merge pull request #487 from artemcm/53workaroundImplementationOnly
Workaround a compiler error with SPI public type using `implementationOnly` properties.
2 parents 77126cf + 2b2242d commit 8126c2f

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

Sources/SwiftDriver/SwiftScan/SwiftScan.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public enum DependencyScanningError: Error, DiagnosticData {
5555
}
5656

5757
/// Wrapper for libSwiftScan, taking care of initialization, shutdown, and dispatching dependency scanning queries.
58-
@_spi(Testing) public final class SwiftScan {
58+
internal final class SwiftScan {
5959
/// The path to the libSwiftScan dylib.
6060
let path: AbsolutePath
6161

@@ -197,6 +197,23 @@ public enum DependencyScanningError: Error, DiagnosticData {
197197
}
198198
}
199199

200+
// Used for testing purposes only
201+
@_spi(Testing) public extension Driver {
202+
func querySupportedArgumentsForTest() throws -> Set<String>? {
203+
// If a capable libSwiftScan is found, manually ensure we can get the supported arguments
204+
let scanLibPath = try Self.getScanLibPath(of: toolchain,
205+
hostTriple: hostTriple,
206+
env: env)
207+
if fileSystem.exists(scanLibPath) {
208+
let libSwiftScanInstance = try SwiftScan(dylib: scanLibPath)
209+
if libSwiftScanInstance.canQuerySupportedArguments() {
210+
return try libSwiftScanInstance.querySupportedArguments()
211+
}
212+
}
213+
return nil
214+
}
215+
}
216+
200217
private extension swiftscan_functions_t {
201218
init(_ swiftscan: DLHandle) throws {
202219
self.init()

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,16 +3124,8 @@ final class SwiftDriverTests: XCTestCase {
31243124
do {
31253125
let driver = try Driver(args: ["swift", "-target", "arm64-apple-ios12.0",
31263126
"-resource-dir", "baz"])
3127-
// If a capable libSwiftScan is found, manually ensure we can get the supported arguments
3128-
let scanLibPath = try Driver.getScanLibPath(of: driver.toolchain,
3129-
hostTriple: driver.hostTriple,
3130-
env: ProcessEnv.vars)
3131-
if localFileSystem.exists(scanLibPath) {
3132-
let libSwiftScanInstance = try SwiftScan(dylib: scanLibPath)
3133-
if libSwiftScanInstance.canQuerySupportedArguments() {
3134-
let supportedArguments = try libSwiftScanInstance.querySupportedArguments()
3135-
XCTAssertTrue(supportedArguments.contains("emit-module"))
3136-
}
3127+
if let libraryBasedResult = try driver.querySupportedArgumentsForTest() {
3128+
XCTAssertTrue(libraryBasedResult.contains("emit-module"))
31373129
}
31383130
}
31393131
do {

0 commit comments

Comments
 (0)