diff --git a/TARGETS b/TARGETS index 4b9460f05..26c6d9a48 100644 --- a/TARGETS +++ b/TARGETS @@ -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 <-- # This file is a Facebook-specific integration for buck builds, so can # only be validated by Facebook employees. diff --git a/buckifier/buckify_rocksdb.py b/buckifier/buckify_rocksdb.py index f0909bc61..6dfedbce1 100644 --- a/buckifier/buckify_rocksdb.py +++ b/buckifier/buckify_rocksdb.py @@ -24,10 +24,10 @@ from util import ColorString # (This generates a TARGET file without user-specified dependency for unit # tests.) # $python3 buckifier/buckify_rocksdb.py \ -# '{"fake": { \ -# "extra_deps": [":test_dep", "//fakes/module:mock1"], \ -# "extra_compiler_flags": ["-DROCKSDB_LITE", "-Os"], \ -# } \ +# '{"fake": { +# "extra_deps": [":test_dep", "//fakes/module:mock1"], +# "extra_compiler_flags": ["-DROCKSDB_LITE", "-Os"] +# } # }' # (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 @@ -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: 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 TARGETS.add_library( diff --git a/buckifier/targets_builder.py b/buckifier/targets_builder.py index e55238b2f..bf61b3ae1 100644 --- a/buckifier/targets_builder.py +++ b/buckifier/targets_builder.py @@ -25,10 +25,11 @@ def pretty_list(lst, indent=8): class TARGETSBuilder(object): - def __init__(self, path): + def __init__(self, path, extra_argv): self.path = path 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.total_lib = 0 self.total_bin = 0 diff --git a/buckifier/targets_cfg.py b/buckifier/targets_cfg.py index 0c20ef095..986a75b88 100644 --- a/buckifier/targets_cfg.py +++ b/buckifier/targets_cfg.py @@ -5,7 +5,8 @@ from __future__ import print_function from __future__ import unicode_literals 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 <-- # This file is a Facebook-specific integration for buck builds, so can # only be validated by Facebook employees. @@ -99,11 +100,11 @@ ROCKSDB_PREPROCESSOR_FLAGS = [ "-I" + REPO_PATH, ] -ROCKSDB_ARCH_PREPROCESSOR_FLAGS = { +ROCKSDB_ARCH_PREPROCESSOR_FLAGS = {{ "x86_64": [ "-DHAVE_PCLMUL", ], -} +}} build_mode = read_config("fbcode", "build_mode")