Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 1 | //===-- 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 Clayton | fc7117a | 2011-03-05 01:04:56 | [diff] [blame] | 11 | |
Greg Clayton | ce6d19a | 2010-12-16 21:33:41 | [diff] [blame] | 12 | using namespace lldb; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 13 | using namespace lldb_private; |
| 14 | |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 | [diff] [blame] | 15 | #include "clang/Basic/Version.h" |
| 16 | |
Chris Bieneman | aa098de | 2016-09-23 23:33:52 | [diff] [blame] | 17 | #ifdef HAVE_SVN_VERSION_INC |
Stephane Sezer | 7a0c218 | 2017-11-02 16:56:52 | [diff] [blame] | 18 | #include "SVNVersion.inc" |
Chris Bieneman | aa098de | 2016-09-23 23:33:52 | [diff] [blame] | 19 | #endif |
| 20 | |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 | [diff] [blame] | 21 | #ifdef HAVE_APPLE_VERSION_INC |
Stephane Sezer | 7a0c218 | 2017-11-02 16:56:52 | [diff] [blame] | 22 | #include "AppleVersion.inc" |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 | [diff] [blame] | 23 | #endif |
| 24 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 25 | static const char *GetLLDBRevision() { |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 | [diff] [blame] | 26 | #ifdef LLDB_REVISION |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 27 | return LLDB_REVISION; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 | [diff] [blame] | 28 | #else |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 29 | return NULL; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 | [diff] [blame] | 30 | #endif |
| 31 | } |
| 32 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 33 | static const char *GetLLDBRepository() { |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 | [diff] [blame] | 34 | #ifdef LLDB_REPOSITORY |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 35 | return LLDB_REPOSITORY; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 | [diff] [blame] | 36 | #else |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 37 | return NULL; |
Greg Clayton | 7170f3f | 2013-02-28 18:09:18 | [diff] [blame] | 38 | #endif |
| 39 | } |
| 40 | |
Chris Bieneman | 1778f69 | 2016-11-10 21:30:16 | [diff] [blame] | 41 | #define QUOTE(str) #str |
| 42 | #define EXPAND_AND_QUOTE(str) QUOTE(str) |
| 43 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 44 | const char *lldb_private::GetVersion() { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 45 | // On platforms other than Darwin, report a version number in the same style |
| 46 | // as the clang tool. |
| 47 | static std::string g_version_str; |
| 48 | if (g_version_str.empty()) { |
| 49 | g_version_str += "lldb version "; |
| 50 | g_version_str += CLANG_VERSION_STRING; |
Stephane Sezer | b55c8b1 | 2017-11-02 16:56:19 | [diff] [blame] | 51 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 52 | const char *lldb_repo = GetLLDBRepository(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 53 | const char *lldb_rev = GetLLDBRevision(); |
Chris Bieneman | bd3d026 | 2016-11-14 22:43:08 | [diff] [blame] | 54 | if (lldb_repo || lldb_rev) { |
| 55 | g_version_str += " ("; |
| 56 | if (lldb_repo) |
| 57 | g_version_str += lldb_repo; |
| 58 | if (lldb_rev) { |
| 59 | g_version_str += " revision "; |
| 60 | g_version_str += lldb_rev; |
| 61 | } |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 | [diff] [blame] | 62 | g_version_str += ")"; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 63 | } |
Chris Bieneman | bd3d026 | 2016-11-14 22:43:08 | [diff] [blame] | 64 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 65 | std::string clang_rev(clang::getClangRevision()); |
| 66 | if (clang_rev.length() > 0) { |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 | [diff] [blame] | 67 | g_version_str += "\n clang revision "; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 68 | g_version_str += clang_rev; |
| 69 | } |
| 70 | std::string llvm_rev(clang::getLLVMRevision()); |
| 71 | if (llvm_rev.length() > 0) { |
Chris Bieneman | b92cfe6 | 2016-11-10 17:33:19 | [diff] [blame] | 72 | g_version_str += "\n llvm revision "; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 73 | g_version_str += llvm_rev; |
| 74 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 | [diff] [blame] | 75 | } |
| 76 | return g_version_str.c_str(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 | [diff] [blame] | 77 | } |