blob: 7757bd16752cc96055d6e5390eae5b4454508fcd [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- lldb.cpp ------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/lldb-private.h"
Greg Claytonfc7117a2011-03-05 01:04:56 +000011
Greg Claytonce6d19a2010-12-16 21:33:41 +000012using namespace lldb;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000013using namespace lldb_private;
14
Greg Clayton7170f3f2013-02-28 18:09:18 +000015#include "clang/Basic/Version.h"
16
Chris Bienemanaa098de2016-09-23 23:33:52 +000017#ifdef HAVE_SVN_VERSION_INC
18# include "SVNVersion.inc"
19#endif
20
Chris Bienemanb92cfe62016-11-10 17:33:19 +000021#ifdef HAVE_APPLE_VERSION_INC
22# include "AppleVersion.inc"
23#endif
24
Kate Stoneb9c1b512016-09-06 20:57:50 +000025static const char *GetLLDBRevision() {
Greg Clayton7170f3f2013-02-28 18:09:18 +000026#ifdef LLDB_REVISION
Kate Stoneb9c1b512016-09-06 20:57:50 +000027 return LLDB_REVISION;
Greg Clayton7170f3f2013-02-28 18:09:18 +000028#else
Kate Stoneb9c1b512016-09-06 20:57:50 +000029 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:18 +000030#endif
31}
32
Kate Stoneb9c1b512016-09-06 20:57:50 +000033static const char *GetLLDBRepository() {
Greg Clayton7170f3f2013-02-28 18:09:18 +000034#ifdef LLDB_REPOSITORY
Kate Stoneb9c1b512016-09-06 20:57:50 +000035 return LLDB_REPOSITORY;
Greg Clayton7170f3f2013-02-28 18:09:18 +000036#else
Kate Stoneb9c1b512016-09-06 20:57:50 +000037 return NULL;
Greg Clayton7170f3f2013-02-28 18:09:18 +000038#endif
39}
40
Daniel Malea3b92f002013-02-28 16:51:15 +000041
Chris Bieneman1778f692016-11-10 21:30:16 +000042#define QUOTE(str) #str
43#define EXPAND_AND_QUOTE(str) QUOTE(str)
44
Kate Stoneb9c1b512016-09-06 20:57:50 +000045const char *lldb_private::GetVersion() {
Kate Stoneb9c1b512016-09-06 20:57:50 +000046 // On platforms other than Darwin, report a version number in the same style
47 // as the clang tool.
48 static std::string g_version_str;
49 if (g_version_str.empty()) {
50 g_version_str += "lldb version ";
51 g_version_str += CLANG_VERSION_STRING;
Stephane Sezerb55c8b12017-11-02 16:56:19 +000052
Kate Stoneb9c1b512016-09-06 20:57:50 +000053 const char *lldb_repo = GetLLDBRepository();
Kate Stoneb9c1b512016-09-06 20:57:50 +000054 const char *lldb_rev = GetLLDBRevision();
Chris Bienemanbd3d0262016-11-14 22:43:08 +000055 if (lldb_repo || lldb_rev) {
56 g_version_str += " (";
57 if (lldb_repo)
58 g_version_str += lldb_repo;
59 if (lldb_rev) {
60 g_version_str += " revision ";
61 g_version_str += lldb_rev;
62 }
Chris Bienemanb92cfe62016-11-10 17:33:19 +000063 g_version_str += ")";
Kate Stoneb9c1b512016-09-06 20:57:50 +000064 }
Chris Bienemanbd3d0262016-11-14 22:43:08 +000065
Kate Stoneb9c1b512016-09-06 20:57:50 +000066 std::string clang_rev(clang::getClangRevision());
67 if (clang_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:19 +000068 g_version_str += "\n clang revision ";
Kate Stoneb9c1b512016-09-06 20:57:50 +000069 g_version_str += clang_rev;
70 }
71 std::string llvm_rev(clang::getLLVMRevision());
72 if (llvm_rev.length() > 0) {
Chris Bienemanb92cfe62016-11-10 17:33:19 +000073 g_version_str += "\n llvm revision ";
Kate Stoneb9c1b512016-09-06 20:57:50 +000074 g_version_str += llvm_rev;
75 }
Chris Bienemanb92cfe62016-11-10 17:33:19 +000076
Kate Stoneb9c1b512016-09-06 20:57:50 +000077 }
78 return g_version_str.c_str();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000079}