text: # Copyright 2016 Google Inc. All Rights Reserved.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #    http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  ################################################################################
  #
  def absl_repositories(bind=True):
      native.git_repository(
          name = "com_google_absl",
          commit = "99477fa9f1e89a7d8253c8aeee331864710d080c",
          remote = "https://github.com/abseil/abseil-cpp",
      )
  
  def protobuf_repositories(bind=True):
      native.git_repository(
          name = "protobuf_git",
          commit = "106ffc04be1abf3ff3399f54ccf149815b287dd9",  # v3.5.1
          remote = "https://github.com/google/protobuf.git",
      )
  
      if bind:
          native.bind(
              name = "protoc",
              actual = "@protobuf_git//:protoc",
          )
  
          native.bind(
              name = "protobuf",
              actual = "@protobuf_git//:protobuf",
          )
  
          native.bind(
              name = "cc_wkt_protos",
              actual = "@protobuf_git//:cc_wkt_protos",
          )
  
          native.bind(
              name = "cc_wkt_protos_genproto",
              actual = "@protobuf_git//:cc_wkt_protos_genproto",
          )
  
          native.bind(
              name = "protobuf_compiler",
              actual = "@protobuf_git//:protoc_lib",
          )
  
          native.bind(
              name = "protobuf_clib",
              actual = "@protobuf_git//:protoc_lib",
          )
  
  
  def googletest_repositories(bind=True):
      BUILD = """
  # Copyright 2016 Google Inc. All Rights Reserved.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #    http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  ################################################################################
  #
  
  cc_library(
      name = "googletest",
      srcs = [
          "googletest/src/gtest-all.cc",
          "googlemock/src/gmock-all.cc",
      ],
      hdrs = glob([
          "googletest/include/**/*.h",
          "googlemock/include/**/*.h",
          "googletest/src/*.cc",
          "googletest/src/*.h",
          "googlemock/src/*.cc",
      ]),
      includes = [
          "googlemock",
          "googletest",
          "googletest/include",
          "googlemock/include",
      ],
      visibility = ["//visibility:public"],
  )
  
  cc_library(
      name = "googletest_main",
      srcs = ["googlemock/src/gmock_main.cc"],
      visibility = ["//visibility:public"],
      linkopts = [
          "-lpthread",
      ],
      deps = [":googletest"],
  )
  
  cc_library(
      name = "googletest_prod",
      hdrs = [
          "googletest/include/gtest/gtest_prod.h",
      ],
      includes = [
          "googletest/include",
      ],
      visibility = ["//visibility:public"],
  )
  """
      native.new_git_repository(
          name = "googletest_git",
          build_file_content = BUILD,
          commit = "43863938377a9ea1399c0596269e0890b5c5515a",
          remote = "https://github.com/google/googletest.git",
      )
  
      if bind:
          native.bind(
              name = "googletest",
              actual = "@googletest_git//:googletest",
          )
  
          native.bind(
              name = "googletest_main",
              actual = "@googletest_git//:googletest_main",
          )
  
          native.bind(
              name = "googletest_prod",
              actual = "@googletest_git//:googletest_prod",
          )
  
  def googleapis_repositories(protobuf_repo="@protobuf_git//", bind=True):
      BUILD = """
  # Copyright 2016 Google Inc. All Rights Reserved.
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #    http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  #
  ################################################################################
  #
  
  licenses(["notice"])
  
  load("{0}:protobuf.bzl", "cc_proto_library")
  
  exports_files(glob(["google/**"]))
  
  cc_proto_library(
      name = "http_api_protos",
      srcs = [
          "google/api/annotations.proto",
          "google/api/http.proto",
      ],
      default_runtime = "//external:protobuf",
      protoc = "//external:protoc",
      visibility = ["//visibility:public"],
      deps = ["{0}:cc_wkt_protos"],
  )
  
  cc_proto_library(
      name = "servicecontrol",
      srcs = [
          "google/api/servicecontrol/v1/check_error.proto",
          "google/api/servicecontrol/v1/distribution.proto",
          "google/api/servicecontrol/v1/log_entry.proto",
          "google/api/servicecontrol/v1/metric_value.proto",
          "google/api/servicecontrol/v1/operation.proto",
          "google/api/servicecontrol/v1/service_controller.proto",
          "google/logging/type/http_request.proto",
          "google/logging/type/log_severity.proto",
          "google/rpc/error_details.proto",
          "google/rpc/status.proto",
          "google/type/money.proto",
      ],
      include = ".",
      visibility = ["//visibility:public"],
      deps = [
          ":service_config",
      ],
      protoc = "//external:protoc",
      default_runtime = "//external:protobuf",
  )
  
  cc_proto_library(
      name = "service_config",
      srcs = [
          "google/api/auth.proto",
          "google/api/backend.proto",
          "google/api/billing.proto",
          "google/api/consumer.proto",
          "google/api/context.proto",
          "google/api/control.proto",
          "google/api/documentation.proto",
          "google/api/endpoint.proto",
          "google/api/label.proto",
          "google/api/log.proto",
          "google/api/logging.proto",
          "google/api/metric.proto",
          "google/api/experimental/experimental.proto",
          "google/api/experimental/authorization_config.proto",
          "google/api/monitored_resource.proto",
          "google/api/monitoring.proto",
          "google/api/quota.proto",
          "google/api/service.proto",
          "google/api/source_info.proto",
          "google/api/system_parameter.proto",
          "google/api/usage.proto",
      ],
      include = ".",
      visibility = ["//visibility:public"],
      deps = [
          ":http_api_protos",
          "//external:cc_wkt_protos",
      ],
      protoc = "//external:protoc",
      default_runtime = "//external:protobuf",
  )
  """.format(protobuf_repo)
  
      native.new_git_repository(
          name = "googleapis_git",
          commit = "5c6df0cd18c6a429eab739fb711c27f6e1393366", # May 14, 2017
          remote = "https://github.com/googleapis/googleapis.git",
          build_file_content = BUILD,
      )
  
      if bind:
          native.bind(
              name = "service_config",
              actual = "@googleapis_git//:service_config",
          )
  
          native.bind(
              name = "http_api_protos",
              actual = "@googleapis_git//:http_api_protos",
          )
  