]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Makefile: generate util/build_version.cc from .in file wip-cmake-build-version 13/head
authorKefu Chai <tchaikov@gmail.com>
Tue, 11 Oct 2016 07:13:09 +0000 (15:13 +0800)
committerKefu Chai <tchaikov@gmail.com>
Tue, 11 Oct 2016 07:17:19 +0000 (15:17 +0800)
* util/build_verion.cc.in: add this file, so cmake and make can share the
  template file for generating util/build_version.cc.
* CMakeLists.txt: also, cmake v2.8.11 does not support file(GENERATE ...),
  so we are using configure_file() for creating build_version.cc.
* Makefile: use util/build_verion.cc.in for creating build_version.cc.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
CMakeLists.txt
Makefile
util/build_version.cc.in [new file with mode: 0644]

index 1688e261b57b04bfc1b2b46e5544cb86013e1b53..c95c43f40cfd12842f357770b4ce2abaf76f9953 100644 (file)
@@ -80,12 +80,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)
index 5a71f457c6ca3ff77c9bb4d080d763b069930061..06f12dbf54306fa198b6cad007873f07bb4d822f 100644 (file)
--- 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 (file)
index 0000000..d2e8c57
--- /dev/null
@@ -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__;