2017-04-04 23:09:31 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import unicode_literals
|
2018-08-29 04:14:52 +00:00
|
|
|
rocksdb_target_header = """
|
|
|
|
load("@fbcode_macros//build_defs:auto_headers.bzl", "AutoHeaders")
|
|
|
|
|
|
|
|
REPO_PATH = package_name() + "/"
|
2017-11-15 22:13:39 +00:00
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
BUCK_BINS = "buck-out/gen/" + REPO_PATH
|
2017-11-15 22:13:39 +00:00
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
TEST_RUNNER = REPO_PATH + "buckifier/rocks_test_runner.sh"
|
2017-11-15 22:13:39 +00:00
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
rocksdb_compiler_flags = [
|
2017-11-15 22:13:39 +00:00
|
|
|
"-fno-builtin-memcmp",
|
|
|
|
"-DROCKSDB_PLATFORM_POSIX",
|
|
|
|
"-DROCKSDB_LIB_IO_POSIX",
|
|
|
|
"-DROCKSDB_FALLOCATE_PRESENT",
|
|
|
|
"-DROCKSDB_MALLOC_USABLE_SIZE",
|
|
|
|
"-DROCKSDB_RANGESYNC_PRESENT",
|
|
|
|
"-DROCKSDB_SCHED_GETCPU_PRESENT",
|
|
|
|
"-DROCKSDB_SUPPORT_THREAD_LOCAL",
|
|
|
|
"-DOS_LINUX",
|
|
|
|
# Flags to enable libs we include
|
|
|
|
"-DSNAPPY",
|
|
|
|
"-DZLIB",
|
|
|
|
"-DBZIP2",
|
|
|
|
"-DLZ4",
|
|
|
|
"-DZSTD",
|
|
|
|
"-DGFLAGS=gflags",
|
|
|
|
"-DNUMA",
|
|
|
|
"-DTBB",
|
|
|
|
# Needed to compile in fbcode
|
|
|
|
"-Wno-expansion-to-defined",
|
2018-03-30 21:23:55 +00:00
|
|
|
# Added missing flags from output of build_detect_platform
|
|
|
|
"-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX",
|
|
|
|
"-DROCKSDB_BACKTRACE",
|
2018-06-21 21:30:00 +00:00
|
|
|
"-Wnarrowing",
|
2017-04-04 23:09:31 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
rocksdb_external_deps = [
|
2017-11-15 22:13:39 +00:00
|
|
|
("bzip2", None, "bz2"),
|
|
|
|
("snappy", None, "snappy"),
|
|
|
|
("zlib", None, "z"),
|
|
|
|
("gflags", None, "gflags"),
|
|
|
|
("lz4", None, "lz4"),
|
|
|
|
("zstd", None),
|
|
|
|
("tbb", None),
|
|
|
|
("numa", None, "numa"),
|
|
|
|
("googletest", None, "gtest"),
|
2017-04-04 23:09:31 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
rocksdb_preprocessor_flags = [
|
2017-11-15 22:13:39 +00:00
|
|
|
# Directories with files for #include
|
|
|
|
"-I" + REPO_PATH + "include/",
|
|
|
|
"-I" + REPO_PATH,
|
2017-04-04 23:09:31 +00:00
|
|
|
]
|
2017-08-14 00:04:19 +00:00
|
|
|
|
|
|
|
rocksdb_arch_preprocessor_flags = {
|
2018-03-06 20:19:15 +00:00
|
|
|
"x86_64": [
|
|
|
|
"-DHAVE_SSE42",
|
|
|
|
"-DHAVE_PCLMUL",
|
|
|
|
],
|
2017-08-14 00:04:19 +00:00
|
|
|
}
|
2017-11-30 18:40:39 +00:00
|
|
|
|
|
|
|
build_mode = read_config("fbcode", "build_mode")
|
|
|
|
|
|
|
|
is_opt_mode = build_mode.startswith("opt")
|
|
|
|
|
|
|
|
# -DNDEBUG is added by default in opt mode in fbcode. But adding it twice
|
|
|
|
# doesn't harm and avoid forgetting to add it.
|
|
|
|
if is_opt_mode:
|
|
|
|
rocksdb_compiler_flags.append("-DNDEBUG")
|
2017-04-04 23:09:31 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
library_template = """
|
|
|
|
cpp_library(
|
|
|
|
name = "%s",
|
|
|
|
srcs = [%s],
|
2017-11-15 22:13:39 +00:00
|
|
|
headers = %s,
|
2017-08-14 00:04:19 +00:00
|
|
|
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
|
2017-04-04 23:09:31 +00:00
|
|
|
compiler_flags = rocksdb_compiler_flags,
|
2017-11-15 22:13:39 +00:00
|
|
|
preprocessor_flags = rocksdb_preprocessor_flags,
|
|
|
|
deps = [%s],
|
2017-04-04 23:09:31 +00:00
|
|
|
external_deps = rocksdb_external_deps,
|
|
|
|
)
|
|
|
|
"""
|
|
|
|
|
|
|
|
binary_template = """
|
|
|
|
cpp_binary(
|
2017-11-15 22:13:39 +00:00
|
|
|
name = "%s",
|
|
|
|
srcs = [%s],
|
|
|
|
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
|
|
|
|
compiler_flags = rocksdb_compiler_flags,
|
|
|
|
preprocessor_flags = rocksdb_preprocessor_flags,
|
|
|
|
deps = [%s],
|
|
|
|
external_deps = rocksdb_external_deps,
|
2017-04-04 23:09:31 +00:00
|
|
|
)
|
|
|
|
"""
|
|
|
|
|
2017-11-15 22:13:39 +00:00
|
|
|
test_cfg_template = """ [
|
|
|
|
"%s",
|
|
|
|
"%s",
|
|
|
|
"%s",
|
|
|
|
],
|
|
|
|
"""
|
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
unittests_template = """
|
|
|
|
# [test_name, test_src, test_type]
|
2017-11-15 22:13:39 +00:00
|
|
|
ROCKS_TESTS = [
|
|
|
|
%s]
|
2017-04-04 23:09:31 +00:00
|
|
|
|
|
|
|
# Generate a test rule for each entry in ROCKS_TESTS
|
2017-11-30 18:40:39 +00:00
|
|
|
# Do not build the tests in opt mode, since SyncPoint and other test code
|
|
|
|
# will not be included.
|
|
|
|
if not is_opt_mode:
|
|
|
|
for test_cfg in ROCKS_TESTS:
|
|
|
|
test_name = test_cfg[0]
|
|
|
|
test_cc = test_cfg[1]
|
|
|
|
ttype = "gtest" if test_cfg[2] == "parallel" else "simple"
|
|
|
|
test_bin = test_name + "_bin"
|
|
|
|
|
|
|
|
cpp_binary (
|
|
|
|
name = test_bin,
|
|
|
|
srcs = [test_cc],
|
|
|
|
deps = [":rocksdb_test_lib"],
|
|
|
|
preprocessor_flags = rocksdb_preprocessor_flags,
|
|
|
|
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
|
|
|
|
compiler_flags = rocksdb_compiler_flags,
|
|
|
|
external_deps = rocksdb_external_deps,
|
|
|
|
)
|
|
|
|
|
|
|
|
custom_unittest(
|
|
|
|
name = test_name,
|
|
|
|
type = ttype,
|
|
|
|
deps = [":" + test_bin],
|
|
|
|
command = [TEST_RUNNER, BUCK_BINS + test_bin]
|
|
|
|
)
|
2017-04-12 22:00:03 +00:00
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
"""
|