diff --git a/.gitignore b/.gitignore index 1c2d2b3780402130b0122675d9ae867d995199a0..03a5f1761a5210a34db053c701c86701484466be 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,4 @@ sst_dump util/build_version.cc build_tools/VALGRIND_LOGS/ coverage/COVERAGE_REPORT -util/build_version.cc.tmp .gdbhistory diff --git a/build_tools/build_detect_version b/build_tools/build_detect_version index 3ee6c92bd2d867a6e747b090539a718f36c1773e..f7d711f0ddd7af9d00d98a5d817d5341d4008c4a 100755 --- a/build_tools/build_detect_version +++ b/build_tools/build_detect_version @@ -5,38 +5,18 @@ # is then built as a regular source file as part of the compilation process. # One can run "strings executable_filename | grep _build_" to find the version of # the source that we used to build the executable file. -# - -# create git version file -VFILE=$PWD/util/build_version.cc.tmp -trap "rm $VFILE" EXIT -# check to see if git is in the path -which git > /dev/null +OUTFILE="$PWD/util/build_version.cc" -if [ "$?" = 0 ]; then - env -i git rev-parse HEAD 2>&1 | - awk ' - BEGIN { - print "#include \"build_version.h\"\n" - } - { print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:" $0"\";" } - ' > ${VFILE} -else - echo "git not found" | - awk ' - BEGIN { - print "#include \"build_version.h\"" - } - { print "const char* rocksdb_build_git_sha = \"rocksdb_build_git_sha:git not found\";" } - ' > ${VFILE} +GIT_SHA="" +if command -v git >/dev/null 2>&1; then + GIT_SHA=$(git rev-parse HEAD 2>/dev/null) fi -echo "const char* rocksdb_build_git_datetime = \"rocksdb_build_git_datetime:$(date)\";" >> ${VFILE} -echo "const char* rocksdb_build_compile_date = __DATE__;" >> ${VFILE} -echo "const char* rocksdb_build_compile_time = __TIME__;" >> ${VFILE} - -OUTFILE=$PWD/util/build_version.cc -if [ ! -e $OUTFILE ] || ! cmp -s $VFILE $OUTFILE; then - cp $VFILE $OUTFILE -fi +cat > "${OUTFILE}" <