@@ -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- internal final class SwiftScan {
58+ @ _spi ( Testing ) public final class SwiftScan {
5959 /// The path to the libSwiftScan dylib.
6060 let path : AbsolutePath
6161
@@ -246,6 +246,26 @@ internal final class SwiftScan {
246246 throw DependencyScanningError . argumentQueryFailed
247247 }
248248 }
249+
250+ @_spi ( Testing) public func canQueryTargetInfo( ) -> Bool {
251+ return api. swiftscan_compiler_target_info_query != nil &&
252+ api. swiftscan_string_set_dispose != nil
253+ }
254+
255+ @_spi ( Testing) public func queryTargetInfo( invocationCommand: [ String ] )
256+ throws -> FrontendTargetInfo {
257+ // Create and configure the scanner invocation
258+ let invocation = api. swiftscan_scan_invocation_create ( )
259+ defer { api. swiftscan_scan_invocation_dispose ( invocation) }
260+ withArrayOfCStrings ( invocationCommand) { invocationStringArray in
261+ api. swiftscan_scan_invocation_set_argv ( invocation,
262+ Int32 ( invocationCommand. count) ,
263+ invocationStringArray)
264+ }
265+ let targetInfoString = try toSwiftString ( api. swiftscan_compiler_target_info_query ( invocation) )
266+ let targetInfoData = Data ( targetInfoString. utf8)
267+ return try JSONDecoder ( ) . decode ( FrontendTargetInfo . self, from: targetInfoData)
268+ }
249269}
250270
251271// Used for testing purposes only
@@ -285,6 +305,10 @@ private extension swiftscan_functions_t {
285305 self . swiftscan_compiler_supported_features_query =
286306 try loadOptional ( " swiftscan_compiler_supported_features_query " )
287307
308+ // Target Info query
309+ self . swiftscan_compiler_target_info_query =
310+ try loadOptional ( " swiftscan_compiler_target_info_query " )
311+
288312 // Dependency scanner serialization/deserialization features
289313 self . swiftscan_scanner_cache_serialize =
290314 try loadOptional ( " swiftscan_scanner_cache_serialize " )
0 commit comments