Allow additional visibility for third_party/abseil-cpp

Internal libraries can depend on absl.
Add a gn args parameter that allows to add additional target that can
depend on absl.

Bug: 1002897
Change-Id: If2efab807dfc5e5e7c745ee0bb8fb9d83d2f2955
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1800306
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#696797}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 4f12a990f95471987d3fb0ad975d40eeb921fed4
diff --git a/abseil_clients.gni b/abseil_clients.gni
new file mode 100644
index 0000000..6a2d1ff
--- /dev/null
+++ b/abseil_clients.gni
@@ -0,0 +1,30 @@
+# Copyright 2019 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
+# adding projects to this list please reach out to cxx@chromium.org and CC:
+# - https://cs.chromium.org/chromium/src/third_party/abseil-cpp/OWNERS
+#
+# More information can be found at:
+# https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
+declare_args() {
+  # Additional targets that can depend on absl.
+  # ** DISCLAIMER **
+  #
+  # Using "additional_absl_clients" is highly discouraged because it will break
+  # the component build since Abseil doesn't have export annotations and WebRTC
+  # is already depending on it. Any CL that use "additional_absl_clients" will
+  # have a really high probability of being reverted.
+  additional_absl_clients = []
+}
+assert(!is_component_build || additional_absl_clients == [])
+
+_chromium_absl_clients = [
+  "//libassistant/*",
+  "//third_party/webrtc/*",
+  "//third_party/abseil-cpp/*",
+  "//third_party/googletest:gtest",
+]
+
+absl_visibility = _chromium_absl_clients + additional_absl_clients
diff --git a/absl/algorithm/BUILD.gn b/absl/algorithm/BUILD.gn
index 665be4a..210c9e3 100644
--- a/absl/algorithm/BUILD.gn
+++ b/absl/algorithm/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/base/BUILD.gn b/absl/base/BUILD.gn
index 0c981b4..beb08f2 100644
--- a/absl/base/BUILD.gn
+++ b/absl/base/BUILD.gn
@@ -3,14 +3,16 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
+# Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
+# adding projects to this list please reach out to cxx@chromium.org and CC:
+# - https://cs.chromium.org/chromium/src/third_party/abseil-cpp/OWNERS
+#
+# More information can be found at:
+# https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/container/BUILD.gn b/absl/container/BUILD.gn
index 12ebdff..452f160 100644
--- a/absl/container/BUILD.gn
+++ b/absl/container/BUILD.gn
@@ -3,14 +3,16 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
+# Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
+# adding projects to this list please reach out to cxx@chromium.org and CC:
+# - https://cs.chromium.org/chromium/src/third_party/abseil-cpp/OWNERS
+#
+# More information can be found at:
+# https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/debugging/BUILD.gn b/absl/debugging/BUILD.gn
index a3c7cfe..35ebbfc 100644
--- a/absl/debugging/BUILD.gn
+++ b/absl/debugging/BUILD.gn
@@ -4,6 +4,7 @@
 
 import("//build/config/sanitizers/sanitizers.gni")
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -12,12 +13,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/flags/BUILD.gn b/absl/flags/BUILD.gn
index 073c74a..ee54fd4 100644
--- a/absl/flags/BUILD.gn
+++ b/absl/flags/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/hash/BUILD.gn b/absl/hash/BUILD.gn
index 21bf881..f1e9391 100644
--- a/absl/hash/BUILD.gn
+++ b/absl/hash/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/memory/BUILD.gn b/absl/memory/BUILD.gn
index 06bc4c5..1709322 100644
--- a/absl/memory/BUILD.gn
+++ b/absl/memory/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/meta/BUILD.gn b/absl/meta/BUILD.gn
index f2e5be2..9fbfc9b 100644
--- a/absl/meta/BUILD.gn
+++ b/absl/meta/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/numeric/BUILD.gn b/absl/numeric/BUILD.gn
index 55b6d0b..b3e3955 100644
--- a/absl/numeric/BUILD.gn
+++ b/absl/numeric/BUILD.gn
@@ -3,14 +3,16 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
+# Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
+# adding projects to this list please reach out to cxx@chromium.org and CC:
+# - https://cs.chromium.org/chromium/src/third_party/abseil-cpp/OWNERS
+#
+# More information can be found at:
+# https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/random/BUILD.gn b/absl/random/BUILD.gn
index c0e094a..7b928c7 100644
--- a/absl/random/BUILD.gn
+++ b/absl/random/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,13 +12,8 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-    "//third_party/openscreen/*",
-  ]
+  visibility = absl_visibility
+  visibility += [ "//third_party/openscreen/*" ]
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/random/internal/BUILD.gn b/absl/random/internal/BUILD.gn
index 00480f4..8665208 100644
--- a/absl/random/internal/BUILD.gn
+++ b/absl/random/internal/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,13 +12,8 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-    "//third_party/openscreen/*",
-  ]
+  visibility = absl_visibility
+  visibility += [ "//third_party/openscreen/*" ]
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/strings/BUILD.gn b/absl/strings/BUILD.gn
index fc1d956..2fff590 100644
--- a/absl/strings/BUILD.gn
+++ b/absl/strings/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,13 +12,8 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-    "//third_party/openscreen/*",
-  ]
+  visibility = absl_visibility
+  visibility += [ "//third_party/openscreen/*" ]
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/synchronization/BUILD.gn b/absl/synchronization/BUILD.gn
index cd60181..8af38bc 100644
--- a/absl/synchronization/BUILD.gn
+++ b/absl/synchronization/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/time/BUILD.gn b/absl/time/BUILD.gn
index 0135cdd..36ae3d2 100644
--- a/absl/time/BUILD.gn
+++ b/absl/time/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/time/internal/cctz/BUILD.gn b/absl/time/internal/cctz/BUILD.gn
index 44e0179..5daa2a3 100644
--- a/absl/time/internal/cctz/BUILD.gn
+++ b/absl/time/internal/cctz/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,12 +12,7 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/types/BUILD.gn b/absl/types/BUILD.gn
index 31ceaf3..4e3eeb8 100644
--- a/absl/types/BUILD.gn
+++ b/absl/types/BUILD.gn
@@ -3,6 +3,7 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
 # Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
 # adding projects to this list please reach out to cxx@chromium.org and CC:
