diff options
author | cmumford <cmumford@google.com> | 2016-01-29 15:58:37 -0800 |
---|---|---|
committer | Chris Mumford <cmumford@chromium.org> | 2016-01-29 16:10:00 -0800 |
commit | adbe3eb073565c468005c48f18d16b8f1dd6ef58 (patch) | |
tree | 72245ee57e11d9c263a654be3739cf4e83400bcc /db/leveldbutil.cc | |
parent | 2d0320a458d0e6a20fff46d5f80b18bfdcce7018 (diff) | |
download | leveldb-adbe3eb073565c468005c48f18d16b8f1dd6ef58.tar.gz |
Putting build artifacts in subdirectory.
1. Object files, libraries, and compiled executables are put
into subdirectories.
2. The shared library is linked from individual object files.
This provides for greater parallelism on large desktops
while at the same time making for easier builds on small
(i.e. embedded) systems. Fixes issue #279.
3. One program, db_bench, is compiled using the shared library.
4. The source file for "leveldbutil" was renamed from
leveldb_main.cc to leveldbutil.cc. This provides for simpler
makefile rules.
5. Because all targets placed the library (libleveldb.a) at the top
level, the last platform built (desktop/device) always overwrote
any prior artifact.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=113407013
Diffstat (limited to 'db/leveldbutil.cc')
-rw-r--r-- | db/leveldbutil.cc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/db/leveldbutil.cc b/db/leveldbutil.cc new file mode 100644 index 0000000..9f4b7dd --- /dev/null +++ b/db/leveldbutil.cc @@ -0,0 +1,64 @@ +// Copyright (c) 2012 The LevelDB Authors. All rights reserved. +// 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. + +#include <stdio.h> +#include "leveldb/dumpfile.h" +#include "leveldb/env.h" +#include "leveldb/status.h" + +namespace leveldb { +namespace { + +class StdoutPrinter : public WritableFile { + public: + virtual Status Append(const Slice& data) { + fwrite(data.data(), 1, data.size(), stdout); + return Status::OK(); + } + virtual Status Close() { return Status::OK(); } + virtual Status Flush() { return Status::OK(); } + virtual Status Sync() { return Status::OK(); } +}; + +bool HandleDumpCommand(Env* env, char** files, int num) { + StdoutPrinter printer; + bool ok = true; + for (int i = 0; i < num; i++) { + Status s = DumpFile(env, files[i], &printer); + if (!s.ok()) { + fprintf(stderr, "%s\n", s.ToString().c_str()); + ok = false; + } + } + return ok; +} + +} // namespace +} // namespace leveldb + +static void Usage() { + fprintf( + stderr, + "Usage: leveldbutil command...\n" + " dump files... -- dump contents of specified files\n" + ); +} + +int main(int argc, char** argv) { + leveldb::Env* env = leveldb::Env::Default(); + bool ok = true; + if (argc < 2) { + Usage(); + ok = false; + } else { + std::string command = argv[1]; + if (command == "dump") { + ok = leveldb::HandleDumpCommand(env, argv+2, argc-2); + } else { + Usage(); + ok = false; + } + } + return (ok ? 0 : 1); +} |