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:
parent
3dafdfb2c4
commit
772f75b3fb
19
Makefile
19
Makefile
@ -9,9 +9,8 @@ INSTALL_PATH ?= $(CURDIR)
|
|||||||
# Uncomment exactly one of the lines labelled (A), (B), and (C) below
|
# Uncomment exactly one of the lines labelled (A), (B), and (C) below
|
||||||
# to switch between compilation modes.
|
# to switch between compilation modes.
|
||||||
|
|
||||||
# OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
|
# OPT ?= -DNDEBUG # (A) Production use (optimized mode)
|
||||||
# OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
|
OPT += -O3 -fno-omit-frame-pointer -momit-leaf-frame-pointer
|
||||||
OPT ?= -O2 -g2 -DNDEBUG -Wall # (C) Profiling mode: opt, but w/debugging symbols
|
|
||||||
#-----------------------------------------------
|
#-----------------------------------------------
|
||||||
|
|
||||||
# detect what platform we're building on
|
# 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
|
# this file is generated by the previous line to set build flags and sources
|
||||||
include build_config.mk
|
include build_config.mk
|
||||||
|
|
||||||
CFLAGS += -Werror -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
|
WARNING_FLAGS = -Wall -Werror -Wno-unused-parameter -Wno-sign-compare
|
||||||
CXXFLAGS += -Werror -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
|
CFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
|
||||||
|
CXXFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
|
||||||
|
|
||||||
LDFLAGS += $(PLATFORM_LDFLAGS)
|
LDFLAGS += $(PLATFORM_LDFLAGS)
|
||||||
|
|
||||||
@ -65,7 +65,6 @@ TOOLS = \
|
|||||||
|
|
||||||
PROGRAMS = db_bench $(TESTS) $(TOOLS)
|
PROGRAMS = db_bench $(TESTS) $(TOOLS)
|
||||||
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
|
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
|
||||||
VERSIONFILE=util/build_version.cc
|
|
||||||
|
|
||||||
LIBRARY = libleveldb.a
|
LIBRARY = libleveldb.a
|
||||||
MEMENVLIBRARY = libmemenv.a
|
MEMENVLIBRARY = libmemenv.a
|
||||||
@ -99,13 +98,17 @@ $(SHARED3):
|
|||||||
|
|
||||||
endif # PLATFORM_SHARED_EXT
|
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)
|
check: all $(PROGRAMS) $(TESTS) $(TOOLS)
|
||||||
for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
|
for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
|
||||||
|
|
||||||
clean:
|
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/*
|
-rm -rf ios-x86/* ios-arm/*
|
||||||
|
|
||||||
$(LIBRARY): $(LIBOBJECTS)
|
$(LIBRARY): $(LIBOBJECTS)
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# create git version file
|
# create git version file
|
||||||
VFILE=util/build_version.cc
|
VFILE=$(mktemp)
|
||||||
|
trap "rm $VFILE" EXIT
|
||||||
|
|
||||||
# check to see if git is in the path
|
# check to see if git is in the path
|
||||||
which git > /dev/null
|
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}
|
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
|
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_date = __DATE__;" >> ${VFILE}
|
||||||
echo "const char * leveldb_build_compile_time = __TIME__;" >> ${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
|
||||||
|
@ -2385,8 +2385,8 @@ Status DestroyDB(const std::string& dbname, const Options& options) {
|
|||||||
// A global method that can dump out the build version
|
// A global method that can dump out the build version
|
||||||
void dumpLeveldbBuildVersion(Logger * log) {
|
void dumpLeveldbBuildVersion(Logger * log) {
|
||||||
Log(log, "Git sha %s", leveldb_build_git_sha);
|
Log(log, "Git sha %s", leveldb_build_git_sha);
|
||||||
Log(log, "Git datetime %s", leveldb_build_git_datetime);
|
Log(log, "Compile time %s %s",
|
||||||
Log(log, "Compile time %s %s", leveldb_build_compile_time, leveldb_build_compile_date);
|
leveldb_build_compile_time, leveldb_build_compile_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace leveldb
|
} // namespace leveldb
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
// these variables tell us about the git config and time
|
// these variables tell us about the git config and time
|
||||||
extern const char* leveldb_build_git_sha;
|
extern const char* leveldb_build_git_sha;
|
||||||
extern const char* leveldb_build_git_datetime;
|
|
||||||
|
|
||||||
// these variables tell us when the compilation occured
|
// these variables tell us when the compilation occured
|
||||||
extern const char* leveldb_build_compile_time;
|
extern const char* leveldb_build_compile_time;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user