2012-08-21 07:33:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Record the version of the source that we are compiling.
|
|
|
|
# We keep a record of the git revision in util/version.cc. This source file
|
|
|
|
# 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
|
2013-01-24 19:45:11 +00:00
|
|
|
VFILE=$(mktemp)
|
|
|
|
trap "rm $VFILE" EXIT
|
2012-08-21 07:33:21 +00:00
|
|
|
|
|
|
|
# check to see if git is in the path
|
|
|
|
which git > /dev/null
|
|
|
|
|
|
|
|
if [ "$?" = 0 ]; then
|
2013-01-14 20:39:24 +00:00
|
|
|
env -i git rev-parse HEAD | awk ' BEGIN {print "#include \"build_version.h\""} {print "const char * leveldb_build_git_sha = \"leveldb_build_git_sha:" $0"\";"} END {}' > ${VFILE}
|
2012-08-21 07:33:21 +00:00
|
|
|
else
|
|
|
|
echo "git not found"| awk ' BEGIN {print "#include \"build_version.h\""} {print "const char * leveldb_build_git_sha = \"leveldb_build_git_sha:git not found\";"} END {}' > ${VFILE}
|
|
|
|
fi
|
|
|
|
|
2013-03-11 17:14:59 +00:00
|
|
|
date | awk 'BEGIN {} {print "const char * leveldb_build_git_datetime = \"leveldb_build_git_datetime:"$0"\";"} END {} ' >> ${VFILE}
|
2012-08-21 07:33:21 +00:00
|
|
|
echo "const char * leveldb_build_compile_date = __DATE__;" >> ${VFILE}
|
|
|
|
echo "const char * leveldb_build_compile_time = __TIME__;" >> ${VFILE}
|
2013-01-24 19:45:11 +00:00
|
|
|
|
|
|
|
OUTFILE=util/build_version.cc
|
|
|
|
if [ ! -e $OUTFILE ] || ! cmp -s $VFILE $OUTFILE; then
|
|
|
|
cp $VFILE $OUTFILE
|
|
|
|
fi
|