mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
[CMake] Update GetSVN.cmake to use LLVM version control helper scripts.
This allows the logic to work with Git, and also uses the variable names to match what Clang is actually looking for. This is a re-application of r190556 and r190808. This changes the interface of GetSVN.cmake. Clang change to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222391 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
06f9f40a1e
commit
61fd8ea520
@ -2,24 +2,44 @@
|
|||||||
#
|
#
|
||||||
# Input variables:
|
# Input variables:
|
||||||
# FIRST_SOURCE_DIR - First source directory
|
# FIRST_SOURCE_DIR - First source directory
|
||||||
# FIRST_REPOSITORY - The macro to define to the first revision number.
|
# FIRST_NAME - The macro prefix for the first repository's info
|
||||||
# SECOND_SOURCE_DIR - Second source directory
|
# SECOND_SOURCE_DIR - Second source directory (opt)
|
||||||
# SECOND_REPOSITORY - The macro to define to the second revision number.
|
# SECOND_NAME - The macro prefix for the second repository's info (opt)
|
||||||
# HEADER_FILE - The header file to write
|
# HEADER_FILE - The header file to write
|
||||||
include(FindSubversion)
|
#
|
||||||
if (Subversion_FOUND AND EXISTS "${FIRST_SOURCE_DIR}/.svn")
|
# The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION,
|
||||||
# Repository information for the first repository.
|
# and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and
|
||||||
Subversion_WC_INFO(${FIRST_SOURCE_DIR} MY)
|
# "SECOND" are substituted with the names specified in the input variables.
|
||||||
file(WRITE ${HEADER_FILE}.txt "#define ${FIRST_REPOSITORY} \"${MY_WC_REVISION}\"\n")
|
|
||||||
|
|
||||||
# Repository information for the second repository.
|
# Chop off cmake/modules/GetSVN.cmake
|
||||||
if (EXISTS "${SECOND_SOURCE_DIR}/.svn")
|
get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
|
||||||
Subversion_WC_INFO(${SECOND_SOURCE_DIR} MY)
|
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
|
||||||
file(APPEND ${HEADER_FILE}.txt
|
get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
|
||||||
"#define ${SECOND_REPOSITORY} \"${MY_WC_REVISION}\"\n")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Copy the file only if it has changed.
|
# Handle strange terminals
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
set(ENV{TERM} "dumb")
|
||||||
${HEADER_FILE}.txt ${HEADER_FILE})
|
|
||||||
|
function(append_info name path)
|
||||||
|
execute_process(COMMAND "${LLVM_DIR}/utils/GetSourceVersion" "${path}"
|
||||||
|
OUTPUT_VARIABLE revision)
|
||||||
|
string(STRIP "${revision}" revision)
|
||||||
|
execute_process(COMMAND "${LLVM_DIR}/utils/GetRepositoryPath" "${path}"
|
||||||
|
OUTPUT_VARIABLE repository
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
string(STRIP "${repository}" repository)
|
||||||
|
file(APPEND "${HEADER_FILE}.txt"
|
||||||
|
"#define ${name}_REVISION \"${revision}\"\n")
|
||||||
|
file(APPEND "${HEADER_FILE}.txt"
|
||||||
|
"#define ${name}_REPOSITORY \"${repository}\"\n")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
append_info(${FIRST_NAME} "${FIRST_SOURCE_DIR}")
|
||||||
|
if(DEFINED SECOND_SOURCE_DIR)
|
||||||
|
append_info(${SECOND_NAME} "${SECOND_SOURCE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# 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")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user