Files
thehub/libs/utils/clientversion.cpp

92 lines
3.2 KiB
C++

/*
* This file is part of the Flowee project
* Copyright (c) 2012-2014 The Bitcoin Core developers
* Copyright (C) 2021 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clientversion.h"
#include "tinyformat.h"
#include <string>
/**
* Client version number
*/
#define CLIENT_VERSION_SUFFIX ""
/**
* The following part of the code determines the CLIENT_BUILD variable.
* Several mechanisms are used for this:
* * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is
* generated by the build environment, possibly containing the output
* of git-describe in a macro called BUILD_DESC
* * secondly, if this is an exported version of the code, GIT_ARCHIVE will
* be defined (automatically using the export-subst git attribute), and
* GIT_COMMIT will contain the commit id.
* * then, three options exist for determining CLIENT_BUILD:
* * if BUILD_DESC is defined, use that literally (output of git-describe)
* * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit]
* * otherwise, use v[maj].[min].[rev].[build]-unk
* finally CLIENT_VERSION_SUFFIX is added
*/
//! First, include build.h if requested
#ifdef HAVE_BUILD_INFO
#include "build.h"
#endif
// Make sure that git not found (or similar) is Ok
#ifndef GIT_COMMIT_ID
# define GIT_COMMIT_ID ":"
#endif
#define BUILD_DESC_WITH_SUFFIX(maj, min, rev, series, suffix) \
DO_STRINGIZE(maj) "-" DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "-" DO_STRINGIZE(suffix) " (v" DO_STRINGIZE(series) ")"
#define BUILD_DESC_SIMPLE(maj, min, series) \
DO_STRINGIZE(maj) "-" DO_STRINGIZE(min) "-" GIT_COMMIT_ID " (v" DO_STRINGIZE(series) ")"
#define BUILD_DESC_NO_SUFFIX(maj, min, rev, series) \
DO_STRINGIZE(maj) "-" DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "-" GIT_COMMIT_ID " (v" DO_STRINGIZE(series) ")"
#ifndef BUILD_DESC
#ifdef BUILD_SUFFIX
#define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, HUB_SERIES, BUILD_SUFFIX)
#elif CLIENT_VERSION_REVISION == 1
#define BUILD_DESC BUILD_DESC_SIMPLE(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, HUB_SERIES)
#else
#define BUILD_DESC BUILD_DESC_NO_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, HUB_SERIES)
#endif
#endif
#ifndef BUILD_DATE
#ifdef GIT_COMMIT_DATE
#define BUILD_DATE GIT_COMMIT_DATE
#else
#define BUILD_DATE __DATE__ ", " __TIME__
#endif
#endif
const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);
const std::string CLIENT_DATE(BUILD_DATE);
std::string FormatFullVersion()
{
return CLIENT_BUILD;
}