[Lldb-commits] [lldb] 247b7d0 - [cmake] Add LLVM_FORCE_VC_REVISION option (#67125)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 25 06:32:59 PDT 2023
Author: David Truby
Date: 2023-09-25T14:32:52+01:00
New Revision: 247b7d068497de085b7fd66c6531034afa9709f0
URL: https://github.com/llvm/llvm-project/commit/247b7d068497de085b7fd66c6531034afa9709f0
DIFF: https://github.com/llvm/llvm-project/commit/247b7d068497de085b7fd66c6531034afa9709f0.diff
LOG: [cmake] Add LLVM_FORCE_VC_REVISION option (#67125)
This patch adds a LLVM_FORCE_VC_REVISION option to force a custom
VC revision to be included instead of trying to fetch one from a
git command. This is helpful in environments where git is not
available or is non-functional but the vc revision is available
through some other means.
Added:
Modified:
clang/lib/Basic/CMakeLists.txt
flang/lib/Common/CMakeLists.txt
lld/Common/CMakeLists.txt
lldb/source/Version/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/modules/GenerateVersionFromVCS.cmake
llvm/docs/CMake.rst
llvm/include/llvm/Support/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index db59d7dd96da0a4..36ccf7d0809453e 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -39,6 +39,8 @@ add_custom_command(OUTPUT "${version_inc}"
"-DHEADER_FILE=${version_inc}"
"-DLLVM_VC_REPOSITORY=${llvm_vc_repository}"
"-DLLVM_VC_REVISION=${llvm_vc_revision}"
+ "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+ "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
# Mark the generated header as being generated.
diff --git a/flang/lib/Common/CMakeLists.txt b/flang/lib/Common/CMakeLists.txt
index 81cee82e04b88ae..c6f818ad27cd19a 100644
--- a/flang/lib/Common/CMakeLists.txt
+++ b/flang/lib/Common/CMakeLists.txt
@@ -12,7 +12,7 @@ endif()
if(flang_vc AND LLVM_APPEND_VC_REV)
set(flang_source_dir ${FLANG_SOURCE_DIR})
endif()
-
+
# Create custom target to generate the VC revision include.
add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${llvm_vc}" "${flang_vc}" "${generate_vcs_version_script}"
@@ -20,6 +20,8 @@ add_custom_command(OUTPUT "${version_inc}"
"-DLLVM_SOURCE_DIR=${llvm_source_dir}"
"-DFLANG_SOURCE_DIR=${flang_source_dir}"
"-DHEADER_FILE=${version_inc}"
+ "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+ "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
# Mark the generated header as being generated.
diff --git a/lld/Common/CMakeLists.txt b/lld/Common/CMakeLists.txt
index c975da2a49b6bda..4f503d04f7844f7 100644
--- a/lld/Common/CMakeLists.txt
+++ b/lld/Common/CMakeLists.txt
@@ -13,6 +13,8 @@ add_custom_command(OUTPUT "${version_inc}"
COMMAND ${CMAKE_COMMAND} "-DNAMES=LLD"
"-DLLD_SOURCE_DIR=${lld_source_dir}"
"-DHEADER_FILE=${version_inc}"
+ "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+ "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
# Mark the generated header as being generated.
diff --git a/lldb/source/Version/CMakeLists.txt b/lldb/source/Version/CMakeLists.txt
index c1393b5dd6e6b62..90fe53d52cc5d05 100644
--- a/lldb/source/Version/CMakeLists.txt
+++ b/lldb/source/Version/CMakeLists.txt
@@ -17,6 +17,8 @@ add_custom_command(OUTPUT "${vcs_version_inc}"
COMMAND ${CMAKE_COMMAND} "-DNAMES=LLDB"
"-DLLDB_SOURCE_DIR=${lldb_source_dir}"
"-DHEADER_FILE=${vcs_version_inc}"
+ "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+ "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
set_source_files_properties("${vcs_version_inc}"
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index fa39c7554de1f61..5985256498dcbb2 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -325,6 +325,12 @@ include(VersionFromVCS)
option(LLVM_APPEND_VC_REV
"Embed the version control system revision in LLVM" ON)
+set(LLVM_FORCE_VC_REVISION
+ "" CACHE STRING "Force custom VC revision for LLVM_APPEND_VC_REV")
+
+set(LLVM_FORCE_VC_REPOSITORY
+ "" CACHE STRING "Force custom VC repository for LLVM_APPEND_VC_REV")
+
option(LLVM_TOOL_LLVM_DRIVER_BUILD "Enables building the llvm multicall tool" OFF)
set(PACKAGE_NAME LLVM)
diff --git a/llvm/cmake/modules/GenerateVersionFromVCS.cmake b/llvm/cmake/modules/GenerateVersionFromVCS.cmake
index 9cd780e5aa162c0..1b3b2946e62b25c 100644
--- a/llvm/cmake/modules/GenerateVersionFromVCS.cmake
+++ b/llvm/cmake/modules/GenerateVersionFromVCS.cmake
@@ -36,7 +36,14 @@ function(append_info name revision repository)
endfunction()
foreach(name IN LISTS NAMES)
- if(${name}_VC_REPOSITORY AND ${name}_VC_REVISION)
+ if(LLVM_FORCE_VC_REVISION AND LLVM_FORCE_VC_REPOSITORY)
+ set(revision ${LLVM_FORCE_VC_REVISION})
+ set(repository ${LLVM_FORCE_VC_REPOSITORY})
+ elseif(LLVM_FORCE_VC_REVISION)
+ set(revision ${LLVM_FORCE_VC_REVISION})
+ elseif(LLVM_FORCE_VC_REPOSITORY)
+ set(repository ${LLVM_FORCE_VC_REPOSITORY})
+ elseif(${name}_VC_REPOSITORY AND ${name}_VC_REVISION)
set(revision ${${name}_VC_REVISION})
set(repository ${${name}_VC_REPOSITORY})
elseif(DEFINED ${name}_SOURCE_DIR)
diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst
index 4d894212fb11d47..668c5e7092e1c34 100644
--- a/llvm/docs/CMake.rst
+++ b/llvm/docs/CMake.rst
@@ -334,6 +334,15 @@ enabled sub-projects. Nearly all of these variable names begin with
need revision info can disable this option to avoid re-linking most binaries
after a branch switch. Defaults to ON.
+**LLVM_FORCE_VC_REVISION**:STRING
+ Force a specific Git revision id rather than calling to git to determine it.
+ This is useful in environments where git is not available or non-functional
+ but the VC revision is available through other means.
+
+**LLVM_FORCE_VC_REPOSITORY**:STRING
+ Set the git repository to include in version info rather than calling git to
+ determine it.
+
**LLVM_BUILD_32_BITS**:BOOL
Build 32-bit executables and libraries on 64-bit systems. This option is
available only on some 64-bit Unix systems. Defaults to OFF.
diff --git a/llvm/include/llvm/Support/CMakeLists.txt b/llvm/include/llvm/Support/CMakeLists.txt
index b6be96525c744a3..76c382bfc644f2e 100644
--- a/llvm/include/llvm/Support/CMakeLists.txt
+++ b/llvm/include/llvm/Support/CMakeLists.txt
@@ -28,6 +28,8 @@ if (fake_version_inc)
COMMAND ${CMAKE_COMMAND} "-DNAMES=LLVM"
"-DLLVM_SOURCE_DIR=${llvm_source_dir}"
"-DHEADER_FILE=${version_inc}"
+ "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+ "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
else()
add_custom_command(OUTPUT "${version_inc}"
@@ -35,6 +37,8 @@ else()
COMMAND ${CMAKE_COMMAND} "-DNAMES=LLVM"
"-DLLVM_SOURCE_DIR=${llvm_source_dir}"
"-DHEADER_FILE=${version_inc}"
+ "-DLLVM_FORCE_VC_REVISION=${LLVM_FORCE_VC_REVISION}"
+ "-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
-P "${generate_vcs_version_script}")
endif()
More information about the lldb-commits
mailing list