[PATCH] D58411: Update `ld.lld --version` string for monorepo.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 19 15:12:28 PST 2019
ruiu updated this revision to Diff 187454.
ruiu added a comment.
- fix typo
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58411/new/
https://reviews.llvm.org/D58411
Files:
lld/Common/CMakeLists.txt
lld/Common/Version.cpp
Index: lld/Common/Version.cpp
===================================================================
--- lld/Common/Version.cpp
+++ lld/Common/Version.cpp
@@ -11,32 +11,29 @@
//===----------------------------------------------------------------------===//
#include "lld/Common/Version.h"
+#include "llvm/ADT/StringExtras.h"
+
+#ifdef HAVE_VCS_VERSION_INC
+#include "VCSVersion.inc"
+#endif
using namespace llvm;
-// Returns an SVN repository path, which is usually "trunk".
-static std::string getRepositoryPath() {
- StringRef S = LLD_REPOSITORY_STRING;
- size_t Pos = S.find("lld/");
- if (Pos != StringRef::npos)
- return S.substr(Pos + 4);
- return S;
-}
+// Returns a version string, e.g.:
+// lld 9.00 (https://github.com/llvm/llvm-project.git 9efdd7ac5e914d3c9fa1ef)
+std::string lld::getLLDVersion() {
+ std::string Repo;
+#ifdef LLD_REPOSITORY
+ Repo = LLD_REPOSITORY;
+#endif
-// Returns an SVN repository name, e.g., " (trunk 284614)"
-// or an empty string if no repository info is available.
-static std::string getRepository() {
- std::string Repo = getRepositoryPath();
- std::string Rev = LLD_REVISION_STRING;
+ std::string Rev;
+#ifdef LLD_REVISION
+ Rev = LLD_REVISION;
+#endif
+ std::string Version = std::string("LLD ") + LLD_VERSION_STRING;
if (Repo.empty() && Rev.empty())
- return "";
- if (!Repo.empty() && !Rev.empty())
- return " (" + Repo + " " + Rev + ")";
- return " (" + Repo + Rev + ")";
-}
-
-// Returns a version string, e.g., "LLD 4.0 (lld/trunk 284614)".
-std::string lld::getLLDVersion() {
- return "LLD " + std::string(LLD_VERSION_STRING) + getRepository();
+ return Version;
+ return Version + " (" + Repo + " " + Rev + ")";
}
Index: lld/Common/CMakeLists.txt
===================================================================
--- lld/Common/CMakeLists.txt
+++ lld/Common/CMakeLists.txt
@@ -2,6 +2,31 @@
set(tablegen_deps intrinsics_gen)
endif()
+find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
+find_first_existing_vc_file("${LLD_SOURCE_DIR}" lld_vc)
+
+set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
+set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+
+if(lld_vc)
+ set(lld_source_dir ${LLD_SOURCE_DIR})
+endif()
+
+add_custom_command(OUTPUT "${version_inc}"
+ DEPENDS "${lld_vc}" "${generate_vcs_version_script}"
+ COMMAND ${CMAKE_COMMAND} "-DNAMES=LLD"
+ "-DLLD_SOURCE_DIR=${LLD_SOURCE_DIR}"
+ "-DHEADER_FILE=${version_inc}"
+ -P "${generate_vcs_version_script}")
+
+# Mark the generated header as being generated.
+set_source_files_properties("${version_inc}"
+ PROPERTIES GENERATED TRUE
+ HEADER_FILE_ONLY TRUE)
+
+set_property(SOURCE Version.cpp APPEND PROPERTY
+ COMPILE_DEFINITIONS "HAVE_VCS_VERSION_INC")
+
add_lld_library(lldCommon
Args.cpp
ErrorHandler.cpp
@@ -12,6 +37,7 @@
Threads.cpp
Timer.cpp
Version.cpp
+ VCSVersion.inc
ADDITIONAL_HEADER_DIRS
${LLD_INCLUDE_DIR}/lld/Common
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58411.187454.patch
Type: text/x-patch
Size: 2972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190219/d658498b/attachment.bin>
More information about the llvm-commits
mailing list