diff --git a/Builds/CMake/deps/Rocksdb.cmake b/Builds/CMake/deps/Rocksdb.cmake index 5437bea911..6a33a8d2b5 100644 --- a/Builds/CMake/deps/Rocksdb.cmake +++ b/Builds/CMake/deps/Rocksdb.cmake @@ -8,7 +8,7 @@ set_target_properties (rocksdb_lib option (local_rocksdb "use local build of rocksdb." OFF) if (NOT local_rocksdb) - find_package (RocksDB 6.7 QUIET CONFIG) + find_package (RocksDB 6.27 QUIET CONFIG) if (TARGET RocksDB::rocksdb) message (STATUS "Found RocksDB using config.") get_target_property (_rockslib_l RocksDB::rocksdb IMPORTED_LOCATION_DEBUG) @@ -40,7 +40,7 @@ if (NOT local_rocksdb) # TBD if there is some way to extract transitive deps..then: #set (RocksDB_USE_STATIC ON) else () - find_package (RocksDB 6.7 MODULE) + find_package (RocksDB 6.27 MODULE) if (ROCKSDB_FOUND) if (RocksDB_LIBRARY_DEBUG) set_target_properties (rocksdb_lib PROPERTIES IMPORTED_LOCATION_DEBUG ${RocksDB_LIBRARY_DEBUG}) @@ -60,7 +60,7 @@ if (local_rocksdb) ExternalProject_Add (rocksdb PREFIX ${nih_cache_path} GIT_REPOSITORY https://github.com/facebook/rocksdb.git - GIT_TAG v6.7.3 + GIT_TAG v6.27.3 PATCH_COMMAND # only used by windows build ${CMAKE_COMMAND} -E copy_if_different @@ -96,9 +96,13 @@ if (local_rocksdb) -Dlz4_FOUND=ON -USNAPPY_* -Usnappy_* + -USnappy_* -Dsnappy_INCLUDE_DIRS=$,::> -Dsnappy_LIBRARIES=$,$,$> -Dsnappy_FOUND=ON + -DSnappy_INCLUDE_DIRS=$,::> + -DSnappy_LIBRARIES=$,$,$> + -DSnappy_FOUND=ON -DWITH_MD_LIBRARY=OFF -DWITH_RUNTIME_DEBUG=$,ON,OFF> -DFAIL_ON_WARNINGS=OFF diff --git a/Builds/CMake/rocksdb_build_version.cc.in b/Builds/CMake/rocksdb_build_version.cc.in index c13c23a652..9ef424669b 100644 --- a/Builds/CMake/rocksdb_build_version.cc.in +++ b/Builds/CMake/rocksdb_build_version.cc.in @@ -1,4 +1,71 @@ -#include "build_version.h" -const char* rocksdb_build_git_sha = "rocksdb_build_git_sha: N/A"; -const char* rocksdb_build_git_date = "rocksdb_build_git_date: N/A"; -const char* rocksdb_build_compile_date = "N/A"; +// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + +#include + +#include "rocksdb/version.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 = "rocksdb_build_git_sha:@GIT_SHA@"; +static const std::string rocksdb_build_git_tag = "rocksdb_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 = "rocksdb_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 = "rocksdb_build_date:@BUILD_DATE@"; +#endif + +namespace ROCKSDB_NAMESPACE { +static void AddProperty(std::unordered_map *props, const std::string& name) { + size_t colon = name.find(":"); + if (colon != std::string::npos && colon > 0 && colon < name.length() - 1) { + // If we found a "@:", then this property was a build-time substitution that failed. Skip it + size_t at = name.find("@", colon); + if (at != colon + 1) { + // Everything before the colon is the name, after is the value + (*props)[name.substr(0, colon)] = name.substr(colon + 1); + } + } +} + +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); + return properties; +} + +const std::unordered_map& GetRocksBuildProperties() { + static std::unique_ptr> props(LoadPropertiesSet()); + return *props; +} + +std::string GetRocksVersionAsString(bool with_patch) { + std::string version = ToString(ROCKSDB_MAJOR) + "." + ToString(ROCKSDB_MINOR); + if (with_patch) { + return version + "." + ToString(ROCKSDB_PATCH); + } else { + return version; + } +} + +std::string GetRocksBuildInfoAsString(const std::string& program, bool verbose) { + std::string info = program + " (RocksDB) " + GetRocksVersionAsString(true); + if (verbose) { + for (const auto& it : GetRocksBuildProperties()) { + info.append("\n "); + info.append(it.first); + info.append(": "); + info.append(it.second); + } + } + return info; +} +} // namespace ROCKSDB_NAMESPACE +