@@ -11,13 +12,8 @@
 # More information can be found at:
 # https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-    "//third_party/openscreen/*",
-  ]
+  visibility = absl_visibility
+  visibility += [ "//third_party/openscreen/*" ]
 } else {
   visibility = [ "*" ]
 }
diff --git a/absl/utility/BUILD.gn b/absl/utility/BUILD.gn
index 49390b3..cbfdd65 100644
--- a/absl/utility/BUILD.gn
+++ b/absl/utility/BUILD.gn
@@ -3,14 +3,16 @@
 # found in the LICENSE file.
 
 import("//build_overrides/build.gni")
+import("//third_party/abseil-cpp/abseil_clients.gni")
 
+# Usage of Abseil in Chromium is guarded by an explicit opt-in list, before
+# adding projects to this list please reach out to cxx@chromium.org and CC:
+# - https://cs.chromium.org/chromium/src/third_party/abseil-cpp/OWNERS
+#
+# More information can be found at:
+# https://docs.google.com/document/d/1DgS1-A3rzboTLjpf4m1sqkJgWjnY_Ru2dokk1X1vBDU
 if (build_with_chromium) {
-  visibility = [
-    "//libassistant/*",
-    "//third_party/webrtc/*",
-    "//third_party/abseil-cpp/*",
-    "//third_party/googletest:gtest",
-  ]
+  visibility = absl_visibility
 } else {
   visibility = [ "*" ]
 }