2019-04-18 17:51:19 +00:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
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
|
2019-11-06 04:19:17 +00:00
|
|
|
|
2020-05-20 18:35:28 +00:00
|
|
|
rocksdb_target_header_template = \
|
2021-01-28 00:19:43 +00:00
|
|
|
"""# This file \100generated by:
|
|
|
|
#$ python3 buckifier/buckify_rocksdb.py{extra_argv}
|
2019-11-06 04:19:17 +00:00
|
|
|
# --> DO NOT EDIT MANUALLY <--
|
|
|
|
# This file is a Facebook-specific integration for buck builds, so can
|
|
|
|
# only be validated by Facebook employees.
|
|
|
|
#
|
|
|
|
load("@fbcode_macros//build_defs:auto_headers.bzl", "AutoHeaders")
|
2019-02-13 18:54:25 +00:00
|
|
|
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
|
2019-01-07 21:35:12 +00:00
|
|
|
load(":defs.bzl", "test_binary")
|
2018-08-29 04:14:52 +00:00
|
|
|
|
|
|
|
REPO_PATH = package_name() + "/"
|
2017-11-15 22:13:39 +00:00
|
|
|
|
2021-06-04 23:28:10 +00:00
|
|
|
ROCKSDB_COMPILER_FLAGS_0 = [
|
2017-11-15 22:13:39 +00:00
|
|
|
"-fno-builtin-memcmp",
|
|
|
|
# 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
|
2018-06-21 21:30:00 +00:00
|
|
|
"-Wnarrowing",
|
2019-06-04 05:59:54 +00:00
|
|
|
"-DROCKSDB_NO_DYNAMIC_EXTENSION",
|
2017-04-04 23:09:31 +00:00
|
|
|
]
|
|
|
|
|
2019-01-07 21:35:12 +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"),
|
2021-02-08 22:44:02 +00:00
|
|
|
("zstd", None, "zstd"),
|
2017-04-04 23:09:31 +00:00
|
|
|
]
|
|
|
|
|
2021-06-04 23:28:10 +00:00
|
|
|
ROCKSDB_OS_DEPS_0 = [
|
2019-07-30 22:56:41 +00:00
|
|
|
(
|
|
|
|
"linux",
|
2021-11-01 17:09:50 +00:00
|
|
|
[
|
|
|
|
"third-party//numa:numa",
|
|
|
|
"third-party//liburing:uring",
|
|
|
|
"third-party//tbb:tbb",
|
|
|
|
],
|
2020-09-23 19:54:29 +00:00
|
|
|
),
|
|
|
|
(
|
|
|
|
"macos",
|
|
|
|
["third-party//tbb:tbb"],
|
2019-07-30 22:56:41 +00:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2021-06-04 23:28:10 +00:00
|
|
|
ROCKSDB_OS_PREPROCESSOR_FLAGS_0 = [
|
2019-07-30 22:56:41 +00:00
|
|
|
(
|
|
|
|
"linux",
|
|
|
|
[
|
|
|
|
"-DOS_LINUX",
|
|
|
|
"-DROCKSDB_FALLOCATE_PRESENT",
|
|
|
|
"-DROCKSDB_MALLOC_USABLE_SIZE",
|
|
|
|
"-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX",
|
|
|
|
"-DROCKSDB_RANGESYNC_PRESENT",
|
|
|
|
"-DROCKSDB_SCHED_GETCPU_PRESENT",
|
2020-02-24 23:45:47 +00:00
|
|
|
"-DROCKSDB_IOURING_PRESENT",
|
2019-07-30 22:56:41 +00:00
|
|
|
"-DHAVE_SSE42",
|
2020-02-24 23:45:47 +00:00
|
|
|
"-DLIBURING",
|
2019-07-30 22:56:41 +00:00
|
|
|
"-DNUMA",
|
2020-09-23 19:54:29 +00:00
|
|
|
"-DROCKSDB_PLATFORM_POSIX",
|
|
|
|
"-DROCKSDB_LIB_IO_POSIX",
|
|
|
|
"-DTBB",
|
2019-07-30 22:56:41 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"macos",
|
2020-09-23 19:54:29 +00:00
|
|
|
[
|
|
|
|
"-DOS_MACOSX",
|
|
|
|
"-DROCKSDB_PLATFORM_POSIX",
|
|
|
|
"-DROCKSDB_LIB_IO_POSIX",
|
|
|
|
"-DTBB",
|
|
|
|
],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"windows",
|
2021-11-01 17:09:50 +00:00
|
|
|
[
|
|
|
|
"-DOS_WIN",
|
|
|
|
"-DWIN32",
|
|
|
|
"-D_MBCS",
|
|
|
|
"-DWIN64",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
],
|
2019-07-30 22:56:41 +00:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2019-01-07 21:35:12 +00:00
|
|
|
ROCKSDB_PREPROCESSOR_FLAGS = [
|
2019-07-30 22:56:41 +00:00
|
|
|
"-DROCKSDB_SUPPORT_THREAD_LOCAL",
|
|
|
|
|
|
|
|
# Flags to enable libs we include
|
|
|
|
"-DSNAPPY",
|
|
|
|
"-DZLIB",
|
|
|
|
"-DBZIP2",
|
|
|
|
"-DLZ4",
|
|
|
|
"-DZSTD",
|
|
|
|
"-DZSTD_STATIC_LINKING_ONLY",
|
|
|
|
"-DGFLAGS=gflags",
|
|
|
|
|
|
|
|
# Added missing flags from output of build_detect_platform
|
|
|
|
"-DROCKSDB_BACKTRACE",
|
2021-04-03 21:41:25 +00:00
|
|
|
]
|
2019-07-30 22:56:41 +00:00
|
|
|
|
2021-04-03 21:41:25 +00:00
|
|
|
# Directories with files for #include
|
|
|
|
ROCKSDB_INCLUDE_PATHS = [
|
|
|
|
"",
|
|
|
|
"include",
|
2017-04-04 23:09:31 +00:00
|
|
|
]
|
2017-08-14 00:04:19 +00:00
|
|
|
|
2021-01-28 00:19:43 +00:00
|
|
|
ROCKSDB_ARCH_PREPROCESSOR_FLAGS = {{
|
2018-03-06 20:19:15 +00:00
|
|
|
"x86_64": [
|
|
|
|
"-DHAVE_PCLMUL",
|
|
|
|
],
|
2021-01-28 00:19:43 +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.
|
2021-06-04 23:28:10 +00:00
|
|
|
ROCKSDB_COMPILER_FLAGS = ROCKSDB_COMPILER_FLAGS_0 + (["-DNDEBUG"] if is_opt_mode else [])
|
2018-10-15 18:39:54 +00:00
|
|
|
|
|
|
|
sanitizer = read_config("fbcode", "sanitizer")
|
|
|
|
|
2019-01-04 00:26:31 +00:00
|
|
|
# Do not enable jemalloc if sanitizer presents. RocksDB will further detect
|
|
|
|
# whether the binary is linked with jemalloc at runtime.
|
2021-06-04 23:28:10 +00:00
|
|
|
ROCKSDB_OS_PREPROCESSOR_FLAGS = ROCKSDB_OS_PREPROCESSOR_FLAGS_0 + ([(
|
2019-07-30 22:56:41 +00:00
|
|
|
"linux",
|
|
|
|
["-DROCKSDB_JEMALLOC"],
|
|
|
|
)] if sanitizer == "" else [])
|
|
|
|
|
2021-06-04 23:28:10 +00:00
|
|
|
ROCKSDB_OS_DEPS = ROCKSDB_OS_DEPS_0 + ([(
|
2019-07-30 22:56:41 +00:00
|
|
|
"linux",
|
|
|
|
["third-party//jemalloc:headers"],
|
|
|
|
)] if sanitizer == "" else [])
|
2020-05-17 04:46:21 +00:00
|
|
|
|
|
|
|
ROCKSDB_LIB_DEPS = [
|
|
|
|
":rocksdb_lib",
|
|
|
|
":rocksdb_test_lib",
|
|
|
|
] if not is_opt_mode else [":rocksdb_lib"]
|
2017-04-04 23:09:31 +00: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 21:20:20 +00:00
|
|
|
name = "{name}",
|
|
|
|
srcs = [{srcs}],
|
|
|
|
{headers_attr_prefix}headers = {headers},
|
2019-01-07 21:35:12 +00:00
|
|
|
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
|
|
|
|
compiler_flags = ROCKSDB_COMPILER_FLAGS,
|
2021-11-01 17:09:50 +00:00
|
|
|
include_paths = ROCKSDB_INCLUDE_PATHS,
|
|
|
|
link_whole = {link_whole},
|
2019-07-30 22:56:41 +00:00
|
|
|
os_deps = ROCKSDB_OS_DEPS,
|
|
|
|
os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS,
|
2019-01-07 21:35:12 +00:00
|
|
|
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
|
2021-11-01 17:09:50 +00:00
|
|
|
unexported_deps_by_default = False,
|
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 21:20:20 +00:00
|
|
|
deps = [{deps}],
|
2020-06-05 19:14:42 +00:00
|
|
|
external_deps = ROCKSDB_EXTERNAL_DEPS{extra_external_deps},
|
2017-04-04 23:09:31 +00:00
|
|
|
)
|
|
|
|
"""
|
|
|
|
|
2020-05-17 04:46:21 +00:00
|
|
|
rocksdb_library_template = """
|
|
|
|
cpp_library(
|
|
|
|
name = "{name}",
|
|
|
|
srcs = [{srcs}],
|
|
|
|
{headers_attr_prefix}headers = {headers},
|
|
|
|
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
|
|
|
|
compiler_flags = ROCKSDB_COMPILER_FLAGS,
|
2021-11-01 17:09:50 +00:00
|
|
|
include_paths = ROCKSDB_INCLUDE_PATHS,
|
2020-05-17 04:46:21 +00:00
|
|
|
os_deps = ROCKSDB_OS_DEPS,
|
|
|
|
os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS,
|
|
|
|
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
|
2021-11-01 17:09:50 +00:00
|
|
|
unexported_deps_by_default = False,
|
2020-05-17 04:46:21 +00:00
|
|
|
deps = ROCKSDB_LIB_DEPS,
|
|
|
|
external_deps = ROCKSDB_EXTERNAL_DEPS,
|
|
|
|
)
|
|
|
|
"""
|
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
binary_template = """
|
|
|
|
cpp_binary(
|
2020-09-23 19:54:29 +00:00
|
|
|
name = "{name}",
|
|
|
|
srcs = [{srcs}],
|
2019-01-07 21:35:12 +00:00
|
|
|
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
|
|
|
|
compiler_flags = ROCKSDB_COMPILER_FLAGS,
|
|
|
|
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
|
2021-04-03 21:41:25 +00:00
|
|
|
include_paths = ROCKSDB_INCLUDE_PATHS,
|
2020-09-23 19:54:29 +00:00
|
|
|
deps = [{deps}],
|
2019-01-07 21:35:12 +00:00
|
|
|
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",
|
2019-08-02 17:40:32 +00:00
|
|
|
%s,
|
|
|
|
%s,
|
2017-11-15 22:13:39 +00:00
|
|
|
],
|
|
|
|
"""
|
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
unittests_template = """
|
2019-08-02 17:40:32 +00:00
|
|
|
# [test_name, test_src, test_type, extra_deps, extra_compiler_flags]
|
2017-11-15 22:13:39 +00:00
|
|
|
ROCKS_TESTS = [
|
2020-09-23 19:54:29 +00:00
|
|
|
{tests}]
|
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.
|
2019-01-07 21:35:12 +00:00
|
|
|
[
|
2020-06-05 19:14:42 +00:00
|
|
|
cpp_unittest(
|
|
|
|
name = test_name,
|
|
|
|
srcs = [test_cc],
|
|
|
|
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
|
2020-09-25 23:43:23 +00:00
|
|
|
compiler_flags = ROCKSDB_COMPILER_FLAGS + extra_compiler_flags,
|
2021-04-03 21:41:25 +00:00
|
|
|
include_paths = ROCKSDB_INCLUDE_PATHS,
|
2021-11-01 17:09:50 +00:00
|
|
|
os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS,
|
|
|
|
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
|
2020-06-05 19:14:42 +00:00
|
|
|
deps = [":rocksdb_test_lib"] + extra_deps,
|
|
|
|
external_deps = ROCKSDB_EXTERNAL_DEPS + [
|
|
|
|
("googletest", None, "gtest"),
|
|
|
|
],
|
2019-01-07 21:35:12 +00:00
|
|
|
)
|
2019-08-02 17:40:32 +00:00
|
|
|
for test_name, test_cc, parallelism, extra_deps, extra_compiler_flags in ROCKS_TESTS
|
2019-01-07 21:35:12 +00:00
|
|
|
if not is_opt_mode
|
|
|
|
]
|
2017-04-04 23:09:31 +00:00
|
|
|
"""
|