diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index aa1f073e8f..bc57eceb8d 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -84,6 +84,7 @@ #include "rocksdb/table.h" #include "rocksdb/version.h" #include "rocksdb/write_buffer_manager.h" +#include "speedb/version.h" #include "table/block_based/block.h" #include "table/block_based/block_based_table_factory.h" #include "table/get_context.h" @@ -4899,7 +4900,8 @@ void DBImpl::EraseThreadStatusDbInfo() const {} // // A global method that can dump out the build version void DumpRocksDBBuildVersion(Logger* log) { - ROCKS_LOG_HEADER(log, "SpeeDB version: %s\n", + ROCKS_LOG_HEADER(log, "SpeeDB version: %s (%s)\n", + GetSpeedbVersionAsString().c_str(), GetRocksVersionAsString().c_str()); const auto& props = GetRocksBuildProperties(); const auto& sha = props.find("speedb_build_git_sha"); diff --git a/speedb/version.h b/speedb/version.h new file mode 100644 index 0000000000..d3e569b726 --- /dev/null +++ b/speedb/version.h @@ -0,0 +1,12 @@ +#pragma once + +#define SPEEDB_MAJOR 1 +#define SPEEDB_MINOR 5 +#define SPEEDB_PATCH 0 + +namespace ROCKSDB_NAMESPACE { +// Returns the current version of SpeeDB as a string (e.g. "1.5.0"). +// If with_patch is true, the patch is included (1.5.x). +// Otherwise, only major and minor version is included (1.5) +std::string GetSpeedbVersionAsString(bool with_patch = true); +} // namespace ROCKSDB_NAMESPACE diff --git a/util/build_version.cc.in b/util/build_version.cc.in index 57c842cc68..26c85df466 100644 --- a/util/build_version.cc.in +++ b/util/build_version.cc.in @@ -3,24 +3,28 @@ #include #include "rocksdb/version.h" +#include "speedb/version.h" #include "rocksdb/utilities/object_registry.h" #include "util/string_util.h" // The build script may replace these values with real values based // on whether or not GIT is available and the platform settings -static const std::string rocksdb_build_git_sha = "speedb_build_git_sha:@GIT_SHA@"; -static const std::string rocksdb_build_git_tag = "speedb_build_git_tag:@GIT_TAG@"; +static const std::string speedb_build_git_sha = "speedb_build_git_sha:@GIT_SHA@"; +static const std::string speedb_build_git_tag = "speedb_build_git_tag:@GIT_TAG@"; #define HAS_GIT_CHANGES @GIT_MOD@ #if HAS_GIT_CHANGES == 0 // If HAS_GIT_CHANGES is 0, the GIT date is used. // Use the time the branch/tag was last modified -static const std::string rocksdb_build_date = "speedb_build_date:@GIT_DATE@"; +static const std::string speedb_build_date = "speedb_build_date:@GIT_DATE@"; #else // If HAS_GIT_CHANGES is > 0, the branch/tag has modifications. // Use the time the build was created. -static const std::string rocksdb_build_date = "speedb_build_date:@BUILD_DATE@"; +static const std::string speedb_build_date = "speedb_build_date:@BUILD_DATE@"; #endif +#define SPDB_BUILD_TAG "@SPDB_BUILD_TAG@" +static const std::string speedb_build_tag = "speedb_build_tag:" SPDB_BUILD_TAG; + #ifndef ROCKSDB_LITE extern "C" { @ROCKSDB_PLUGIN_EXTERNS@ @@ -46,9 +50,14 @@ static void AddProperty(std::unordered_map *props, con static std::unordered_map* LoadPropertiesSet() { auto * properties = new std::unordered_map(); - AddProperty(properties, rocksdb_build_git_sha); - AddProperty(properties, rocksdb_build_git_tag); - AddProperty(properties, rocksdb_build_date); + AddProperty(properties, speedb_build_git_sha); + AddProperty(properties, speedb_build_git_tag); + AddProperty(properties, speedb_build_date); + if (SPDB_BUILD_TAG[0] == '@') { + AddProperty(properties, "?"); + } else { + AddProperty(properties, speedb_build_tag); + } return properties; } @@ -60,14 +69,32 @@ const std::unordered_map& GetRocksBuildProperties() { std::string GetRocksVersionAsString(bool with_patch) { std::string version = std::to_string(ROCKSDB_MAJOR) + "." + std::to_string(ROCKSDB_MINOR); if (with_patch) { - return version + "." + std::to_string(ROCKSDB_PATCH); + return version + "." + ToString(ROCKSDB_PATCH); } else { return version; - } + } +} + +std::string GetSpeedbVersionAsString(bool with_patch) { + std::string version = ToString(SPEEDB_MAJOR) + "." + ToString(SPEEDB_MINOR); + if (with_patch) { + version += "." + ToString(SPEEDB_PATCH); + // Only add a build tag if it was specified (e.g. not a release build) + if (SPDB_BUILD_TAG[0] != '\0') { + if (SPDB_BUILD_TAG[0] == '@') { + // In case build tag substitution at build time failed, add a question mark + version += "-?"; + } else { + version += "-" + std::string(SPDB_BUILD_TAG); + } + } + } + return version; } std::string GetRocksBuildInfoAsString(const std::string& program, bool verbose) { - std::string info = program + " (SpeeDB) " + GetRocksVersionAsString(true); + std::string info = program + " (Speedb) " + GetSpeedbVersionAsString(true) + + " (" + GetRocksVersionAsString(true) + ")"; if (verbose) { for (const auto& it : GetRocksBuildProperties()) { info.append("\n ");