diff options
| author | Petr Hosek <phosek@chromium.org> | 2019-02-06 03:51:00 +0000 |
|---|---|---|
| committer | Petr Hosek <phosek@chromium.org> | 2019-02-06 03:51:00 +0000 |
| commit | 23fdd5a37ff4e0512af0b40f6ff3e6db4694e937 (patch) | |
| tree | a4fbb8b7393f37d271f6879275dbecedf9bed6cc /llvm/cmake/modules/AddLLVM.cmake | |
| parent | 00ae46ba5291628d6a8433d370b900c8543e10d2 (diff) | |
| download | bcm5719-llvm-23fdd5a37ff4e0512af0b40f6ff3e6db4694e937.tar.gz bcm5719-llvm-23fdd5a37ff4e0512af0b40f6ff3e6db4694e937.zip | |
[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
llvm-svn: 353268
Diffstat (limited to 'llvm/cmake/modules/AddLLVM.cmake')
| -rw-r--r-- | llvm/cmake/modules/AddLLVM.cmake | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index 607d6e682b4..95a88af3bbf 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1717,35 +1717,35 @@ function(setup_dependency_debugging name) set_target_properties(${name} PROPERTIES RULE_LAUNCH_COMPILE ${sandbox_command}) endfunction() -# Figure out if we can track VC revisions. -function(find_first_existing_file out_var) - foreach(file ${ARGN}) - if(EXISTS "${file}") - set(${out_var} "${file}" PARENT_SCOPE) - return() - endif() - endforeach() -endfunction() - -macro(find_first_existing_vc_file out_var path) - find_program(git_executable NAMES git git.exe git.cmd) - # Run from a subdirectory to force git to print an absolute path. - execute_process(COMMAND ${git_executable} rev-parse --git-dir - WORKING_DIRECTORY ${path}/cmake - RESULT_VARIABLE git_result - OUTPUT_VARIABLE git_dir - ERROR_QUIET) - if(git_result EQUAL 0) - string(STRIP "${git_dir}" git_dir) - set(${out_var} "${git_dir}/logs/HEAD") - # some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD - if (NOT EXISTS "${git_dir}/logs/HEAD") - file(WRITE "${git_dir}/logs/HEAD" "") +function(find_first_existing_vc_file path out_var) + if(EXISTS "${path}/.svn") + set(svn_files + "${path}/.svn/wc.db" # SVN 1.7 + "${path}/.svn/entries" # SVN 1.6 + ) + foreach(file IN LISTS svn_files) + if(EXISTS "${file}") + set(${out_var} "${file}" PARENT_SCOPE) + return() + endif() + endforeach() + else() + find_package(Git) + if(GIT_FOUND) + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir + WORKING_DIRECTORY ${path} + RESULT_VARIABLE git_result + OUTPUT_VARIABLE git_output + ERROR_QUIET) + if(git_result EQUAL 0) + string(STRIP "${git_output}" git_output) + get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path}) + # Some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD + if (NOT EXISTS "${git_dir}/logs/HEAD") + file(WRITE "${git_dir}/logs/HEAD" "") + endif() + set(${out_var} "${git_dir}/logs/HEAD" PARENT_SCOPE) endif() - else() - find_first_existing_file(${out_var} - "${path}/.svn/wc.db" # SVN 1.7 - "${path}/.svn/entries" # SVN 1.6 - ) endif() -endmacro() + endif() +endfunction() |

