Add support for copybara inline directives in BUILD and .bzl files.

Open-source BUILD files are mapped to the Google-internal variants and vice-versa using a [copybara](https://github.com/google/copybara) workflow. This change adds a step to this workflow that allows inline directives to (un-)comment code:

```python
cc_binary(
    ...
    srcs = [
        "common_src.cc",
        # copybara:uncomment(<reason here>) "google_only_src.cc",
        "oss_only_src.cc",  # copybara:comment(<reason here>)
    ],
    deps = [
        ":common_dep",
        # copybara:uncomment_begin(<reason here>)
        # ":google_only_dep",
        # copybara:uncomment_end_and_comment_begin
        ":oss_only_dep",
        # copybara:comment_end
    ],
)
```

The intended use case is to encode relatively small one-off
differences between internal and OSS BUILD files. Making those differences
explicit and inline will hopefully help contributors to write PRs that don't trip up our internal build, and Googlers to write changes that don't break the OSS build.

PiperOrigin-RevId: 351841102
Change-Id: Id3751e90966e73db66b9b37c62184233c08e74d5
This commit is contained in:
Christian Sigg 2021-01-14 11:30:44 -08:00 committed by TensorFlower Gardener
parent a70d68b3ac
commit 3ca937c9ef
3 changed files with 6 additions and 11 deletions

View File

@ -14,7 +14,6 @@ load(
)
load(
"//tensorflow/core/platform:build_config.bzl",
"tf_additional_env_hdrs",
"tf_additional_lib_hdrs",
"tf_additional_tensor_coding_deps",
"tf_additional_test_srcs",
@ -1382,10 +1381,6 @@ filegroup(
"numa.h",
"path.h",
"prefetch.h",
"//tensorflow/core/platform/profile_utils:android_armv7a_cpu_utils_helper.h",
"//tensorflow/core/platform/profile_utils:clock_cycle_profiler.h",
"//tensorflow/core/platform/profile_utils:cpu_utils.h",
"//tensorflow/core/platform/profile_utils:i_cpu_utils_helper.h",
"protobuf.h",
"ram_file_system.h",
"random.h",
@ -1401,7 +1396,12 @@ filegroup(
"subprocess.h",
"thread_annotations.h",
":base_hdrs",
] + tf_additional_env_hdrs(),
# copybara:uncomment(GoogleFileSystem) "//tensorflow/core/platform/google:env.h",
"//tensorflow/core/platform/profile_utils:android_armv7a_cpu_utils_helper.h",
"//tensorflow/core/platform/profile_utils:clock_cycle_profiler.h",
"//tensorflow/core/platform/profile_utils:cpu_utils.h",
"//tensorflow/core/platform/profile_utils:i_cpu_utils_helper.h",
],
visibility = ["//tensorflow/core:__pkg__"],
)

View File

@ -10,7 +10,6 @@ load(
_tf_additional_core_deps = "tf_additional_core_deps",
_tf_additional_cupti_utils_cuda_deps = "tf_additional_cupti_utils_cuda_deps",
_tf_additional_device_tracer_srcs = "tf_additional_device_tracer_srcs",
_tf_additional_env_hdrs = "tf_additional_env_hdrs",
_tf_additional_lib_deps = "tf_additional_lib_deps",
_tf_additional_lib_hdrs = "tf_additional_lib_hdrs",
_tf_additional_rpc_deps = "tf_additional_rpc_deps",
@ -53,7 +52,6 @@ tf_additional_binary_deps = _tf_additional_binary_deps
tf_additional_core_deps = _tf_additional_core_deps
tf_additional_cupti_utils_cuda_deps = _tf_additional_cupti_utils_cuda_deps
tf_additional_device_tracer_srcs = _tf_additional_device_tracer_srcs
tf_additional_env_hdrs = _tf_additional_env_hdrs
tf_additional_lib_deps = _tf_additional_lib_deps
tf_additional_lib_hdrs = _tf_additional_lib_hdrs
tf_additional_rpc_deps = _tf_additional_rpc_deps

View File

@ -586,9 +586,6 @@ def tf_additional_lib_hdrs():
],
})
def tf_additional_env_hdrs():
return []
def tf_additional_all_protos():
return [clean_dep("//tensorflow/core:protos_all")]