aboutsummaryrefslogtreecommitdiffhomepage
path: root/bazel
diff options
context:
space:
mode:
authorGravatar Alexander Polcyn <apolcyn@google.com>2017-11-29 17:06:16 -0800
committerGravatar Alexander Polcyn <apolcyn@google.com>2017-12-14 18:11:25 -0800
commit54a70409c0c4059c19c14ec759633637fd0656d8 (patch)
tree316ecff46d56cec2dcaa901f2143ff654ad7d30b /bazel
parent00a7d47e5b04fa508c1dc8edf52084f5736f7c3d (diff)
Move more special cases in bazel build to the .bzl files
Diffstat (limited to 'bazel')
-rw-r--r--bazel/grpc_build_system.bzl29
-rw-r--r--bazel/grpc_deps.bzl129
2 files changed, 98 insertions, 60 deletions
diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl
index 234d129aa3..d146ca9c2c 100644
--- a/bazel/grpc_build_system.bzl
+++ b/bazel/grpc_build_system.bzl
@@ -26,6 +26,27 @@
# The set of pollers to test against if a test exercises polling
POLLERS = ['epollex', 'epollsig', 'epoll1', 'poll', 'poll-cv']
+def _get_external_deps(external_deps):
+ ret = []
+ for dep in external_deps:
+ if dep == "nanopb":
+ ret.append("//third_party/nanopb")
+ else:
+ ret.append("//external:" + dep)
+ return ret
+
+def _maybe_update_cc_library_hdrs(hdrs):
+ ret = []
+ hdrs_to_update = {
+ "third_party/objective_c/Cronet/bidirectional_stream_c.h": "//third_party:objective_c/Cronet/bidirectional_stream_c.h",
+ }
+ for h in hdrs:
+ if h in hdrs_to_update.keys():
+ ret.append(hdrs_to_update[h])
+ else:
+ ret.append(h)
+ return ret
+
def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [],
external_deps = [], deps = [], standalone = False,
language = "C++", testonly = False, visibility = None,
@@ -40,8 +61,8 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [],
"//conditions:default": [],}) +
select({"//:remote_execution": ["GRPC_PORT_ISOLATED_RUNTIME=1"],
"//conditions:default": [],}),
- hdrs = hdrs + public_hdrs,
- deps = deps + ["//external:" + dep for dep in external_deps],
+ hdrs = _maybe_update_cc_library_hdrs(hdrs + public_hdrs),
+ deps = deps + _get_external_deps(external_deps),
copts = copts,
visibility = visibility,
testonly = testonly,
@@ -82,7 +103,7 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
'srcs': srcs,
'args': args,
'data': data,
- 'deps': deps + ["//external:" + dep for dep in external_deps],
+ 'deps': deps + _get_external_deps(external_deps),
'copts': copts,
'linkopts': ["-pthread"],
}
@@ -114,7 +135,7 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da
data = data,
testonly = testonly,
linkshared = linkshared,
- deps = deps + ["//external:" + dep for dep in external_deps],
+ deps = deps + _get_external_deps(external_deps),
copts = copts,
linkopts = ["-pthread"] + linkopts,
)
diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl
index fd848d80e6..e465312a40 100644
--- a/bazel/grpc_deps.bzl
+++ b/bazel/grpc_deps.bzl
@@ -1,9 +1,7 @@
-def grpc_deps():
- native.bind(
- name = "nanopb",
- actual = "@com_github_grpc_grpc//third_party/nanopb",
- )
+"""Load dependencies needed to compile and test the grpc library as a 3rd-party consumer."""
+def grpc_deps():
+ """Loads dependencies need to compile and test the grpc library."""
native.bind(
name = "libssl",
actual = "@boringssl//:ssl",
@@ -59,54 +57,73 @@ def grpc_deps():
actual = "@com_github_gflags_gflags//:gflags",
)
- native.http_archive(
- name = "boringssl",
- # on the master-with-bazel branch
- url = "https://boringssl.googlesource.com/boringssl/+archive/886e7d75368e3f4fab3f4d0d3584e4abfc557755.tar.gz",
- )
-
- native.new_http_archive(
- name = "com_github_madler_zlib",
- build_file = "@com_github_grpc_grpc//third_party:zlib.BUILD",
- strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f",
- url = "https://github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
- )
-
- native.http_archive(
- name = "com_google_protobuf",
- strip_prefix = "protobuf-80a37e0782d2d702d52234b62dd4b9ec74fd2c95",
- url = "https://github.com/google/protobuf/archive/80a37e0782d2d702d52234b62dd4b9ec74fd2c95.tar.gz",
- )
-
- native.new_http_archive(
- name = "com_github_google_googletest",
- build_file = "@com_github_grpc_grpc//third_party:gtest.BUILD",
- strip_prefix = "googletest-ec44c6c1675c25b9827aacd08c02433cccde7780",
- url = "https://github.com/google/googletest/archive/ec44c6c1675c25b9827aacd08c02433cccde7780.tar.gz",
- )
-
- native.http_archive(
- name = "com_github_gflags_gflags",
- strip_prefix = "gflags-30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e",
- url = "https://github.com/gflags/gflags/archive/30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e.tar.gz",
- )
-
- native.new_http_archive(
- name = "com_github_google_benchmark",
- build_file = "@com_github_grpc_grpc//third_party:benchmark.BUILD",
- strip_prefix = "benchmark-5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8",
- url = "https://github.com/google/benchmark/archive/5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8.tar.gz",
- )
-
- native.new_http_archive(
- name = "com_github_cares_cares",
- build_file = "@com_github_grpc_grpc//third_party:cares/cares.BUILD",
- strip_prefix = "c-ares-3be1924221e1326df520f8498d704a5c4c8d0cce",
- url = "https://github.com/c-ares/c-ares/archive/3be1924221e1326df520f8498d704a5c4c8d0cce.tar.gz",
- )
-
- native.http_archive(
- name = "com_google_absl",
- strip_prefix = "abseil-cpp-cc4bed2d74f7c8717e31f9579214ab52a9c9c610",
- url = "https://github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
- )
+ if "boringssl" not in native.existing_rules():
+ native.http_archive(
+ name = "boringssl",
+ # on the master-with-bazel branch
+ url = "https://boringssl.googlesource.com/boringssl/+archive/886e7d75368e3f4fab3f4d0d3584e4abfc557755.tar.gz",
+ )
+
+ if "com_github_madler_zlib" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_madler_zlib",
+ build_file = "@com_github_grpc_grpc//third_party:zlib.BUILD",
+ strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f",
+ url = "https://github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
+ )
+
+ if "com_google_protobuf" not in native.existing_rules():
+ native.http_archive(
+ name = "com_google_protobuf",
+ strip_prefix = "protobuf-2761122b810fe8861004ae785cc3ab39f384d342",
+ url = "https://github.com/google/protobuf/archive/2761122b810fe8861004ae785cc3ab39f384d342.tar.gz",
+ )
+
+ if "com_github_google_googletest" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_google_googletest",
+ build_file = "@com_github_grpc_grpc//third_party:gtest.BUILD",
+ strip_prefix = "googletest-ec44c6c1675c25b9827aacd08c02433cccde7780",
+ url = "https://github.com/google/googletest/archive/ec44c6c1675c25b9827aacd08c02433cccde7780.tar.gz",
+ )
+
+ if "com_github_gflags_gflags" not in native.existing_rules():
+ native.http_archive(
+ name = "com_github_gflags_gflags",
+ strip_prefix = "gflags-30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e",
+ url = "https://github.com/gflags/gflags/archive/30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e.tar.gz",
+ )
+
+ if "com_github_google_benchmark" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_google_benchmark",
+ build_file = "@com_github_grpc_grpc//third_party:benchmark.BUILD",
+ strip_prefix = "benchmark-5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8",
+ url = "https://github.com/google/benchmark/archive/5b7683f49e1e9223cf9927b24f6fd3d6bd82e3f8.tar.gz",
+ )
+
+ if "com_github_cares_cares" not in native.existing_rules():
+ native.new_http_archive(
+ name = "com_github_cares_cares",
+ build_file = "@com_github_grpc_grpc//third_party:cares/cares.BUILD",
+ strip_prefix = "c-ares-3be1924221e1326df520f8498d704a5c4c8d0cce",
+ url = "https://github.com/c-ares/c-ares/archive/3be1924221e1326df520f8498d704a5c4c8d0cce.tar.gz",
+ )
+
+ if "com_google_absl" not in native.existing_rules():
+ native.http_archive(
+ name = "com_google_absl",
+ strip_prefix = "abseil-cpp-cc4bed2d74f7c8717e31f9579214ab52a9c9c610",
+ url = "https://github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
+ )
+
+ if "com_github_bazelbuild_bazeltoolchains" not in native.existing_rules():
+ native.http_archive(
+ name = "com_github_bazelbuild_bazeltoolchains",
+ strip_prefix = "bazel-toolchains-af4681c3d19f063f090222ec3d04108c4e0ca255",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz",
+ "https://github.com/bazelbuild/bazel-toolchains/archive/af4681c3d19f063f090222ec3d04108c4e0ca255.tar.gz",
+ ],
+ sha256 = "d58bb2d6c8603f600d522b6104d6192a65339aa26cbba9f11ff5c4b36dedb928",
+ )