mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-28 03:28:48 +08:00
mdbx: поддержка Semantic Versioning.
Было `MAJOR.MINOR.RELEASE.REVISION` Теперь `MAJOR.MINOR.PATCH[.TWEAK][-PRERELEASE][+BUILDMETADATA]` https://semver.org/ - вместо квартета `MAJOR.MINOR.RELEASE.REVISION` триплет c опцинальным четвертым членом `MAJOR.MINOR.PATCH[.TWEAK]` - `TWEAK` не входит в тег git, а формируется автоматически и соответствует кол-ву коммитов после тега git и опускается если 0. - Поле `PRERELEASE` опционально и переносится в версию из тега git. - Поле `BUILDMETADATA` опционально, не входит в тег git, а добавляется во время сборки если задана опцией `MDBX_BUILD_METADATA`.
This commit is contained in:
parent
bcf0a1273f
commit
9daff17c82
@ -195,6 +195,15 @@ else()
|
||||
"PLEASE, AVOID USING ANY OTHER TECHNIQUES.")
|
||||
endif()
|
||||
|
||||
# Provide version
|
||||
include(cmake/utils.cmake)
|
||||
set(MDBX_BUILD_METADATA
|
||||
"${MDBX_BUILD_METADATA}"
|
||||
CACHE STRING "An extra/custom information provided during libmdbx build")
|
||||
semver_provide(MDBX "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${MDBX_BUILD_METADATA}" FALSE)
|
||||
message(STATUS "libmdbx version is ${MDBX_VERSION}")
|
||||
|
||||
if(DEFINED PROJECT_NAME)
|
||||
option(
|
||||
MDBX_FORCE_BUILD_AS_MAIN_PROJECT
|
||||
@ -304,7 +313,6 @@ if(NOT DEFINED THREADS_PREFER_PTHREAD_FLAG)
|
||||
endif()
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
include(cmake/utils.cmake)
|
||||
include(cmake/compiler.cmake)
|
||||
include(cmake/profile.cmake)
|
||||
|
||||
@ -650,10 +658,6 @@ endif()
|
||||
# ~~~
|
||||
# ##############################################################################
|
||||
|
||||
set(MDBX_BUILD_METADATA
|
||||
""
|
||||
CACHE STRING "An extra/custom information provided during libmdbx build")
|
||||
|
||||
set(MDBX_BUILD_OPTIONS ENABLE_UBSAN ENABLE_ASAN ENABLE_MEMCHECK ENABLE_GPROF
|
||||
ENABLE_GCOV)
|
||||
macro(add_mdbx_option NAME DESCRIPTION DEFAULT)
|
||||
@ -812,11 +816,6 @@ if(MDBX_BUILD_CXX)
|
||||
probe_libcxx_filesystem()
|
||||
endif()
|
||||
|
||||
# Get version
|
||||
fetch_version(MDBX "${CMAKE_CURRENT_SOURCE_DIR}" FALSE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(STATUS "libmdbx version is ${MDBX_VERSION}")
|
||||
|
||||
# sources list
|
||||
set(LIBMDBX_PUBLIC_HEADERS mdbx.h)
|
||||
set(LIBMDBX_SOURCES mdbx.h "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||
@ -1370,11 +1369,9 @@ if(NOT SUBPROJECT)
|
||||
set(PACKAGE "libmdbx")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${MDBX_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${MDBX_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${MDBX_VERSION_RELEASE})
|
||||
set(CPACK_PACKAGE_VERSION_COMMIT ${MDBX_VERSION_REVISION})
|
||||
set(PACKAGE_VERSION
|
||||
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${CPACK_PACKAGE_VERSION_COMMIT}"
|
||||
)
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${MDBX_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION_TWEAK ${MDBX_VERSION_TWEAK})
|
||||
set(PACKAGE_VERSION ${MDBX_VERSION})
|
||||
message(STATUS "libmdbx package version is ${PACKAGE_VERSION}")
|
||||
endif()
|
||||
|
||||
|
49
GNUmakefile
49
GNUmakefile
@ -398,11 +398,14 @@ reformat:
|
||||
|
||||
MAN_SRCDIR := src/man1/
|
||||
ALLOY_DEPS := $(shell git ls-files src/ | grep -e /tools -e /man -v)
|
||||
git_DIR := $(shell if [ -d .git ]; then echo .git; elif [ -s .git -a -f .git ]; then grep '^gitdir: ' .git | cut -d ':' -f 2; else echo git_directory_is_absent; fi)
|
||||
MDBX_GIT_VERSION = $(shell set -o pipefail; git describe --tags '--match=v[0-9]*' 2>&- | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)|\1|p' || echo 'Please fetch tags and/or use non-obsolete git version')
|
||||
MDBX_GIT_REVISION = $(shell set -o pipefail; git rev-list `git describe --tags --abbrev=0`..HEAD --count 2>&- || echo 'Please fetch tags and/or use non-obsolete git version')
|
||||
MDBX_GIT_TIMESTAMP = $(shell git show --no-patch --format=%cI HEAD 2>&- || echo 'Please install latest get version')
|
||||
MDBX_GIT_DESCRIBE = $(shell git describe --tags --long --dirty=-dirty '--match=v[0-9]*' 2>&- || echo 'Please fetch tags and/or install non-obsolete git version')
|
||||
MDBX_GIT_DIR := $(shell if [ -d .git ]; then echo .git; elif [ -s .git -a -f .git ]; then grep '^gitdir: ' .git | cut -d ':' -f 2; else echo git_directory_is_absent; fi)
|
||||
MDBX_GIT_LASTVTAG := $(shell git describe --tags --dirty=-DIRTY --abbrev=0 '--match=v[0-9]*' 2>&- || echo 'Please fetch tags and/or install non-obsolete git version')
|
||||
MDBX_GIT_3DOT := $(shell set -o pipefail; echo "$(MDBX_GIT_LASTVTAG)" | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)|\1|p' || echo 'Please fetch tags and/or use non-obsolete git version')
|
||||
MDBX_GIT_TWEAK := $(shell set -o pipefail; git rev-list $(shell git describe --tags --abbrev=0 '--match=v[0-9]*')..HEAD --count 2>&- || echo 'Please fetch tags and/or use non-obsolete git version')
|
||||
MDBX_GIT_TIMESTAMP := $(shell git show --no-patch --format=%cI HEAD 2>&- || echo 'Please install latest get version')
|
||||
MDBX_GIT_DESCRIBE := $(shell git describe --tags --long --dirty '--match=v[0-9]*' 2>&- || echo 'Please fetch tags and/or install non-obsolete git version')
|
||||
MDBX_GIT_PRERELEASE := $(shell echo "$(MDBX_GIT_LASTVTAG)" | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)-\([-.0-1a-zA-Z]\+\)|\3|p')
|
||||
MDBX_VERSION_PURE = $(MDBX_GIT_3DOT)$(if $(filter-out 0,$(MDBX_GIT_TWEAK)),.$(MDBX_GIT_TWEAK),)$(if $(MDBX_GIT_PRERELEASE),-$(MDBX_GIT_PRERELEASE),)
|
||||
MDBX_VERSION_IDENT = $(shell set -o pipefail; echo -n '$(MDBX_GIT_DESCRIBE)' | tr -c -s '[a-zA-Z0-9.]' _)
|
||||
MDBX_VERSION_NODOT = $(subst .,_,$(MDBX_VERSION_IDENT))
|
||||
MDBX_BUILD_SOURCERY = $(shell set -o pipefail; $(MAKE) IOARENA=false CXXSTD= -s src/version.c >/dev/null && (openssl dgst -r -sha256 src/version.c || sha256sum src/version.c || shasum -a 256 src/version.c) 2>/dev/null | cut -d ' ' -f 1 || (echo 'Please install openssl or sha256sum or shasum' >&2 && echo sha256sum_is_no_available))_$(MDBX_VERSION_NODOT)
|
||||
@ -529,7 +532,7 @@ mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX)
|
||||
@echo ' LD $@'
|
||||
$(QUIET)$(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) $(LIBS) -o $@
|
||||
|
||||
$(git_DIR)/HEAD $(git_DIR)/index $(git_DIR)/refs/tags:
|
||||
$(MDBX_GIT_DIR)/HEAD $(MDBX_GIT_DIR)/index $(MDBX_GIT_DIR)/refs/tags:
|
||||
@echo '*** ' >&2
|
||||
@echo '*** Please don''t use tarballs nor zips which are automatically provided by Github !' >&2
|
||||
@echo '*** These archives do not contain version information and thus are unfit to build libmdbx.' >&2
|
||||
@ -539,17 +542,19 @@ $(git_DIR)/HEAD $(git_DIR)/index $(git_DIR)/refs/tags:
|
||||
@echo '*** ' >&2
|
||||
@false
|
||||
|
||||
src/version.c: src/version.c.in $(lastword $(MAKEFILE_LIST)) $(git_DIR)/HEAD $(git_DIR)/index $(git_DIR)/refs/tags LICENSE NOTICE
|
||||
src/version.c: src/version.c.in $(lastword $(MAKEFILE_LIST)) $(MDBX_GIT_DIR)/HEAD $(MDBX_GIT_DIR)/index $(MDBX_GIT_DIR)/refs/tags LICENSE NOTICE
|
||||
@echo ' MAKE $@'
|
||||
$(QUIET)sed \
|
||||
-e "s|@MDBX_GIT_TIMESTAMP@|$(MDBX_GIT_TIMESTAMP)|" \
|
||||
-e "s|@MDBX_GIT_TREE@|$(shell git show --no-patch --format=%T HEAD || echo 'Please install latest get version')|" \
|
||||
-e "s|@MDBX_GIT_COMMIT@|$(shell git show --no-patch --format=%H HEAD || echo 'Please install latest get version')|" \
|
||||
-e "s|@MDBX_GIT_DESCRIBE@|$(MDBX_GIT_DESCRIBE)|" \
|
||||
-e "s|\$${MDBX_VERSION_MAJOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 1)|" \
|
||||
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 2)|" \
|
||||
-e "s|\$${MDBX_VERSION_RELEASE}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 3)|" \
|
||||
-e "s|\$${MDBX_VERSION_REVISION}|$(MDBX_GIT_REVISION)|" \
|
||||
-e "s|\$${MDBX_VERSION_MAJOR}|$(shell echo '$(MDBX_GIT_3DOT)' | cut -d . -f 1)|" \
|
||||
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_GIT_3DOT)' | cut -d . -f 2)|" \
|
||||
-e "s|\$${MDBX_VERSION_PATCH}|$(shell echo '$(MDBX_GIT_3DOT)' | cut -d . -f 3)|" \
|
||||
-e "s|\$${MDBX_VERSION_TWEAK}|$(MDBX_GIT_TWEAK)|" \
|
||||
-e "s|\$${MDBX_VERSION_PRERELEASE}|$(MDBX_GIT_PRERELEASE)|" \
|
||||
-e "s|\$${MDBX_VERSION_PURE}|$(MDBX_VERSION_PURE)|" \
|
||||
src/version.c.in >$@
|
||||
|
||||
src/config.h: @buildflags.tag $(WAIT) src/version.c $(lastword $(MAKEFILE_LIST)) LICENSE NOTICE
|
||||
@ -578,10 +583,12 @@ docs/Doxyfile: docs/Doxyfile.in src/version.c $(lastword $(MAKEFILE_LIST))
|
||||
-e "s|@MDBX_GIT_TREE@|$(shell git show --no-patch --format=%T HEAD || echo 'Please install latest get version')|" \
|
||||
-e "s|@MDBX_GIT_COMMIT@|$(shell git show --no-patch --format=%H HEAD || echo 'Please install latest get version')|" \
|
||||
-e "s|@MDBX_GIT_DESCRIBE@|$(MDBX_GIT_DESCRIBE)|" \
|
||||
-e "s|\$${MDBX_VERSION_MAJOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 1)|" \
|
||||
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 2)|" \
|
||||
-e "s|\$${MDBX_VERSION_RELEASE}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 3)|" \
|
||||
-e "s|\$${MDBX_VERSION_REVISION}|$(MDBX_GIT_REVISION)|" \
|
||||
-e "s|\$${MDBX_VERSION_MAJOR}|$(shell echo '$(MDBX_GIT_3DOT)' | cut -d . -f 1)|" \
|
||||
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_GIT_3DOT)' | cut -d . -f 2)|" \
|
||||
-e "s|\$${MDBX_VERSION_PATCH}|$(shell echo '$(MDBX_GIT_3DOT)' | cut -d . -f 3)|" \
|
||||
-e "s|\$${MDBX_VERSION_TWEAK}|$(MDBX_GIT_TWEAK)|" \
|
||||
-e "s|\$${MDBX_VERSION_PRERELEASE}|$(MDBX_GIT_PRERELEASE)|" \
|
||||
-e "s|\$${MDBX_VERSION_PURE}|$(MDBX_VERSION_PURE)|" \
|
||||
docs/Doxyfile.in >$@
|
||||
|
||||
define md-extract-section
|
||||
@ -629,11 +636,11 @@ tags:
|
||||
@echo ' FETCH git tags...'
|
||||
$(QUIET)git fetch --tags --force
|
||||
|
||||
release-assets: libmdbx-amalgamated-$(MDBX_GIT_VERSION).zpaq \
|
||||
libmdbx-amalgamated-$(MDBX_GIT_VERSION).tar.xz \
|
||||
libmdbx-amalgamated-$(MDBX_GIT_VERSION).tar.bz2 \
|
||||
libmdbx-amalgamated-$(MDBX_GIT_VERSION).tar.gz \
|
||||
libmdbx-amalgamated-$(subst .,_,$(MDBX_GIT_VERSION)).zip
|
||||
release-assets: libmdbx-amalgamated-$(MDBX_GIT_3DOT).zpaq \
|
||||
libmdbx-amalgamated-$(MDBX_GIT_3DOT).tar.xz \
|
||||
libmdbx-amalgamated-$(MDBX_GIT_3DOT).tar.bz2 \
|
||||
libmdbx-amalgamated-$(MDBX_GIT_3DOT).tar.gz \
|
||||
libmdbx-amalgamated-$(subst .,_,$(MDBX_GIT_3DOT)).zip
|
||||
$(QUIET)([ \
|
||||
"$$(set -o pipefail; git describe | sed -n '/^v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$$/p' || echo fail-left)" \
|
||||
== \
|
||||
@ -759,7 +766,7 @@ $(foreach file,mdbx.h mdbx.h++ $(filter-out man1/% VERSION.json .clang-format-ig
|
||||
|
||||
dist/VERSION.json: src/version.c
|
||||
@echo ' MAKE $@'
|
||||
$(QUIET)mkdir -p dist/ && echo "{ \"git_describe\": \"$(MDBX_GIT_DESCRIBE)\", \"git_timestamp\": \"$(MDBX_GIT_TIMESTAMP)\", \"git_tree\": \"$(shell git show --no-patch --format=%T HEAD 2>&1)\", \"git_commit\": \"$(shell git show --no-patch --format=%H HEAD 2>&1)\", \"version_4dot\": \"$(MDBX_GIT_VERSION).$(MDBX_GIT_REVISION)\" }" >$@
|
||||
$(QUIET)mkdir -p dist/ && echo "{ \"git_describe\": \"$(MDBX_GIT_DESCRIBE)\", \"git_timestamp\": \"$(MDBX_GIT_TIMESTAMP)\", \"git_tree\": \"$(shell git show --no-patch --format=%T HEAD 2>&1)\", \"git_commit\": \"$(shell git show --no-patch --format=%H HEAD 2>&1)\", \"semver\": \"$(MDBX_VERSION_PURE)\" }" >$@
|
||||
|
||||
dist/.clang-format-ignore: $(lastword $(MAKEFILE_LIST))
|
||||
@echo ' MAKE $@'
|
||||
|
@ -74,15 +74,313 @@ macro(set_source_files_compile_flags)
|
||||
unset(_lang)
|
||||
endmacro(set_source_files_compile_flags)
|
||||
|
||||
macro(fetch_version name source_root_directory parent_scope
|
||||
build_directory_for_json_output)
|
||||
set(_version_4dot "")
|
||||
macro(semver_parse str)
|
||||
set(_semver_ok FALSE)
|
||||
set(_semver_err "")
|
||||
set(_semver_major 0)
|
||||
set(_semver_minor 0)
|
||||
set(_semver_patch 0)
|
||||
set(_semver_tweak_withdot "")
|
||||
set(_semver_tweak "")
|
||||
set(_semver_extra "")
|
||||
set(_semver_prerelease_withdash "")
|
||||
set(_semver_prerelease "")
|
||||
set(_semver_buildmetadata_withplus "")
|
||||
set(_semver_buildmetadata "")
|
||||
if("${str}"
|
||||
MATCHES
|
||||
"^v?(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?([-+]-*[0-9a-zA-Z]+.*)?$"
|
||||
)
|
||||
set(_semver_major ${CMAKE_MATCH_1})
|
||||
set(_semver_minor ${CMAKE_MATCH_2})
|
||||
set(_semver_patch ${CMAKE_MATCH_3})
|
||||
set(_semver_tweak_withdot ${CMAKE_MATCH_4})
|
||||
set(_semver_tweak ${CMAKE_MATCH_5})
|
||||
set(_semver_extra "${CMAKE_MATCH_6}")
|
||||
if("${_semver_extra}" STREQUAL "")
|
||||
set(_semver_ok TRUE)
|
||||
elseif("${_semver_extra}" MATCHES "^([.-][a-zA-Z0-9-]+)*(\\+[^+]+)?$")
|
||||
set(_semver_prerelease_withdash "${CMAKE_MATCH_1}")
|
||||
if(NOT "${_semver_prerelease_withdash}" STREQUAL "")
|
||||
string(SUBSTRING "${_semver_prerelease_withdash}" 1 -1
|
||||
_semver_prerelease)
|
||||
endif()
|
||||
set(_semver_buildmetadata_withplus "${CMAKE_MATCH_2}")
|
||||
if(NOT "${_semver_buildmetadata_withplus}" STREQUAL "")
|
||||
string(SUBSTRING "${_semver_buildmetadata_withplus}" 1 -1
|
||||
_semver_buildmetadata)
|
||||
endif()
|
||||
set(_semver_ok TRUE)
|
||||
else()
|
||||
set(_semver_err
|
||||
"Поля prerelease и/или buildmetadata (строка `-foo+bar` в составе `0.0.0[.0][-foo][+bar]`) не соответствуют SemVer-спецификации"
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
set(_semver_err
|
||||
"Версионная отметка в целом не соответствует шаблону `0.0.0[.0][-foo][+bar]` SemVer-спецификации"
|
||||
)
|
||||
endif()
|
||||
endmacro(semver_parse)
|
||||
|
||||
function(_semver_parse_probe str expect)
|
||||
semver_parse(${str})
|
||||
if(expect AND NOT _semver_ok)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"semver_parse(${str}) expect SUCCESS, got ${_semver_ok}: ${_semver_err}"
|
||||
)
|
||||
elseif(NOT expect AND _semver_ok)
|
||||
message(FATAL_ERROR "semver_parse(${str}) expect FAIL, got ${_semver_ok}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(semver_parse_selfcheck)
|
||||
_semver_parse_probe("0.0.4" TRUE)
|
||||
_semver_parse_probe("v1.2.3" TRUE)
|
||||
_semver_parse_probe("10.20.30" TRUE)
|
||||
_semver_parse_probe("10.20.30.42" TRUE)
|
||||
_semver_parse_probe("1.1.2-prerelease+meta" TRUE)
|
||||
_semver_parse_probe("1.1.2+meta" TRUE)
|
||||
_semver_parse_probe("1.1.2+meta-valid" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha" TRUE)
|
||||
_semver_parse_probe("1.0.0-beta" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha.beta" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha.beta.1" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha.1" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha0.valid" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha.0valid" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha-a.b-c-somethinglong+build.1-aef.1-its-okay"
|
||||
TRUE)
|
||||
_semver_parse_probe("1.0.0-rc.1+build.1" TRUE)
|
||||
_semver_parse_probe("2.0.0-rc.1+build.123" TRUE)
|
||||
_semver_parse_probe("1.2.3-beta" TRUE)
|
||||
_semver_parse_probe("10.2.3-DEV-SNAPSHOT" TRUE)
|
||||
_semver_parse_probe("1.2.3-SNAPSHOT-123" TRUE)
|
||||
_semver_parse_probe("1.0.0" TRUE)
|
||||
_semver_parse_probe("2.0.0" TRUE)
|
||||
_semver_parse_probe("1.1.7" TRUE)
|
||||
_semver_parse_probe("2.0.0+build.1848" TRUE)
|
||||
_semver_parse_probe("2.0.1-alpha.1227" TRUE)
|
||||
_semver_parse_probe("1.0.0-alpha+beta" TRUE)
|
||||
_semver_parse_probe("1.2.3----RC-SNAPSHOT.12.9.1--.12+788" TRUE)
|
||||
_semver_parse_probe("1.2.3----R-S.12.9.1--.12+meta" TRUE)
|
||||
_semver_parse_probe("1.2.3----RC-SNAPSHOT.12.9.1--.12" TRUE)
|
||||
_semver_parse_probe("1.0.0+0.build.1-rc.10000aaa-kk-0.1" TRUE)
|
||||
_semver_parse_probe(
|
||||
"99999999999999999999999.999999999999999999.99999999999999999" TRUE)
|
||||
_semver_parse_probe("v1.0.0-0A.is.legal" TRUE)
|
||||
|
||||
_semver_parse_probe("1" FALSE)
|
||||
_semver_parse_probe("1.2" FALSE)
|
||||
# _semver_parse_probe("1.2.3-0123" FALSE)
|
||||
# _semver_parse_probe("1.2.3-0123.0123" FALSE)
|
||||
_semver_parse_probe("1.1.2+.123" FALSE)
|
||||
_semver_parse_probe("+invalid" FALSE)
|
||||
_semver_parse_probe("-invalid" FALSE)
|
||||
_semver_parse_probe("-invalid+invalid" FALSE)
|
||||
_semver_parse_probe("-invalid.01" FALSE)
|
||||
_semver_parse_probe("alpha" FALSE)
|
||||
_semver_parse_probe("alpha.beta" FALSE)
|
||||
_semver_parse_probe("alpha.beta.1" FALSE)
|
||||
_semver_parse_probe("alpha.1" FALSE)
|
||||
_semver_parse_probe("alpha+beta" FALSE)
|
||||
_semver_parse_probe("alpha_beta" FALSE)
|
||||
_semver_parse_probe("alpha." FALSE)
|
||||
_semver_parse_probe("alpha.." FALSE)
|
||||
_semver_parse_probe("beta" FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha_beta" FALSE)
|
||||
_semver_parse_probe("-alpha." FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha.." FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha..1" FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha...1" FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha....1" FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha.....1" FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha......1" FALSE)
|
||||
_semver_parse_probe("1.0.0-alpha.......1" FALSE)
|
||||
_semver_parse_probe("01.1.1" FALSE)
|
||||
_semver_parse_probe("1.01.1" FALSE)
|
||||
_semver_parse_probe("1.1.01" FALSE)
|
||||
_semver_parse_probe("1.2" FALSE)
|
||||
_semver_parse_probe("1.2.3.DEV" FALSE)
|
||||
_semver_parse_probe("1.2-SNAPSHOT" FALSE)
|
||||
_semver_parse_probe("1.2.31.2.3----RC-SNAPSHOT.12.09.1--..12+788" FALSE)
|
||||
_semver_parse_probe("1.2-RC-SNAPSHOT" FALSE)
|
||||
_semver_parse_probe("-1.0.3-gamma+b7718" FALSE)
|
||||
_semver_parse_probe("+justmeta" FALSE)
|
||||
_semver_parse_probe("9.8.7+meta+meta" FALSE)
|
||||
_semver_parse_probe("9.8.7-whatever+meta+meta" FALSE)
|
||||
_semver_parse_probe(
|
||||
"99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12"
|
||||
FALSE)
|
||||
endfunction()
|
||||
|
||||
macro(git_get_versioninfo source_root_directory)
|
||||
set(_git_describe "")
|
||||
set(_git_timestamp "")
|
||||
set(_git_tree "")
|
||||
set(_git_commit "")
|
||||
set(_git_last_vtag "")
|
||||
set(_git_trailing_commits 0)
|
||||
set(_git_is_dirty FALSE)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%cI HEAD
|
||||
OUTPUT_VARIABLE _git_timestamp
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_timestamp STREQUAL "%cI")
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%ci HEAD
|
||||
OUTPUT_VARIABLE _git_timestamp
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_timestamp STREQUAL "%ci")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`show --no-patch --format=%cI HEAD` failed)"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%T HEAD
|
||||
OUTPUT_VARIABLE _git_tree
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_tree STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`show --no-patch --format=%T HEAD` failed)"
|
||||
)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%H HEAD
|
||||
OUTPUT_VARIABLE _git_commit
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_commit STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`show --no-patch --format=%H HEAD` failed)"
|
||||
)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} status --untracked-files=no --porcelain
|
||||
OUTPUT_VARIABLE _git_status
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`status --untracked-files=no --porcelain` failed)"
|
||||
)
|
||||
endif()
|
||||
if(NOT _git_status STREQUAL "")
|
||||
set(_git_commit "DIRTY-${_git_commit}")
|
||||
set(_git_is_dirty TRUE)
|
||||
endif()
|
||||
unset(_git_status)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags --abbrev=0 "--match=v[0-9]*"
|
||||
OUTPUT_VARIABLE _git_last_vtag
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_last_vtag STREQUAL "")
|
||||
execute_process(
|
||||
COMMAND ${GIT} tag
|
||||
OUTPUT_VARIABLE _git_tags_dump
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-list --count --no-merges --remove-empty HEAD
|
||||
OUTPUT_VARIABLE _git_whole_count
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`git rev-list --count --no-merges --remove-empty HEAD` failed)"
|
||||
)
|
||||
endif()
|
||||
if(_git_whole_count GREATER 42 AND _git_tags_dump STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please fetch tags (`describe --tags --abbrev=0 --match=v[0-9]*` failed)"
|
||||
)
|
||||
else()
|
||||
message(
|
||||
NOTICE
|
||||
"Falling back to version `0.0.0` (have you made an initial release?")
|
||||
endif()
|
||||
set(_git_last_vtag "0.0.0")
|
||||
set(_git_trailing_commits ${_git_whole_count})
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags --dirty --long --always
|
||||
OUTPUT_VARIABLE _git_describe
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_describe STREQUAL "")
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags --all --dirty --long --always
|
||||
OUTPUT_VARIABLE _git_describe
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_describe STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`describe --tags --all --long` failed)"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags --dirty --long "--match=v[0-9]*"
|
||||
OUTPUT_VARIABLE _git_describe
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_describe STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`describe --tags --long --match=v[0-9]*`)"
|
||||
)
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-list --count "${_git_last_vtag}..HEAD"
|
||||
OUTPUT_VARIABLE _git_trailing_commits
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_trailing_commits STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`rev-list --count ${_git_last_vtag}..HEAD` failed)"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endmacro(git_get_versioninfo)
|
||||
|
||||
macro(semver_provide name source_root_directory build_directory_for_json_output
|
||||
build_metadata parent_scope)
|
||||
set(_semver "")
|
||||
set(_git_describe "")
|
||||
set(_git_timestamp "")
|
||||
set(_git_tree "")
|
||||
set(_git_commit "")
|
||||
set(_git_revision 0)
|
||||
set(_git_version "")
|
||||
set(_version_from "")
|
||||
set(_git_root FALSE)
|
||||
|
||||
@ -134,247 +432,29 @@ macro(fetch_version name source_root_directory parent_scope
|
||||
string(JSON _git_timestamp GET "${_versioninfo_json}" "git_timestamp")
|
||||
string(JSON _git_tree GET "${_versioninfo_json}" "git_tree")
|
||||
string(JSON _git_commit GET "${_versioninfo_json}" "git_commit")
|
||||
string(JSON _version_4dot GET "${_versioninfo_json}" "version_4dot")
|
||||
string(JSON _semver GET "${_versioninfo_json}" "semver")
|
||||
unset(_json_object)
|
||||
string(REPLACE "." ";" _version_list "${_version_4dot}")
|
||||
|
||||
if(NOT _version_4dot)
|
||||
if(NOT _semver)
|
||||
message(
|
||||
ERROR
|
||||
"Unable to retrieve ${name} version from \"${_version_from}\" file.")
|
||||
set(_version_list ${_git_version})
|
||||
string(REPLACE ";" "." _version_4dot "${_git_version}")
|
||||
else()
|
||||
string(REPLACE "." ";" _version_list ${_version_4dot})
|
||||
FATAL_ERROR
|
||||
"Unable to retrieve ${name} version from \"${_version_from}\" file.")
|
||||
endif()
|
||||
semver_parse("${_semver}")
|
||||
if(NOT _semver_ok)
|
||||
message(
|
||||
FATAL_ERROR "SemVer `${_semver}` from ${_version_from}: ${_semver_err}")
|
||||
endif()
|
||||
|
||||
elseif(_git_root AND _source_root STREQUAL _git_root)
|
||||
set(_version_from git)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%cI HEAD
|
||||
OUTPUT_VARIABLE _git_timestamp
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_timestamp STREQUAL "%cI")
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%ci HEAD
|
||||
OUTPUT_VARIABLE _git_timestamp
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_timestamp STREQUAL "%ci")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`show --no-patch --format=%cI HEAD` failed)"
|
||||
)
|
||||
endif()
|
||||
git_get_versioninfo(${source_root_directory})
|
||||
semver_parse(${_git_last_vtag})
|
||||
if(NOT _semver_ok)
|
||||
message(FATAL_ERROR "Git tag `${_git_last_vtag}`: ${_semver_err}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%T HEAD
|
||||
OUTPUT_VARIABLE _git_tree
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_tree STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`show --no-patch --format=%T HEAD` failed)"
|
||||
)
|
||||
if(_git_trailing_commits GREATER 0 AND "${_semver_tweak}" STREQUAL "")
|
||||
set(_semver_tweak ${_git_trailing_commits})
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} show --no-patch --format=%H HEAD
|
||||
OUTPUT_VARIABLE _git_commit
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_commit STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`show --no-patch --format=%H HEAD` failed)"
|
||||
)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} status --untracked-files=no --porcelain
|
||||
OUTPUT_VARIABLE _git_status
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`status --untracked-files=no --porcelain` failed)"
|
||||
)
|
||||
endif()
|
||||
if(NOT _git_status STREQUAL "")
|
||||
set(_git_commit "${_git_commit}-dirty")
|
||||
endif()
|
||||
unset(_git_status)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-list --tags --count
|
||||
OUTPUT_VARIABLE _tag_count
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`git rev-list --tags --count` failed)"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(_tag_count EQUAL 0)
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-list --all --count
|
||||
OUTPUT_VARIABLE _whole_count
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`git rev-list --all --count` failed)"
|
||||
)
|
||||
endif()
|
||||
if(_whole_count GREATER 42)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please fetch tags (no any tags for ${_whole_count} commits)")
|
||||
endif()
|
||||
set(_git_version "0;0;0")
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-list --count --all --no-merges
|
||||
OUTPUT_VARIABLE _git_revision
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_revision STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`rev-list --count --all --no-merges` failed)"
|
||||
)
|
||||
endif()
|
||||
else(_tag_count EQUAL 0)
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags --long --dirty=-dirty "--match=v[0-9]*"
|
||||
OUTPUT_VARIABLE _git_describe
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_describe STREQUAL "")
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-list --all --count
|
||||
OUTPUT_VARIABLE _whole_count
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`git rev-list --all --count` failed)"
|
||||
)
|
||||
endif()
|
||||
if(_whole_count GREATER 42)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please fetch tags (`describe --tags --long --dirty --match=v[0-9]*` failed)"
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --all --long --dirty=-dirty
|
||||
OUTPUT_VARIABLE _git_describe
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_describe STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`git rev-list --tags --count` and/or `git rev-list --all --count` failed)"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT} describe --tags --abbrev=0 "--match=v[0-9]*"
|
||||
OUTPUT_VARIABLE _last_release_tag
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`describe --tags --abbrev=0 --match=v[0-9]*` failed)"
|
||||
)
|
||||
endif()
|
||||
if(_last_release_tag)
|
||||
set(_git_revlist_arg "${_last_release_tag}..HEAD")
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND ${GIT} tag --sort=-version:refname
|
||||
OUTPUT_VARIABLE _tag_list
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`tag --sort=-version:refname` failed)"
|
||||
)
|
||||
endif()
|
||||
string(REGEX REPLACE "\n" ";" _tag_list "${_tag_list}")
|
||||
set(_git_revlist_arg "HEAD")
|
||||
foreach(_tag IN LISTS _tag_list)
|
||||
if(NOT _last_release_tag)
|
||||
string(REGEX MATCH "^v[0-9]+(\.[0-9]+)+" _last_release_tag
|
||||
"${_tag}")
|
||||
set(_git_revlist_arg "${_tag}..HEAD")
|
||||
endif()
|
||||
endforeach(_tag)
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-list --count "${_git_revlist_arg}"
|
||||
OUTPUT_VARIABLE _git_revision
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${source_root_directory}
|
||||
RESULT_VARIABLE _rc)
|
||||
if(_rc OR _git_revision STREQUAL "")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Please install latest version of git (`rev-list --count ${_git_revlist_arg}` failed)"
|
||||
)
|
||||
endif()
|
||||
|
||||
string(REGEX MATCH "^(v)?([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?"
|
||||
_git_version_valid "${_git_describe}")
|
||||
if(_git_version_valid)
|
||||
string(REGEX REPLACE "^(v)?([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?"
|
||||
"\\2;\\3;\\4" _git_version ${_git_describe})
|
||||
else()
|
||||
string(REGEX MATCH "^(v)?([0-9]+)\\.([0-9]+)(.*)?" _git_version_valid
|
||||
"${_git_describe}")
|
||||
if(_git_version_valid)
|
||||
string(REGEX REPLACE "^(v)?([0-9]+)\\.([0-9]+)(.*)?" "\\2;\\3;0"
|
||||
_git_version ${_git_describe})
|
||||
else()
|
||||
message(
|
||||
AUTHOR_WARNING
|
||||
"Bad ${name} version \"${_git_describe}\"; falling back to 0.0.0 (have you made an initial release?)"
|
||||
)
|
||||
set(_git_version "0;0;0")
|
||||
endif()
|
||||
endif()
|
||||
endif(_tag_count EQUAL 0)
|
||||
|
||||
list(APPEND _git_version "${_git_revision}")
|
||||
set(_version_list "${_git_version}")
|
||||
string(REPLACE ";" "." _version_4dot "${_version_list}")
|
||||
|
||||
elseif(GIT)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
@ -384,44 +464,68 @@ macro(fetch_version name source_root_directory parent_scope
|
||||
message(FATAL_ERROR "Требуется git для получения информации о версии")
|
||||
endif()
|
||||
|
||||
list(LENGTH _version_list _version_list_length)
|
||||
list(GET _version_list 0 _version_major)
|
||||
list(GET _version_list 1 _version_minor)
|
||||
list(GET _version_list 2 _version_release)
|
||||
list(GET _version_list 3 _version_revision)
|
||||
|
||||
if(NOT _git_describe
|
||||
OR NOT _git_timestamp
|
||||
OR NOT _git_tree
|
||||
OR NOT _git_commit
|
||||
OR _git_revision STREQUAL ""
|
||||
OR NOT _version_list_length EQUAL 4
|
||||
OR _version_major STREQUAL ""
|
||||
OR _version_minor STREQUAL ""
|
||||
OR _version_release STREQUAL ""
|
||||
OR _version_revision STREQUAL "")
|
||||
OR _semver_major STREQUAL ""
|
||||
OR _semver_minor STREQUAL ""
|
||||
OR _semver_patch STREQUAL "")
|
||||
message(ERROR "Unable to retrieve ${name} version from ${_version_from}.")
|
||||
else()
|
||||
list(APPEND _git_version "${_git_revision}")
|
||||
endif()
|
||||
|
||||
set(_semver "${_semver_major}.${_semver_minor}.${_semver_patch}")
|
||||
if(_semver_tweak STREQUAL "")
|
||||
set(_semver_tweak 0)
|
||||
elseif(_semver_tweak GREATER 0)
|
||||
string(APPEND _semver ".${_semver_tweak}")
|
||||
endif()
|
||||
if(NOT _semver_prerelease STREQUAL "")
|
||||
string(APPEND _semver "-${_semver_prerelease}")
|
||||
endif()
|
||||
if(_git_is_dirty)
|
||||
string(APPEND _semver "-DIRTY")
|
||||
endif()
|
||||
|
||||
set(_semver_complete "${_semver}")
|
||||
if(NOT "${build_metadata}" STREQUAL "")
|
||||
string(APPEND _semver_complete "+${build_metadata}")
|
||||
endif()
|
||||
|
||||
set(${name}_VERSION "${_semver_complete}")
|
||||
set(${name}_VERSION_PURE "${_semver}")
|
||||
set(${name}_VERSION_MAJOR ${_semver_major})
|
||||
set(${name}_VERSION_MINOR ${_semver_minor})
|
||||
set(${name}_VERSION_PATCH ${_semver_patch})
|
||||
set(${name}_VERSION_TWEAK "${_semver_tweak}")
|
||||
set(${name}_VERSION_PRERELEASE "${_semver_prerelease}")
|
||||
set(${name}_GIT_DESCRIBE "${_git_describe}")
|
||||
set(${name}_GIT_TIMESTAMP "${_git_timestamp}")
|
||||
set(${name}_GIT_TREE "${_git_tree}")
|
||||
set(${name}_GIT_COMMIT "${_git_commit}")
|
||||
|
||||
if(${parent_scope})
|
||||
set(${name}_VERSION
|
||||
"${_semver_complete}"
|
||||
PARENT_SCOPE)
|
||||
set(${name}_VERSION_PURE
|
||||
"${_semver}"
|
||||
PARENT_SCOPE)
|
||||
set(${name}_VERSION_MAJOR
|
||||
"${_version_major}"
|
||||
${_semver_major}
|
||||
PARENT_SCOPE)
|
||||
set(${name}_VERSION_MINOR
|
||||
"${_version_minor}"
|
||||
${_semver_minor}
|
||||
PARENT_SCOPE)
|
||||
set(${name}_VERSION_RELEASE
|
||||
"${_version_release}"
|
||||
set(${name}_VERSION_PATCH
|
||||
${_semver_patch}
|
||||
PARENT_SCOPE)
|
||||
set(${name}_VERSION_REVISION
|
||||
"${_version_revision}"
|
||||
set(${name}_VERSION_TWEAK
|
||||
"${_semver_tweak}"
|
||||
PARENT_SCOPE)
|
||||
set(${name}_VERSION
|
||||
"${_version_4dot}"
|
||||
set(${name}_VERSION_PRERELEASE
|
||||
"${_semver_prerelease}"
|
||||
PARENT_SCOPE)
|
||||
|
||||
set(${name}_GIT_DESCRIBE
|
||||
"${_git_describe}"
|
||||
PARENT_SCOPE)
|
||||
@ -434,21 +538,6 @@ macro(fetch_version name source_root_directory parent_scope
|
||||
set(${name}_GIT_COMMIT
|
||||
"${_git_commit}"
|
||||
PARENT_SCOPE)
|
||||
set(${name}_GIT_REVISION
|
||||
"${_git_revision}"
|
||||
PARENT_SCOPE)
|
||||
else()
|
||||
set(${name}_VERSION_MAJOR "${_version_major}")
|
||||
set(${name}_VERSION_MINOR "${_version_minor}")
|
||||
set(${name}_VERSION_RELEASE "${_version_release}")
|
||||
set(${name}_VERSION_REVISION "${_version_revision}")
|
||||
set(${name}_VERSION "${_version_4dot}")
|
||||
|
||||
set(${name}_GIT_DESCRIBE "${_git_describe}")
|
||||
set(${name}_GIT_TIMESTAMP "${_git_timestamp}")
|
||||
set(${name}_GIT_TREE "${_git_tree}")
|
||||
set(${name}_GIT_COMMIT "${_git_commit}")
|
||||
set(${name}_GIT_REVISION "${_git_revision}")
|
||||
endif()
|
||||
|
||||
if(_version_from STREQUAL "git")
|
||||
@ -459,12 +548,12 @@ macro(fetch_version name source_root_directory parent_scope
|
||||
\"git_timestamp\" : \"@_git_timestamp@\",
|
||||
\"git_tree\" : \"@_git_tree@\",
|
||||
\"git_commit\" : \"@_git_commit@\",
|
||||
\"version_4dot\" : \"@_version_4dot@\"\n}"
|
||||
\"semver\" : \"@_semver@\"\n}"
|
||||
_versioninfo_json
|
||||
@ONLY ESCAPE_QUOTES)
|
||||
file(WRITE "${build_directory_for_json_output}/VERSION.json"
|
||||
"${_versioninfo_json}")
|
||||
endif()
|
||||
endmacro(fetch_version)
|
||||
endmacro(semver_provide)
|
||||
|
||||
cmake_policy(POP)
|
||||
|
@ -48,7 +48,7 @@ PROJECT_NAME = libmdbx
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = "${MDBX_VERSION_MAJOR}.${MDBX_VERSION_MINOR}.${MDBX_VERSION_RELEASE}.${MDBX_VERSION_REVISION} (@MDBX_GIT_TIMESTAMP@)"
|
||||
PROJECT_NUMBER = "${MDBX_VERSION_MAJOR}.${MDBX_VERSION_MINOR}.${MDBX_VERSION_PATCH}.${MDBX_VERSION_TWEAK} (@MDBX_GIT_TIMESTAMP@)"
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
11
mdbx.h
11
mdbx.h
@ -660,12 +660,13 @@ extern "C" {
|
||||
#define LIBMDBX_VERINFO_API __dll_export
|
||||
#endif /* LIBMDBX_VERINFO_API */
|
||||
|
||||
/** \brief libmdbx version information */
|
||||
/** \brief libmdbx version information, \see https://semver.org/ */
|
||||
extern LIBMDBX_VERINFO_API const struct MDBX_version_info {
|
||||
uint8_t major; /**< Major version number */
|
||||
uint8_t minor; /**< Minor version number */
|
||||
uint16_t release; /**< Release number of Major.Minor */
|
||||
uint32_t revision; /**< Revision number of Release */
|
||||
uint16_t major; /**< Major version number */
|
||||
uint16_t minor; /**< Minor version number */
|
||||
uint16_t patch; /**< Patch number */
|
||||
uint16_t tweak; /**< Tweak number */
|
||||
const char *semver_prerelease; /**< Semantic Versioning `pre-release` */
|
||||
struct {
|
||||
const char *datetime; /**< committer date, strict ISO-8601 format */
|
||||
const char *tree; /**< commit hash (hexadecimal digits) */
|
||||
|
@ -475,8 +475,8 @@ int main(int argc, char *argv[]) {
|
||||
" - build: %s for %s by %s\n"
|
||||
" - flags: %s\n"
|
||||
" - options: %s\n",
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||
mdbx_version.revision, mdbx_version.git.describe,
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.patch,
|
||||
mdbx_version.tweak, mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||
mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
|
||||
mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
|
||||
|
@ -91,8 +91,8 @@ int main(int argc, char *argv[]) {
|
||||
" - build: %s for %s by %s\n"
|
||||
" - flags: %s\n"
|
||||
" - options: %s\n",
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||
mdbx_version.revision, mdbx_version.git.describe,
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.patch,
|
||||
mdbx_version.tweak, mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||
mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
|
||||
mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
|
||||
|
@ -86,8 +86,8 @@ int main(int argc, char *argv[]) {
|
||||
" - build: %s for %s by %s\n"
|
||||
" - flags: %s\n"
|
||||
" - options: %s\n",
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||
mdbx_version.revision, mdbx_version.git.describe,
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.patch,
|
||||
mdbx_version.tweak, mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||
mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
|
||||
mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
|
||||
|
@ -274,8 +274,8 @@ int main(int argc, char *argv[]) {
|
||||
" - build: %s for %s by %s\n"
|
||||
" - flags: %s\n"
|
||||
" - options: %s\n",
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||
mdbx_version.revision, mdbx_version.git.describe,
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.patch,
|
||||
mdbx_version.tweak, mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||
mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
|
||||
mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
|
||||
|
@ -530,8 +530,8 @@ int main(int argc, char *argv[]) {
|
||||
" - build: %s for %s by %s\n"
|
||||
" - flags: %s\n"
|
||||
" - options: %s\n",
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||
mdbx_version.revision, mdbx_version.git.describe,
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.patch,
|
||||
mdbx_version.tweak, mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||
mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
|
||||
mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
|
||||
|
@ -129,8 +129,8 @@ int main(int argc, char *argv[]) {
|
||||
" - build: %s for %s by %s\n"
|
||||
" - flags: %s\n"
|
||||
" - options: %s\n",
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.release,
|
||||
mdbx_version.revision, mdbx_version.git.describe,
|
||||
mdbx_version.major, mdbx_version.minor, mdbx_version.patch,
|
||||
mdbx_version.tweak, mdbx_version.git.describe,
|
||||
mdbx_version.git.datetime, mdbx_version.git.commit,
|
||||
mdbx_version.git.tree, mdbx_sourcery_anchor, mdbx_build.datetime,
|
||||
mdbx_build.target, mdbx_build.compiler, mdbx_build.flags,
|
||||
|
@ -25,8 +25,10 @@ __dll_export
|
||||
const struct MDBX_version_info mdbx_version = {
|
||||
${MDBX_VERSION_MAJOR},
|
||||
${MDBX_VERSION_MINOR},
|
||||
${MDBX_VERSION_RELEASE},
|
||||
${MDBX_VERSION_REVISION},
|
||||
${MDBX_VERSION_PATCH},
|
||||
${MDBX_VERSION_TWEAK},
|
||||
"@MDBX_VERSION_PRERELEASE@", /* pre-release suffix of SemVer
|
||||
@MDBX_VERSION_PURE@ */
|
||||
{"@MDBX_GIT_TIMESTAMP@", "@MDBX_GIT_TREE@", "@MDBX_GIT_COMMIT@",
|
||||
"@MDBX_GIT_DESCRIBE@"},
|
||||
sourcery};
|
||||
|
Loading…
x
Reference in New Issue
Block a user