1 //===- lib/Config/Version.cpp - LLD Version Number ---------------*- C++-=====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines several version-related utility functions for LLD.
12 //===----------------------------------------------------------------------===//
14 #include "lld/Config/Version.h"
18 // Returns an SVN repository path, which is usually "trunk".
19 static std::string getRepositoryPath() {
20 StringRef S = LLD_REPOSITORY_STRING;
21 size_t Pos = S.find("lld/");
22 if (Pos != StringRef::npos)
23 return S.substr(Pos + 4);
27 // Returns an SVN repository name, e.g., " (trunk 284614)"
28 // or an empty string if no repository info is available.
29 static std::string getRepository() {
30 std::string Repo = getRepositoryPath();
31 std::string Rev = LLD_REVISION_STRING;
33 if (Repo.empty() && Rev.empty())
35 if (!Repo.empty() && !Rev.empty())
36 return " (" + Repo + " " + Rev + ")";
37 return " (" + Repo + Rev + ")";
40 // Returns a version string, e.g., "LLD 4.0 (lld/trunk 284614)".
41 std::string lld::getLLDVersion() {
42 return "LLD " + std::string(LLD_VERSION_STRING) + getRepository();