[x265] [PATCH 3 of 3] Make git X265_VERSION output the same as mercurial
Ricardo Constantino
wiiaboo at gmail.com
Tue May 31 15:17:26 CEST 2016
# HG changeset patch
# User Ricardo Constantino <wiiaboo at gmail.com>
# Date 1464700015 -3600
# Tue May 31 14:06:55 2016 +0100
# Node ID b32b40d45adc80af6dd7b4024b59fc34cd64866e
# Parent 227fc2663961b470a250ca1cdcebf79a411e6d9d
Make git X265_VERSION output the same as mercurial
(except X265_REVISION_ID)
diff -r 227fc2663961 -r b32b40d45adc source/cmake/version.cmake
--- a/source/cmake/version.cmake Tue May 31 14:06:50 2016 +0100
+++ b/source/cmake/version.cmake Tue May 31 14:06:55 2016 +0100
@@ -54,20 +54,15 @@
COMMAND
${HG_EXECUTABLE} log -r. --template "{node}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE HG_REVISION_ID
+ OUTPUT_VARIABLE X265_REVISION_ID
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
- string(SUBSTRING "${HG_REVISION_ID}" 0 16 HG_REVISION_ID)
+ string(SUBSTRING "${X265_REVISION_ID}" 0 16 X265_REVISION_ID)
if(X265_LATEST_TAG MATCHES "^r")
string(SUBSTRING ${X265_LATEST_TAG} 1 -1 X265_LATEST_TAG)
endif()
- if(X265_TAG_DISTANCE STREQUAL "0")
- set(X265_VERSION "${X265_LATEST_TAG}")
- else()
- set(X265_VERSION "${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${HG_REVISION_ID}")
- endif()
elseif(GIT_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git)
execute_process(
COMMAND
@@ -77,15 +72,27 @@
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
-
execute_process(
COMMAND
- ${GIT_EXECUTABLE} describe --tags --first-parent
+ ${GIT_EXECUTABLE} rev-list ${X265_LATEST_TAG}.. --count --first-parent
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- OUTPUT_VARIABLE X265_VERSION
+ OUTPUT_VARIABLE X265_TAG_DISTANCE
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ execute_process(
+ COMMAND
+ ${GIT_EXECUTABLE} log -1 --format=g%h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT_VARIABLE X265_REVISION_ID
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
+if(X265_TAG_DISTANCE STREQUAL "0")
+ set(X265_VERSION "${X265_LATEST_TAG}")
+else()
+ set(X265_VERSION "${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${X265_REVISION_ID}")
+endif()
message(STATUS "x265 version ${X265_VERSION}")
More information about the x265-devel
mailing list