targets_cfg.py 2.9 KB
Newer Older
1 2 3 4
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
I
Islam AbdelRahman 已提交
5 6 7 8
rocksdb_target_header = """
import os

TARGETS_PATH = os.path.dirname(__file__)
9
REPO_PATH = "rocksdb/src/"
10 11 12 13 14 15 16 17
BUCK_BINS = "buck-out/gen/" + REPO_PATH
TEST_RUNNER = REPO_PATH + "buckifier/rocks_test_runner.sh"
rocksdb_compiler_flags = [
  "-fno-builtin-memcmp",
  "-DROCKSDB_PLATFORM_POSIX",
  "-DROCKSDB_LIB_IO_POSIX",
  "-DROCKSDB_FALLOCATE_PRESENT",
  "-DROCKSDB_MALLOC_USABLE_SIZE",
A
Aaron Gao 已提交
18 19 20
  "-DROCKSDB_RANGESYNC_PRESENT",
  "-DROCKSDB_SCHED_GETCPU_PRESENT",
  "-DROCKSDB_SUPPORT_THREAD_LOCAL",
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  "-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",
]

rocksdb_external_deps = [
  ('bzip2', None, 'bz2'),
  ('snappy', None, "snappy"),
  ('zlib', None, 'z'),
  ('gflags', None, 'gflags'),
  ('lz4', None, 'lz4'),
  ('zstd', None),
  ('tbb', None),
Y
Yi Wu 已提交
43
  ("numa", None, "numa"),
44 45 46 47 48 49 50 51
  ("googletest", None, "gtest"),
]

rocksdb_preprocessor_flags = [
  # Directories with files for #include
  "-I" + REPO_PATH + "include/",
  "-I" + REPO_PATH,
]
52 53 54 55

rocksdb_arch_preprocessor_flags = {
  "x86_64": ["-DHAVE_SSE42"],
}
56 57 58 59 60 61 62 63 64 65
"""


library_template = """
cpp_library(
    name = "%s",
    headers = %s,
    srcs = [%s],
    deps = [%s],
    preprocessor_flags = rocksdb_preprocessor_flags,
66
    arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
67 68 69 70 71 72 73 74 75 76 77
    compiler_flags = rocksdb_compiler_flags,
    external_deps = rocksdb_external_deps,
)
"""

binary_template = """
cpp_binary(
  name = "%s",
  srcs = [%s],
  deps = [%s],
  preprocessor_flags = rocksdb_preprocessor_flags,
78
  arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  compiler_flags = rocksdb_compiler_flags,
  external_deps = rocksdb_external_deps,
)
"""

unittests_template = """
# [test_name, test_src, test_type]
ROCKS_TESTS = %s


# Generate a test rule for each entry in ROCKS_TESTS
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,
101
      arch_preprocessor_flags = rocksdb_arch_preprocessor_flags,
102 103 104 105 106 107 108 109 110 111
      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]
    )
112 113 114 115 116 117 118 119 120 121 122 123

custom_unittest(
    name = "make_rocksdbjavastatic",
    type = "simple",
    command = ["internal_repo_rocksdb/make_rocksdbjavastatic.sh"],
)

custom_unittest(
    name = "make_rocksdb_lite_release",
    type = "simple",
    command = ["internal_repo_rocksdb/make_rocksdb_lite_release.sh"],
)
124
"""