diff options
| author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-16 07:33:14 +0000 |
|---|---|---|
| committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-16 07:33:14 +0000 |
| commit | 1d30fcaccf6886190d635304cfa120fdf4b938ff (patch) | |
| tree | b9852755d98fa9a4a35d10d848a0556627238b2f /llvm/cmake | |
| parent | 4e0cc9e0fde93dc2537ce762e82dd5e8811d76aa (diff) | |
| download | bcm5719-llvm-1d30fcaccf6886190d635304cfa120fdf4b938ff.tar.gz bcm5719-llvm-1d30fcaccf6886190d635304cfa120fdf4b938ff.zip | |
Add SVN version to libLLVMLTO
Summary: For Incremental LTO, we need to make sure that an old
cache entry is not used when incrementally re-linking with a new
libLTO.
Adding a global LLVM_REVISION in llvm-config.h would for to
rebuild/relink the world for every "git pull"/"svn update".
So instead only libLTO is made dependent on the VCS and will
be rebuilt (and the dependent binaries relinked, i.e. as of
today: libLTO.dylib and llvm-lto).
Reviewers: beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D18987
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266523
Diffstat (limited to 'llvm/cmake')
| -rw-r--r-- | llvm/cmake/modules/GenerateVersionFromCVS.cmake | 39 | ||||
| -rw-r--r-- | llvm/cmake/modules/VersionFromVCS.cmake | 24 |
2 files changed, 54 insertions, 9 deletions
diff --git a/llvm/cmake/modules/GenerateVersionFromCVS.cmake b/llvm/cmake/modules/GenerateVersionFromCVS.cmake new file mode 100644 index 00000000000..6b1c7198346 --- /dev/null +++ b/llvm/cmake/modules/GenerateVersionFromCVS.cmake @@ -0,0 +1,39 @@ +# CMake project that writes Subversion revision information to a header. +# +# Input variables: +# SRC - Source directory +# HEADER_FILE - The header file to write +# +# The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION, +# and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and +# "SECOND" are substituted with the names specified in the input variables. + + + +# Chop off cmake/modules/GetSVN.cmake +get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH) +get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH) +get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH) + +set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + "${LLVM_DIR}/cmake/modules") +include(VersionFromVCS) + +# Handle strange terminals +set(ENV{TERM} "dumb") + +function(append_info name path) + add_version_info_from_vcs(REVISION ${path}) + string(STRIP "${REVISION}" REVISION) + file(APPEND "${HEADER_FILE}.txt" + "#define ${name} \"${REVISION}\"\n") +endfunction() + +append_info(${NAME} "${SOURCE_DIR}") + +# Copy the file only if it has changed. +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${HEADER_FILE}.txt" "${HEADER_FILE}") +file(REMOVE "${HEADER_FILE}.txt") + diff --git a/llvm/cmake/modules/VersionFromVCS.cmake b/llvm/cmake/modules/VersionFromVCS.cmake index 6be4daa3166..8d56b66fa47 100644 --- a/llvm/cmake/modules/VersionFromVCS.cmake +++ b/llvm/cmake/modules/VersionFromVCS.cmake @@ -1,17 +1,22 @@ # Adds version control information to the variable VERS. For # determining the Version Control System used (if any) it inspects the -# existence of certain subdirectories under CMAKE_CURRENT_SOURCE_DIR. +# existence of certain subdirectories under SOURCE_DIR (if provided as an +# extra argument, otherwise uses CMAKE_CURRENT_SOURCE_DIR). function(add_version_info_from_vcs VERS) + SET(SOURCE_DIR ${ARGV1}) + if("${SOURCE_DIR}" STREQUAL "") + SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + endif() string(REPLACE "svn" "" result "${${VERS}}") - if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn" ) + if( EXISTS "${SOURCE_DIR}/.svn" ) set(result "${result}svn") # FindSubversion does not work with symlinks. See PR 8437 - if( NOT IS_SYMLINK "${CMAKE_CURRENT_SOURCE_DIR}" ) + if( NOT IS_SYMLINK "${SOURCE_DIR}" ) find_package(Subversion) endif() if( Subversion_FOUND ) - subversion_wc_info( ${CMAKE_CURRENT_SOURCE_DIR} Project ) + subversion_wc_info( ${SOURCE_DIR} Project ) if( Project_WC_REVISION ) set(SVN_REVISION ${Project_WC_REVISION} PARENT_SCOPE) set(result "${result}-r${Project_WC_REVISION}") @@ -20,16 +25,16 @@ function(add_version_info_from_vcs VERS) set(LLVM_REPOSITORY ${Project_WC_URL} PARENT_SCOPE) endif() endif() - elseif( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git ) + elseif( EXISTS ${SOURCE_DIR}/.git ) set(result "${result}git") # Try to get a ref-id - if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/svn ) + if( EXISTS ${SOURCE_DIR}/.git/svn ) find_program(git_executable NAMES git git.exe git.cmd) if( git_executable ) set(is_git_svn_rev_exact false) execute_process(COMMAND ${git_executable} svn info - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${SOURCE_DIR} TIMEOUT 5 RESULT_VARIABLE git_result OUTPUT_VARIABLE git_output) @@ -46,7 +51,7 @@ function(add_version_info_from_vcs VERS) # Determine if the HEAD points directly at a subversion revision. execute_process(COMMAND ${git_executable} svn find-rev HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${SOURCE_DIR} TIMEOUT 5 RESULT_VARIABLE git_result OUTPUT_VARIABLE git_output) @@ -61,10 +66,11 @@ function(add_version_info_from_vcs VERS) endif() execute_process(COMMAND ${git_executable} rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${SOURCE_DIR} TIMEOUT 5 RESULT_VARIABLE git_result OUTPUT_VARIABLE git_output) + if( git_result EQUAL 0 AND NOT is_git_svn_rev_exact ) string(STRIP "${git_output}" git_ref_id) set(GIT_COMMIT ${git_ref_id} PARENT_SCOPE) |

