Set version we're building from snapcraft
This commit is contained in:
parent
3c70c4a80d
commit
45ac3ecf6a
7 changed files with 43 additions and 64 deletions
|
|
@ -94,6 +94,17 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC")
|
|||
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 VERSION)
|
||||
set(VERSION 2)
|
||||
if ("${cmake_build_type_lower}" STREQUAL "release")
|
||||
set(VERSION_SUFFIX "")
|
||||
else()
|
||||
set(VERSION_SUFFIX dev)
|
||||
endif()
|
||||
endif()
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/version.h)
|
||||
|
||||
add_subdirectory(external)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
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: 2
|
||||
summary: Android in a Box
|
||||
description: |
|
||||
|
|
@ -84,6 +88,7 @@ parts:
|
|||
# FIXME: Anbox currently has some paths with hard coded prefixes. Once
|
||||
# that is fixed we can avoid using a prefix here.
|
||||
- -DCMAKE_INSTALL_PREFIX:PATH=/usr
|
||||
- -DVERSION=$SNAPCRAFT_PROJECT_VERSION
|
||||
build-packages:
|
||||
- build-essential
|
||||
- cmake
|
||||
|
|
|
|||
|
|
@ -57,11 +57,13 @@ set(SOURCES
|
|||
anbox/utils.cpp
|
||||
anbox/cli.cpp
|
||||
anbox/runtime.cpp
|
||||
anbox/version.cpp
|
||||
anbox/daemon.cpp
|
||||
anbox/config.cpp
|
||||
anbox/not_reachable.cpp
|
||||
|
||||
anbox/build/version.cpp
|
||||
anbox/build/version.h.in
|
||||
|
||||
anbox/android/intent.cpp
|
||||
|
||||
anbox/common/fd.cpp
|
||||
|
|
|
|||
|
|
@ -17,11 +17,22 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "anbox/version.h"
|
||||
#ifndef ANBOX_VERSION_H_
|
||||
#define ANBOX_VERSION_H_
|
||||
|
||||
void anbox::version(std::uint32_t& major, std::uint32_t& minor,
|
||||
std::uint32_t& patch) {
|
||||
major = anbox::build::version_major;
|
||||
minor = anbox::build::version_minor;
|
||||
patch = anbox::build::version_patch;
|
||||
}
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace anbox {
|
||||
namespace build {
|
||||
/// @brief version_major marks the major version
|
||||
static constexpr const std::uint32_t version_major{@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 const std::string version_suffix{"@VERSION_SUFFIX@"};
|
||||
/// @brief version queries the version of Anbox
|
||||
std::string version();
|
||||
} // namespace build
|
||||
} // namespace anbox
|
||||
|
||||
#endif // ANBOX_VERSION_H_
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#include "anbox/graphics/emugl/RenderApi.h"
|
||||
#include "anbox/graphics/emugl/DispatchTables.h"
|
||||
#include "anbox/utils/environment_file.h"
|
||||
#include "anbox/version.h"
|
||||
#include "anbox/logger.h"
|
||||
#include "anbox/version.h"
|
||||
|
||||
#include "anbox/build/version.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
|
@ -50,10 +50,7 @@ class SystemInformation {
|
|||
std::stringstream s;
|
||||
|
||||
s << "version: "
|
||||
<< anbox::utils::string_format("%d.%d.%d",
|
||||
anbox::build::version_major,
|
||||
anbox::build::version_minor,
|
||||
anbox::build::version_patch)
|
||||
<< anbox::build::version()
|
||||
<< std::endl;
|
||||
|
||||
s << "os:" << std::endl
|
||||
|
|
|
|||
|
|
@ -18,16 +18,15 @@
|
|||
*/
|
||||
|
||||
#include "anbox/cmds/version.h"
|
||||
#include "anbox/version.h"
|
||||
#include "anbox/build/version.h"
|
||||
#include "anbox/utils.h"
|
||||
|
||||
anbox::cmds::Version::Version()
|
||||
: CommandWithFlagsAndAction{
|
||||
cli::Name{"version"}, cli::Usage{"version"},
|
||||
cli::Description{"print the version of the daemon"}} {
|
||||
action([](const cli::Command::Context& ctxt) {
|
||||
std::uint32_t major, minor, patch;
|
||||
anbox::version(major, minor, patch);
|
||||
ctxt.cout << "anbox " << major << "." << minor << "." << patch << std::endl;
|
||||
ctxt.cout << "anbox " << build::version() << std::endl;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Canonical, Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; version 3.
|
||||
*
|
||||
* 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authored by: Thomas Voß <thomas.voss@canonical.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ANBOX_VERSION_H_
|
||||
#define ANBOX_VERSION_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace anbox {
|
||||
namespace build {
|
||||
/// @brief version_major marks the major version of the library. The constant is
|
||||
/// meant to be used
|
||||
/// by client code both at build and runtime, enabling version checks.
|
||||
static constexpr const std::uint32_t version_major{0};
|
||||
/// @brief version_major marks the minor version of the library. The constant is
|
||||
/// meant to be used
|
||||
/// by client code both at build and runtime, enabling version checks.
|
||||
static constexpr const std::uint32_t version_minor{1};
|
||||
/// @brief version_patch marks the major version of the library. The constant is
|
||||
/// meant to be used
|
||||
/// by client code both at build and runtime, enabling version checks.
|
||||
static constexpr const std::uint32_t version_patch{0};
|
||||
} // namespace build
|
||||
|
||||
/// @brief version queries the version of the library, placing the result in
|
||||
/// major, minor and patch.
|
||||
void version(std::uint32_t& major, std::uint32_t& minor, std::uint32_t& patch);
|
||||
} // namespace build
|
||||
|
||||
#endif // ANBOX_VERSION_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue