From fec4269966c0436c6429ef5da00ccc0d9cdb3c78 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Fri, 9 May 2014 08:34:18 -0700 Subject: [PATCH] Fix more gflag namespace issues --- table/table_reader_bench.cc | 19 ++++++++++++++++--- util/bloom_test.cc | 14 +++++++++++++- util/dynamic_bloom_test.cc | 14 +++++++++++++- util/log_write_bench.cc | 19 ++++++++++++++++--- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/table/table_reader_bench.cc b/table/table_reader_bench.cc index a0ff0d7f0..650849a55 100644 --- a/table/table_reader_bench.cc +++ b/table/table_reader_bench.cc @@ -3,6 +3,14 @@ // 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 GFLAGS +#include +int main() { + fprintf(stderr, "Please install gflags to run rocksdb tools\n"); + return 1; +} +#else + #include #include "rocksdb/db.h" @@ -18,6 +26,9 @@ #include "util/testharness.h" #include "util/testutil.h" +using GFLAGS::ParseCommandLineFlags; +using GFLAGS::SetUsageMessage; + namespace rocksdb { namespace { @@ -232,9 +243,9 @@ DEFINE_string(time_unit, "microsecond", "`microsecond` (default) or `nanosecond`"); int main(int argc, char** argv) { - google::SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) + - " [OPTIONS]..."); - google::ParseCommandLineFlags(&argc, &argv, true); + SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) + + " [OPTIONS]..."); + ParseCommandLineFlags(&argc, &argv, true); rocksdb::TableFactory* tf = new rocksdb::BlockBasedTableFactory(); rocksdb::Options options; @@ -269,3 +280,5 @@ int main(int argc, char** argv) { delete tf; return 0; } + +#endif // GFLAGS diff --git a/util/bloom_test.cc b/util/bloom_test.cc index 2c430e203..881e3b0f5 100644 --- a/util/bloom_test.cc +++ b/util/bloom_test.cc @@ -7,6 +7,14 @@ // 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. +#ifndef GFLAGS +#include +int main() { + fprintf(stderr, "Please install gflags to run rocksdb tools\n"); + return 1; +} +#else + #include #include "rocksdb/filter_policy.h" @@ -15,6 +23,8 @@ #include "util/testharness.h" #include "util/testutil.h" +using GFLAGS::ParseCommandLineFlags; + DEFINE_int32(bits_per_key, 10, ""); namespace rocksdb { @@ -164,7 +174,9 @@ TEST(BloomTest, VaryingLengths) { } // namespace rocksdb int main(int argc, char** argv) { - google::ParseCommandLineFlags(&argc, &argv, true); + ParseCommandLineFlags(&argc, &argv, true); return rocksdb::test::RunAllTests(); } + +#endif // GFLAGS diff --git a/util/dynamic_bloom_test.cc b/util/dynamic_bloom_test.cc index 4a34d509a..b72ab24c5 100644 --- a/util/dynamic_bloom_test.cc +++ b/util/dynamic_bloom_test.cc @@ -3,6 +3,14 @@ // 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 GFLAGS +#include +int main() { + fprintf(stderr, "Please install gflags to run rocksdb tools\n"); + return 1; +} +#else + #define __STDC_FORMAT_MACROS #include #include @@ -15,6 +23,8 @@ #include "util/testutil.h" #include "util/stop_watch.h" +using GFLAGS::ParseCommandLineFlags; + DEFINE_int32(bits_per_key, 10, ""); DEFINE_int32(num_probes, 6, ""); DEFINE_bool(enable_perf, false, ""); @@ -196,7 +206,9 @@ TEST(DynamicBloomTest, perf) { } // namespace rocksdb int main(int argc, char** argv) { - google::ParseCommandLineFlags(&argc, &argv, true); + ParseCommandLineFlags(&argc, &argv, true); return rocksdb::test::RunAllTests(); } + +#endif // GFLAGS diff --git a/util/log_write_bench.cc b/util/log_write_bench.cc index 536d14ff8..16e7af7e2 100644 --- a/util/log_write_bench.cc +++ b/util/log_write_bench.cc @@ -3,6 +3,14 @@ // 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 GFLAGS +#include +int main() { + fprintf(stderr, "Please install gflags to run rocksdb tools\n"); + return 1; +} +#else + #include #include "rocksdb/env.h" @@ -10,6 +18,9 @@ #include "util/testharness.h" #include "util/testutil.h" +using GFLAGS::ParseCommandLineFlags; +using GFLAGS::SetUsageMessage; + // A simple benchmark to simulate transactional logs DEFINE_int32(num_records, 6000, "Number of records."); @@ -60,10 +71,12 @@ void RunBenchmark() { } // namespace rocksdb int main(int argc, char** argv) { - google::SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) + - " [OPTIONS]..."); - google::ParseCommandLineFlags(&argc, &argv, true); + SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) + + " [OPTIONS]..."); + ParseCommandLineFlags(&argc, &argv, true); rocksdb::RunBenchmark(); return 0; } + +#endif // GFLAGS