]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/buckifier/targets_cfg.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rocksdb / buckifier / targets_cfg.py
1 from __future__ import absolute_import
2 from __future__ import division
3 from __future__ import print_function
4 from __future__ import unicode_literals
5 rocksdb_target_header = """load("@fbcode_macros//build_defs:auto_headers.bzl", "AutoHeaders")
6
7 REPO_PATH = package_name() + "/"
8
9 BUCK_BINS = "buck-out/gen/" + REPO_PATH
10
11 TEST_RUNNER = REPO_PATH + "buckifier/rocks_test_runner.sh"
12
13 rocksdb_compiler_flags = [
14 "-fno-builtin-memcmp",
15 "-DROCKSDB_PLATFORM_POSIX",
16 "-DROCKSDB_LIB_IO_POSIX",
17 "-DROCKSDB_FALLOCATE_PRESENT",
18 "-DROCKSDB_MALLOC_USABLE_SIZE",
19 "-DROCKSDB_RANGESYNC_PRESENT",
20 "-DROCKSDB_SCHED_GETCPU_PRESENT",
21 "-DROCKSDB_SUPPORT_THREAD_LOCAL",
22 "-DOS_LINUX",
23 # Flags to enable libs we include
24 "-DSNAPPY",
25 "-DZLIB",
26 "-DBZIP2",
27 "-DLZ4",
28 "-DZSTD",
29 "-DGFLAGS=gflags",
30 "-DNUMA",
31 "-DTBB",
32 # Needed to compile in fbcode
33 "-Wno-expansion-to-defined",
34 # Added missing flags from output of build_detect_platform
35 "-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX",
36 "-DROCKSDB_BACKTRACE",
37 "-Wnarrowing",
38 ]
39
40 rocksdb_external_deps = [
41 ("bzip2", None, "bz2"),
42 ("snappy", None, "snappy"),
43 ("zlib", None, "z"),
44 ("gflags", None, "gflags"),
45 ("lz4", None, "lz4"),
46 ("zstd", None),
47 ("tbb", None),
48 ("numa", None, "numa"),
49 ("googletest", None, "gtest"),
50 ]
51
52 rocksdb_preprocessor_flags = [
53 # Directories with files for #include
54 "-I" + REPO_PATH + "include/",
55 "-I" + REPO_PATH,
56 ]
57
58 rocksdb_arch_preprocessor_flags = {
59 "x86_64": [
60 "-DHAVE_SSE42",
61 "-DHAVE_PCLMUL",
62 ],
63 }
64
65 build_mode = read_config("fbcode", "build_mode")
66
67 is_opt_mode = build_mode.startswith("opt")
68
69 # -DNDEBUG is added by default in opt mode in fbcode. But adding it twice
70 # doesn't harm and avoid forgetting to add it.
71 if is_opt_mode:
72 rocksdb_compiler_flags.append("-DNDEBUG")
73 """
74
75
76 library_template = """
77 cpp_library(
78 name = "{name}",
79 srcs = [{srcs}],
80 {headers_attr_prefix}headers = {headers},
81 arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
82 compiler_flags = rocksdb_compiler_flags,
83 preprocessor_flags = rocksdb_preprocessor_flags,
84 deps = [{deps}],
85 external_deps = rocksdb_external_deps,
86 )
87 """
88
89 binary_template = """
90 cpp_binary(
91 name = "%s",
92 srcs = [%s],
93 arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
94 compiler_flags = rocksdb_compiler_flags,
95 preprocessor_flags = rocksdb_preprocessor_flags,
96 deps = [%s],
97 external_deps = rocksdb_external_deps,
98 )
99 """
100
101 test_cfg_template = """ [
102 "%s",
103 "%s",
104 "%s",
105 ],
106 """
107
108 unittests_template = """
109 # [test_name, test_src, test_type]
110 ROCKS_TESTS = [
111 %s]
112
113 # Generate a test rule for each entry in ROCKS_TESTS
114 # Do not build the tests in opt mode, since SyncPoint and other test code
115 # will not be included.
116 if not is_opt_mode:
117 for test_cfg in ROCKS_TESTS:
118 test_name = test_cfg[0]
119 test_cc = test_cfg[1]
120 ttype = "gtest" if test_cfg[2] == "parallel" else "simple"
121 test_bin = test_name + "_bin"
122
123 cpp_binary(
124 name = test_bin,
125 srcs = [test_cc],
126 arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
127 compiler_flags = rocksdb_compiler_flags,
128 preprocessor_flags = rocksdb_preprocessor_flags,
129 deps = [":rocksdb_test_lib"],
130 external_deps = rocksdb_external_deps,
131 )
132
133 custom_unittest(
134 name = test_name,
135 command = [TEST_RUNNER, BUCK_BINS + test_bin],
136 type = ttype,
137 deps = [":" + test_bin],
138 )
139 """