1# Copyright 2021 The gRPC Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Loads the dependencies necessary for the external repositories defined in grpc_deps.bzl.""" 15 16load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") 17load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") 18load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") 19load("@com_envoyproxy_protoc_gen_validate//:dependencies.bzl", "go_third_party") 20load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") 21load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 22load("@envoy_api//bazel:repositories.bzl", "api_dependencies") 23load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps") 24load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") 25load("@rules_python//python:repositories.bzl", "py_repositories") 26 27def grpc_extra_deps(ignore_version_differences = False): 28 """Loads the extra dependencies. 29 30 These are necessary for using the external repositories defined in 31 grpc_deps.bzl. Projects that depend on gRPC as an external repository need 32 to call both grpc_deps and grpc_extra_deps, if they have not already loaded 33 the extra dependencies. For example, they can do the following in their 34 WORKSPACE 35 ``` 36 load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps", "grpc_test_only_deps") 37 grpc_deps() 38 39 grpc_test_only_deps() 40 41 load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") 42 43 grpc_extra_deps() 44 ``` 45 46 Args: 47 ignore_version_differences: Plumbed directly to the invocation of 48 apple_rules_dependencies. 49 """ 50 protobuf_deps() 51 52 api_dependencies() 53 54 go_rules_dependencies() 55 go_register_toolchains(version = "1.18") 56 gazelle_dependencies() 57 58 # Pull-in the go 3rd party dependencies for protoc_gen_validate, which is 59 # needed for building C++ xDS protos 60 go_third_party() 61 62 apple_rules_dependencies(ignore_version_differences = ignore_version_differences) 63 64 apple_support_dependencies() 65 66 # Initialize Google APIs with only C++ and Python targets 67 switched_rules_by_language( 68 name = "com_google_googleapis_imports", 69 cc = True, 70 grpc = True, 71 python = True, 72 ) 73 74 google_cloud_cpp_deps() 75 76 py_repositories() 77