1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[cmake] Remove SVN support from VersionFromVCS.cmake

Reviewers: phosek

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D69682
This commit is contained in:
Tom Stellard 2019-10-31 13:39:48 -07:00
parent 46f4f86cde
commit 88a51c3cc2
2 changed files with 30 additions and 79 deletions

View File

@ -805,11 +805,7 @@ set(LLVM_SRPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/srpm")
get_source_info(${CMAKE_CURRENT_SOURCE_DIR} revision repository) get_source_info(${CMAKE_CURRENT_SOURCE_DIR} revision repository)
string(LENGTH "${revision}" revision_length) string(LENGTH "${revision}" revision_length)
if(revision MATCHES "^[0-9]+$" AND revision_length LESS 40) set(LLVM_RPM_SPEC_REVISION "${revision}")
set(LLVM_RPM_SPEC_REVISION "r${revision}")
else()
set(LLVM_RPM_SPEC_REVISION "${revision}")
endif()
configure_file( configure_file(
${LLVM_SRPM_USER_BINARY_SPECFILE} ${LLVM_SRPM_USER_BINARY_SPECFILE}

View File

@ -3,27 +3,7 @@
# existence of certain subdirectories under SOURCE_DIR (if provided as an # existence of certain subdirectories under SOURCE_DIR (if provided as an
# extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR). # extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR).
function(get_source_info_svn path revision repository) function(get_source_info path revision repository)
# If svn is a bat file, find_program(Subversion) doesn't find it.
# Explicitly search for that here; Subversion_SVN_EXECUTABLE will override
# the find_program call in FindSubversion.cmake.
find_program(Subversion_SVN_EXECUTABLE NAMES svn svn.bat)
find_package(Subversion)
# Subversion module does not work with symlinks, see PR8437.
get_filename_component(realpath ${path} REALPATH)
if(Subversion_FOUND)
subversion_wc_info(${realpath} Project)
if(Project_WC_REVISION)
set(${revision} ${Project_WC_REVISION} PARENT_SCOPE)
endif()
if(Project_WC_URL)
set(${repository} ${Project_WC_URL} PARENT_SCOPE)
endif()
endif()
endfunction()
function(get_source_info_git path revision repository)
find_package(Git) find_package(Git)
if(GIT_FOUND) if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir
@ -34,61 +14,36 @@ function(get_source_info_git path revision repository)
if(git_result EQUAL 0) if(git_result EQUAL 0)
string(STRIP "${git_output}" git_output) string(STRIP "${git_output}" git_output)
get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path}) get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path})
if(EXISTS "${git_dir}/svn/refs") execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
execute_process(COMMAND ${GIT_EXECUTABLE} svn info WORKING_DIRECTORY ${path}
WORKING_DIRECTORY ${path} RESULT_VARIABLE git_result
RESULT_VARIABLE git_result OUTPUT_VARIABLE git_output)
OUTPUT_VARIABLE git_output) if(git_result EQUAL 0)
if(git_result EQUAL 0) string(STRIP "${git_output}" git_output)
string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" set(${revision} ${git_output} PARENT_SCOPE)
"\\2" git_svn_rev "${git_output}") endif()
set(${revision} ${git_svn_rev} PARENT_SCOPE) execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref --symbolic-full-name @{upstream}
string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" WORKING_DIRECTORY ${path}
"\\2" git_url "${git_output}") RESULT_VARIABLE git_result
set(${repository} ${git_url} PARENT_SCOPE) OUTPUT_VARIABLE git_output
endif() ERROR_QUIET)
if(git_result EQUAL 0)
string(REPLACE "/" ";" branch ${git_output})
list(GET branch 0 remote)
else() else()
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD set(remote "origin")
WORKING_DIRECTORY ${path} endif()
RESULT_VARIABLE git_result execute_process(COMMAND ${GIT_EXECUTABLE} remote get-url ${remote}
OUTPUT_VARIABLE git_output) WORKING_DIRECTORY ${path}
if(git_result EQUAL 0) RESULT_VARIABLE git_result
string(STRIP "${git_output}" git_output) OUTPUT_VARIABLE git_output
set(${revision} ${git_output} PARENT_SCOPE) ERROR_QUIET)
endif() if(git_result EQUAL 0)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref --symbolic-full-name @{upstream} string(STRIP "${git_output}" git_output)
WORKING_DIRECTORY ${path} set(${repository} ${git_output} PARENT_SCOPE)
RESULT_VARIABLE git_result else()
OUTPUT_VARIABLE git_output set(${repository} ${path} PARENT_SCOPE)
ERROR_QUIET)
if(git_result EQUAL 0)
string(REPLACE "/" ";" branch ${git_output})
list(GET branch 0 remote)
else()
set(remote "origin")
endif()
execute_process(COMMAND ${GIT_EXECUTABLE} remote get-url ${remote}
WORKING_DIRECTORY ${path}
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output
ERROR_QUIET)
if(git_result EQUAL 0)
string(STRIP "${git_output}" git_output)
set(${repository} ${git_output} PARENT_SCOPE)
else()
set(${repository} ${path} PARENT_SCOPE)
endif()
endif() endif()
endif() endif()
endif() endif()
endfunction() endfunction()
function(get_source_info path revision repository)
if(EXISTS "${path}/.svn")
get_source_info_svn("${path}" revision_info repository_info)
else()
get_source_info_git("${path}" revision_info repository_info)
endif()
set(${repository} "${repository_info}" PARENT_SCOPE)
set(${revision} "${revision_info}" PARENT_SCOPE)
endfunction()