Permalink
Browse files

Updated LevelDB to 1.5.0.

  • Loading branch information...
justmoon committed Jul 24, 2012
1 parent f6fbfd5 commit 97ca7a86f033f54a070b9181154faf885436c107
Showing with 2,761 additions and 1,001 deletions.
  1. +81 −95 deps/leveldb/Makefile
  2. +146 −45 deps/leveldb/build_detect_platform
  3. +110 −0 deps/leveldb/db/c.cc
  4. +91 −1 deps/leveldb/db/c_test.c
  5. +105 −4 deps/leveldb/db/db_bench.cc
  6. +135 −45 deps/leveldb/db/db_impl.cc
  7. +12 −10 deps/leveldb/db/db_impl.h
  8. +666 −431 deps/leveldb/db/db_test.cc
  9. +20 −0 deps/leveldb/db/dbformat.cc
  10. +12 −0 deps/leveldb/db/dbformat.h
  11. +3 −1 deps/leveldb/db/repair.cc
  12. +2 −1 deps/leveldb/db/skiplist.h
  13. +42 −16 deps/leveldb/db/table_cache.cc
  14. +11 −0 deps/leveldb/db/table_cache.h
  15. +46 −41 deps/leveldb/db/version_set.cc
  16. +9 −0 deps/leveldb/db/version_set.h
  17. +13 −4 deps/leveldb/db/write_batch.cc
  18. +2 −0 deps/leveldb/db/write_batch_internal.h
  19. +31 −0 deps/leveldb/db/write_batch_test.cc
  20. +25 −3 deps/leveldb/doc/bench/db_bench_sqlite3.cc
  21. +26 −4 deps/leveldb/doc/bench/db_bench_tree_db.cc
  22. +63 −0 deps/leveldb/doc/index.html
  23. +41 −0 deps/leveldb/doc/table_format.txt
  24. +29 −0 deps/leveldb/include/leveldb/c.h
  25. +2 −1 deps/leveldb/include/leveldb/db.h
  26. +70 −0 deps/leveldb/include/leveldb/filter_policy.h
  27. +8 −0 deps/leveldb/include/leveldb/options.h
  28. +6 −0 deps/leveldb/include/leveldb/status.h
  29. +15 −0 deps/leveldb/include/leveldb/table.h
  30. +1 −0 deps/leveldb/include/leveldb/table_builder.h
  31. +25 −0 deps/leveldb/leveldb.gyp
  32. +13 −5 deps/leveldb/port/atomic_pointer.h
  33. +0 −2 deps/leveldb/port/port.h
  34. +0 −64 deps/leveldb/port/port_android.cc
  35. +0 −156 deps/leveldb/port/port_android.h
  36. +10 −0 deps/leveldb/port/port_example.h
  37. +4 −0 deps/leveldb/port/port_posix.cc
  38. +33 −10 deps/leveldb/port/port_posix.h
  39. +8 −4 deps/leveldb/table/block.cc
  40. +3 −2 deps/leveldb/table/block.h
  41. +111 −0 deps/leveldb/table/filter_block.cc
  42. +68 −0 deps/leveldb/table/filter_block.h
  43. +128 −0 deps/leveldb/table/filter_block_test.cc
  44. +17 −7 deps/leveldb/table/format.cc
  45. +9 −4 deps/leveldb/table/format.h
  46. +107 −6 deps/leveldb/table/table.cc
  47. +49 −6 deps/leveldb/table/table_builder.cc
  48. +8 −24 deps/leveldb/table/table_test.cc
  49. +95 −0 deps/leveldb/util/bloom.cc
  50. +159 −0 deps/leveldb/util/bloom_test.cc
  51. +23 −0 deps/leveldb/util/coding_test.cc
  52. +8 −3 deps/leveldb/util/comparator.cc
  53. +46 −4 deps/leveldb/util/env_posix.cc
  54. +11 −0 deps/leveldb/util/filter_policy.cc
  55. +2 −1 deps/leveldb/util/options.cc
  56. +1 −1 test/package-test.coffee
