提交 dc21069a 编写于 作者: S Simon Fels

Rework versioning to include git rev in snap version

上级 4a5ce925
......@@ -97,12 +97,11 @@ set(ANBOX_TRANSLATOR_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/anbox/translators)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTRANSLATOR_INSTALL_DIR=\\\"${CMAKE_INSTALL_PREFIX}/${ANBOX_TRANSLATOR_INSTALL_DIR}\\\"")
if (NOT ANBOX_VERSION)
set(ANBOX_VERSION 2)
if ("${cmake_build_type_lower}" STREQUAL "release")
set(ANBOX_VERSION_SUFFIX "")
else()
set(ANBOX_VERSION_SUFFIX dev)
endif()
exec_program("git" ${CMAKE_SOURCE_DIR} ARGS "rev-parse --short HEAD" OUTPUT_VARIABLE GIT_COMMIT_HASH)
set(ANBOX_VERSION "local-${GIT_COMMIT_HASH}")
endif()
if (ANBOX_VERSION_SUFFIX)
set(ANBOX_VERSION "${ANBOX_VERSION}-${ANBOX_VERSION_SUFFIX}")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h.in
${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h)
......
name: anbox
# NOTE: Always only use increasing numeric values here. This is
# passed down into cmake and assigned to an integer variable which
# can be used for version number comparision inside the code base
# to accomondate for any breaking changes.
version: 3
version-script: |
if [ "$SNAPCRAFT_GRADE" = "stable" ]; then
echo $SNAPCRAFT_PROJECT_VERSION
else
echo $SNAPCRAFT_PROJECT_VERSION-$(git rev-parse --short HEAD)
fi
summary: Android in a Box
description: |
Runtime for Android applications which runs a full Android system
......
......@@ -25,9 +25,9 @@ namespace build {
static std::string init_version_string() {
std::string v;
if (!version_suffix || std::strlen(version_suffix) == 0)
v = utils::string_format("%d", version_major);
v = utils::string_format("%s", version);
else
v = utils::string_format("%d-%s", version_major, version_suffix);
v = utils::string_format("%s-%s", version, version_suffix);
return v;
}
......
......@@ -25,8 +25,8 @@
namespace anbox {
namespace build {
/// @brief version_major marks the major version
static constexpr const std::uint32_t version_major{@ANBOX_VERSION@};
/// @brief version marks the version
static constexpr const char *version{"@ANBOX_VERSION@"};
/// @brief version_suffix is an additional suffix which can be amended to
/// the major version number to indicate a dev build for example.
static constexpr const char *version_suffix{"@ANBOX_VERSION_SUFFIX@"};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册