Mr-Z-2697 / x265-Yuuki-Asuna

A fork of x265. A modded version. With useful changes from others and me.
GNU General Public License v2.0
5 stars 0 forks source link

A cursed way to follow the "official versioning" #1

Open Mr-Z-2697 opened 7 months ago

Mr-Z-2697 commented 7 months ago

As the recent merge of dozens of commits the "versioning" (the base distance number) went very different (there used to be a +1 but now it's like +53 or something) so I came up with this crazy s*it a few days ago.

I don't feel good about put it in the actual repo so here it goes.

(It's not necessary to rm -rf the cloned folder but I did it anyway) (woce is pinyin of "我测" which translates "I test") ( ͡° ͜ʖ ͡°)

diff --git a/source/cmake/YuukiVersion.cmake b/source/cmake/YuukiVersion.cmake
index 6ab969aa3..2f5fd63da 100644
--- a/source/cmake/YuukiVersion.cmake
+++ b/source/cmake/YuukiVersion.cmake
@@ -3,7 +3,7 @@
 find_package(Git)

 execute_process(COMMAND
-    ${GIT_EXECUTABLE} describe --tags HEAD
+    ${GIT_EXECUTABLE} describe --tags --long HEAD
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
         OUTPUT_VARIABLE X265_HEAD_TAG
         ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -16,7 +16,7 @@ else()
 endif()

 execute_process(COMMAND
-    ${GIT_EXECUTABLE} describe --tags origin/${X265_BASE_BRANCH}
+    ${GIT_EXECUTABLE} describe --tags --long origin/${X265_BASE_BRANCH}
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
         OUTPUT_VARIABLE X265_BASE_TAG
         ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -30,15 +30,30 @@ list(GET X265_HEAD_TAG_ARR 2 X265_HEAD_COMMIT)
 list(GET X265_BASE_TAG_ARR 1 X265_BASE_DISTANCE)
 list(GET X265_BASE_TAG_ARR 2 X265_BASE_COMMIT)

+execute_process(COMMAND
+    ${GIT_EXECUTABLE} clone /trunk/x265-Yuuki-Asuna woce --branch ${X265_BASE_BRANCH}
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    )
+execute_process(COMMAND
+    ${GIT_EXECUTABLE} rev-list --count ${X265_ORIG_TAG}.. --first-parent
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/woce
+        OUTPUT_VARIABLE X265_BASE_VS
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+execute_process(COMMAND
+    rm -rf woce
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    )
+
 string(REPLACE "M" "" X265_LATEST_TAG ${X265_ORIG_TAG})

 if("${X265_HEAD_COMMIT}" STREQUAL "${X265_BASE_COMMIT}")
-    set(X265_VERSION "${X265_LATEST_TAG}+${X265_BASE_DISTANCE}-${X265_BASE_COMMIT}")
+    set(X265_VERSION "${X265_LATEST_TAG}+${X265_BASE_VS}-${X265_BASE_COMMIT}")
 else()
     math(EXPR X265_VERSION_DIFF "${X265_HEAD_DISTANCE} - ${X265_BASE_DISTANCE}")
-    set(X265_VERSION "${X265_LATEST_TAG}+${X265_BASE_DISTANCE}-${X265_BASE_COMMIT}+${X265_VERSION_DIFF}")
+    set(X265_VERSION "${X265_LATEST_TAG}+${X265_BASE_VS}-${X265_BASE_COMMIT}+${X265_VERSION_DIFF}")
 endif()

-set(X265_TAG_DISTANCE ${X265_BASE_DISTANCE})
+set(X265_TAG_DISTANCE ${X265_BASE_VS})
 message(STATUS "x265 Mod: ${MOD_BUILD}")
 message(STATUS "x265 Release Version: ${X265_VERSION}")
Mr-Z-2697 commented 2 months ago

It's not very necessary now as version 3.6 released, we are back to +1 difference, but it can still make this difference disappear.

The default "source" /trunk/x265-Yuuki-Asuna is for media-build_suite, when use in other environment change it accordingly.