Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ scripts/docs/en/components_schema
scripts/docs/en/dynamic_configs
scripts/docs/en/versions.md
scripts/docs/scripts/versions.js
universal/include/userver/version.hpp
5 changes: 3 additions & 2 deletions cmake/GetUserverVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ endif()

file(READ ${USERVER_ROOT_DIR}/version.txt VERSION)
string(STRIP ${VERSION} VERSION)
string(REGEX MATCH "^([0-9]+)\.([0-9]+[\-a-z0-9]*)" USERVER_MATCHED_VERSION_STRING "${VERSION}")
string(REGEX MATCH "^([0-9]+)\.([0-9]+)([\-a-z0-9]*)" USERVER_MATCHED_VERSION_STRING "${VERSION}")
if(NOT USERVER_MATCHED_VERSION_STRING STREQUAL VERSION)
message(FATAL_ERROR "Failed to retrieve userver major/minor version number from '${VERSION}'")
endif()
set(USERVER_MAJOR_VERSION ${CMAKE_MATCH_1})
set(USERVER_MINOR_VERSION ${CMAKE_MATCH_2})
set(USERVER_RELEASE_CANDIDATE ${CMAKE_MATCH_3})

set(USERVER_VERSION "${USERVER_MAJOR_VERSION}.${USERVER_MINOR_VERSION}")
set(USERVER_VERSION "${USERVER_MAJOR_VERSION}.${USERVER_MINOR_VERSION}${USERVER_RELEASE_CANDIDATE}")
string(REPLACE "-" "_" USERVER_VERSION_STR "${USERVER_VERSION}")
string(REPLACE "." "_" USERVER_VERSION_STR "${USERVER_VERSION_STR}")
set(USERVER_VERSION_STR "v${USERVER_VERSION_STR}")
7 changes: 7 additions & 0 deletions universal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ target_compile_definitions(
"USERVER_NAMESPACE_END=${USERVER_NAMESPACE_END}" "USERVER=1"
)

set(VERSION_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/include/userver/version.hpp)
math(EXPR USERVER_VERSION_FULL "10000 * ${USERVER_MAJOR_VERSION} + 100 * ${USERVER_MINOR_VERSION}")
if(USERVER_RELEASE_CANDIDATE)
math(EXPR USERVER_VERSION_FULL "${USERVER_VERSION_FULL} - 1")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.hpp.in ${VERSION_CONFIG} ESCAPE_QUOTES @ONLY)

# https://github.com/jemalloc/jemalloc/issues/820
if(USERVER_FEATURE_JEMALLOC
AND NOT USERVER_SANITIZE
Expand Down
18 changes: 18 additions & 0 deletions universal/version.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

/// @file userver/version.hpp
/// @brief Version macro

/// @brief Version in form of `10000*major + 100*minor - (is_rc ? 1 : 0)`
///
/// Examples:
/// @code
/// 2.1 -> 20100
/// 2.16 -> 21600
/// 2.16-rc -> 21599
/// 3.0 -> 30000
/// 3.0-rc -> 29999
/// @endcode
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define USERVER_VERSION_FULL @USERVER_VERSION_FULL@

2 changes: 1 addition & 1 deletion ydb/functional_tests/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project(userver-ydb-tests-basic CXX)

add_executable(
${PROJECT_NAME} "ydb_service.cpp" "views/describe-table/post/view.cpp" "views/select-list/post/view.cpp"
"views/select-rows/post/view.cpp" "views/upsert-row/post/view.cpp" "views/upsert-row-old/post/view.cpp""
"views/select-rows/post/view.cpp" "views/upsert-row/post/view.cpp" "views/upsert-row-old/post/view.cpp"
)
target_link_libraries(${PROJECT_NAME} userver::ydb)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down
Loading