From d0d2ab0b1a26dec722a8fd7b86373df75a66ba87 Mon Sep 17 00:00:00 2001 From: Andrew Gallagher Date: Sat, 3 Apr 2021 14:41:25 -0700 Subject: [PATCH] Use `include_paths` instead of raw `-I` in TARGETS (#8143) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/8143 The latter assume the location of the compile root, which can break if the build root changes. Switch to the slightly more intelligent `include_paths`, which should provide the same functionality, but do with independent of include root. Reviewed By: riversand963 Differential Revision: D27535869 fbshipit-source-id: 0129e47c0ce23e08528c9139114a591c14866fa8 --- TARGETS | 16 +++++++++++++--- buckifier/targets_builder.py | 1 + buckifier/targets_cfg.py | 12 +++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/TARGETS b/TARGETS index 3b73b164c..7e1b3ac6b 100644 --- a/TARGETS +++ b/TARGETS @@ -87,10 +87,12 @@ ROCKSDB_PREPROCESSOR_FLAGS = [ # Added missing flags from output of build_detect_platform "-DROCKSDB_BACKTRACE", +] - # Directories with files for #include - "-I" + REPO_PATH + "include/", - "-I" + REPO_PATH, +# Directories with files for #include +ROCKSDB_INCLUDE_PATHS = [ + "", + "include", ] ROCKSDB_ARCH_PREPROCESSOR_FLAGS = { @@ -428,6 +430,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [], external_deps = ROCKSDB_EXTERNAL_DEPS, link_whole = False, @@ -735,6 +738,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [], external_deps = ROCKSDB_EXTERNAL_DEPS, link_whole = True, @@ -758,6 +762,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [":rocksdb_lib"], external_deps = ROCKSDB_EXTERNAL_DEPS + [ ("googletest", None, "gtest"), @@ -779,6 +784,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [":rocksdb_lib"], external_deps = ROCKSDB_EXTERNAL_DEPS, link_whole = False, @@ -806,6 +812,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = ROCKSDB_LIB_DEPS, external_deps = ROCKSDB_EXTERNAL_DEPS, ) @@ -817,6 +824,7 @@ cpp_binary( os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [":rocksdb_test_lib"], ) if not is_opt_mode else None @@ -838,6 +846,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [":rocksdb_test_lib"], external_deps = ROCKSDB_EXTERNAL_DEPS, link_whole = False, @@ -2118,6 +2127,7 @@ ROCKS_TESTS = [ os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS + extra_compiler_flags, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [":rocksdb_test_lib"] + extra_deps, external_deps = ROCKSDB_EXTERNAL_DEPS + [ ("googletest", None, "gtest"), diff --git a/buckifier/targets_builder.py b/buckifier/targets_builder.py index bf61b3ae1..d2649c131 100644 --- a/buckifier/targets_builder.py +++ b/buckifier/targets_builder.py @@ -87,6 +87,7 @@ cpp_binary( os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [":rocksdb_test_lib"], ) if not is_opt_mode else None diff --git a/buckifier/targets_cfg.py b/buckifier/targets_cfg.py index 603aea1b4..56cf77b6a 100644 --- a/buckifier/targets_cfg.py +++ b/buckifier/targets_cfg.py @@ -94,10 +94,12 @@ ROCKSDB_PREPROCESSOR_FLAGS = [ # Added missing flags from output of build_detect_platform "-DROCKSDB_BACKTRACE", +] - # Directories with files for #include - "-I" + REPO_PATH + "include/", - "-I" + REPO_PATH, +# Directories with files for #include +ROCKSDB_INCLUDE_PATHS = [ + "", + "include", ] ROCKSDB_ARCH_PREPROCESSOR_FLAGS = {{ @@ -145,6 +147,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [{deps}], external_deps = ROCKSDB_EXTERNAL_DEPS{extra_external_deps}, link_whole = {link_whole}, @@ -161,6 +164,7 @@ cpp_library( os_deps = ROCKSDB_OS_DEPS, os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = ROCKSDB_LIB_DEPS, external_deps = ROCKSDB_EXTERNAL_DEPS, ) @@ -173,6 +177,7 @@ cpp_binary( arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [{deps}], external_deps = ROCKSDB_EXTERNAL_DEPS, ) @@ -203,6 +208,7 @@ ROCKS_TESTS = [ os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS, compiler_flags = ROCKSDB_COMPILER_FLAGS + extra_compiler_flags, preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS, + include_paths = ROCKSDB_INCLUDE_PATHS, deps = [":rocksdb_test_lib"] + extra_deps, external_deps = ROCKSDB_EXTERNAL_DEPS + [ ("googletest", None, "gtest"),