[cfe-commits] r115049 - in /cfe/trunk: include/clang/Basic/Version.h lib/Basic/Makefile lib/Basic/Version.cpp
Daniel Dunbar
daniel at zuster.org
Wed Sep 29 10:57:10 PDT 2010
Author: ddunbar
Date: Wed Sep 29 12:57:10 2010
New Revision: 115049
URL: http://llvm.org/viewvc/llvm-project?rev=115049&view=rev
Log:
Basic: Add support for git svn to get the repo version in clang executable,
patch by Jonathan Mulder!
Modified:
cfe/trunk/include/clang/Basic/Version.h
cfe/trunk/lib/Basic/Makefile
cfe/trunk/lib/Basic/Version.cpp
Modified: cfe/trunk/include/clang/Basic/Version.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Version.h?rev=115049&r1=115048&r2=115049&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Version.h (original)
+++ cfe/trunk/include/clang/Basic/Version.h Wed Sep 29 12:57:10 2010
@@ -48,7 +48,7 @@
/// \brief Retrieves the repository revision number (or identifer) from which
/// this Clang was built.
- std::string getClangRevision();
+ llvm::StringRef getClangRevision();
/// \brief Retrieves the full repository version that is an amalgamation of
/// the information in getClangRepositoryPath() and getClangRevision().
Modified: cfe/trunk/lib/Basic/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Makefile?rev=115049&r1=115048&r2=115049&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Makefile (original)
+++ cfe/trunk/lib/Basic/Makefile Wed Sep 29 12:57:10 2010
@@ -18,8 +18,10 @@
SVN_REVISION := $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(PROJ_SRC_DIR)/../..)
+SVN_REPOSITORY := $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(PROJ_SRC_DIR)/../..)
+
CPP.Defines += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include \
- -DSVN_REVISION='"$(SVN_REVISION)"'
+ -DSVN_REVISION='"$(SVN_REVISION)"' -DSVN_REPOSITORY='"$(SVN_REPOSITORY)"'
$(ObjDir)/.ver-svn .ver: $(ObjDir)/.dir
@if [ '$(SVN_REVISION)' != '$(shell cat $(ObjDir)/.ver-svn 2>/dev/null)' ]; then\
Modified: cfe/trunk/lib/Basic/Version.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Version.cpp?rev=115049&r1=115048&r2=115049&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Version.cpp (original)
+++ cfe/trunk/lib/Basic/Version.cpp Wed Sep 29 12:57:10 2010
@@ -21,26 +21,27 @@
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;
+
+ // Strip off version from a build from an integration branch.
+ const char *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 *End = strstr(URL, "/lib/Basic");
- 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);
-
- 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 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();
}
More information about the cfe-commits
mailing list