View
@@ -2,8 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. See the AUTHORS file for names of contributors.
-CXX ?= g++
-CC ?= gcc
+# Inherit some settings from environment variables, if available
+INSTALL_PATH ?= $(CURDIR)
#-----------------------------------------------
# Uncomment exactly one of the lines labelled (A), (B), and (C) below
@@ -15,74 +15,24 @@ OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
#-----------------------------------------------
# detect what platform we're building on
-$(shell sh ./build_detect_platform)
-# this file is generated by build_detect_platform to set build flags
+$(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
-# If Snappy is installed, add compilation and linker flags
-# (see http://code.google.com/p/snappy/)
-ifeq ($(SNAPPY), 1)
-SNAPPY_CFLAGS=-DSNAPPY
-SNAPPY_LDFLAGS=-lsnappy
-else
-SNAPPY_CFLAGS=
-SNAPPY_LDFLAGS=
-endif
+CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
+CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
-# If Google Perf Tools are installed, add compilation and linker flags
-# (see http://code.google.com/p/google-perftools/)
-ifeq ($(GOOGLE_PERFTOOLS), 1)
-GOOGLE_PERFTOOLS_LDFLAGS=-ltcmalloc
-else
-GOOGLE_PERFTOOLS_LDFLAGS=
-endif
+LDFLAGS += $(PLATFORM_LDFLAGS)
-CFLAGS = -c -I. -I./include $(PORT_CFLAGS) $(PLATFORM_CFLAGS) $(OPT) $(SNAPPY_CFLAGS)
-
-LDFLAGS += $(PLATFORM_LDFLAGS) $(SNAPPY_LDFLAGS) $(GOOGLE_PERFTOOLS_LDFLAGS)
-
-LIBOBJECTS = \
- ./db/builder.o \
- ./db/c.o \
- ./db/db_impl.o \
- ./db/db_iter.o \
- ./db/filename.o \
- ./db/dbformat.o \
- ./db/log_reader.o \
- ./db/log_writer.o \
- ./db/memtable.o \
- ./db/repair.o \
- ./db/table_cache.o \
- ./db/version_edit.o \
- ./db/version_set.o \
- ./db/write_batch.o \
- ./port/port_posix.o \
- ./table/block.o \
- ./table/block_builder.o \
- ./table/format.o \
- ./table/iterator.o \
- ./table/merger.o \
- ./table/table.o \
- ./table/table_builder.o \
- ./table/two_level_iterator.o \
- ./util/arena.o \
- ./util/cache.o \
- ./util/coding.o \
- ./util/comparator.o \
- ./util/crc32c.o \
- ./util/env.o \
- ./util/env_posix.o \
- ./util/hash.o \
- ./util/histogram.o \
- ./util/logging.o \
- ./util/options.o \
- ./util/status.o
+LIBOBJECTS = $(SOURCES:.cc=.o)
+MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
TESTUTIL = ./util/testutil.o
TESTHARNESS = ./util/testharness.o $(TESTUTIL)
TESTS = \
arena_test \
+ bloom_test \
c_test \
cache_test \
coding_test \
@@ -92,6 +42,7 @@ TESTS = \
dbformat_test \
env_test \
filename_test \
+ filter_block_test \
log_test \
memenv_test \
skiplist_test \
@@ -106,109 +57,144 @@ BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
LIBRARY = libleveldb.a
MEMENVLIBRARY = libmemenv.a
-all: $(LIBRARY)
+default: all
-check: $(PROGRAMS) $(TESTS)
+# Should we build shared libraries?
+ifneq ($(PLATFORM_SHARED_EXT),)
+
+ifneq ($(PLATFORM_SHARED_VERSIONED),true)
+SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
+SHARED2 = $(SHARED1)
+SHARED3 = $(SHARED1)
+SHARED = $(SHARED1)
+else
+# Update db.h if you change these.
+SHARED_MAJOR = 1
+SHARED_MINOR = 5
+SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
+SHARED2 = $(SHARED1).$(SHARED_MAJOR)
+SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
+SHARED = $(SHARED1) $(SHARED2) $(SHARED3)
+$(SHARED1): $(SHARED3)
+ ln -fs $(SHARED3) $(SHARED1)
+$(SHARED2): $(SHARED3)
+ ln -fs $(SHARED3) $(SHARED2)
+endif
+
+$(SHARED3):
+ $(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3)
+
+endif # PLATFORM_SHARED_EXT
+
+all: $(SHARED) $(LIBRARY)
+
+check: all $(PROGRAMS) $(TESTS)
for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
clean:
- -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o
+ -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
-rm -rf ios-x86/* ios-arm/*
- -rm build_config.mk
$(LIBRARY): $(LIBOBJECTS)
rm -f $@
$(AR) -rs $@ $(LIBOBJECTS)
db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
- $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@
+ $(CXX) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS)
db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
- $(CXX) $(LDFLAGS) -lsqlite3 doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@
+ $(CXX) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS) -lsqlite3
db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
- $(CXX) $(LDFLAGS) -lkyotocabinet doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@
+ $(CXX) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS) -lkyotocabinet
arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
+
+bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
+ $(CXX) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
+
+filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
+ $(CXX) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
+ $(CXX) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
-$(MEMENVLIBRARY) : helpers/memenv/memenv.o
+$(MEMENVLIBRARY) : $(MEMENVOBJECTS)
rm -f $@
- $(AR) -rs $@ helpers/memenv/memenv.o
+ $(AR) -rs $@ $(MEMENVOBJECTS)
memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
- $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@
+ $(CXX) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LDFLAGS)
ifeq ($(PLATFORM), IOS)
# For iOS, create universal object files to be used on both the simulator and
# a device.
-SIMULATORROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer
-DEVICEROOT=/Developer/Platforms/iPhoneOS.platform/Developer
-IOSVERSION=$(shell defaults read /Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString)
+PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
+SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
+DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
+IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
.cc.o:
mkdir -p ios-x86/$(dir $@)
- $(SIMULATORROOT)/usr/bin/$(CXX) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
+ $(SIMULATORROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
mkdir -p ios-arm/$(dir $@)
- $(DEVICEROOT)/usr/bin/$(CXX) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
+ $(DEVICEROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
lipo ios-x86/$@ ios-arm/$@ -create -output $@
.c.o:
mkdir -p ios-x86/$(dir $@)
- $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
+ $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
mkdir -p ios-arm/$(dir $@)
- $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
+ $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
lipo ios-x86/$@ ios-arm/$@ -create -output $@
else
.cc.o:
- $(CXX) $(CFLAGS) $< -o $@
+ $(CXX) $(CXXFLAGS) -c $< -o $@
.c.o:
- $(CC) $(CFLAGS) $< -o $@
+ $(CC) $(CFLAGS) -c $< -o $@
endif
Oops, something went wrong.

0 comments on commit 97ca7a8

Please sign in to comment.