@@ -212,10 +212,6 @@ public class SwiftTool<Options: ToolOptions> {
212212 /// The stream to print standard output on.
213213 fileprivate var stdoutStream : OutputByteStream = Basic . stdoutStream
214214
215- /// If true, Redirects the stdout stream to stderr when invoking
216- /// `swift-build-tool`.
217- private var shouldRedirectStdoutToStderr = false
218-
219215 /// Create an instance of this tool.
220216 ///
221217 /// - parameter args: The command line arguments to be passed to this tool.
@@ -329,11 +325,6 @@ public class SwiftTool<Options: ToolOptions> {
329325 usage: " Link Swift stdlib statically " ) ,
330326 to: { $0. shouldLinkStaticSwiftStdlib = $1 } )
331327
332- binder. bind (
333- option: parser. add ( option: " --enable-llbuild-library " , kind: Bool . self,
334- usage: " Enable building with the llbuild library " ) ,
335- to: { $0. shouldEnableLLBuildLibrary = $1 } )
336-
337328 binder. bind (
338329 option: parser. add ( option: " --force-resolved-versions " , kind: Bool . self) ,
339330 to: { $0. forceResolvedVersions = $1 } )
@@ -514,7 +505,6 @@ public class SwiftTool<Options: ToolOptions> {
514505
515506 /// Start redirecting the standard output stream to the standard error stream.
516507 func redirectStdoutToStderr( ) {
517- self . shouldRedirectStdoutToStderr = true
518508 self . stdoutStream = Basic . stderrStream
519509 DiagnosticsEngineHandler . default. stdoutStream = Basic . stderrStream
520510 }
@@ -598,14 +588,14 @@ public class SwiftTool<Options: ToolOptions> {
598588 return
599589 }
600590
601- let yaml = plan. buildParameters. llbuildManifest
591+ let manifest = plan. buildParameters. llbuildManifest
602592 // Generate the llbuild manifest.
603- let client = options. shouldEnableLLBuildLibrary ? " basic " : " swift-build "
604- let llbuild = LLBuildManifestGenerator ( plan, client: client)
605- try llbuild. generateManifest ( at: yaml)
593+ let llbuild = LLBuildManifestGenerator ( plan, client: " basic " )
594+ try llbuild. generateManifest ( at: manifest)
606595
607596 // Run llbuild.
608- try runLLBuild ( plan: plan, manifest: yaml, llbuildTarget: llbuildTargetName)
597+ assert ( localFileSystem. isFile ( manifest) , " llbuild manifest not present: \( manifest) " )
598+ try runLLBuild ( plan: plan, manifest: manifest, llbuildTarget: llbuildTargetName)
609599
610600 // Create backwards-compatibilty symlink to old build path.
611601 let oldBuildPath = buildPath. appending ( component: options. configuration. dirname)
@@ -616,15 +606,6 @@ public class SwiftTool<Options: ToolOptions> {
616606 }
617607
618608 func runLLBuild( plan: BuildPlan , manifest: AbsolutePath , llbuildTarget: String ) throws {
619- assert ( localFileSystem. isFile ( manifest) , " llbuild manifest not present: \( manifest) " )
620- if options. shouldEnableLLBuildLibrary {
621- try runLLBuildAsLibrary ( plan: plan, manifest: manifest, llbuildTarget: llbuildTarget)
622- } else {
623- try runLLBuildAsExecutable ( manifest: manifest, llbuildTarget: llbuildTarget)
624- }
625- }
626-
627- func runLLBuildAsLibrary( plan: BuildPlan , manifest: AbsolutePath , llbuildTarget: String ) throws {
628609 // Setup the build delegate.
629610 let isVerbose = verbosity != . concise
630611 let progressAnimation : ProgressAnimationProtocol = isVerbose ?
@@ -646,59 +627,6 @@ public class SwiftTool<Options: ToolOptions> {
646627 guard success else { throw Diagnostics . fatalError }
647628 }
648629
649- func runLLBuildAsExecutable( manifest: AbsolutePath , llbuildTarget: String ) throws {
650- // Create a temporary directory for the build process.
651- let tempDirName = " org.swift.swiftpm. \( NSUserName ( ) ) "
652- let tempDir = try determineTempDirectory ( ) . appending ( component: tempDirName)
653- try localFileSystem. createDirectory ( tempDir, recursive: true )
654-
655- // Run the swift-build-tool with the generated manifest.
656- var args = [ String] ( )
657-
658- #if os(macOS)
659- // If enabled, use sandbox-exec on macOS. This provides some safety
660- // against arbitrary code execution. We only allow the permissions which
661- // are absolutely necessary for performing a build.
662- if !options. shouldDisableSandbox {
663- let allowedDirectories = [
664- tempDir,
665- buildPath,
666- ] . map ( resolveSymlinks)
667- args += [ " sandbox-exec " , " -p " , sandboxProfile ( allowedDirectories: allowedDirectories) ]
668- }
669- #endif
670-
671- args += [ try getToolchain ( ) . llbuild. pathString, " -f " , manifest. pathString, llbuildTarget]
672- if verbosity != . concise {
673- args. append ( " -v " )
674- }
675-
676- // Create the environment for llbuild.
677- var env = Process . env
678- // We override the temporary directory so tools assuming full access to
679- // the tmp dir can create files here freely, provided they respect this
680- // variable.
681- env [ " TMPDIR " ] = tempDir. pathString
682-
683- // Run llbuild and print output on standard streams.
684- let process = Process ( arguments: args, environment: env, outputRedirection: shouldRedirectStdoutToStderr ? . collect : . none)
685- try process. launch ( )
686- try processSet. add ( process)
687- let result = try process. waitUntilExit ( )
688-
689- // Emit the output to the selected stream if we need to redirect the
690- // stream.
691- if shouldRedirectStdoutToStderr {
692- self . stdoutStream <<< ( try result. utf8stderrOutput ( ) )
693- self . stdoutStream <<< ( try result. utf8Output ( ) )
694- self . stdoutStream. flush ( )
695- }
696-
697- guard result. exitStatus == . terminated( code: 0 ) else {
698- throw ProcessResult . Error. nonZeroExit ( result)
699- }
700- }
701-
702630 /// Return the build parameters.
703631 func buildParameters( ) throws -> BuildParameters {
704632 return try _buildParameters. dematerialize ( )
0 commit comments