[cfe-commits] r151910 - in /cfe/trunk: include/clang/Basic/Version.h lib/Basic/Makefile lib/Basic/Version.cpp
Jia Liu
proljc at gmail.com
Fri Mar 2 06:37:41 PST 2012
Author: jialiu
Date: Fri Mar 2 08:37:41 2012
New Revision: 151910
URL: http://llvm.org/viewvc/llvm-project?rev=151910&view=rev
Log:
clang -v support for separate clang.git and llvm.git, patch by Andrew Trick.
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=151910&r1=151909&r2=151910&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Version.h (original)
+++ cfe/trunk/include/clang/Basic/Version.h Fri Mar 2 08:37:41 2012
@@ -47,10 +47,19 @@
/// Clang was built.
std::string getClangRepositoryPath();
+ /// \brief Retrieves the repository path from which LLVM was built. Supports
+ /// LLVM residing in a separate repository from clang.
+ std::string getLLVMRepositoryPath();
+
/// \brief Retrieves the repository revision number (or identifer) from which
/// this Clang was built.
std::string getClangRevision();
+ /// \brief Retrieves the repository revision number (or identifer) from which
+ /// LLVM was built. If Clang and LLVM are in the same repository, this returns
+ /// the same string as getClangRevision.
+ std::string getLLVMRevision();
+
/// \brief Retrieves the full repository version that is an amalgamation of
/// the information in getClangRepositoryPath() and getClangRevision().
std::string getClangFullRepositoryVersion();
Modified: cfe/trunk/lib/Basic/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Makefile?rev=151910&r1=151909&r2=151910&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Makefile (original)
+++ cfe/trunk/lib/Basic/Makefile Fri Mar 2 08:37:41 2012
@@ -1,10 +1,10 @@
##===- clang/lib/Basic/Makefile ----------------------------*- Makefile -*-===##
-#
+#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
-#
+#
##===----------------------------------------------------------------------===##
#
# This implements the Basic library for the C-Language front-end.
@@ -17,17 +17,24 @@
include $(CLANG_LEVEL)/Makefile
SVN_REVISION := $(strip \
- $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(PROJ_SRC_DIR)/../..))
+ $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(PROJ_SRC_DIR)/../..))
SVN_REPOSITORY := $(strip \
- $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(PROJ_SRC_DIR)/../..))
+ $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(PROJ_SRC_DIR)/../..))
+
+LLVM_REVISION := $(strip \
+ $(shell $(LLVM_SRC_ROOT)/utils/GetSourceVersion $(LLVM_SRC_ROOT)))
+
+LLVM_REPOSITORY := $(strip \
+ $(shell $(LLVM_SRC_ROOT)/utils/GetRepositoryPath $(LLVM_SRC_ROOT)))
CPP.Defines += -I$(PROJ_SRC_DIR)/../../include -I$(PROJ_OBJ_DIR)/../../include \
- -DSVN_REVISION='"$(SVN_REVISION)"' -DSVN_REPOSITORY='"$(SVN_REPOSITORY)"'
+ -DSVN_REVISION='"$(SVN_REVISION)"' -DSVN_REPOSITORY='"$(SVN_REPOSITORY)"' \
+ -DLLVM_REVISION='"$(LLVM_REVISION)"' -DLLVM_REPOSITORY='"$(LLVM_REPOSITORY)"'
$(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
+ @if [ '$(SVN_REVISION) $(LLVM_REVISION)' != '$(shell cat $(ObjDir)/.ver-svn 2>/dev/null)' ]; then\
+ echo '$(SVN_REVISION) $(LLVM_REVISION)' > $(ObjDir)/.ver-svn; \
+ fi
$(ObjDir)/.ver-svn: .ver
$(ObjDir)/Version.o: $(ObjDir)/.ver-svn
Modified: cfe/trunk/lib/Basic/Version.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Version.cpp?rev=151910&r1=151909&r2=151910&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Version.cpp (original)
+++ cfe/trunk/lib/Basic/Version.cpp Fri Mar 2 08:37:41 2012
@@ -19,7 +19,7 @@
#include <cstdlib>
namespace clang {
-
+
std::string getClangRepositoryPath() {
#if defined(CLANG_REPOSITORY_STRING)
return CLANG_REPOSITORY_STRING;
@@ -50,6 +50,21 @@
#endif
}
+std::string getLLVMRepositoryPath() {
+#ifdef LLVM_REPOSITORY
+ StringRef URL(LLVM_REPOSITORY);
+#else
+ StringRef URL("");
+#endif
+
+ // Trim path prefix off, assuming path came from standard llvm path.
+ size_t Start = URL.find("llvm/");
+ if (Start != StringRef::npos)
+ URL = URL.substr(Start + 5);
+
+ return URL;
+}
+
std::string getClangRevision() {
#ifdef SVN_REVISION
return SVN_REVISION;
@@ -58,6 +73,14 @@
#endif
}
+std::string getLLVMRevision() {
+#ifdef LLVM_REVISION
+ return LLVM_REVISION;
+#else
+ return "";
+#endif
+}
+
std::string getClangFullRepositoryVersion() {
std::string buf;
llvm::raw_string_ostream OS(buf);
@@ -70,9 +93,17 @@
OS << ' ';
OS << Revision;
}
+ // Support LLVM in a separate repository.
+ std::string LLVMRev = getLLVMRevision();
+ if (!LLVMRev.empty() && LLVMRev != Revision) {
+ std::string LLVMRepo = getLLVMRepositoryPath();
+ if (!LLVMRepo.empty())
+ OS << ' ' << LLVMRepo;
+ OS << ' ' << LLVMRev;
+ }
return OS.str();
}
-
+
std::string getClangFullVersion() {
std::string buf;
llvm::raw_string_ostream OS(buf);
More information about the cfe-commits
mailing list