2017-04-05 01:09:31 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import unicode_literals
|
2018-09-25 23:12:12 +02:00
|
|
|
rocksdb_target_header = """load("@fbcode_macros//build_defs:auto_headers.bzl", "AutoHeaders")
|
2019-01-07 22:35:12 +01:00
|
|
|
load(":defs.bzl", "test_binary")
|
2018-08-29 06:14:52 +02:00
|
|
|
|
|
|
|
REPO_PATH = package_name() + "/"
|
2017-11-15 23:13:39 +01:00
|
|
|
|
2019-01-07 22:35:12 +01:00
|
|
|
ROCKSDB_COMPILER_FLAGS = [
|
2017-11-15 23:13:39 +01: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 23:23:55 +02:00
|
|
|
# Added missing flags from output of build_detect_platform
|
|
|
|
"-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX",
|
|
|
|
"-DROCKSDB_BACKTRACE",
|
2018-06-21 23:30:00 +02:00
|
|
|
"-Wnarrowing",
|
2017-04-05 01:09:31 +02:00
|
|
|
]
|
|
|
|
|
2019-01-07 22:35:12 +01:00
|
|
|
ROCKSDB_EXTERNAL_DEPS = [
|
2017-11-15 23:13:39 +01: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-05 01:09:31 +02:00
|
|
|
]
|
|
|
|
|
2019-01-07 22:35:12 +01:00
|
|
|
ROCKSDB_PREPROCESSOR_FLAGS = [
|
2017-11-15 23:13:39 +01:00
|
|
|
# Directories with files for #include
|
|
|
|
"-I" + REPO_PATH + "include/",
|
|
|
|
"-I" + REPO_PATH,
|
2017-04-05 01:09:31 +02:00
|
|
|
]
|
2017-08-14 02:04:19 +02:00
|
|
|
|
2019-01-07 22:35:12 +01:00
|
|
|
ROCKSDB_ARCH_PREPROCESSOR_FLAGS = {
|
2018-03-06 21:19:15 +01:00
|
|
|
"x86_64": [
|
|
|
|
"-DHAVE_SSE42",
|
|
|
|
"-DHAVE_PCLMUL",
|
|
|
|
],
|
2017-08-14 02:04:19 +02:00
|
|
|
}
|
2017-11-30 19:40:39 +01: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.
|
2019-01-07 22:35:12 +01:00
|
|
|
ROCKSDB_COMPILER_FLAGS += (["-DNDEBUG"] if is_opt_mode else [])
|
2018-10-15 20:39:54 +02:00
|
|
|
|
|
|
|
sanitizer = read_config("fbcode", "sanitizer")
|
|
|
|
|
2019-01-04 01:26:31 +01:00
|
|
|
# Do not enable jemalloc if sanitizer presents. RocksDB will further detect
|
|
|
|
# whether the binary is linked with jemalloc at runtime.
|
2019-01-07 22:35:12 +01:00
|
|
|
ROCKSDB_COMPILER_FLAGS += (["-DROCKSDB_JEMALLOC"] if sanitizer == "" else [])
|
|
|
|
|
|
|
|
ROCKSDB_EXTERNAL_DEPS += ([("jemalloc", None, "headers")] if sanitizer == "" else [])
|
2017-04-05 01:09:31 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
library_template = """
|
|
|
|
cpp_library(
|
Change BUCK template files (#4624)
Summary:
Slightly changes the format of generated BUCK files for Facebook consumption. Generated targets end up looking like this:
```
cpp_library(
name = "rocksdb_tools_lib",
srcs = [
"tools/db_bench_tool.cc",
"tools/trace_analyzer_tool.cc",
"util/testutil.cc",
],
auto_headers = AutoHeaders.RECURSIVE_GLOB,
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
compiler_flags = rocksdb_compiler_flags,
preprocessor_flags = rocksdb_preprocessor_flags,
deps = [":rocksdb_lib"],
external_deps = rocksdb_external_deps,
)
```
Instead of
```
cpp_library(
name = "rocksdb_tools_lib",
srcs = [
"tools/db_bench_tool.cc",
"tools/trace_analyzer_tool.cc",
"util/testutil.cc",
],
headers = AutoHeaders.RECURSIVE_GLOB,
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
compiler_flags = rocksdb_compiler_flags,
preprocessor_flags = rocksdb_preprocessor_flags,
deps = [":rocksdb_lib"],
external_deps = rocksdb_external_deps,
)
```
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4624
Reviewed By: riversand963
Differential Revision: D12906711
Pulled By: philipjameson
fbshipit-source-id: 32ab64a3390cdcf2c4043ff77517ac1ad58a5e2b
2018-11-02 22:20:20 +01:00
|
|
|
name = "{name}",
|
|
|
|
srcs = [{srcs}],
|
|
|
|
{headers_attr_prefix}headers = {headers},
|
2019-01-07 22:35:12 +01:00
|
|
|
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
|
|
|
|
compiler_flags = ROCKSDB_COMPILER_FLAGS,
|
|
|
|
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
|
Change BUCK template files (#4624)
Summary:
Slightly changes the format of generated BUCK files for Facebook consumption. Generated targets end up looking like this:
```
cpp_library(
name = "rocksdb_tools_lib",
srcs = [
"tools/db_bench_tool.cc",
"tools/trace_analyzer_tool.cc",
"util/testutil.cc",
],
auto_headers = AutoHeaders.RECURSIVE_GLOB,
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
compiler_flags = rocksdb_compiler_flags,
preprocessor_flags = rocksdb_preprocessor_flags,
deps = [":rocksdb_lib"],
external_deps = rocksdb_external_deps,
)
```
Instead of
```
cpp_library(
name = "rocksdb_tools_lib",
srcs = [
"tools/db_bench_tool.cc",
"tools/trace_analyzer_tool.cc",
"util/testutil.cc",
],
headers = AutoHeaders.RECURSIVE_GLOB,
arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
compiler_flags = rocksdb_compiler_flags,
preprocessor_flags = rocksdb_preprocessor_flags,
deps = [":rocksdb_lib"],
external_deps = rocksdb_external_deps,
)
```
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4624
Reviewed By: riversand963
Differential Revision: D12906711
Pulled By: philipjameson
fbshipit-source-id: 32ab64a3390cdcf2c4043ff77517ac1ad58a5e2b
2018-11-02 22:20:20 +01:00
|
|
|
deps = [{deps}],
|
2019-01-07 22:35:12 +01:00
|
|
|
external_deps = ROCKSDB_EXTERNAL_DEPS,
|
2017-04-05 01:09:31 +02:00
|
|
|
)
|
|
|
|
"""
|
|
|
|
|
|
|
|
binary_template = """
|
|
|
|
cpp_binary(
|
2017-11-15 23:13:39 +01:00
|
|
|
name = "%s",
|
|
|
|
srcs = [%s],
|
2019-01-07 22:35:12 +01:00
|
|
|
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
|
|
|
|
compiler_flags = ROCKSDB_COMPILER_FLAGS,
|
|
|
|
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
|
2017-11-15 23:13:39 +01:00
|
|
|
deps = [%s],
|
2019-01-07 22:35:12 +01:00
|
|
|
external_deps = ROCKSDB_EXTERNAL_DEPS,
|
2017-04-05 01:09:31 +02:00
|
|
|
)
|
|
|
|
"""
|
|
|
|
|
2017-11-15 23:13:39 +01:00
|
|
|
test_cfg_template = """ [
|
|
|
|
"%s",
|
|
|
|
"%s",
|
|
|
|
"%s",
|
|
|
|
],
|
|
|
|
"""
|
|
|
|
|
2017-04-05 01:09:31 +02:00
|
|
|
unittests_template = """
|
|
|
|
# [test_name, test_src, test_type]
|
2017-11-15 23:13:39 +01:00
|
|
|
ROCKS_TESTS = [
|
|
|
|
%s]
|
2017-04-05 01:09:31 +02:00
|
|
|
|
|
|
|
# Generate a test rule for each entry in ROCKS_TESTS
|
2017-11-30 19:40:39 +01:00
|
|
|
# Do not build the tests in opt mode, since SyncPoint and other test code
|
|
|
|
# will not be included.
|
2019-01-07 22:35:12 +01:00
|
|
|
[
|
|
|
|
test_binary(
|
|
|
|
parallelism = parallelism,
|
|
|
|
rocksdb_arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
|
|
|
|
rocksdb_compiler_flags = ROCKSDB_COMPILER_FLAGS,
|
|
|
|
rocksdb_external_deps = ROCKSDB_EXTERNAL_DEPS,
|
|
|
|
rocksdb_preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
|
|
|
|
test_cc = test_cc,
|
|
|
|
test_name = test_name,
|
|
|
|
)
|
|
|
|
for test_name, test_cc, parallelism in ROCKS_TESTS
|
|
|
|
if not is_opt_mode
|
|
|
|
]
|
2017-04-05 01:09:31 +02:00
|
|
|
"""
|