From 3ca937c9ef47f662bc613b1086476b0b6f2042d8 Mon Sep 17 00:00:00 2001
From: Christian Sigg <csigg@google.com>
Date: Thu, 14 Jan 2021 11:30:44 -0800
Subject: [PATCH] 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
---
 tensorflow/core/platform/BUILD                    | 12 ++++++------
 tensorflow/core/platform/build_config.bzl         |  2 --
 tensorflow/core/platform/default/build_config.bzl |  3 ---
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/tensorflow/core/platform/BUILD b/tensorflow/core/platform/BUILD
index 2ef10347d1e..64d94de3742 100644
--- a/tensorflow/core/platform/BUILD
+++ b/tensorflow/core/platform/BUILD
@@ -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__"],
 )
 
diff --git a/tensorflow/core/platform/build_config.bzl b/tensorflow/core/platform/build_config.bzl
index e58c70313ad..eaa9972e68f 100644
--- a/tensorflow/core/platform/build_config.bzl
+++ b/tensorflow/core/platform/build_config.bzl
@@ -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
diff --git a/tensorflow/core/platform/default/build_config.bzl b/tensorflow/core/platform/default/build_config.bzl
index aab107b7f3f..d903e6eb27b 100644
--- a/tensorflow/core/platform/default/build_config.bzl
+++ b/tensorflow/core/platform/default/build_config.bzl
@@ -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")]