From 772f75b3fbc5cfcf4d519114751efeae04411fa1 Mon Sep 17 00:00:00 2001 From: Chip Turner Date: Thu, 24 Jan 2013 11:45:11 -0800 Subject: [PATCH] Stop continually re-creating build_version.c Summary: We continually rebuilt build_version.c because we put the current date into it, but that's what __DATE__ already is. This makes builds faster. This also fixes an issue with 'make clean FOO' not working properly. Also tweak the build rules to be more consistent, always have warnings, and add a 'make release' rule to handle flags for release builds. Test Plan: make, make clean Reviewers: dhruba Reviewed By: dhruba Differential Revision: https://reviews.facebook.net/D8139 --- Makefile | 19 +++++++++++-------- build_detect_version | 9 +++++++-- db/db_impl.cc | 4 ++-- util/build_version.h | 1 - 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 13062d8e7..4436aa0d6 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,8 @@ INSTALL_PATH ?= $(CURDIR) # Uncomment exactly one of the lines labelled (A), (B), and (C) below # to switch between compilation modes. -# OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode) -# OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols -OPT ?= -O2 -g2 -DNDEBUG -Wall # (C) Profiling mode: opt, but w/debugging symbols +# OPT ?= -DNDEBUG # (A) Production use (optimized mode) +OPT += -O3 -fno-omit-frame-pointer -momit-leaf-frame-pointer #----------------------------------------------- # detect what platform we're building on @@ -19,8 +18,9 @@ $(shell ./build_detect_platform build_config.mk) # this file is generated by the previous line to set build flags and sources include build_config.mk -CFLAGS += -Werror -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) -CXXFLAGS += -Werror -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) +WARNING_FLAGS = -Wall -Werror -Wno-unused-parameter -Wno-sign-compare +CFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) +CXXFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) LDFLAGS += $(PLATFORM_LDFLAGS) @@ -65,7 +65,6 @@ TOOLS = \ PROGRAMS = db_bench $(TESTS) $(TOOLS) BENCHMARKS = db_bench_sqlite3 db_bench_tree_db -VERSIONFILE=util/build_version.cc LIBRARY = libleveldb.a MEMENVLIBRARY = libmemenv.a @@ -99,13 +98,17 @@ $(SHARED3): endif # PLATFORM_SHARED_EXT -all: $(VERSIONFILE) $(SHARED) $(LIBRARY) $(TOOLS) +all: $(SHARED) $(LIBRARY) $(PROGRAMS) + +release: + make clean + OPT=-DNDEBUG make -j32 check: all $(PROGRAMS) $(TESTS) $(TOOLS) for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done clean: - -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) $(THRIFTSERVER) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk $(VERSIONFILE) */*.d + -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) $(THRIFTSERVER) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk -rm -rf ios-x86/* ios-arm/* $(LIBRARY): $(LIBOBJECTS) diff --git a/build_detect_version b/build_detect_version index db2fca8ef..73dbf62af 100755 --- a/build_detect_version +++ b/build_detect_version @@ -8,7 +8,8 @@ # # create git version file -VFILE=util/build_version.cc +VFILE=$(mktemp) +trap "rm $VFILE" EXIT # check to see if git is in the path which git > /dev/null @@ -19,6 +20,10 @@ 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 -date | awk 'BEGIN {} {print "const char * leveldb_build_git_datetime = \"leveldb_build_git_datetime:"$0"\";"} END {} ' >> ${VFILE} echo "const char * leveldb_build_compile_date = __DATE__;" >> ${VFILE} echo "const char * leveldb_build_compile_time = __TIME__;" >> ${VFILE} + +OUTFILE=util/build_version.cc +if [ ! -e $OUTFILE ] || ! cmp -s $VFILE $OUTFILE; then + cp $VFILE $OUTFILE +fi diff --git a/db/db_impl.cc b/db/db_impl.cc index 4d508517f..dc2a3650a 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -2385,8 +2385,8 @@ Status DestroyDB(const std::string& dbname, const Options& options) { // A global method that can dump out the build version void dumpLeveldbBuildVersion(Logger * log) { Log(log, "Git sha %s", leveldb_build_git_sha); - Log(log, "Git datetime %s", leveldb_build_git_datetime); - Log(log, "Compile time %s %s", leveldb_build_compile_time, leveldb_build_compile_date); + Log(log, "Compile time %s %s", + leveldb_build_compile_time, leveldb_build_compile_date); } } // namespace leveldb diff --git a/util/build_version.h b/util/build_version.h index bcf869372..516c6404b 100644 --- a/util/build_version.h +++ b/util/build_version.h @@ -4,7 +4,6 @@ // these variables tell us about the git config and time extern const char* leveldb_build_git_sha; -extern const char* leveldb_build_git_datetime; // these variables tell us when the compilation occured extern const char* leveldb_build_compile_time;