Rework version string initialization
This commit is contained in:
parent
6c65da7a2c
commit
7b737733ba
1 changed files with 12 additions and 7 deletions
|
|
@ -18,16 +18,21 @@
|
||||||
#include "anbox/build/version.h"
|
#include "anbox/build/version.h"
|
||||||
#include "anbox/utils.h"
|
#include "anbox/utils.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace build {
|
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);
|
||||||
|
else
|
||||||
|
v = utils::string_format("%d-%s", version_major, version_suffix);
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
std::string print_version() {
|
std::string print_version() {
|
||||||
static std::string v;
|
static const std::string v{init_version_string()};
|
||||||
if (v.empty()) {
|
|
||||||
if (version_suffix.empty())
|
|
||||||
v = utils::string_format("%d", version_major);
|
|
||||||
else
|
|
||||||
v = utils::string_format("%d-%s", version_major, version_suffix);
|
|
||||||
}
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
} // namespace build
|
} // namespace build
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue