Skip to content

Commit e296577

Browse files
committed
Don't compile ldb tool into static library
Summary: This is first step of my effort to reduce size of librocksdb.a for use in mobile. ldb object files are huge and are ment to be used as a command line tool. I moved them to `tools/` directory and include them only when compiling `ldb` This diff reduced librocksdb.a from 42MB to 39MB on my mac (not stripped). Test Plan: ran ldb Reviewers: dhruba, haobo, sdong, ljin, yhchiang Reviewed By: yhchiang CC: leveldb Differential Revision: https://reviews.facebook.net/D17823
1 parent dbe0f32 commit e296577

7 files changed

+16
-14
lines changed

Makefile

+9-5
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,17 @@ TESTS = \
106106
geodb_test
107107

108108
TOOLS = \
109-
sst_dump \
109+
sst_dump \
110110
db_sanity_test \
111-
db_stress \
112-
ldb \
111+
db_stress \
112+
ldb \
113113
db_repl_stress \
114114
blob_store_bench
115115

116+
LDB_OBJECTS = \
117+
tools/ldb_cmd.o \
118+
tools/ldb_tool.o
119+
116120

117121
PROGRAMS = db_bench signal_test table_reader_bench $(TESTS) $(TOOLS)
118122
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db table_reader_bench
@@ -410,8 +414,8 @@ auto_roll_logger_test: util/auto_roll_logger_test.o $(LIBOBJECTS) $(TESTHARNESS)
410414
sst_dump: tools/sst_dump.o $(LIBOBJECTS)
411415
$(CXX) tools/sst_dump.o $(LIBOBJECTS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
412416

413-
ldb: tools/ldb.o $(LIBOBJECTS)
414-
$(CXX) tools/ldb.o $(LIBOBJECTS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
417+
ldb: tools/ldb.o $(LDB_OBJECTS) $(LIBOBJECTS)
418+
$(CXX) tools/ldb.o $(LDB_OBJECTS) $(LIBOBJECTS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
415419

416420
# ---------------------------------------------------------------------------
417421
# Jni stuff

tools/ldb.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// of patent rights can be found in the PATENTS file in the same directory.
55
//
66

7-
#include "rocksdb/ldb_tool.h"
7+
#include "tools/ldb_tool.h"
88

99
int main(int argc, char** argv) {
1010
rocksdb::LDBTool tool;

util/ldb_cmd.cc tools/ldb_cmd.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// LICENSE file in the root directory of this source tree. An additional grant
44
// of patent rights can be found in the PATENTS file in the same directory.
55
//
6-
#include "util/ldb_cmd.h"
6+
#include "tools/ldb_cmd.h"
77

88
#include "db/dbformat.h"
99
#include "db/db_impl.h"

util/ldb_cmd.h tools/ldb_cmd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "rocksdb/iterator.h"
1818
#include "rocksdb/slice.h"
1919
#include "util/logging.h"
20-
#include "util/ldb_cmd_execute_result.h"
20+
#include "tools/ldb_cmd_execute_result.h"
2121
#include "util/string_util.h"
2222
#include "utilities/utility_db.h"
2323
#include "utilities/ttl/db_ttl.h"
File renamed without changes.

util/ldb_tool.cc tools/ldb_tool.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// LICENSE file in the root directory of this source tree. An additional grant
44
// of patent rights can be found in the PATENTS file in the same directory.
55
//
6-
#include "rocksdb/ldb_tool.h"
7-
#include "util/ldb_cmd.h"
6+
#include "tools/ldb_tool.h"
7+
#include "tools/ldb_cmd.h"
88

99
namespace rocksdb {
1010

include/rocksdb/ldb_tool.h tools/ldb_tool.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// This source code is licensed under the BSD-style license found in the
33
// LICENSE file in the root directory of this source tree. An additional grant
44
// of patent rights can be found in the PATENTS file in the same directory.
5-
#ifndef STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H
6-
#define STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H
5+
#pragma once
6+
77
#include "rocksdb/options.h"
88

99
namespace rocksdb {
@@ -14,5 +14,3 @@ class LDBTool {
1414
};
1515

1616
} // namespace rocksdb
17-
18-
#endif // STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H

0 commit comments

Comments
 (0)