Skip to content

Commit

Permalink
Don't compile ldb tool into static library
Browse files Browse the repository at this point in the history
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
  • Loading branch information
igorcanadi committed Apr 15, 2014
1 parent dbe0f32 commit e296577
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ TESTS = \
geodb_test

TOOLS = \
sst_dump \
sst_dump \
db_sanity_test \
db_stress \
ldb \
db_stress \
ldb \
db_repl_stress \
blob_store_bench

LDB_OBJECTS = \
tools/ldb_cmd.o \
tools/ldb_tool.o


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

ldb: tools/ldb.o $(LIBOBJECTS)
$(CXX) tools/ldb.o $(LIBOBJECTS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
ldb: tools/ldb.o $(LDB_OBJECTS) $(LIBOBJECTS)
$(CXX) tools/ldb.o $(LDB_OBJECTS) $(LIBOBJECTS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)

# ---------------------------------------------------------------------------
# Jni stuff
Expand Down
2 changes: 1 addition & 1 deletion tools/ldb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// of patent rights can be found in the PATENTS file in the same directory.
//

#include "rocksdb/ldb_tool.h"
#include "tools/ldb_tool.h"

int main(int argc, char** argv) {
rocksdb::LDBTool tool;
Expand Down
2 changes: 1 addition & 1 deletion util/ldb_cmd.cc → tools/ldb_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#include "util/ldb_cmd.h"
#include "tools/ldb_cmd.h"

#include "db/dbformat.h"
#include "db/db_impl.h"
Expand Down
2 changes: 1 addition & 1 deletion util/ldb_cmd.h → tools/ldb_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "rocksdb/iterator.h"
#include "rocksdb/slice.h"
#include "util/logging.h"
#include "util/ldb_cmd_execute_result.h"
#include "tools/ldb_cmd_execute_result.h"
#include "util/string_util.h"
#include "utilities/utility_db.h"
#include "utilities/ttl/db_ttl.h"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions util/ldb_tool.cc → tools/ldb_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
#include "rocksdb/ldb_tool.h"
#include "util/ldb_cmd.h"
#include "tools/ldb_tool.h"
#include "tools/ldb_cmd.h"

namespace rocksdb {

Expand Down
6 changes: 2 additions & 4 deletions include/rocksdb/ldb_tool.h → tools/ldb_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
#ifndef STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H
#define STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H
#pragma once

#include "rocksdb/options.h"

namespace rocksdb {
Expand All @@ -14,5 +14,3 @@ class LDBTool {
};

} // namespace rocksdb

#endif // STORAGE_ROCKSDB_INCLUDE_LDB_TOOL_H

0 comments on commit e296577

Please sign in to comment.