# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
defines = [ "LEVELDB_PLATFORM_CHROMIUM=1" ]
config("leveldb_config") {
include_dirs = [
".",
"src",
"src/include",
]
}
leveldb_sources = [
"env_chromium.cc",
"env_chromium.h",
"leveldb_chrome.cc",
"leveldb_chrome.h",
"port/port_chromium.cc",
"port/port_chromium.h",
"src/db/builder.cc",
"src/db/builder.h",
"src/db/db_impl.cc",
"src/db/db_impl.h",
"src/db/db_iter.cc",
"src/db/db_iter.h",
"src/db/dbformat.cc",
"src/db/dbformat.h",
"src/db/dumpfile.cc",
"src/db/filename.cc",
"src/db/filename.h",
"src/db/log_format.h",
"src/db/log_reader.cc",
"src/db/log_reader.h",
"src/db/log_writer.cc",
"src/db/log_writer.h",
"src/db/memtable.cc",
"src/db/memtable.h",
"src/db/repair.cc",
"src/db/skiplist.h",
"src/db/snapshot.h",
"src/db/table_cache.cc",
"src/db/table_cache.h",
"src/db/version_edit.cc",
"src/db/version_edit.h",
"src/db/version_set.cc",
"src/db/version_set.h",
"src/db/write_batch.cc",
"src/db/write_batch_internal.h",
"src/helpers/memenv/memenv.cc",
"src/helpers/memenv/memenv.h",
"src/include/leveldb/cache.h",
"src/include/leveldb/comparator.h",
"src/include/leveldb/db.h",
"src/include/leveldb/dumpfile.h",
"src/include/leveldb/env.h",
"src/include/leveldb/filter_policy.h",
"src/include/leveldb/iterator.h",
"src/include/leveldb/options.h",
"src/include/leveldb/slice.h",
"src/include/leveldb/status.h",
"src/include/leveldb/table.h",
"src/include/leveldb/table_builder.h",
"src/include/leveldb/write_batch.h",
"src/port/port.h",
"src/table/block.cc",
"src/table/block.h",
"src/table/block_builder.cc",
"src/table/block_builder.h",
"src/table/filter_block.cc",
"src/table/filter_block.h",
"src/table/format.cc",
"src/table/format.h",
"src/table/iterator.cc",
"src/table/iterator_wrapper.h",
"src/table/merger.cc",
"src/table/merger.h",
"src/table/table.cc",
"src/table/table_builder.cc",
"src/table/two_level_iterator.cc",
"src/table/two_level_iterator.h",
"src/util/arena.cc",
"src/util/arena.h",
"src/util/bloom.cc",
"src/util/cache.cc",
"src/util/coding.cc",
"src/util/coding.h",
"src/util/comparator.cc",
"src/util/crc32c.cc",
"src/util/crc32c.h",
"src/util/env.cc",
"src/util/filter_policy.cc",
"src/util/hash.cc",
"src/util/hash.h",
"src/util/logging.cc",
"src/util/logging.h",
"src/util/mutexlock.h",
"src/util/options.cc",
"src/util/random.h",
"src/util/status.cc",
]
config("leveldb_component_config") {
if (is_component_build) {
# Must be exported to all dependencies so LEVELDB_EXPORT is correctly
# defined throughout the component build.
defines += [ "LEVELDB_SHARED_LIBRARY" ]
}
}
component("leveldatabase") {
sources = leveldb_sources
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [
":leveldb_config",
":leveldb_component_config",
]
public_deps = [ "//base" ]
deps = [
"//build:chromeos_buildflags",
"//components/services/storage/public/cpp/filesystem",
"//third_party/crc32c",
"//third_party/re2",
"//third_party/snappy",
]
if (is_win) {
# leveldb compiles with a limited set of warnings enabled, and is not
# likely to accept fixes for other warnings. See crbug.com/698013
cflags = [ "/wd4018" ] # Signed/unsigned mismatch in comparison.
if (is_official_build) {
# Function recursive on all control paths, crbug.com/620018
cflags += [ "/wd4717" ]
}
}
defines += [ "LEVELDB_COMPILE_LIBRARY" ]
}
# leveldb does not mark symbols used by tests or its command-line utility as
# LEVELDB_EXPORT. So, these targets can only be linked statically against the
# leveldb source code.
static_library("leveldb_static") {
visibility = [
":leveldb_leveldbutil",
":leveldb_testutil",
]
sources = leveldb_sources
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":leveldb_config" ]
public_deps = [ "//base" ]
deps = [
"//build:chromeos_buildflags",
"//components/services/storage/public/cpp/filesystem",
"//third_party/crc32c",
"//third_party/re2",
"//third_party/snappy",
]
if (is_win) {
# leveldb compiles with a limited set of warnings enabled, and is not
# likely to accept fixes for other warnings. See crbug.com/698013
cflags = [ "/wd4018" ] # Signed/unsigned mismatch in comparison.
if (is_official_build) {
# Function recursive on all control paths, crbug.com/620018
cflags += [ "/wd4717" ]
}
}
}
test("env_chromium_unittests") {
sources = [ "env_chromium_unittest.cc" ]
deps = [
":leveldatabase",
"//base/test:test_support",
"//testing/gtest",
]
}
static_library("leveldb_testutil") {
testonly = true
visibility = [ ":*" ]
sources = [
"src/util/testutil.cc",
"src/util/testutil.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_deps = [
":leveldb_static",
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
]
deps = [ "//base" ]
}
test("leveldb_unittests") {
sources = [
# The project's tests.
"src/db/autocompact_test.cc",
"src/db/corruption_test.cc",
"src/db/db_test.cc",
"src/db/dbformat_test.cc",
"src/db/filename_test.cc",
"src/db/log_test.cc",
"src/db/recovery_test.cc",
"src/db/skiplist_test.cc",
"src/db/version_edit_test.cc",
"src/db/version_set_test.cc",
"src/db/write_batch_test.cc",
"src/helpers/memenv/memenv_test.cc",
"src/issues/issue178_test.cc",
"src/issues/issue200_test.cc",
"src/issues/issue320_test.cc",
"src/table/filter_block_test.cc",
"src/table/table_test.cc",
"src/util/arena_test.cc",
"src/util/bloom_test.cc",
"src/util/cache_test.cc",
"src/util/coding_test.cc",
"src/util/crc32c_test.cc",
"src/util/env_test.cc",
"src/util/hash_test.cc",
"src/util/logging_test.cc",
"src/util/no_destructor_test.cc",
"src/util/status_test.cc",
# Custom main() needed by Chromium's leveldb::Env.
"leveldb_unittest_main.cc",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
if (is_win) {
# util\cache_test.cc(167): warning C4018: '<': signed/unsigned mismatch
# util\cache_test.cc(171): warning C4018: '<': signed/unsigned mismatch
cflags = [ "/wd4018" ] # Signed/unsigned mismatch in comparison.
}
deps = [
":leveldb_testutil",
"//base",
"//base/test:test_support",
]
}
if (!is_ios && !is_android) {
test("leveldb_db_bench") {
sources = [
"src/benchmarks/db_bench.cc",
"src/util/histogram.cc",
"src/util/histogram.h",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [ ":leveldb_testutil" ]
}
test("leveldb_db_bench_log") {
sources = [ "src/benchmarks/db_bench_log.cc" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [
":leveldb_testutil",
"//third_party/google_benchmark",
]
}
executable("leveldb_leveldbutil") {
sources = [ "src/db/leveldbutil.cc" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
deps = [ ":leveldb_static" ]
}
group("leveldb_test_targets") {
testonly = true
deps = [
":env_chromium_unittests",
":leveldb_db_bench",
":leveldb_db_bench_log",
":leveldb_unittests",
]
}
}
fuzzer_test("leveldb_put_get_delete_fuzzer") {
sources = [ "leveldb_put_get_delete_fuzzer.cc" ]
deps = [ ":leveldatabase" ]
}