Skip to content

Commit

Permalink
Remove last user of AutoHeaders.RECURSIVE_GLOB
Browse files Browse the repository at this point in the history
Summary: I came across this code while buckifying parts of folly and fizz in open source. This is pretty hacky code and cleaning it up doesn't seem that hard, so I did it.

Reviewed By: zertosh, pdillinger

Differential Revision: D62781766

fbshipit-source-id: 43714bce992c53149d1e619063d803297362fb5d
  • Loading branch information
bigfootjon authored and facebook-github-bot committed Sep 17, 2024
1 parent 8648fbc commit a164576
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
14 changes: 7 additions & 7 deletions TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
"//folly/experimental/coro:coroutine",
"//folly/experimental/coro:task",
"//folly/synchronization:distributed_mutex",
], headers=None, link_whole=False, extra_test_libs=False)
], headers=glob(["**/*.h"]), link_whole=False, extra_test_libs=False)

cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[], deps=[":rocksdb_lib"], headers=None, link_whole=True, extra_test_libs=False)
cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[], deps=[":rocksdb_lib"], headers=[], link_whole=True, extra_test_libs=False)

cpp_library_wrapper(name="rocksdb_test_lib", srcs=[
"db/db_test_util.cc",
Expand All @@ -378,17 +378,17 @@ cpp_library_wrapper(name="rocksdb_test_lib", srcs=[
"tools/trace_analyzer_tool.cc",
"utilities/agg_merge/test_agg_merge.cc",
"utilities/cassandra/test_utils.cc",
], deps=[":rocksdb_lib"], headers=None, link_whole=False, extra_test_libs=True)
], deps=[":rocksdb_lib"], headers=[], link_whole=False, extra_test_libs=True)

cpp_library_wrapper(name="rocksdb_tools_lib", srcs=[
"test_util/testutil.cc",
"tools/block_cache_analyzer/block_cache_trace_analyzer.cc",
"tools/db_bench_tool.cc",
"tools/simulated_hybrid_file_system.cc",
"tools/trace_analyzer_tool.cc",
], deps=[":rocksdb_lib"], headers=None, link_whole=False, extra_test_libs=False)
], deps=[":rocksdb_lib"], headers=[], link_whole=False, extra_test_libs=False)

cpp_library_wrapper(name="rocksdb_cache_bench_tools_lib", srcs=["cache/cache_bench_tool.cc"], deps=[":rocksdb_lib"], headers=None, link_whole=False, extra_test_libs=False)
cpp_library_wrapper(name="rocksdb_cache_bench_tools_lib", srcs=["cache/cache_bench_tool.cc"], deps=[":rocksdb_lib"], headers=[], link_whole=False, extra_test_libs=False)

rocks_cpp_library_wrapper(name="rocksdb_stress_lib", srcs=[
"db_stress_tool/batched_ops_stress.cc",
Expand All @@ -410,7 +410,7 @@ rocks_cpp_library_wrapper(name="rocksdb_stress_lib", srcs=[
"test_util/testutil.cc",
"tools/block_cache_analyzer/block_cache_trace_analyzer.cc",
"tools/trace_analyzer_tool.cc",
], headers=None)
], headers=[])


cpp_binary_wrapper(name="ldb", srcs=["tools/ldb.cc"], deps=[":rocksdb_tools_lib"], extra_preprocessor_flags=[], extra_bench_libs=False)
Expand Down Expand Up @@ -5026,7 +5026,7 @@ cpp_unittest_wrapper(name="dynamic_bloom_test",
extra_compiler_flags=[])


cpp_library_wrapper(name="env_basic_test_lib", srcs=["env/env_basic_test.cc"], deps=[":rocksdb_test_lib"], headers=None, link_whole=False, extra_test_libs=True)
cpp_library_wrapper(name="env_basic_test_lib", srcs=["env/env_basic_test.cc"], deps=[":rocksdb_test_lib"], headers=[], link_whole=False, extra_test_libs=True)

cpp_unittest_wrapper(name="env_basic_test",
srcs=["env/env_basic_test.cc"],
Expand Down
4 changes: 2 additions & 2 deletions buckifier/buckify_rocksdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import sys

from targets_builder import TARGETSBuilder
from targets_builder import TARGETSBuilder, LiteralValue

from util import ColorString

Expand Down Expand Up @@ -150,6 +150,7 @@ def generate_targets(repo_path, deps_map):
"//folly/experimental/coro:task",
"//folly/synchronization:distributed_mutex",
],
headers=LiteralValue("glob([\"**/*.h\"])")
)
# rocksdb_whole_archive_lib
TARGETS.add_library(
Expand All @@ -158,7 +159,6 @@ def generate_targets(repo_path, deps_map):
deps=[
":rocksdb_lib",
],
headers=None,
extra_external_deps="",
link_whole=True,
)
Expand Down
29 changes: 22 additions & 7 deletions buckifier/targets_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,28 @@

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 '"%s"' % lst[0]
return smart_quote_value(lst[0])

separator = '",\n%s"' % (" " * indent)
res = separator.join(sorted(lst))
res = "\n" + (" " * indent) + '"' + res + '",\n' + (" " * (indent - 4))
separator = ',\n%s' % (" " * indent)
res = separator.join(sorted(map(smart_quote_value, lst)))
res = "\n" + (" " * indent) + res + ',\n' + (" " * (indent - 4))
return res


Expand Down Expand Up @@ -48,7 +59,12 @@ def add_library(
extra_test_libs=False,
):
if headers is not None:
headers = "[" + pretty_list(headers) + "]"
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(
Expand All @@ -65,8 +81,7 @@ def add_library(
self.total_lib = self.total_lib + 1

def add_rocksdb_library(self, name, srcs, headers=None, external_dependencies=None):
if headers is not None:
headers = "[" + pretty_list(headers) + "]"
headers = "[" + pretty_list(headers) + "]"
with open(self.path, "ab") as targets_file:
targets_file.write(
targets_cfg.rocksdb_library_template.format(
Expand Down

0 comments on commit a164576

Please sign in to comment.