diff --git a/CMakeLists.txt b/CMakeLists.txt index 677fadc08..6c3a012f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,12 +79,7 @@ endif() string(REGEX REPLACE "[^0-9a-f]+" "" GIT_SHA "${GIT_SHA}") set(BUILD_VERSION_CC ${CMAKE_BINARY_DIR}/build_version.cc) -file(GENERATE OUTPUT ${BUILD_VERSION_CC} CONTENT - "#include \"build_version.h\" -const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:${GIT_SHA}\"; -const char* rocksdb_build_git_datetime = \"rocksdb_build_git_datetime:${GIT_DATE_TIME}\"; -const char* rocksdb_build_compile_date = __DATE__; -") +configure_file(util/build_version.cc.in ${BUILD_VERSION_CC} @ONLY) add_library(build_version OBJECT ${BUILD_VERSION_CC}) target_include_directories(build_version PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/util) diff --git a/Makefile b/Makefile index 9d0c14931..d88ec9418 100644 --- a/Makefile +++ b/Makefile @@ -231,14 +231,7 @@ ifdef FORCE_GIT_SHA else git_sha := $(shell git rev-parse HEAD 2>/dev/null) endif -gen_build_version = \ - printf '%s\n' \ - '\#include "build_version.h"' \ - 'const char* rocksdb_build_git_sha = \ - "rocksdb_build_git_sha:$(git_sha)";' \ - 'const char* rocksdb_build_git_date = \ - "rocksdb_build_git_date:$(date)";' \ - 'const char* rocksdb_build_compile_date = __DATE__;' +gen_build_version = sed -e s/@@GIT_SHA@@/$(git_sha)/ -e s/@@GIT_DATE_TIME@@/$(date)/ util/build_version.cc.in # Record the version of the source that we are compiling. # We keep a record of the git revision in this file. It is then built diff --git a/util/build_version.cc.in b/util/build_version.cc.in new file mode 100644 index 000000000..d2e8c5780 --- /dev/null +++ b/util/build_version.cc.in @@ -0,0 +1,4 @@ +#include "build_version.h" +const char* rocksdb_build_git_sha = "rocksdb_build_git_sha:@@GIT_SHA@@"; +const char* rocksdb_build_git_date = "rocksdb_build_git_date:@@GIT_DATE_TIME@@"; +const char* rocksdb_build_compile_date = __DATE__;