@@ -52,8 +52,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
5252 /// The loaded package graph.
5353 private var packageGraph : PackageGraph ?
5454
55- /// The stdout stream for the build delegate.
56- let stdoutStream : OutputByteStream
55+ /// The output stream for the build delegate.
56+ let outputStream : OutputByteStream
5757
5858 public var builtTestProducts : [ BuiltTestProduct ] {
5959 ( try ? getBuildDescription ( ) ) ? . builtTestProducts ?? [ ]
@@ -65,14 +65,14 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
6565 packageGraphLoader: @escaping ( ) throws -> PackageGraph ,
6666 pluginInvoker: @escaping ( PackageGraph ) throws -> [ ResolvedTarget : [ PluginInvocationResult ] ] ,
6767 diagnostics: DiagnosticsEngine ,
68- stdoutStream : OutputByteStream
68+ outputStream : OutputByteStream
6969 ) {
7070 self . buildParameters = buildParameters
7171 self . cacheBuildManifest = cacheBuildManifest
7272 self . packageGraphLoader = packageGraphLoader
7373 self . pluginInvoker = pluginInvoker
7474 self . diagnostics = diagnostics
75- self . stdoutStream = stdoutStream
75+ self . outputStream = outputStream
7676 }
7777
7878 public func getPackageGraph( ) throws -> PackageGraph {
@@ -121,7 +121,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
121121 /// Perform a build using the given build description and subset.
122122 public func build( subset: BuildSubset ) throws {
123123 // Create the build system.
124- let buildSystem = try createBuildSystem ( with: getBuildDescription ( ) )
124+ let buildDescription = try self . getBuildDescription ( )
125+ let buildSystem = try createBuildSystem ( with: buildDescription)
125126 self . buildSystem = buildSystem
126127
127128 // Perform the build.
@@ -194,9 +195,21 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
194195 diagnostics: diagnostics
195196 )
196197 self . buildPlan = plan
198+
199+ let ( buildDescription, buildManifest) = try BuildDescription . create ( with: plan)
200+
201+ // FIXME: ideally this would be done outside of the planning phase,
202+ // but it would require deeper changes in how we serialize BuildDescription
203+ // Output a dot graph
204+ if buildParameters. printManifestGraphviz {
205+ // FIXME: this seems like the wrong place to print
206+ var serializer = DOTManifestSerializer ( manifest: buildManifest)
207+ serializer. writeDOT ( to: self . outputStream)
208+ self . outputStream. flush ( )
209+ }
197210
198211 // Finally create the llbuild manifest from the plan.
199- return try BuildDescription . create ( with : plan )
212+ return buildDescription
200213 }
201214
202215 /// Build the package structure target.
@@ -220,8 +233,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
220233 // Figure out which progress bar we have to use during the build.
221234 let isVerbose = verbosity != . concise
222235 let progressAnimation : ProgressAnimationProtocol = isVerbose
223- ? MultiLineNinjaProgressAnimation ( stream: self . stdoutStream )
224- : NinjaProgressAnimation ( stream: self . stdoutStream )
236+ ? MultiLineNinjaProgressAnimation ( stream: self . outputStream )
237+ : NinjaProgressAnimation ( stream: self . outputStream )
225238
226239 let bctx = BuildExecutionContext (
227240 buildParameters,
@@ -235,7 +248,7 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
235248 buildSystem: self ,
236249 bctx: bctx,
237250 diagnostics: diagnostics,
238- outputStream: self . stdoutStream ,
251+ outputStream: self . outputStream ,
239252 progressAnimation: progressAnimation,
240253 delegate: self . delegate
241254 )
@@ -294,10 +307,10 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
294307}
295308
296309extension BuildDescription {
297- static func create( with plan: BuildPlan ) throws -> BuildDescription {
310+ static func create( with plan: BuildPlan ) throws -> ( BuildDescription , BuildManifest ) {
298311 // Generate the llbuild manifest.
299312 let llbuild = LLBuildManifestBuilder ( plan)
300- try llbuild. generateManifest ( at: plan. buildParameters. llbuildManifest)
313+ let buildManifest = try llbuild. generateManifest ( at: plan. buildParameters. llbuildManifest)
301314
302315 let swiftCommands = llbuild. manifest. getCmdToolMap ( kind: SwiftCompilerTool . self)
303316 let swiftFrontendCommands = llbuild. manifest. getCmdToolMap ( kind: SwiftFrontendTool . self)
@@ -317,7 +330,7 @@ extension BuildDescription {
317330 recursive: true
318331 )
319332 try buildDescription. write ( to: plan. buildParameters. buildDescriptionPath)
320- return buildDescription
333+ return ( buildDescription, buildManifest )
321334 }
322335}
323336
0 commit comments