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
|
|
|
|
import targets_cfg
|
|
|
|
|
2017-11-15 22:13:39 +00:00
|
|
|
def pretty_list(lst, indent=8):
|
2017-04-04 23:09:31 +00:00
|
|
|
if lst is None or len(lst) == 0:
|
|
|
|
return ""
|
|
|
|
|
|
|
|
if len(lst) == 1:
|
|
|
|
return "\"%s\"" % lst[0]
|
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
|
|
|
|
2017-04-04 23:09:31 +00:00
|
|
|
separator = "\",\n%s\"" % (" " * indent)
|
2017-11-15 22:13:39 +00:00
|
|
|
res = separator.join(sorted(lst))
|
|
|
|
res = "\n" + (" " * indent) + "\"" + res + "\",\n" + (" " * (indent - 4))
|
2017-04-04 23:09:31 +00:00
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
class TARGETSBuilder:
|
|
|
|
def __init__(self, path):
|
|
|
|
self.path = path
|
|
|
|
self.targets_file = open(path, 'w')
|
|
|
|
self.targets_file.write(targets_cfg.rocksdb_target_header)
|
|
|
|
self.total_lib = 0
|
|
|
|
self.total_bin = 0
|
|
|
|
self.total_test = 0
|
2017-11-15 22:13:39 +00:00
|
|
|
self.tests_cfg = ""
|
2017-04-04 23:09:31 +00:00
|
|
|
|
|
|
|
def __del__(self):
|
|
|
|
self.targets_file.close()
|
|
|
|
|
|
|
|
def add_library(self, name, srcs, deps=None, headers=None):
|
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
|
|
|
headers_attr_prefix = ""
|
2017-04-04 23:09:31 +00:00
|
|
|
if headers is None:
|
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
|
|
|
headers_attr_prefix = "auto_"
|
2017-04-04 23:09:31 +00:00
|
|
|
headers = "AutoHeaders.RECURSIVE_GLOB"
|
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
|
|
|
self.targets_file.write(targets_cfg.library_template.format(
|
|
|
|
name=name,
|
|
|
|
srcs=pretty_list(srcs),
|
|
|
|
headers_attr_prefix=headers_attr_prefix,
|
|
|
|
headers=headers,
|
|
|
|
deps=pretty_list(deps)))
|
2017-04-04 23:09:31 +00:00
|
|
|
self.total_lib = self.total_lib + 1
|
|
|
|
|
|
|
|
def add_binary(self, name, srcs, deps=None):
|
|
|
|
self.targets_file.write(targets_cfg.binary_template % (
|
|
|
|
name,
|
|
|
|
pretty_list(srcs),
|
|
|
|
pretty_list(deps)))
|
|
|
|
self.total_bin = self.total_bin + 1
|
|
|
|
|
|
|
|
def register_test(self, test_name, src, is_parallel):
|
|
|
|
exec_mode = "serial"
|
|
|
|
if is_parallel:
|
|
|
|
exec_mode = "parallel"
|
2017-11-15 22:13:39 +00:00
|
|
|
self.tests_cfg += targets_cfg.test_cfg_template % (
|
|
|
|
test_name,
|
|
|
|
str(src),
|
|
|
|
str(exec_mode))
|
2017-04-04 23:09:31 +00:00
|
|
|
|
|
|
|
self.total_test = self.total_test + 1
|
|
|
|
|
|
|
|
def flush_tests(self):
|
2017-11-15 22:13:39 +00:00
|
|
|
self.targets_file.write(targets_cfg.unittests_template % self.tests_cfg)
|
|
|
|
self.tests_cfg = ""
|