Accurate re-generate command in TARGETS file (#7902)

Summary:
TIL we have different versions of TARGETS file generated with
options passed to buckifier. Someone thought they were totally fine to
squash the file by re-running the command to generate (pretty reasonable
assumption) but the command was incorrect due to missing the extra
argument used to generate THAT TARGETS file.

This change includes in the command written in the TARGETS header the
extra argument passed to buckify (when used).

Pull Request resolved: https://github.com/facebook/rocksdb/pull/7902

Test Plan:
manual, as in the (now fixed) comments at the top of
buckify_rocksdb.py

Reviewed By: ajkr

Differential Revision: D26108317

Pulled By: pdillinger

fbshipit-source-id: 46e93dc1465e27bd18e0e0baa8eeee1b591c765d
This commit is contained in:
Peter Dillinger 2021-01-27 16:19:43 -08:00 committed by Facebook GitHub Bot
parent 8944a3bf27
commit 19210d5715
4 changed files with 20 additions and 11 deletions

View File

@ -1,4 +1,5 @@
# This file @generated by `python3 buckifier/buckify_rocksdb.py` # This file @generated by:
#$ python3 buckifier/buckify_rocksdb.py
# --> DO NOT EDIT MANUALLY <-- # --> DO NOT EDIT MANUALLY <--
# This file is a Facebook-specific integration for buck builds, so can # This file is a Facebook-specific integration for buck builds, so can
# only be validated by Facebook employees. # only be validated by Facebook employees.

View File

@ -24,10 +24,10 @@ from util import ColorString
# (This generates a TARGET file without user-specified dependency for unit # (This generates a TARGET file without user-specified dependency for unit
# tests.) # tests.)
# $python3 buckifier/buckify_rocksdb.py \ # $python3 buckifier/buckify_rocksdb.py \
# '{"fake": { \ # '{"fake": {
# "extra_deps": [":test_dep", "//fakes/module:mock1"], \ # "extra_deps": [":test_dep", "//fakes/module:mock1"],
# "extra_compiler_flags": ["-DROCKSDB_LITE", "-Os"], \ # "extra_compiler_flags": ["-DROCKSDB_LITE", "-Os"]
# } \ # }
# }' # }'
# (Generated TARGETS file has test_dep and mock1 as dependencies for RocksDB # (Generated TARGETS file has test_dep and mock1 as dependencies for RocksDB
# unit tests, and will use the extra_compiler_flags to compile the unit test # unit tests, and will use the extra_compiler_flags to compile the unit test
@ -129,7 +129,13 @@ def generate_targets(repo_path, deps_map):
if src_mk is None or cc_files is None or parallel_tests is None: if src_mk is None or cc_files is None or parallel_tests is None:
return False return False
TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path) extra_argv = ""
if len(sys.argv) >= 2:
# Heuristically quote and canonicalize whitespace for inclusion
# in how the file was generated.
extra_argv = " '{0}'".format(" ".join(sys.argv[1].split()))
TARGETS = TARGETSBuilder("%s/TARGETS" % repo_path, extra_argv)
# rocksdb_lib # rocksdb_lib
TARGETS.add_library( TARGETS.add_library(

View File

@ -25,10 +25,11 @@ def pretty_list(lst, indent=8):
class TARGETSBuilder(object): class TARGETSBuilder(object):
def __init__(self, path): def __init__(self, path, extra_argv):
self.path = path self.path = path
self.targets_file = open(path, 'wb') self.targets_file = open(path, 'wb')
header = targets_cfg.rocksdb_target_header_template header = targets_cfg.rocksdb_target_header_template.format(
extra_argv=extra_argv)
self.targets_file.write(header.encode("utf-8")) self.targets_file.write(header.encode("utf-8"))
self.total_lib = 0 self.total_lib = 0
self.total_bin = 0 self.total_bin = 0

View File

@ -5,7 +5,8 @@ from __future__ import print_function
from __future__ import unicode_literals from __future__ import unicode_literals
rocksdb_target_header_template = \ rocksdb_target_header_template = \
"""# This file \100generated by `python3 buckifier/buckify_rocksdb.py` """# This file \100generated by:
#$ python3 buckifier/buckify_rocksdb.py{extra_argv}
# --> DO NOT EDIT MANUALLY <-- # --> DO NOT EDIT MANUALLY <--
# This file is a Facebook-specific integration for buck builds, so can # This file is a Facebook-specific integration for buck builds, so can
# only be validated by Facebook employees. # only be validated by Facebook employees.
@ -99,11 +100,11 @@ ROCKSDB_PREPROCESSOR_FLAGS = [
"-I" + REPO_PATH, "-I" + REPO_PATH,
] ]
ROCKSDB_ARCH_PREPROCESSOR_FLAGS = { ROCKSDB_ARCH_PREPROCESSOR_FLAGS = {{
"x86_64": [ "x86_64": [
"-DHAVE_PCLMUL", "-DHAVE_PCLMUL",
], ],
} }}
build_mode = read_config("fbcode", "build_mode") build_mode = read_config("fbcode", "build_mode")