Skip to content

Commit 7bf676d

Browse files
committed
[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.
1 parent cea9d5c commit 7bf676d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,12 @@ static void printTargetInfo(const CompilerInvocation &invocation,
19851985
llvm::raw_ostream &out) {
19861986
out << "{\n";
19871987

1988+
// Compiler version, as produced by --version.
1989+
out << " \"compilerVersion\": \"";
1990+
out.write_escaped(version::getSwiftFullVersion(
1991+
version::Version::getCurrentLanguageVersion()));
1992+
out << "\",\n";
1993+
19881994
// Target triple and target variant triple.
19891995
auto &langOpts = invocation.getLangOptions();
19901996
out << " \"target\": ";

test/Driver/print_target_info.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
// RUN: %swift_driver -print-target-info -target x86_64-apple-ios12.0 | %FileCheck -check-prefix CHECK-IOS-SIM %s
1111

12+
// CHECK-IOS: "compilerVersion": "Swift version
13+
1214
// CHECK-IOS: "target": {
1315
// CHECK-IOS: "triple": "arm64-apple-ios12.0",
1416
// CHECK-IOS: "unversionedTriple": "arm64-apple-ios",
@@ -28,6 +30,8 @@
2830
// CHECK-IOS: }
2931

3032

33+
// CHECK-LINUX: "compilerVersion": "Swift version
34+
3135
// CHECK-LINUX: "target": {
3236
// CHECK-LINUX: "triple": "x86_64-unknown-linux",
3337
// CHECK-LINUX: "moduleTriple": "x86_64-unknown-linux",

0 commit comments

Comments
 (0)