@@ -345,6 +345,35 @@ class SWBServiceConsolePrepareForIndexCommand: SWBServiceConsoleCommand {
345345 }
346346}
347347
348+ class SWBServiceConsoleDependencyInfoCommand : SWBServiceConsoleCommand {
349+ public static let name = " generateDependencyInfo "
350+
351+ static func usage( ) -> String {
352+ return name + " [options] <container-path> "
353+ }
354+
355+ static func validate( invocation: SWBServiceConsoleCommandInvocation ) -> SWBServiceConsoleError ? {
356+ return nil
357+ }
358+
359+ static func perform( invocation: SWBServiceConsoleCommandInvocation ) async -> SWBCommandResult {
360+ return await SWBServiceConsoleBuildCommand . perform ( invocation: invocation, operationFunc: generateDependencyInfo)
361+ }
362+ }
363+
364+ fileprivate func generateDependencyInfo( startInfo: SwiftBuildMessage . BuildStartedInfo , session: SWBBuildServiceSession , sessionCreationDiagnostics: [ SwiftBuildMessage . DiagnosticInfo ] , request: SWBBuildRequest ) async -> SWBCommandResult {
365+ do {
366+ let output = try await withTemporaryDirectory ( removeTreeOnDeinit: true ) {
367+ let outputPath = $0. join ( " dump.json " )
368+ try await session. dumpBuildDependencyInfo ( for: request, to: outputPath. str)
369+ return try String ( contentsOf: URL ( fileURLWithPath: outputPath. str) )
370+ }
371+ return . success( . init( output: output) )
372+ } catch {
373+ return . failure( . failedCommandError( description: " \( error) " ) )
374+ }
375+ }
376+
348377extension SWBWorkspaceInfo {
349378 func configuredTargets( targetNames: [ String ] , parameters: SWBBuildParameters ) throws -> [ SWBConfiguredTarget ] {
350379 return try targetNames. map { targetName in
@@ -499,6 +528,7 @@ func registerBuildCommands() {
499528 SWBServiceConsoleBuildCommand . self,
500529 SWBServiceConsolePrepareForIndexCommand . self,
501530 SWBServiceConsoleCreateBuildDescriptionCommand . self,
531+ SWBServiceConsoleDependencyInfoCommand . self,
502532 ] as [ any SWBServiceConsoleCommand . Type ] ) { SWBServiceConsoleCommandRegistry . registerCommandClass ( commandClass) }
503533}
504534
0 commit comments