1*0eae32dcSDimitry Andric //===-- Version.cpp -------------------------------------------------------===// 2*0eae32dcSDimitry Andric // 3*0eae32dcSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0eae32dcSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0eae32dcSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0eae32dcSDimitry Andric // 7*0eae32dcSDimitry Andric //===----------------------------------------------------------------------===// 8*0eae32dcSDimitry Andric 9*0eae32dcSDimitry Andric #include "lldb/Version/Version.h" 10*0eae32dcSDimitry Andric #include "VCSVersion.inc" 11*0eae32dcSDimitry Andric #include "lldb/Version/Version.inc" 12*0eae32dcSDimitry Andric #include "clang/Basic/Version.h" 13*0eae32dcSDimitry Andric GetLLDBVersion()14*0eae32dcSDimitry Andricstatic const char *GetLLDBVersion() { 15*0eae32dcSDimitry Andric #ifdef LLDB_FULL_VERSION_STRING 16*0eae32dcSDimitry Andric return LLDB_FULL_VERSION_STRING; 17*0eae32dcSDimitry Andric #else 18*0eae32dcSDimitry Andric return "lldb version " LLDB_VERSION_STRING; 19*0eae32dcSDimitry Andric #endif 20*0eae32dcSDimitry Andric } 21*0eae32dcSDimitry Andric GetLLDBRevision()22*0eae32dcSDimitry Andricstatic const char *GetLLDBRevision() { 23*0eae32dcSDimitry Andric #ifdef LLDB_REVISION 24*0eae32dcSDimitry Andric return LLDB_REVISION; 25*0eae32dcSDimitry Andric #else 26*0eae32dcSDimitry Andric return nullptr; 27*0eae32dcSDimitry Andric #endif 28*0eae32dcSDimitry Andric } 29*0eae32dcSDimitry Andric GetLLDBRepository()30*0eae32dcSDimitry Andricstatic const char *GetLLDBRepository() { 31*0eae32dcSDimitry Andric #ifdef LLDB_REPOSITORY 32*0eae32dcSDimitry Andric return LLDB_REPOSITORY; 33*0eae32dcSDimitry Andric #else 34*0eae32dcSDimitry Andric return nullptr; 35*0eae32dcSDimitry Andric #endif 36*0eae32dcSDimitry Andric } 37*0eae32dcSDimitry Andric GetVersion()38*0eae32dcSDimitry Andricconst char *lldb_private::GetVersion() { 39*0eae32dcSDimitry Andric static std::string g_version_str; 40*0eae32dcSDimitry Andric 41*0eae32dcSDimitry Andric if (g_version_str.empty()) { 42*0eae32dcSDimitry Andric const char *lldb_version = GetLLDBVersion(); 43*0eae32dcSDimitry Andric const char *lldb_repo = GetLLDBRepository(); 44*0eae32dcSDimitry Andric const char *lldb_rev = GetLLDBRevision(); 45*0eae32dcSDimitry Andric g_version_str += lldb_version; 46*0eae32dcSDimitry Andric if (lldb_repo || lldb_rev) { 47*0eae32dcSDimitry Andric g_version_str += " ("; 48*0eae32dcSDimitry Andric if (lldb_repo) 49*0eae32dcSDimitry Andric g_version_str += lldb_repo; 50*0eae32dcSDimitry Andric if (lldb_repo && lldb_rev) 51*0eae32dcSDimitry Andric g_version_str += " "; 52*0eae32dcSDimitry Andric if (lldb_rev) { 53*0eae32dcSDimitry Andric g_version_str += "revision "; 54*0eae32dcSDimitry Andric g_version_str += lldb_rev; 55*0eae32dcSDimitry Andric } 56*0eae32dcSDimitry Andric g_version_str += ")"; 57*0eae32dcSDimitry Andric } 58*0eae32dcSDimitry Andric 59*0eae32dcSDimitry Andric std::string clang_rev(clang::getClangRevision()); 60*0eae32dcSDimitry Andric if (clang_rev.length() > 0) { 61*0eae32dcSDimitry Andric g_version_str += "\n clang revision "; 62*0eae32dcSDimitry Andric g_version_str += clang_rev; 63*0eae32dcSDimitry Andric } 64*0eae32dcSDimitry Andric 65*0eae32dcSDimitry Andric std::string llvm_rev(clang::getLLVMRevision()); 66*0eae32dcSDimitry Andric if (llvm_rev.length() > 0) { 67*0eae32dcSDimitry Andric g_version_str += "\n llvm revision "; 68*0eae32dcSDimitry Andric g_version_str += llvm_rev; 69*0eae32dcSDimitry Andric } 70*0eae32dcSDimitry Andric } 71*0eae32dcSDimitry Andric 72*0eae32dcSDimitry Andric return g_version_str.c_str(); 73*0eae32dcSDimitry Andric } 74