Merge pull request #984 from zyearn/fix_missing_brpc_version_in_release

fix_missing_brpc_version_in_release
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22b685d..38469e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -91,7 +91,7 @@
 )
 
 execute_process(
-    COMMAND bash -c "git rev-parse --short HEAD | tr -d '\n'"
+    COMMAND bash -c "${PROJECT_SOURCE_DIR}/tools/get_brpc_version.sh ${PROJECT_SOURCE_DIR} | tr -d '\n'"
     OUTPUT_VARIABLE BRPC_REVISION
 )
 
diff --git a/Makefile b/Makefile
index 0049ea8..8428d65 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@
 # 2. Added -D__const__= : Avoid over-optimizations of TLS variables by GCC>=4.8
 # 3. Removed -Werror: Not block compilation for non-vital warnings, especially when the
 #    code is tested on newer systems. If the code is used in production, add -Werror back
-CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"$(shell git rev-parse --short HEAD)\"
+CPPFLAGS+=-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DNDEBUG -DBRPC_REVISION=\"$(shell ./tools/get_brpc_version.sh .)\"
 CXXFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x
 CFLAGS=$(CPPFLAGS) -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer
 DEBUG_CXXFLAGS = $(filter-out -DNDEBUG,$(CXXFLAGS)) -DUNIT_TEST -DBVAR_NOT_LINK_DEFAULT_VARIABLES
diff --git a/RELEASE_VERSION b/RELEASE_VERSION
new file mode 100644
index 0000000..c81aa44
--- /dev/null
+++ b/RELEASE_VERSION
@@ -0,0 +1 @@
+0.9.7
diff --git a/tools/get_brpc_version.sh b/tools/get_brpc_version.sh
new file mode 100755
index 0000000..919470c
--- /dev/null
+++ b/tools/get_brpc_version.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+output=$(cat $1/RELEASE_VERSION)
+version=$(git log -1 --format="%h\\|%cI" 2> /dev/null)
+branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
+if [ $? -eq 0 ]
+then
+    output=$output"\\|"$branch"\\|"$version
+fi
+echo $output