summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f7e6156)
raw | patch | inline | side by side (parent: f7e6156)
author | Jordan Rose <jordan_rose@apple.com> | |
Wed, 11 Sep 2013 22:46:41 +0000 (22:46 +0000) | ||
committer | Jordan Rose <jordan_rose@apple.com> | |
Wed, 11 Sep 2013 22:46:41 +0000 (22:46 +0000) |
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
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
cmake/modules/GetSVN.cmake | patch | blob | history |
index acccc12a94e8e6f29b02caf70e7c425e8b6de4e7..3ddc3ad5c99075b9ef8a6bc43a6a9649c24d8cb7 100644 (file)
#
# Input variables:
# FIRST_SOURCE_DIR - First source directory
-# FIRST_REPOSITORY - The macro to define to the first revision number.
-# SECOND_SOURCE_DIR - Second source directory
-# SECOND_REPOSITORY - The macro to define to the second revision number.
+# FIRST_NAME - The macro prefix for the first repository's info
+# SECOND_SOURCE_DIR - Second source directory (opt)
+# SECOND_NAME - The macro prefix for the second repository's info (opt)
# HEADER_FILE - The header file to write
-include(FindSubversion)
-if (Subversion_FOUND AND EXISTS "${FIRST_SOURCE_DIR}/.svn")
- # Repository information for the first repository.
- Subversion_WC_INFO(${FIRST_SOURCE_DIR} MY)
- file(WRITE ${HEADER_FILE}.txt "#define ${FIRST_REPOSITORY} \"${MY_WC_REVISION}\"\n")
+#
+# 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)
- # Repository information for the second repository.
- if (EXISTS "${SECOND_SOURCE_DIR}/.svn")
- Subversion_WC_INFO(${SECOND_SOURCE_DIR} MY)
- file(APPEND ${HEADER_FILE}.txt
- "#define ${SECOND_REPOSITORY} \"${MY_WC_REVISION}\"\n")
- endif ()
+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()
- # Copy the file only if it has changed.
- execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${HEADER_FILE}.txt ${HEADER_FILE})
+append_info(${FIRST_NAME} "${FIRST_SOURCE_DIR}")
+if(DEFINED SECOND_SOURCE_DIR)
+ append_info(${SECOND_NAME} "${SECOND_SOURCE_DIR}")
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")
+