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
This commit is contained in:
Chip Turner 2013-01-24 11:45:11 -08:00
parent 3dafdfb2c4
commit 772f75b3fb
4 changed files with 20 additions and 13 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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;