llvm.org GIT mirror llvm / 6c32111
[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 changes the interface of GetSVN.cmake. Clang change to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190556 91177308-0d34-0410-b5e6-96231b3b80d8 Jordan Rose 6 years ago
1 changed file(s) with 34 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
11 #
22 # Input variables:
33 # FIRST_SOURCE_DIR - First source directory
4 # FIRST_REPOSITORY - The macro to define to the first revision number.
5 # SECOND_SOURCE_DIR - Second source directory
6 # SECOND_REPOSITORY - The macro to define to the second revision number.
4 # FIRST_NAME - The macro prefix for the first repository's info
5 # SECOND_SOURCE_DIR - Second source directory (opt)
6 # SECOND_NAME - The macro prefix for the second repository's info (opt)
77 # HEADER_FILE - The header file to write
8 include(FindSubversion)
9 if (Subversion_FOUND AND EXISTS "${FIRST_SOURCE_DIR}/.svn")
10 # Repository information for the first repository.
11 Subversion_WC_INFO(${FIRST_SOURCE_DIR} MY)
12 file(WRITE ${HEADER_FILE}.txt "#define ${FIRST_REPOSITORY} \"${MY_WC_REVISION}\"\n")
8 #
9 # The output header will contain macros FIRST_REPOSITORY and FIRST_REVISION,
10 # and SECOND_REPOSITORY and SECOND_REVISION if requested, where "FIRST" and
11 # "SECOND" are substituted with the names specified in the input variables.
1312
14 # Repository information for the second repository.
15 if (EXISTS "${SECOND_SOURCE_DIR}/.svn")
16 Subversion_WC_INFO(${SECOND_SOURCE_DIR} MY)
17 file(APPEND ${HEADER_FILE}.txt
18 "#define ${SECOND_REPOSITORY} \"${MY_WC_REVISION}\"\n")
19 endif ()
13 # Chop off cmake/modules/GetSVN.cmake
14 get_filename_component(LLVM_DIR "${CMAKE_SCRIPT_MODE_FILE}" PATH)
15 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
16 get_filename_component(LLVM_DIR "${LLVM_DIR}" PATH)
2017
21 # Copy the file only if it has changed.
22 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
23 ${HEADER_FILE}.txt ${HEADER_FILE})
18 function(append_info name path)
19 execute_process(COMMAND "${LLVM_DIR}/utils/GetSourceVersion" "${path}"
20 OUTPUT_VARIABLE revision)
21 string(STRIP "${revision}" revision)
22 execute_process(COMMAND "${LLVM_DIR}/utils/GetRepositoryPath" "${path}"
23 OUTPUT_VARIABLE repository
24 OUTPUT_STRIP_TRAILING_WHITESPACE)
25 string(STRIP "${repository}" repository)
26 file(APPEND "${HEADER_FILE}.txt"
27 "#define ${name}_REVISION \"${revision}\"\n")
28 file(APPEND "${HEADER_FILE}.txt"
29 "#define ${name}_REPOSITORY \"${repository}\"\n")
30 endfunction()
31
32 append_info(${FIRST_NAME} "${FIRST_SOURCE_DIR}")
33 if(DEFINED SECOND_SOURCE_DIR)
34 append_info(${SECOND_NAME} "${SECOND_SOURCE_DIR}")
2435 endif()
36
37 # Copy the file only if it has changed.
38 execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
39 "${HEADER_FILE}.txt" "${HEADER_FILE}")
40 file(REMOVE "${HEADER_FILE}.txt")
41