Skip to content

Commit

Permalink
Move extra dependencies out of WORKSPACE to its own macro.
Browse files Browse the repository at this point in the history
This could be useful for projects that use gRPC as an external
repository. This could not be done within the same grpc_deps.bzl due to
the problem discussed in
- bazelbuild/bazel#1550
- bazelbuild/bazel#1943
  • Loading branch information
fm966mhz authored and mhala-tolar committed Nov 15, 2019
1 parent c1d1765 commit bf0c4b9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 deletions.
24 changes: 4 additions & 20 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ grpc_deps()

grpc_test_only_deps()

load("//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()

register_execution_platforms(
"//third_party/toolchains:local",
"//third_party/toolchains:local_large",
Expand Down Expand Up @@ -50,23 +54,3 @@ load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories")
load("@grpc_python_dependencies//:requirements.bzl", "pip_install")
pip_repositories()
pip_install()

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

load("@upb//bazel:workspace_deps.bzl", "upb_deps")
upb_deps()

load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
api_dependencies()

load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()


load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
apple_rules_dependencies()

load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
apple_support_dependencies()
10 changes: 9 additions & 1 deletion bazel/grpc_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,16 @@ def grpc_deps():
sha256 = "bdc8e66e70b8a75da23b79f1f8c6207356df07d041d96d2189add7ee0780cf4e",
)

grpc_python_deps()
if "build_bazel_apple_support" not in native.existing_rules():
http_archive(
name = "build_bazel_apple_support",
urls = [
"https://github.com/bazelbuild/apple_support/releases/download/0.7.1/apple_support.0.7.1.tar.gz",
],
sha256 = "122ebf7fe7d1c8e938af6aeaee0efe788a3a2449ece5a8d6a428cb18d6f88033",
)

grpc_python_deps()

# TODO: move some dependencies from "grpc_deps" here?
def grpc_test_only_deps():
Expand Down
40 changes: 40 additions & 0 deletions bazel/grpc_extra_deps.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Loads the dependencies necessary for the external repositories defined in grpc_deps.bzl."""

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@upb//bazel:workspace_deps.bzl", "upb_deps")
load("@envoy_api//bazel:repositories.bzl", "api_dependencies")
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")

def grpc_extra_deps():
"""Loads the extra dependencies.
These are necessary for using the external repositories defined in
grpc_deps.bzl. Projects that depend on gRPC as an external repository need
to call both grpc_deps and grpc_extra_deps, if they have not already loaded
the extra dependencies. For example, they can do the following in their
WORKSPACE
```
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps", "grpc_test_only_deps")
grpc_deps()
grpc_test_only_deps()
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()
```
"""
protobuf_deps()

upb_deps()

api_dependencies()

go_rules_dependencies()
go_register_toolchains()

apple_rules_dependencies()

apple_support_dependencies()

0 comments on commit bf0c4b9

Please sign in to comment.