[x265] [X265] [PATCH] [Master and Release 3.x] Adds support for archival and version reporting for git repositories

Srikanth Kurapati srikanth.kurapati at multicorewareinc.com
Tue Oct 20 13:49:02 CEST 2020


On Mon, Oct 19, 2020 at 9:09 PM Aruna Matheswaran <
aruna at multicorewareinc.com> wrote:

>
>
> On Sun, Oct 18, 2020 at 5:28 PM Srikanth Kurapati <
> srikanth.kurapati at multicorewareinc.com> wrote:
>
>> From 89c497c96918c22aa4dd074e603ec8ce56982415 Mon Sep 17 00:00:00 2001
>> From: Srikanth Kurapati <srikanth.kurapati at multicorewareinc.com>
>> Date: Tue, 13 Oct 2020 20:46:56 +0530
>> Subject: [PATCH] fix enables git repository archival for x265 release
>> versions
>>
> [AM] Commit message is confusing to me. Needs to be changed to something
> like "Fix incorrect version display in archived git repositories"
>
   [KS] simplified.

>
>> ---
>>  doc/reST/cli.rst           |   8 +-
>>  source/CMakeLists.txt      |   2 +-
>>  source/cmake/Version.cmake | 172 +++++++++++++++++++++++++++++++++++++
>>  source/cmake/version.cmake |  97 ---------------------
>>  x265Version.txt            |   5 ++
>>  5 files changed, 184 insertions(+), 100 deletions(-)
>>  create mode 100644 source/cmake/Version.cmake
>>  delete mode 100644 source/cmake/version.cmake
>>  create mode 100644 x265Version.txt
>>
>> diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst
>> index 1a1de9f50..716b51e01 100755
>> --- a/doc/reST/cli.rst
>> +++ b/doc/reST/cli.rst
>> @@ -36,13 +36,17 @@ Executable Options
>>
>>  .. option:: --help, -h
>>
>> - Display help text
>> + Displays help text
>>
>>   **CLI ONLY**
>>
>>  .. option:: --version, -V
>>
>> - Display version details
>> + Displays version details in  *[Version Name]+[commit count from Release
>> Tag]-[Tag SHA-1 paraphrase formatted string or substring]* format using
>> input from
>> + version control software *Git or Mercurial*. Product Archives display
>> the same using information from configuration in file *x265Version.txt*
>> + **Example for git repositories:** <h1>x265 [info]: HEVC encoder version
>> 3.4+26-a82c6c7a7<\h1>
>> +
>>
> [AM] The help statement is misleading. --version is not just restricted to
> displaying tag details. It does provide other build details.
>
   [re phrased]

> + .. seeAlso::  For more information please refer to `<
>> https://bitbucket.org/multicoreware/x265_git/wiki/Home>`_  and
>> Contribute pages for updates.
>>
>>   **CLI ONLY**
>>
>> diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
>> index 67e737512..95218f5dc 100755
>> --- a/source/CMakeLists.txt
>> +++ b/source/CMakeLists.txt
>> @@ -485,7 +485,7 @@ if(POWER)
>>      endif()
>>  endif()
>>
>> -include(version) # determine X265_VERSION and X265_LATEST_TAG
>> +include(Version) # determine X265_VERSION and X265_LATEST_TAG
>>  include_directories(. common encoder "${PROJECT_BINARY_DIR}")
>>
>>  option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF)
>> diff --git a/source/cmake/Version.cmake b/source/cmake/Version.cmake
>> new file mode 100644
>> index 000000000..836f482e6
>> --- /dev/null
>> +++ b/source/cmake/Version.cmake
>> @@ -0,0 +1,172 @@
>> +
>> #################################################################################################################
>> + #
>> + #    Copyright (C) 2013-2020 MulticoreWare, Inc
>> + #
>> + # This program is free software; you can redistribute it and/or modify
>> + # it under the terms of the GNU General Public License as published by
>> + # the Free Software Foundation; either version 2 of the License, or
>> + # (at your option) any later version.
>> + #
>> + # This program is distributed in the hope that it will be useful,
>> + # but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + # GNU General Public License for more details.
>> + #
>> + # You should have received a copy of the GNU General Public License
>> + # along with this program; if not, write to the Free Software
>> + # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111,
>> USA.
>> + #
>> + # This program is also available under a commercial proprietary license.
>> + # For more information, contact us at license @ x265.com
>> + #
>> + # Authors: Janani T.E <janani.te at multicorewareinc.com>, Srikanth
>> Kurapati <srikanthkurapati at multicorewareinc.com>
>> + #
>> +
>> #################################################################################################################
>> + # PURPOSE: Identity version control software version display, also read
>> version files to present x265 version.
>> +
>> #################################################################################################################
>> + #Default Settings, for user to be vigilant about x265 version being
>> reported during product build.
>> +set(X265_VERSION "unknown")
>> +set(X265_REPO_ID "unknown")
>> +set(X265_LATEST_TAG "0.0")
>> +set(X265_TAG_DISTANCE "0")
>> +set(IS_HG_ARCHIVE_REPO "0")
>> +set(IS_HG_LIVE_REPO "0")
>>
> [AM] Why is another flag IS_HG_LIVE_REPO required? Shall be handled with
> one flag.
>
   [KS] optimized, had initially added them for keeping the cases
distinctly readable

> +set(IS_GIT_ARCHIVE_REPO "0")
>> +set(IS_GIT_LIVE_REPO "0")
>> +
>> +#Find version control software to be used for live and extracted
>> repositories from compressed tarballs
>> +if(CMAKE_VERSION VERSION_LESS "2.8.10")
>> +    find_program(HG_EXECUTABLE hg)
>> +    if(EXISTS "${HG_EXECUTABLE}.bat")
>> +        set(HG_EXECUTABLE "${HG_EXECUTABLE}.bat")
>> +    endif()
>> +    message(STATUS "hg found at ${HG_EXECUTABLE}")
>> +else()
>> +    find_package(Hg QUIET)
>> +endif()
>> +if(HG_EXECUTABLE)
>> +    #Set Version Control binary for source code kind
>> +    if(EXISTS CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt)
>> +        set(IS_HG_ARCHIVE_REPO "1")
>> +    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg)
>> +        set(IS_HG_LIVE_REPO "1")
>> +    endif()
>> +endif(HG_EXECUTABLE)
>> +find_package(Git QUIET) #No restrictions on Git versions used, any
>> versions from 1.8.x to 2.2.x or later should do.
>> +if(Git_FOUND)
>> +    find_program(GIT_EXECUTABLE git)
>> +    message(STATUS "GIT_EXECUTABLE ${GIT_EXECUTABLE}")
>> +    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git)
>> +        set(IS_GIT_LIVE_REPO "1")
>> +    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../x265Version.txt)
>> +        set(IS_GIT_ARCHIVE_REPO "1")
>> +    endif()
>> +endif(Git_FOUND)
>> +if(IS_HG_ARCHIVE_REPO STREQUAL "1")
>> +    #Read the lines of the archive summary file to extract the version
>> +    message(STATUS "SOURCE CODE IS FROM x265 ARCHIVED ZIP OR TAR BALL")
>> +    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt archive)
>> +    STRING(REGEX REPLACE "\n" ";" archive "${archive}")
>> +    foreach(f ${archive})
>> +        string(FIND "${f}" ": " pos)
>> +        string(SUBSTRING "${f}" 0 ${pos} key)
>> +        string(SUBSTRING "${f}" ${pos} -1 value)
>> +        string(SUBSTRING "${value}" 2 -1 value)
>> +        set(hg_${key} ${value})
>> +    endforeach()
>> +    if(DEFINED hg_tag)
>> +        set(X265_LATEST_TAG ${hg_tag})
>> +    elseif(DEFINED hg_node)
>> +        set(X265_LATEST_TAG ${hg_latesttag})
>> +        set(X265_TAG_DISTANCE ${hg_latesttagdistance})
>> +        string(SUBSTRING "${hg_node}" 0 12 X265_REVISION_ID)
>> +    endif()
>> +    message(STATUS "HG ARCHIVAL INFORMATION PROCESSED")
>> +elseif(IS_HG_LIVE_REPO STREQUAL "1")
>> +    execute_process(COMMAND
>> +        ${HG_EXECUTABLE} log -r. --template "{latesttag}"
>> +        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> +        OUTPUT_VARIABLE X265_LATEST_TAG
>> +        ERROR_QUIET
>> +        OUTPUT_STRIP_TRAILING_WHITESPACE
>> +        )
>> +    execute_process(COMMAND
>> +        ${HG_EXECUTABLE} log -r. --template "{latesttagdistance}"
>> +        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> +        OUTPUT_VARIABLE X265_TAG_DISTANCE
>> +        ERROR_QUIET
>> +        OUTPUT_STRIP_TRAILING_WHITESPACE
>> +        )
>> +    execute_process(
>> +        COMMAND
>> +        ${HG_EXECUTABLE} log -r. --template "{node}"
>> +        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> +        OUTPUT_VARIABLE X265_REVISION_ID
>> +        ERROR_QUIET
>> +        OUTPUT_STRIP_TRAILING_WHITESPACE
>> +        )
>> +    string(SUBSTRING "${X265_REVISION_ID}" 0 12 X265_REVISION_ID)
>> +    if(X265_LATEST_TAG MATCHES "^r")
>> +        string(SUBSTRING ${X265_LATEST_TAG} 1 -1 X265_LATEST_TAG)
>> +    endif()
>> +    message(STATUS "HG LIVE REPO STATUS CHECK DONE")
>> +elseif(IS_GIT_LIVE_REPO STREQUAL "1")
>> +    execute_process(
>> +        COMMAND
>> +        ${GIT_EXECUTABLE} describe --abbrev=0 --tags
>> +        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> +        OUTPUT_VARIABLE X265_LATEST_TAG
>> +        ERROR_QUIET
>> +        OUTPUT_STRIP_TRAILING_WHITESPACE
>> +        )
>> +    execute_process(
>> +        COMMAND
>> +        ${GIT_EXECUTABLE} rev-list ${X265_LATEST_TAG}.. --count
>> --first-parent
>> +        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> +        OUTPUT_VARIABLE X265_TAG_DISTANCE
>> +        ERROR_QUIET
>> +        OUTPUT_STRIP_TRAILING_WHITESPACE
>> +        )
>> +    execute_process(
>> +        COMMAND
>> +        ${GIT_EXECUTABLE} log --pretty=format:%h -n 1
>> +        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> +        OUTPUT_VARIABLE X265_REVISION_ID
>> +        ERROR_QUIET
>> +        OUTPUT_STRIP_TRAILING_WHITESPACE
>> +        )
>> +elseif(IS_GIT_ARCHIVE_REPO STREQUAL "1")
>> +    message(STATUS "X265 GIT ARCHIVE EXTRACT VERSION INFORMATION
>> PROCESSING")
>> +    #Read the lines of the archive summary file to extract the version
>> +    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../x265Version.txt filebuf)
>> +    STRING(REGEX REPLACE "\n" ";" filebuf "${filebuf}")
>> +    foreach(line ${filebuf})
>> +        string(FIND "${line}" ": " pos)
>> +        string(SUBSTRING "${line}" 0 ${pos} key)
>> +        string(SUBSTRING "${line}" ${pos} -1 value)
>> +        string(SUBSTRING "${value}" 2 -1 value)
>> +        set(git_${key} ${value})
>> +    endforeach()
>> +    if(DEFINED git_releasetag)
>> +        set(X265_LATEST_TAG ${git_releasetag})
>> +        if(DEFINED git_releasetagcommitid)
>> +            string(SUBSTRING "${git_releasetagcommitid}" 0 9
>> X265_REVISION_ID)
>> +        else()
>> +            message(WARNING "RELEASE CHANGESET INFO NOT PRESENT IN
>> VERSION FILE")
>>
> [AM] Shouldn't it throw an error message?
>
   [KS] As shared with you offline before the cmake error messages will
abort the build whereas warnings will inform the user with stack trace and
proceed. Which one do you think is desirable for the functionality. I feel
we can inform the user with warning and carry on with the rest of the
build. The warning will appear when make-solutions is run and also during
cmake configure through gui so by then users might become aware that they
might have to re configure the version file correctly before archival of
the repository.

> +        endif()
>> +        if(DEFINED git_repositorychangeset)
>> +           string(SUBSTRING "${git_repositorychangeset}" 0 9
>> X265_REPO_ID)
>>
> [AM] I don't see  X265_REPO_ID getting used anywhere. Please clarify the
> need for  X265_REPO_ID.
>
   [KS] updated code for using the same as the archive can be created
at/before or after the latest tag.

> +        else()
>> +           message(STATUS "X265 LATEST COMMIT TIP INFORMATION NOT
>> AVAILABLE")
>> +        endif()
>> +        if(DEFINED git_releasetagdistance)
>> +           set(X265_TAG_DISTANCE ${git_releasetagdistance})
>> +        else()
>> +           message(WARNING "COMMIT INFORMATION AFTER LATEST REVISION
>> UNAVAILABLE")
>> +        endif()
>> +    else()
>> +        message(WARNING "X265 RELEASE VERSION LABEL MISSING:
>> ${X265_LATEST_TAG}")
>> +    endif()
>> +endif()
>> +set(X265_VERSION
>> "${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${X265_REVISION_ID}")
>> +message(STATUS "x265 RELEASE VERSION ${X265_VERSION}")
>> diff --git a/source/cmake/version.cmake b/source/cmake/version.cmake
>> deleted file mode 100644
>> index 35302249a..000000000
>> --- a/source/cmake/version.cmake
>>
> [AM] Renaming the file makes it tough to review the changes as it replaces
> the file instead of modifying the code. Any reason behind the renaming?
>
   [KS] Most of the files in cmake source dir follow Camel case hence
updated the same for uniformity also cmake is case sensitive to file names
in linux.

> +++ /dev/null
>> @@ -1,97 +0,0 @@
>> -if(CMAKE_VERSION VERSION_LESS "2.8.10")
>> -    find_program(HG_EXECUTABLE hg)
>> -else()
>> -    find_package(Hg QUIET)
>> -endif()
>> -find_package(Git QUIET) # present in 2.8.8
>> -
>> -# defaults, in case everything below fails
>> -set(X265_VERSION "unknown")
>> -set(X265_LATEST_TAG "0.0")
>> -set(X265_TAG_DISTANCE "0")
>> -
>> -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt)
>> -    # read the lines of the archive summary file to extract the version
>> -    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt archive)
>> -    STRING(REGEX REPLACE "\n" ";" archive "${archive}")
>> -    foreach(f ${archive})
>> -        string(FIND "${f}" ": " pos)
>> -        string(SUBSTRING "${f}" 0 ${pos} key)
>> -        string(SUBSTRING "${f}" ${pos} -1 value)
>> -        string(SUBSTRING "${value}" 2 -1 value)
>> -        set(hg_${key} ${value})
>> -    endforeach()
>> -    if(DEFINED hg_tag)
>> -        set(X265_LATEST_TAG ${hg_tag})
>> -    elseif(DEFINED hg_node)
>> -        set(X265_LATEST_TAG ${hg_latesttag})
>> -        set(X265_TAG_DISTANCE ${hg_latesttagdistance})
>> -        string(SUBSTRING "${hg_node}" 0 12 X265_REVISION_ID)
>> -    endif()
>> -elseif(HG_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg)
>> -    if(EXISTS "${HG_EXECUTABLE}.bat")
>> -        # mercurial source installs on Windows require .bat extension
>> -        set(HG_EXECUTABLE "${HG_EXECUTABLE}.bat")
>> -    endif()
>> -    message(STATUS "hg found at ${HG_EXECUTABLE}")
>> -
>> -    execute_process(COMMAND
>> -        ${HG_EXECUTABLE} log -r. --template "{latesttag}"
>> -        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> -        OUTPUT_VARIABLE X265_LATEST_TAG
>> -        ERROR_QUIET
>> -        OUTPUT_STRIP_TRAILING_WHITESPACE
>> -        )
>> -    execute_process(COMMAND
>> -        ${HG_EXECUTABLE} log -r. --template "{latesttagdistance}"
>> -        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> -        OUTPUT_VARIABLE X265_TAG_DISTANCE
>> -        ERROR_QUIET
>> -        OUTPUT_STRIP_TRAILING_WHITESPACE
>> -        )
>> -    execute_process(
>> -        COMMAND
>> -        ${HG_EXECUTABLE} log -r. --template "{node}"
>> -        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> -        OUTPUT_VARIABLE X265_REVISION_ID
>> -        ERROR_QUIET
>> -        OUTPUT_STRIP_TRAILING_WHITESPACE
>> -        )
>> -    string(SUBSTRING "${X265_REVISION_ID}" 0 12 X265_REVISION_ID)
>> -
>> -    if(X265_LATEST_TAG MATCHES "^r")
>> -        string(SUBSTRING ${X265_LATEST_TAG} 1 -1 X265_LATEST_TAG)
>> -    endif()
>> -elseif(GIT_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git)
>> -    execute_process(
>> -        COMMAND
>> -        ${GIT_EXECUTABLE} describe --abbrev=0 --tags
>> -        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> -        OUTPUT_VARIABLE X265_LATEST_TAG
>> -        ERROR_QUIET
>> -        OUTPUT_STRIP_TRAILING_WHITESPACE
>> -        )
>> -    execute_process(
>> -        COMMAND
>> -        ${GIT_EXECUTABLE} rev-list ${X265_LATEST_TAG}.. --count
>> --first-parent
>> -        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
>> -        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}")
>>
> [AM] Since this chunk has been removed in Version.cmake, the version info
> will look messy if   X265_LATEST_TAG is 0.
>
    Its printed as Release_3.4+0-abcedf07- simplified for readability in
this case but once the user has understood the version format documentation
and wiki updates it should not be a problem.

> -else()
>> -    set(X265_VERSION
>> "${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${X265_REVISION_ID}")
>> -endif()
>> -
>> -message(STATUS "x265 version ${X265_VERSION}")
>> diff --git a/x265Version.txt b/x265Version.txt
>> new file mode 100644
>> index 000000000..74b23469e
>> --- /dev/null
>> +++ b/x265Version.txt
>> @@ -0,0 +1,5 @@
>> +#Attribute:     Values
>> +repositorychangeset: a82c6c7a7
>> +releasetagcommitid: 6722fce1f
>> +releasetagdistance: 28
>> +releasetag: 3.5
>>
> [AM] 3.5 isn't a valid tag.
>
   [KS] ok set of Release_3.5 or it can be 3.5_RC1 or 2 and so on as per
wiki pages.

> Also, the commit message says the patch is applicable for master and
> Release_3.x. In that case, one x265Version.txt file per branch is expected.
>
  [KS] No then we will have to keep adding one file per release. Instead if
the same patch is pushed to all branches and with the version file updated
for a given branch we don't need multiple copies for maintaining the same
information, the file can be appended from release to release as the latest
entries are always considered for populating the version string.

Please get back on my answers so that I can send the patch soon.

-- 
>> 2.20.1.windows.1
>>
>>
>> --
>> *With Regards,*
>> *Srikanth Kurapati.*
>> _______________________________________________
>> x265-devel mailing list
>> x265-devel at videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
>
>
> --
> Regards,
> *Aruna Matheswaran,*
> Video Codec Engineer,
> Media & AI analytics BU,
>
>
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>


-- 
*With Regards,*
*Srikanth Kurapati.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20201020/89feef80/attachment-0001.html>


More information about the x265-devel mailing list