Append the version number to the name reported to the server

This commit is contained in:
King_DuckZ 2020-08-16 15:42:45 +01:00
parent cef5060eb2
commit 1fcd7bd749
4 changed files with 40 additions and 1 deletions

View file

@ -25,5 +25,8 @@ constexpr const char g_base_url[] = @BASE_URL@;
constexpr const char g_config_file_path[] = @CONFIG_FILE_PATH@;
constexpr const char g_def_sqlite_db_name[] = @DEF_SQLITE_DB_NAME@;
constexpr const char g_def_worker_threads[] = "2";
constexpr const unsigned short int g_version_major = @PROJECT_VERSION_MAJOR@;
constexpr const unsigned short int g_version_minor = @PROJECT_VERSION_MINOR@;
constexpr const unsigned short int g_version_patch = @PROJECT_VERSION_PATCH@;
} //namespace duck

View file

@ -20,6 +20,8 @@
#include "orotool_config.hpp"
#include "evloop.hpp"
#include "app_config.hpp"
#include "duckhandy/int_conv.hpp"
#include "duckhandy/string_bt.hpp"
#include <iostream>
#include <restc-cpp/error.h>
@ -38,6 +40,25 @@ namespace {
std::cout << "answer: " << ping.second.message << '\n';
std::cout << "version: " << ping.second.version << '\n';
}
constexpr auto app_version() {
constexpr const auto dot = dhandy::bt::make_string(".");
constexpr const auto maj = dhandy::int_to_ary(duck::g_version_major);
constexpr const auto min = dhandy::int_to_ary(duck::g_version_minor);
constexpr const auto pat = dhandy::int_to_ary(duck::g_version_patch);
constexpr const dhandy::bt::string<maj.size(), char> maj_n(maj.data());
constexpr const dhandy::bt::string<min.size(), char> min_n(min.data());
constexpr const dhandy::bt::string<pat.size(), char> pat_n(pat.data());
return (maj_n + dot + min_n + dot + pat_n);
}
constexpr auto app_api_name() {
constexpr const auto name = dhandy::bt::make_string(duck::g_project_name);
constexpr const auto us = dhandy::bt::make_string("_");
return (name + us + app_version());
}
} //unnamed namespace
int main(int argc, char* argv[]) {
@ -47,7 +68,7 @@ int main(int argc, char* argv[]) {
oro::Api oro_api(
duck::g_base_url,
std::string(api_key),
duck::g_project_name,
app_api_name().data(),
duck::g_build_purpose
);

View file

@ -29,6 +29,10 @@ if get_option('buildtype') == 'debug'
else
conf.set_quoted('BUILD_PURPOSE', 'Production')
endif
version_arr = meson.project_version().split('.')
conf.set('PROJECT_VERSION_MAJOR', version_arr[0])
conf.set('PROJECT_VERSION_MINOR', version_arr[1])
conf.set('PROJECT_VERSION_PATCH', version_arr[2])
project_config_file = configure_file(
input: 'config.hpp.in',
output: meson.project_name() + '_config.hpp',

View file

@ -21,6 +21,9 @@
#include <restc-cpp/restc-cpp.h>
#include <restc-cpp/RequestBuilder.h>
#include <boost/fusion/adapted.hpp>
#if !defined(NDEBUG)
# include <iostream>
#endif
namespace rc = restc_cpp;
@ -189,6 +192,14 @@ Api::Api (
{
if (not m_prefix.empty() and m_prefix[m_prefix.size() - 1] != '/')
m_prefix.push_back('/');
#if !defined(NDEBUG)
std::cout << "OriginsRO API settings\n" <<
"\troot_address: \"" << m_prefix << "\"\n" <<
"\tapi_key: \"" << m_api_key << "\"\n" <<
"\tclient_name: \"" << m_client_name << "\"\n" <<
"\tclient_purpose: \"" << m_client_purpose << "\"\n" <<
"";
#endif
}
Api::~Api() noexcept = default;