mirror of
https://gitee.com/openharmony/third_party_benchmark
synced 2024-11-23 07:20:12 +00:00
Implemented git versioning
This patch automatically versions the shared libraries from any annotated `git` tags: ``` git tag -a v1.0.0 ``` It expects semver version tags such as `v1.0.0`. It would be trivial to support `1.0.0` but looking around it seems that most C/C++ projects follow `vX.X.X` rather that `X.X.X` like a lot of `Node.js` stuff. This determines that the if the project has had a certain amount of commits since the last tag and also if the project is _dirty_ (has modified files), but does __nothing__ with that information. In the future a more robust release could be implemented in the script. This is pretty brittle and has little in the way of configuration. Ideally we should use `find_program` to work out where `git` is so that users can configure it. This implementation assumes that `git` will be available in `PATH` Outputs the following on the command line: ``` -- git Version: v[MAJOR].[MINOR].[PATCH]-[COMMITS_SINCE_TAG]-[SHA1](-dirty)? -- Version: [MAJOR].[MINOR].[PATCH] ```
This commit is contained in:
parent
890908c197
commit
d591edf513
@ -38,9 +38,38 @@ if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86")
|
||||
add_definitions(-DARCH_X86)
|
||||
endif()
|
||||
|
||||
# Read the git tags to determine the project version
|
||||
execute_process(COMMAND git describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
|
||||
RESULT_VARIABLE status
|
||||
OUTPUT_VARIABLE GIT_VERSION
|
||||
ERROR_QUIET)
|
||||
if(${status})
|
||||
set(GIT_VERSION "v0.0.0")
|
||||
else()
|
||||
string(STRIP ${GIT_VERSION} GIT_VERSION)
|
||||
string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
|
||||
endif()
|
||||
|
||||
# Work out if the repository is dirty
|
||||
execute_process(COMMAND git update-index -q --refresh
|
||||
OUTPUT_QUIET
|
||||
ERROR_QUIET)
|
||||
execute_process(COMMAND git diff-index --name-only HEAD --
|
||||
OUTPUT_VARIABLE GIT_DIFF_INDEX
|
||||
ERROR_QUIET)
|
||||
string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
|
||||
if (${GIT_DIRTY})
|
||||
string(CONCAT GIT_VERSION ${GIT_VERSION} "-dirty")
|
||||
endif()
|
||||
|
||||
# Tell the user what versions we are using
|
||||
message("-- git Version: ${GIT_VERSION}")
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
|
||||
message("-- Version: ${VERSION}")
|
||||
|
||||
# The version of the libraries
|
||||
set(GENERIC_LIB_VERSION "0.0.0")
|
||||
set(GENERIC_LIB_SOVERSION "0")
|
||||
set(GENERIC_LIB_VERSION ${VERSION})
|
||||
string(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION)
|
||||
|
||||
# Set up directories
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
|
Loading…
Reference in New Issue
Block a user