mirror of
https://github.com/facebook/rocksdb.git
synced 2026-10-23 08:09:02 +03:00
Summary: Finish OpenZL, the internal RocksDB source tree, and the released RocksDB copy, removing all three parent AutoHeaders opt-ins. Declare inferred headers while preserving aliases, globs, selectors, and visibility. RocksDB's generator lists library headers and passes test source headers through its template and shared wrapper. Header lists account for the source files compiled by each release, so the older released tree does not gain headers from newer internal test helpers. Add `release_to_fbcode.py internal_repo_rocksdb --buck-only -y` to refresh the four Buck generator files and regenerate BUCK against the existing release's source lists. The command restores its five outputs if copying or generation fails, applies the existing generated-file warning, and rejects release-commit options. It does not copy runtime sources, change the release version, clone, commit, or deploy. Both RocksDB BUCK files are produced by the maintained generators. Graft the OpenZL dev declarations into prod. Align the predictor's Folly include paths and dependencies with prod so promotion is reproducible. Add the IPNext controller transition header explicitly. Authored with Codex. Reviewed By: IanChilds Differential Revision: D123482073 fbshipit-source-id: 05ab47e592d710834da56bbea57f5f93a0aea565
187 lines
6.1 KiB
Python
187 lines
6.1 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
|
|
|
try:
|
|
from builtins import object, str
|
|
except ImportError:
|
|
from __builtin__ import object, str
|
|
import pprint
|
|
|
|
import targets_cfg
|
|
|
|
class LiteralValue:
|
|
def __init__(self, value):
|
|
self.value = value
|
|
|
|
def __str__(self):
|
|
return str(self.value)
|
|
|
|
def smart_quote_value(val):
|
|
if isinstance(val, LiteralValue):
|
|
return str(val)
|
|
return '"%s"' % val
|
|
|
|
def pretty_list(lst, indent=8):
|
|
if lst is None or len(lst) == 0:
|
|
return ""
|
|
|
|
if len(lst) == 1:
|
|
return smart_quote_value(lst[0])
|
|
|
|
separator = ',\n%s' % (" " * indent)
|
|
res = separator.join(sorted(map(smart_quote_value, lst)))
|
|
res = "\n" + (" " * indent) + res + ',\n' + (" " * (indent - 4))
|
|
return res
|
|
|
|
|
|
class TARGETSBuilder:
|
|
def __init__(self, path, extra_argv):
|
|
self.path = path
|
|
header = targets_cfg.rocksdb_target_header_template.format(
|
|
extra_argv=extra_argv
|
|
)
|
|
with open(path, "wb") as targets_file:
|
|
targets_file.write(header.encode("utf-8"))
|
|
self.total_lib = 0
|
|
self.total_bin = 0
|
|
self.total_test = 0
|
|
self.tests_cfg = ""
|
|
|
|
def add_oncall(self, oncall):
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(targets_cfg.oncall_template.format(name=oncall).encode("utf-8"))
|
|
|
|
|
|
def add_library(
|
|
self,
|
|
name,
|
|
srcs,
|
|
deps=None,
|
|
headers=None,
|
|
extra_external_deps="",
|
|
link_whole=False,
|
|
external_dependencies=None,
|
|
extra_test_libs=False,
|
|
):
|
|
if headers is not None:
|
|
if isinstance(headers, LiteralValue):
|
|
headers = str(headers)
|
|
else:
|
|
headers = "[" + pretty_list(headers) + "]"
|
|
else:
|
|
headers = "[]"
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(
|
|
targets_cfg.library_template.format(
|
|
name=name,
|
|
srcs=pretty_list(srcs),
|
|
headers=headers,
|
|
deps=pretty_list(deps),
|
|
extra_external_deps=extra_external_deps,
|
|
link_whole=link_whole,
|
|
external_dependencies=pretty_list(external_dependencies),
|
|
extra_test_libs=extra_test_libs,
|
|
).encode("utf-8")
|
|
)
|
|
self.total_lib = self.total_lib + 1
|
|
|
|
def add_rocksdb_library(self, name, srcs, headers=None, external_dependencies=None):
|
|
headers = "[" + pretty_list(headers) + "]"
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(
|
|
targets_cfg.rocksdb_library_template.format(
|
|
name=name,
|
|
srcs=pretty_list(srcs),
|
|
headers=headers,
|
|
external_dependencies=pretty_list(external_dependencies),
|
|
).encode("utf-8")
|
|
)
|
|
self.total_lib = self.total_lib + 1
|
|
|
|
def add_binary(
|
|
self,
|
|
name,
|
|
srcs,
|
|
deps=None,
|
|
extra_preprocessor_flags=None,
|
|
extra_bench_libs=False,
|
|
):
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(
|
|
targets_cfg.binary_template.format(
|
|
name=name,
|
|
srcs=pretty_list(srcs),
|
|
deps=pretty_list(deps),
|
|
extra_preprocessor_flags=pretty_list(extra_preprocessor_flags),
|
|
extra_bench_libs=extra_bench_libs,
|
|
).encode("utf-8")
|
|
)
|
|
self.total_bin = self.total_bin + 1
|
|
|
|
def add_c_test(self):
|
|
# The actual c_test_bin target is defined by add_c_test_wrapper in the
|
|
# internal //rocks/buckifier:defs.bzl (not in this OSS repo). db/c_test.c
|
|
# #includes the generated c_api_gen/*.inc fragments, so under Buck's
|
|
# hermetic sandbox that wrapper must expose them as headers, e.g.
|
|
# headers = native.glob(["c_api_gen/**/*.inc"])
|
|
# (Make/CMake resolve the include via -I. / PROJECT_SOURCE_DIR.)
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(
|
|
b"""
|
|
add_c_test_wrapper()
|
|
"""
|
|
)
|
|
|
|
def add_test_header(self):
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(
|
|
b"""
|
|
# Generate a test rule for each entry in ROCKS_TESTS
|
|
# Do not build the tests in opt mode, since SyncPoint and other test code
|
|
# will not be included.
|
|
"""
|
|
)
|
|
|
|
def add_fancy_bench_config(
|
|
self,
|
|
name,
|
|
bench_config,
|
|
slow,
|
|
expected_runtime,
|
|
sl_iterations,
|
|
regression_threshold,
|
|
):
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(
|
|
targets_cfg.fancy_bench_template.format(
|
|
name=name,
|
|
bench_config=pprint.pformat(bench_config),
|
|
slow=slow,
|
|
expected_runtime=expected_runtime,
|
|
sl_iterations=sl_iterations,
|
|
regression_threshold=regression_threshold,
|
|
).encode("utf-8")
|
|
)
|
|
|
|
def register_test(self, test_name, src, deps, extra_compiler_flags, source_headers):
|
|
with open(self.path, "ab") as targets_file:
|
|
targets_file.write(
|
|
targets_cfg.unittests_template.format(
|
|
test_name=test_name,
|
|
test_cc=str(src),
|
|
source_headers=(
|
|
f" source_headers=[{pretty_list(source_headers, 16)}],\n"
|
|
if source_headers
|
|
else ""
|
|
),
|
|
deps=deps,
|
|
extra_compiler_flags=extra_compiler_flags,
|
|
).encode("utf-8")
|
|
)
|
|
self.total_test = self.total_test + 1
|
|
|
|
def export_file(self, name):
|
|
with open(self.path, "a") as targets_file:
|
|
targets_file.write(
|
|
targets_cfg.export_file_template.format(name=name)
|
|
)
|