[Lldb-commits] [lldb] r353268 - [CMake] Unify scripts for generating VCS headers

Petr Hosek via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 5 19:51:00 PST 2019


Author: phosek
Date: Tue Feb  5 19:51:00 2019
New Revision: 353268

URL: http://llvm.org/viewvc/llvm-project?rev=353268&view=rev
Log:
[CMake] Unify scripts for generating VCS headers

Previously, there were two different scripts for generating VCS headers:
one used by LLVM and one used by Clang and lldb. They were both similar,
but different. They were both broken in their own ways, for example the
one used by Clang didn't properly handle monorepo resulting in an
incorrect version information reported by Clang.

This change unifies two the scripts by introducing a new script that's
used from both LLVM, Clang and lldb, ensures that the new script
supports both monorepo and standalone SVN and Git setups, and removes
the old scripts.

Differential Revision: https://reviews.llvm.org/D57063

Modified:
    lldb/trunk/source/CMakeLists.txt
    lldb/trunk/source/lldb.cpp

Modified: lldb/trunk/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=353268&r1=353267&r2=353268&view=diff
==============================================================================
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/trunk/source/CMakeLists.txt Tue Feb  5 19:51:00 2019
@@ -15,30 +15,30 @@ foreach(file
   endif()
 endforeach()
 
-if(DEFINED lldb_vc)
-  set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc")
-  set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake")
-
-  # Create custom target to generate the VC revision include.
-  add_custom_command(OUTPUT "${version_inc}"
-    DEPENDS "${lldb_vc}" "${get_svn_script}"
-    COMMAND
-    ${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${LLDB_SOURCE_DIR}"
-                     "-DFIRST_NAME=LLDB"
-                     "-DHEADER_FILE=${version_inc}"
-                     -P "${get_svn_script}")
-
-  # Mark the generated header as being generated.
-  set_source_files_properties("${version_inc}"
-    PROPERTIES GENERATED TRUE
-               HEADER_FILE_ONLY TRUE)
-
-  # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC.
-  set_property(SOURCE lldb.cpp APPEND PROPERTY 
-               COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC")
-  list(APPEND lldbBase_SOURCES ${version_inc})
+set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")
+set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")
+
+if(lldb_vc)
+  set(lldb_source_dir ${LLDB_SOURCE_DIR})
 endif()
 
+add_custom_command(OUTPUT "${version_inc}"
+  DEPENDS "${lldb_vc}" "${generate_vcs_version_script}"
+  COMMAND ${CMAKE_COMMAND} "-DNAMES=LLDB"
+                           "-DLLDB_SOURCE_DIR=${LLDB_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 lldb.cpp APPEND PROPERTY
+             COMPILE_DEFINITIONS "HAVE_VCS_VERSION_INC")
+
+list(APPEND lldbBase_SOURCES ${version_inc})
+
 if(APPLE)
   set(apple_version_inc "${CMAKE_CURRENT_BINARY_DIR}/AppleVersion.inc")
   set(apple_version_script "${LLDB_SOURCE_DIR}/cmake/modules/EmbedAppleVersion.cmake")

Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=353268&r1=353267&r2=353268&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Tue Feb  5 19:51:00 2019
@@ -13,8 +13,8 @@ using namespace lldb_private;
 
 #include "clang/Basic/Version.h"
 
-#ifdef HAVE_SVN_VERSION_INC
-#include "SVNVersion.inc"
+#ifdef HAVE_VCS_VERSION_INC
+#include "VCSVersion.inc"
 #endif
 
 #ifdef HAVE_APPLE_VERSION_INC




More information about the lldb-commits mailing list