From 8f6e31951e77f727c2c25a40bb96954d6ccff06d Mon Sep 17 00:00:00 2001 From: Kai Liu Date: Sat, 4 Jan 2014 23:47:44 -0800 Subject: [PATCH 1/2] Add a hack to build_detect_platform so it works in all types of fb-servers --- build_tools/build_detect_platform | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 87c4c871d..93eac07e0 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -172,7 +172,11 @@ echo "MEMENV_SOURCES=helpers/memenv/memenv.cc" >> $OUTPUT if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then # Cross-compiling; do not try any compilation tests. # Also don't need any compilation tests if compiling on fbcode - true + # TODO(kailiu) For some fb-supported environments, they have trouble finding + # symbols from gflags if -lgflags wasn't specified. As a temporary resort, + # we added it to PLATFORM_LDFLAGS although for some environments it is + # unnecessary. + PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -gflags" else # do fPIC on 64 bit in non-fbcode environment case "$TARGET_OS" in From d800dc567aa072b865f445a7a984b3740ed8ba3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dog=CC=86an=20C=CC=A7ec=CC=A7en?= Date: Sun, 5 Jan 2014 22:52:19 +0200 Subject: [PATCH 2/2] Refactor build_tools/build_detect_version --- .gitignore | 1 - build_tools/build_detect_version | 42 +++++++++----------------------- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 1c2d2b378..03a5f1761 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 3ee6c92bd..f7d711f0d 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 +OUTFILE="$PWD/util/build_version.cc" -# check to see if git is in the path -which git > /dev/null - -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}" <