|
12 | 12 | import SwiftOptions
|
13 | 13 |
|
14 | 14 | import class Dispatch.DispatchQueue
|
15 |
| - |
16 |
| -import TSCBasic // <<< |
17 | 15 | import class TSCBasic.DiagnosticsEngine
|
| 16 | +import class TSCBasic.UnknownLocation |
18 | 17 | import enum TSCBasic.ProcessEnv
|
| 18 | +import func TSCBasic.withTemporaryDirectory |
19 | 19 | import protocol TSCBasic.DiagnosticData
|
20 | 20 | import protocol TSCBasic.FileSystem
|
21 | 21 | import protocol TSCBasic.OutputByteStream
|
22 | 22 | import struct TSCBasic.AbsolutePath
|
| 23 | +import struct TSCBasic.ByteString |
23 | 24 | import struct TSCBasic.Diagnostic
|
24 | 25 | import struct TSCBasic.FileInfo
|
25 | 26 | import struct TSCBasic.RelativePath
|
@@ -475,23 +476,23 @@ public struct Driver {
|
475 | 476 | stdErrQueue.sync {
|
476 | 477 | let stream = stderrStream
|
477 | 478 | if !(diagnostic.location is UnknownLocation) {
|
478 |
| - stream <<< diagnostic.location.description <<< ": " |
| 479 | + stream.send("\(diagnostic.location.description): ") |
479 | 480 | }
|
480 | 481 |
|
481 | 482 | switch diagnostic.message.behavior {
|
482 | 483 | case .error:
|
483 |
| - stream <<< "error: " |
| 484 | + stream.send("error: ") |
484 | 485 | case .warning:
|
485 |
| - stream <<< "warning: " |
| 486 | + stream.send("warning: ") |
486 | 487 | case .note:
|
487 |
| - stream <<< "note: " |
| 488 | + stream.send("note: ") |
488 | 489 | case .remark:
|
489 |
| - stream <<< "remark: " |
| 490 | + stream.send("remark: ") |
490 | 491 | case .ignored:
|
491 | 492 | break
|
492 | 493 | }
|
493 | 494 |
|
494 |
| - stream <<< diagnostic.localizedDescription <<< "\n" |
| 495 | + stream.send("\(diagnostic.localizedDescription)\n") |
495 | 496 | stream.flush()
|
496 | 497 | }
|
497 | 498 | }
|
@@ -1430,7 +1431,7 @@ extension Driver {
|
1430 | 1431 |
|
1431 | 1432 | if parsedOptions.contains(.driverPrintOutputFileMap) {
|
1432 | 1433 | if let outputFileMap = self.outputFileMap {
|
1433 |
| - stderrStream <<< outputFileMap.description |
| 1434 | + stderrStream.send(outputFileMap.description) |
1434 | 1435 | stderrStream.flush()
|
1435 | 1436 | } else {
|
1436 | 1437 | diagnosticEngine.emit(.error_no_output_file_map_specified)
|
@@ -1507,17 +1508,17 @@ extension Driver {
|
1507 | 1508 | // Print the driver source version first before we print the compiler
|
1508 | 1509 | // versions.
|
1509 | 1510 | if inPlaceJob.kind == .versionRequest && !Driver.driverSourceVersion.isEmpty {
|
1510 |
| - stderrStream <<< "swift-driver version: " <<< Driver.driverSourceVersion <<< " " |
| 1511 | + stderrStream.send("swift-driver version: \(Driver.driverSourceVersion) ") |
1511 | 1512 | if let blocklistVersion = try Driver.findCompilerClientsConfigVersion(RelativeTo: try toolchain.executableDir) {
|
1512 |
| - stderrStream <<< blocklistVersion <<< " " |
| 1513 | + stderrStream.send("\(blocklistVersion) ") |
1513 | 1514 | }
|
1514 | 1515 | stderrStream.flush()
|
1515 | 1516 | }
|
1516 | 1517 | // In verbose mode, print out the job
|
1517 | 1518 | if parsedOptions.contains(.v) {
|
1518 | 1519 | let arguments: [String] = try executor.resolver.resolveArgumentList(for: inPlaceJob,
|
1519 | 1520 | useResponseFiles: forceResponseFiles ? .forced : .heuristic)
|
1520 |
| - stdoutStream <<< arguments.map { $0.spm_shellEscaped() }.joined(separator: " ") <<< "\n" |
| 1521 | + stdoutStream.send("\(arguments.map { $0.spm_shellEscaped() }.joined(separator: " "))\n") |
1521 | 1522 | stdoutStream.flush()
|
1522 | 1523 | }
|
1523 | 1524 | try executor.execute(job: inPlaceJob,
|
@@ -1640,17 +1641,16 @@ extension Driver {
|
1640 | 1641 | }
|
1641 | 1642 |
|
1642 | 1643 | private func printBindings(_ job: Job) {
|
1643 |
| - stdoutStream <<< #"# ""# <<< targetTriple.triple |
1644 |
| - stdoutStream <<< #"" - ""# <<< job.tool.basename |
1645 |
| - stdoutStream <<< #"", inputs: ["# |
1646 |
| - stdoutStream <<< job.displayInputs.map { "\"" + $0.file.name + "\"" }.joined(separator: ", ") |
| 1644 | + stdoutStream.send(#"# ""#).send(targetTriple.triple) |
| 1645 | + stdoutStream.send(#"" - ""#).send(job.tool.basename) |
| 1646 | + stdoutStream.send(#"", inputs: ["#) |
| 1647 | + stdoutStream.send(job.displayInputs.map { "\"" + $0.file.name + "\"" }.joined(separator: ", ")) |
1647 | 1648 |
|
1648 |
| - stdoutStream <<< "], output: {" |
| 1649 | + stdoutStream.send("], output: {") |
1649 | 1650 |
|
1650 |
| - stdoutStream <<< job.outputs.map { $0.type.name + ": \"" + $0.file.name + "\"" }.joined(separator: ", ") |
| 1651 | + stdoutStream.send(job.outputs.map { $0.type.name + ": \"" + $0.file.name + "\"" }.joined(separator: ", ")) |
1651 | 1652 |
|
1652 |
| - stdoutStream <<< "}" |
1653 |
| - stdoutStream <<< "\n" |
| 1653 | + stdoutStream.send("}\n") |
1654 | 1654 | stdoutStream.flush()
|
1655 | 1655 | }
|
1656 | 1656 |
|
@@ -1721,36 +1721,36 @@ extension Driver {
|
1721 | 1721 | }
|
1722 | 1722 |
|
1723 | 1723 | // Print current Job
|
1724 |
| - stdoutStream <<< nextId <<< ": " <<< job.kind.rawValue <<< ", {" |
| 1724 | + stdoutStream.send("\(nextId): ").send(job.kind.rawValue).send(", {") |
1725 | 1725 | switch job.kind {
|
1726 | 1726 | // Don't sort for compile jobs. Puts pch last
|
1727 | 1727 | case .compile:
|
1728 |
| - stdoutStream <<< inputIds.map(\.description).joined(separator: ", ") |
| 1728 | + stdoutStream.send(inputIds.map(\.description).joined(separator: ", ")) |
1729 | 1729 | default:
|
1730 |
| - stdoutStream <<< inputIds.sorted().map(\.description).joined(separator: ", ") |
| 1730 | + stdoutStream.send(inputIds.sorted().map(\.description).joined(separator: ", ")) |
1731 | 1731 | }
|
1732 | 1732 | var typeName = job.outputs.first?.type.name
|
1733 | 1733 | if typeName == nil {
|
1734 | 1734 | typeName = "none"
|
1735 | 1735 | }
|
1736 |
| - stdoutStream <<< "}, " <<< typeName! <<< "\n" |
| 1736 | + stdoutStream.send("}, \(typeName!)\n") |
1737 | 1737 | jobIdMap[job] = nextId
|
1738 | 1738 | nextId += 1
|
1739 | 1739 | }
|
1740 | 1740 | }
|
1741 | 1741 |
|
1742 | 1742 | private static func printInputIfNew(_ input: TypedVirtualPath, inputIdMap: inout [TypedVirtualPath: UInt], nextId: inout UInt) {
|
1743 | 1743 | if inputIdMap[input] == nil {
|
1744 |
| - stdoutStream <<< nextId <<< ": " <<< "input, " |
1745 |
| - stdoutStream <<< "\"" <<< input.file <<< "\", " <<< input.type <<< "\n" |
| 1744 | + stdoutStream.send("\(nextId): input, ") |
| 1745 | + stdoutStream.send("\"\(input.file)\", \(input.type)\n") |
1746 | 1746 | inputIdMap[input] = nextId
|
1747 | 1747 | nextId += 1
|
1748 | 1748 | }
|
1749 | 1749 | }
|
1750 | 1750 |
|
1751 | 1751 | private func printVersion<S: OutputByteStream>(outputStream: inout S) throws {
|
1752 |
| - outputStream <<< frontendTargetInfo.compilerVersion <<< "\n" |
1753 |
| - outputStream <<< "Target: \(frontendTargetInfo.target.triple.triple)\n" |
| 1752 | + outputStream.send("\(frontendTargetInfo.compilerVersion)\n") |
| 1753 | + outputStream.send("Target: \(frontendTargetInfo.target.triple.triple)\n") |
1754 | 1754 | outputStream.flush()
|
1755 | 1755 | }
|
1756 | 1756 | }
|
@@ -2007,9 +2007,9 @@ extension Driver {
|
2007 | 2007 | let filePath = VirtualPath.absolute(absPath.appending(component: "main.swift"))
|
2008 | 2008 |
|
2009 | 2009 | try fileSystem.writeFileContents(filePath) { file in
|
2010 |
| - file <<< ###"#sourceLocation(file: "-e", line: 1)\###n"### |
| 2010 | + file.send(###"#sourceLocation(file: "-e", line: 1)\###n"###) |
2011 | 2011 | for option in parsedOptions.arguments(for: .e) {
|
2012 |
| - file <<< option.argument.asSingle <<< "\n" |
| 2012 | + file.send("\(option.argument.asSingle)\n") |
2013 | 2013 | }
|
2014 | 2014 | }
|
2015 | 2015 |
|
|
0 commit comments