@@ -212,10 +212,6 @@ public class SwiftTool<Options: ToolOptions> {
212
212
/// The stream to print standard output on.
213
213
fileprivate var stdoutStream : OutputByteStream = Basic . stdoutStream
214
214
215
- /// If true, Redirects the stdout stream to stderr when invoking
216
- /// `swift-build-tool`.
217
- private var shouldRedirectStdoutToStderr = false
218
-
219
215
/// Create an instance of this tool.
220
216
///
221
217
/// - parameter args: The command line arguments to be passed to this tool.
@@ -329,11 +325,6 @@ public class SwiftTool<Options: ToolOptions> {
329
325
usage: " Link Swift stdlib statically " ) ,
330
326
to: { $0. shouldLinkStaticSwiftStdlib = $1 } )
331
327
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
-
337
328
binder. bind (
338
329
option: parser. add ( option: " --force-resolved-versions " , kind: Bool . self) ,
339
330
to: { $0. forceResolvedVersions = $1 } )
@@ -514,7 +505,6 @@ public class SwiftTool<Options: ToolOptions> {
514
505
515
506
/// Start redirecting the standard output stream to the standard error stream.
516
507
func redirectStdoutToStderr( ) {
517
- self . shouldRedirectStdoutToStderr = true
518
508
self . stdoutStream = Basic . stderrStream
519
509
DiagnosticsEngineHandler . default. stdoutStream = Basic . stderrStream
520
510
}
@@ -598,14 +588,14 @@ public class SwiftTool<Options: ToolOptions> {
598
588
return
599
589
}
600
590
601
- let yaml = plan. buildParameters. llbuildManifest
591
+ let manifest = plan. buildParameters. llbuildManifest
602
592
// 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)
606
595
607
596
// 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)
609
599
610
600
// Create backwards-compatibilty symlink to old build path.
611
601
let oldBuildPath = buildPath. appending ( component: options. configuration. dirname)
@@ -616,15 +606,6 @@ public class SwiftTool<Options: ToolOptions> {
616
606
}
617
607
618
608
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 {
628
609
// Setup the build delegate.
629
610
let isVerbose = verbosity != . concise
630
611
let progressAnimation : ProgressAnimationProtocol = isVerbose ?
@@ -646,59 +627,6 @@ public class SwiftTool<Options: ToolOptions> {
646
627
guard success else { throw Diagnostics . fatalError }
647
628
}
648
629
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
-
702
630
/// Return the build parameters.
703
631
func buildParameters( ) throws -> BuildParameters {
704
632
return try _buildParameters. dematerialize ( )
0 commit comments