[PATCH] D34955: [Basic] Detect Git submodule version in CMake
Brian Gesiak via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 3 08:54:36 PDT 2017
modocache created this revision.
Herald added a subscriber: mgorny.
When searching for Git version control information, libBasic's CMake
checks for the path '.git/logs/HEAD'. However, when LLVM is included as
a Git submodule, this path does not exist. Instead, it contains a '.git'
file with the following:
gitdir: ../../.git/modules/external/llvm
Where '../..' is the relative path to the root repository that contains
the LLVM Git submodule.
Because of this discrepancy, `clang --version` does not output source
control information if built from a Git submodule.
The full '.git/logs/HEAD' path is only used to gate the invocation of LLVM
CMake's GetSVN.cmake script, which is invoked using the `LLVM_MAIN_SRC_DIR`
and `CLANG_SOURCE_DIR` paths, which point to the right places even when
Clang is built as a submodule. Once invoked with these paths, GetSVN.cmake
works just fine, and correct version control information is retrieved, even
when Clang is built as a submodule.
To work around the problem, truncate the path being checked for: just
'.git' instead of '.git/logs/HEAD'.
Test Plan:
1. Before applying this change, build Clang as a Git submodule in a repository that places it in external/clang, and confirm no revision information is output when `clang --version` is invoked (just "clang 5.0.0" is output, no Git hashes).
2. Apply these changes and build Clang as a Git repository nested under llvm/tools/clang, and confirm that `clang --version` displays correct version information.
3. Apply these changes and build Clang as a Git submodule using the structure described in (1), and confirm version control information is output as in (2).
https://reviews.llvm.org/D34955
Files:
lib/Basic/CMakeLists.txt
Index: lib/Basic/CMakeLists.txt
===================================================================
--- lib/Basic/CMakeLists.txt
+++ lib/Basic/CMakeLists.txt
@@ -16,7 +16,7 @@
macro(find_first_existing_vc_file out_var path)
find_first_existing_file(${out_var}
- "${path}/.git/logs/HEAD" # Git
+ "${path}/.git" # Git
"${path}/.svn/wc.db" # SVN 1.7
"${path}/.svn/entries" # SVN 1.6
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34955.105094.patch
Type: text/x-patch
Size: 425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170703/a0987385/attachment.bin>
More information about the cfe-commits
mailing list