File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Sources/SwiftDriver/Driver Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -570,6 +570,15 @@ extension Driver {
570
570
return
571
571
}
572
572
573
+ if parsedOptions. hasArgument ( . version) || parsedOptions. hasArgument ( . version_) {
574
+ // Follow gcc/clang behavior and use stdout for --version and stderr for -v.
575
+ try printVersion ( outputStream: & stdoutStream)
576
+ return
577
+ }
578
+ if parsedOptions. hasArgument ( . v) {
579
+ try printVersion ( outputStream: & stderrStream)
580
+ }
581
+
573
582
// Plan the build.
574
583
let jobs = try planBuild ( )
575
584
if jobs. isEmpty { return }
@@ -632,6 +641,11 @@ extension Driver {
632
641
633
642
return try exec ( path: tool, args: arguments)
634
643
}
644
+
645
+ private func printVersion< S: OutputByteStream > ( outputStream: inout S ) throws {
646
+ outputStream. write ( try Process . checkNonZeroExit ( args: swiftCompiler. pathString, " --version " ) )
647
+ outputStream. flush ( )
648
+ }
635
649
}
636
650
637
651
extension Diagnostic . Message {
You can’t perform that action at this time.
0 commit comments