[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:18:15 PST 2019
ruiu updated this revision to Diff 187455.
ruiu added a comment.
- Simplify
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
@@ -12,31 +12,18 @@
#include "lld/Common/Version.h"
-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;
-}
+#ifdef HAVE_VCS_VERSION_INC
+#include "VCSVersion.inc"
+#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;
-
- if (Repo.empty() && Rev.empty())
- return "";
- if (!Repo.empty() && !Rev.empty())
- return " (" + Repo + " " + Rev + ")";
- return " (" + Repo + Rev + ")";
-}
+using namespace llvm;
-// Returns a version string, e.g., "LLD 4.0 (lld/trunk 284614)".
+// Returns a version string, e.g.:
+// lld 9.00 (https://github.com/llvm/llvm-project.git 9efdd7ac5e914d3c9fa1ef)
std::string lld::getLLDVersion() {
- return "LLD " + std::string(LLD_VERSION_STRING) + getRepository();
+#if defined(LLD_REPOSITORY) && defined(LLD_REVISION)
+ return "LLD " LLD_VERSION_STRING " (" LLD_REPOSITORY " " LLD_REVISION ")";
+#else
+ return "LLD " LLD_VERSION_STRING;
+#endif
}
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.187455.patch
Type: text/x-patch
Size: 2734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190219/fa285065/attachment.bin>
More information about the llvm-commits
mailing list