mirror of
https://github.com/matrix-construct/construct
synced 2024-09-27 11:18:51 +02:00
ircd::info: Do autogeneration of missing version string in ctor.
This commit is contained in:
parent
f2e84a6b0e
commit
364e98d564
3 changed files with 27 additions and 25 deletions
11
ircd/db.cc
11
ircd/db.cc
|
@ -98,22 +98,13 @@ ircd::db::version_api
|
||||||
"RocksDB", info::versions::API, 0,
|
"RocksDB", info::versions::API, 0,
|
||||||
{
|
{
|
||||||
ROCKSDB_MAJOR, ROCKSDB_MINOR, ROCKSDB_PATCH,
|
ROCKSDB_MAJOR, ROCKSDB_MINOR, ROCKSDB_PATCH,
|
||||||
},
|
|
||||||
|
|
||||||
// version string generator
|
|
||||||
[](auto &version, const auto &buf)
|
|
||||||
{
|
|
||||||
::snprintf(data(buf), size(buf), "%ld.%ld.%ld",
|
|
||||||
version[0],
|
|
||||||
version[1],
|
|
||||||
version[2]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
decltype(ircd::db::version_abi)
|
decltype(ircd::db::version_abi)
|
||||||
ircd::db::version_abi
|
ircd::db::version_abi
|
||||||
{
|
{
|
||||||
"RocksDB", info::versions::ABI, 0, {0}, "<unknown>" //TODO: get this
|
"RocksDB", info::versions::ABI //TODO: get this
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
30
ircd/info.cc
30
ircd/info.cc
|
@ -169,12 +169,15 @@ ircd::info::versions::versions(const string_view &name,
|
||||||
const long &monotonic,
|
const long &monotonic,
|
||||||
const std::array<long, 3> &semantic,
|
const std::array<long, 3> &semantic,
|
||||||
const string_view &string)
|
const string_view &string)
|
||||||
:name{name}
|
:versions
|
||||||
,type{type}
|
{
|
||||||
,monotonic{monotonic}
|
name, type, monotonic, semantic, [&string]
|
||||||
,semantic{semantic}
|
(auto &that, const mutable_buffer &buf)
|
||||||
|
{
|
||||||
|
strlcpy(buf, string);
|
||||||
|
}
|
||||||
|
}
|
||||||
{
|
{
|
||||||
strlcpy(this->string, string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construction of versions members with closure for custom string generation.
|
/// Construction of versions members with closure for custom string generation.
|
||||||
|
@ -190,6 +193,23 @@ ircd::info::versions::versions(const string_view &name,
|
||||||
,semantic{semantic}
|
,semantic{semantic}
|
||||||
{
|
{
|
||||||
closure(*this, this->string);
|
closure(*this, this->string);
|
||||||
|
|
||||||
|
// User provided a string already; nothing else to do
|
||||||
|
if(strnlen(this->string, sizeof(this->string)) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Generate a string from the semantic version number or if all zeroes
|
||||||
|
// from the monotonic version number instead.
|
||||||
|
if(monotonic && !semantic[0] && !semantic[1] && !semantic[2])
|
||||||
|
::snprintf(this->string, sizeof(this->string), "%ld",
|
||||||
|
monotonic);
|
||||||
|
else if(!monotonic)
|
||||||
|
::snprintf(this->string, sizeof(this->string), "%ld.%ld.%ld",
|
||||||
|
semantic[0],
|
||||||
|
semantic[1],
|
||||||
|
semantic[2]);
|
||||||
|
else
|
||||||
|
::snprintf(this->string, sizeof(this->string), "<unknown>");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
11
ircd/ios.cc
11
ircd/ios.cc
|
@ -32,22 +32,13 @@ ircd::boost_version_api
|
||||||
BOOST_VERSION / 100000,
|
BOOST_VERSION / 100000,
|
||||||
BOOST_VERSION / 100 % 1000,
|
BOOST_VERSION / 100 % 1000,
|
||||||
BOOST_VERSION % 100,
|
BOOST_VERSION % 100,
|
||||||
},
|
|
||||||
|
|
||||||
// Version string generator since boost doesn't provide any strings.
|
|
||||||
[](auto &version, const auto &buf)
|
|
||||||
{
|
|
||||||
::snprintf(data(buf), size(buf), "%ld.%ld.%ld",
|
|
||||||
version[0],
|
|
||||||
version[1],
|
|
||||||
version[2]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
decltype(ircd::boost_version_abi)
|
decltype(ircd::boost_version_abi)
|
||||||
ircd::boost_version_abi
|
ircd::boost_version_abi
|
||||||
{
|
{
|
||||||
"boost", info::versions::ABI, 0, {0}, "<unknown>" //TODO: get this
|
"boost", info::versions::ABI //TODO: get this
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue