[Frontend] Add compiler version information to -print-target-info output.

Clients that use -print-target-info can avoid an extra frontend
invocation by using this information.
This commit is contained in:
Doug Gregor
2020-07-07 22:11:19 -07:00
parent cea9d5cd67
commit 7bf676d335
2 changed files with 10 additions and 0 deletions

View File

@@ -1985,6 +1985,12 @@ static void printTargetInfo(const CompilerInvocation &invocation,
llvm::raw_ostream &out) {
out << "{\n";
// Compiler version, as produced by --version.
out << " \"compilerVersion\": \"";
out.write_escaped(version::getSwiftFullVersion(
version::Version::getCurrentLanguageVersion()));
out << "\",\n";
// Target triple and target variant triple.
auto &langOpts = invocation.getLangOptions();
out << " \"target\": ";

View File

@@ -9,6 +9,8 @@
// RUN: %swift_driver -print-target-info -target x86_64-apple-ios12.0 | %FileCheck -check-prefix CHECK-IOS-SIM %s
// CHECK-IOS: "compilerVersion": "Swift version
// CHECK-IOS: "target": {
// CHECK-IOS: "triple": "arm64-apple-ios12.0",
// CHECK-IOS: "unversionedTriple": "arm64-apple-ios",
@@ -28,6 +30,8 @@
// CHECK-IOS: }
// CHECK-LINUX: "compilerVersion": "Swift version
// CHECK-LINUX: "target": {
// CHECK-LINUX: "triple": "x86_64-unknown-linux",
// CHECK-LINUX: "moduleTriple": "x86_64-unknown-linux",