• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_features//:deps.bzl", "bazel_features_deps")
17load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
18load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
19load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
20load("@com_envoyproxy_protoc_gen_validate//:dependencies.bzl", "go_third_party")
21load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
22load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
23load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
24load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")
25load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
26load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
27load("@rules_python//python:repositories.bzl", "py_repositories")
28
29def grpc_extra_deps(ignore_version_differences = False):
30    """Loads the extra dependencies.
31
32    These are necessary for using the external repositories defined in
33    grpc_deps.bzl. Projects that depend on gRPC as an external repository need
34    to call both grpc_deps and grpc_extra_deps, if they have not already loaded
35    the extra dependencies. For example, they can do the following in their
36    WORKSPACE
37    ```
38    load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps", "grpc_test_only_deps")
39    grpc_deps()
40
41    grpc_test_only_deps()
42
43    load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
44
45    grpc_extra_deps()
46    ```
47
48    Args:
49      ignore_version_differences: Plumbed directly to the invocation of
50        apple_rules_dependencies.
51    """
52    protobuf_deps()
53
54    rules_proto_dependencies()
55    bazel_features_deps()
56
57    api_dependencies()
58
59    go_rules_dependencies()
60    go_register_toolchains(version = "1.22.5")
61    gazelle_dependencies()
62
63    # Pull-in the go 3rd party dependencies for protoc_gen_validate, which is
64    # needed for building C++ xDS protos
65    go_third_party()
66
67    apple_rules_dependencies(ignore_version_differences = ignore_version_differences)
68
69    apple_support_dependencies()
70
71    # Initialize Google APIs with only C++ and Python targets
72    switched_rules_by_language(
73        name = "com_google_googleapis_imports",
74        cc = True,
75        grpc = True,
76        python = True,
77    )
78
79    google_cloud_cpp_deps()
80
81    py_repositories()
82