diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-09-29 17:57:10 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-09-29 17:57:10 +0000 |
commit | b800fdb063285b6d3044cff7773d99f743568d7c (patch) | |
tree | fb2f4ef278a3b9646078ca1b8f974ed744ae0bf1 /clang/lib/Basic/Version.cpp | |
parent | afd363e65b5202f02f91defc880befc0a0a4a872 (diff) | |
download | bcm5719-llvm-b800fdb063285b6d3044cff7773d99f743568d7c.tar.gz bcm5719-llvm-b800fdb063285b6d3044cff7773d99f743568d7c.zip |
Basic: Add support for git svn to get the repo version in clang executable,
patch by Jonathan Mulder!
llvm-svn: 115049
Diffstat (limited to 'clang/lib/Basic/Version.cpp')
-rw-r--r-- | clang/lib/Basic/Version.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp index 036ee00545f..e9649e284d0 100644 --- a/clang/lib/Basic/Version.cpp +++ b/clang/lib/Basic/Version.cpp @@ -21,26 +21,27 @@ using namespace std; namespace clang { llvm::StringRef getClangRepositoryPath() { - static const char URL[] = "$URL$"; - const char *URLEnd = URL + strlen(URL); +#ifdef SVN_REPOSITORY + if (SVN_REPOSITORY[0] != '\0') { + static const char URL[] = SVN_REPOSITORY; + const char *URLEnd = URL + strlen(URL) - 1; - const char *End = strstr(URL, "/lib/Basic"); - if (End) - URLEnd = End; + // Strip off version from a build from an integration branch. + const char *End = strstr(URL, "/src/tools/clang"); + if (End) + URLEnd = End; - // Strip off version from a build from an integration branch. - End = strstr(URL, "/src/tools/clang"); - if (End) - URLEnd = End; + const char *Begin = strstr(URL, "cfe/"); + if (Begin) + return llvm::StringRef(Begin + 4, URLEnd - Begin - 4); - const char *Begin = strstr(URL, "cfe/"); - if (Begin) - return llvm::StringRef(Begin + 4, URLEnd - Begin - 4); - - return llvm::StringRef(URL, URLEnd - URL); + return llvm::StringRef(URL, URLEnd - URL); + } +#endif + return ""; } -std::string getClangRevision() { +llvm::StringRef getClangRevision() { #ifdef SVN_REVISION if (SVN_REVISION[0] != '\0') { std::string revision; @@ -55,10 +56,15 @@ std::string getClangRevision() { std::string getClangFullRepositoryVersion() { std::string buf; llvm::raw_string_ostream OS(buf); - OS << getClangRepositoryPath(); - const std::string &Revision = getClangRevision(); - if (!Revision.empty()) - OS << ' ' << Revision; + const llvm::StringRef &Path = getClangRepositoryPath(); + const llvm::StringRef &Revision = getClangRevision(); + if (!Path.empty()) + OS << Path; + if (!Revision.empty()) { + if (!Path.empty()) + OS << ' '; + OS << Revision; + } return OS.str(); } |