summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-05 20:33:49 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-05 20:33:49 +0000
commit1b7035da6f79e1eed8fad4d38151c9a00cc716f1 (patch)
treed48d31b25ddec35af9d9c1594b1df193091203fc /clang/lib/Basic
parent7550a6c186b1ea1df9f618de187fcfc9603862f1 (diff)
downloadbcm5719-llvm-1b7035da6f79e1eed8fad4d38151c9a00cc716f1.tar.gz
bcm5719-llvm-1b7035da6f79e1eed8fad4d38151c9a00cc716f1.zip
Provide a common set of routines in Version.h that return Subversion
branch/revision information. Use that information in the driver, rather than one-off branch/revision computation. llvm-svn: 83321
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r--clang/lib/Basic/CMakeLists.txt11
-rw-r--r--clang/lib/Basic/Makefile11
-rw-r--r--clang/lib/Basic/Version.cpp18
3 files changed, 24 insertions, 16 deletions
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index e0e9a10e519..527ebf96593 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -11,8 +11,19 @@ add_clang_library(clangBasic
TargetInfo.cpp
Targets.cpp
TokenKinds.cpp
+ Version.cpp
)
+# Determine Subversion revision.
+# FIXME: This only gets updated when CMake is run, so this revision number
+# may be out-of-date!
+find_package(Subversion)
+if (Subversion_FOUND)
+ Subversion_WC_INFO(${CLANG_SOURCE_DIR} CLANG)
+ set_source_files_properties(Version.cpp
+ PROPERTIES COMPILE_DEFINITIONS "SVN_REVISION=\"${CLANG_WC_REVISION}\"")
+endif()
+
add_dependencies(clangBasic
ClangDiagnosticAnalysis
ClangDiagnosticAST
diff --git a/clang/lib/Basic/Makefile b/clang/lib/Basic/Makefile
index a81f03b4f71..46c725998c9 100644
--- a/clang/lib/Basic/Makefile
+++ b/clang/lib/Basic/Makefile
@@ -23,3 +23,14 @@ CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include
include $(LEVEL)/Makefile.common
+SVN_REVISION := $(shell cd $(PROJ_SRC_DIR)/../.. && svnversion)
+
+CPP.Defines += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include \
+ -DSVN_REVISION='"$(SVN_REVISION)"'
+
+$(ObjDir)/.ver-svn .ver: $(ObjDir)/.dir
+ @if [ '$(SVN_REVISION)' != '$(shell cat $(ObjDir)/.ver-svn 2>/dev/null)' ]; then\
+ echo '$(SVN_REVISION)' > $(ObjDir)/.ver-svn; \
+ fi
+$(ObjDir)/.ver-svn: .ver
+$(ObjDir)/Version.o: $(ObjDir)/.ver-svn
diff --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index 3a51ccb5e72..9699ee416be 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -39,24 +39,10 @@ const char *getClangSubversionPath() {
unsigned getClangSubversionRevision() {
#ifndef SVN_REVISION
+ // Subversion was not available at build time?
return 0;
#else
- // What follows is an evil trick. We can end up getting three different
- // kinds of results when asking for the Subversion information:
- // - if SVN_REVISION is a number, we return that number (adding 0 to it is
- // harmless).
- // - if SVN_REVISION is "exported" (for an tree without any Subversion
- // info), we end up referencing the local variable "exported" and adding
- // zero to it, and we return 0.
- // - if SVN_REVISION is empty (because "svn info" returned no results),
- // the "+" turns into a unary "+" operator and we return 0.
- //
- // Making this less ugly requires doing more computation in the CMake- and
- // Makefile-based build systems, with all sorts of checking to make sure we
- // don't end up breaking this build. It's better this way. Really.
- const unsigned exported = 0;
- (void)exported;
- return SVN_REVISION + 0;
+ return strtol(SVN_REVISION, 0, 10);
#endif
}
OpenPOWER on IntegriCloud