Unverified Commit f80342b8 authored by Connor's avatar Connor Committed by GitHub

print git hash (#40)

Signed-off-by: 's avatarConnor1996 <zbk602423539@gmail.com>
parent 397b6d22
......@@ -14,12 +14,13 @@ include_directories(${ROCKSDB_DIR})
include_directories(${ROCKSDB_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/util)
file(GLOB SOURCES src/*.cc)
file(GLOB TEST_SOURCES src/*test.cc)
list(REMOVE_ITEM SOURCES ${TEST_SOURCES})
add_library(titan STATIC ${SOURCES})
add_library(titan STATIC ${SOURCES} $<TARGET_OBJECTS:titan_build_version>)
option(WITH_TITAN_TESTS "Build with tests." ON)
option(WITH_TITAN_TOOLS "Build with tools." ON)
......@@ -30,6 +31,24 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(WITH_TITAN_TESTS OFF)
endif()
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
if(WIN32)
execute_process(COMMAND $ENV{COMSPEC} /C ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE GIT_SHA)
else()
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE GIT_SHA)
endif()
else()
set(GIT_SHA 0)
endif()
string(REGEX REPLACE "[^0-9a-f]+" "" GIT_SHA "${GIT_SHA}")
set(TITAN_BUILD_VERSION_CC ${CMAKE_BINARY_DIR}/titan_build_version.cc)
configure_file(util/titan_build_version.cc.in ${TITAN_BUILD_VERSION_CC} @ONLY)
add_library(titan_build_version OBJECT ${TITAN_BUILD_VERSION_CC})
target_include_directories(titan_build_version PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/util)
if (CODE_COVERAGE)
target_compile_options(titan PRIVATE "--coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
......
......@@ -15,6 +15,7 @@
#include "blob_gc.h"
#include "db_iter.h"
#include "table_factory.h"
#include "titan_build_version.h"
namespace rocksdb {
namespace titandb {
......@@ -244,6 +245,8 @@ Status TitanDBImpl::Open(const std::vector<TitanCFDescriptor>& descs,
stats_->Initialize(column_families, db_->DefaultColumnFamily()->GetID());
}
ROCKS_LOG_INFO(db_options_.info_log, "Titan DB open.");
ROCKS_LOG_HEADER(db_options_.info_log, "Titan git sha: %s",
titan_build_git_sha);
db_options_.Dump(db_options_.info_log.get());
for (auto& desc : descs) {
ROCKS_LOG_HEADER(db_options_.info_log,
......
#include "titan_build_version.h"
const char* titan_build_git_sha = "titan_build_git_sha:@@GIT_SHA@@";
#pragma once
extern const char* titan_build_git_sha;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment