diff options
-rw-r--r-- | WORKSPACE | 3 | ||||
-rw-r--r-- | bazel/grpc_build_system.bzl | 6 | ||||
-rw-r--r-- | bazel/grpc_deps.bzl | 54 | ||||
-rw-r--r-- | third_party/BUILD | 5 | ||||
-rw-r--r-- | third_party/constantly.BUILD | 7 | ||||
-rw-r--r-- | third_party/incremental.BUILD | 10 | ||||
-rw-r--r-- | third_party/twisted.BUILD | 15 | ||||
-rw-r--r-- | third_party/yaml.BUILD | 10 | ||||
-rw-r--r-- | third_party/zope_interface.BUILD | 13 | ||||
-rwxr-xr-x | tools/run_tests/sanity/check_bazel_workspace.py | 37 |
10 files changed, 150 insertions, 10 deletions
@@ -1,4 +1,5 @@ workspace(name = "com_github_grpc_grpc") -load("//bazel:grpc_deps.bzl", "grpc_deps") +load("//bazel:grpc_deps.bzl", "grpc_deps", "grpc_test_only_deps") grpc_deps() +grpc_test_only_deps() diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl index 3fbefc41e7..9d75af4dba 100644 --- a/bazel/grpc_build_system.bzl +++ b/bazel/grpc_build_system.bzl @@ -165,8 +165,10 @@ def grpc_sh_binary(name, srcs, data = []): def grpc_py_binary(name, srcs, data = [], deps = []): if name == "test_dns_server": - # TODO: allow running test_dns_server in oss bazel test suite - deps = [] + deps = _get_external_deps([ + "twisted", + "yaml", + ]) native.py_binary( name = name, srcs = srcs, diff --git a/bazel/grpc_deps.bzl b/bazel/grpc_deps.bzl index 47d33085a2..9053d9d109 100644 --- a/bazel/grpc_deps.bzl +++ b/bazel/grpc_deps.bzl @@ -127,3 +127,57 @@ def grpc_deps(): ], sha256 = "ed829b5eea8af1f405f4cc3d6ecfc3b1365bb7843171036030a31b5127002311", ) + +# TODO: move some dependencies from "grpc_deps" here? +def grpc_test_only_deps(): + """Internal, not intended for use by packages that are consuming grpc. + Loads dependencies that are only needed to run grpc library's tests.""" + native.bind( + name = "twisted", + actual = "@com_github_twisted_twisted//:twisted", + ) + + native.bind( + name = "yaml", + actual = "@com_github_yaml_pyyaml//:yaml", + ) + + if "com_github_twisted_twisted" not in native.existing_rules(): + native.new_http_archive( + name = "com_github_twisted_twisted", + strip_prefix = "twisted-twisted-17.5.0", + url = "https://github.com/twisted/twisted/archive/twisted-17.5.0.zip", + build_file = "@com_github_grpc_grpc//third_party:twisted.BUILD", + ) + + if "com_github_yaml_pyyaml" not in native.existing_rules(): + native.new_http_archive( + name = "com_github_yaml_pyyaml", + strip_prefix = "pyyaml-3.12", + url = "https://github.com/yaml/pyyaml/archive/3.12.zip", + build_file = "@com_github_grpc_grpc//third_party:yaml.BUILD", + ) + + if "com_github_twisted_incremental" not in native.existing_rules(): + native.new_http_archive( + name = "com_github_twisted_incremental", + strip_prefix = "incremental-incremental-17.5.0", + url = "https://github.com/twisted/incremental/archive/incremental-17.5.0.zip", + build_file = "@com_github_grpc_grpc//third_party:incremental.BUILD", + ) + + if "com_github_zopefoundation_zope_interface" not in native.existing_rules(): + native.new_http_archive( + name = "com_github_zopefoundation_zope_interface", + strip_prefix = "zope.interface-4.4.3", + url = "https://github.com/zopefoundation/zope.interface/archive/4.4.3.zip", + build_file = "@com_github_grpc_grpc//third_party:zope_interface.BUILD", + ) + + if "com_github_twisted_constantly" not in native.existing_rules(): + native.new_http_archive( + name = "com_github_twisted_constantly", + strip_prefix = "constantly-15.1.0", + url = "https://github.com/twisted/constantly/archive/15.1.0.zip", + build_file = "@com_github_grpc_grpc//third_party:constantly.BUILD", + ) diff --git a/third_party/BUILD b/third_party/BUILD index dea1229684..f06c5e9c67 100644 --- a/third_party/BUILD +++ b/third_party/BUILD @@ -3,4 +3,9 @@ exports_files([ "gtest.BUILD", "objective_c/Cronet/bidirectional_stream_c.h", "zlib.BUILD", + "twisted.BUILD", + "yaml.BUILD", + "incremental.BUILD", + "zope_interface.BUILD", + "constantly.BUILD", ]) diff --git a/third_party/constantly.BUILD b/third_party/constantly.BUILD new file mode 100644 index 0000000000..f1f93cb79f --- /dev/null +++ b/third_party/constantly.BUILD @@ -0,0 +1,7 @@ +py_library( + name = "constantly", + srcs = glob(["constantly/*.py"]), + visibility = [ + "//visibility:public", + ], +) diff --git a/third_party/incremental.BUILD b/third_party/incremental.BUILD new file mode 100644 index 0000000000..f2a06b49dc --- /dev/null +++ b/third_party/incremental.BUILD @@ -0,0 +1,10 @@ +py_library( + name = "incremental", + srcs = glob(["src/incremental/*.py"]), + imports = [ + "src", + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/third_party/twisted.BUILD b/third_party/twisted.BUILD new file mode 100644 index 0000000000..5005c5a3f8 --- /dev/null +++ b/third_party/twisted.BUILD @@ -0,0 +1,15 @@ +py_library( + name = "twisted", + srcs = glob(["src/twisted/**/*.py"]), + imports = [ + "src", + ], + visibility = [ + "//visibility:public", + ], + deps = [ + "@com_github_twisted_incremental//:incremental", + "@com_github_twisted_constantly//:constantly", + "@com_github_zopefoundation_zope_interface//:zope_interface", + ], +) diff --git a/third_party/yaml.BUILD b/third_party/yaml.BUILD new file mode 100644 index 0000000000..f88854c571 --- /dev/null +++ b/third_party/yaml.BUILD @@ -0,0 +1,10 @@ +py_library( + name = "yaml", + srcs = glob(["lib/yaml/*.py"]), + imports = [ + "lib", + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/third_party/zope_interface.BUILD b/third_party/zope_interface.BUILD new file mode 100644 index 0000000000..b7b8d1e6cf --- /dev/null +++ b/third_party/zope_interface.BUILD @@ -0,0 +1,13 @@ +py_library( + name = "zope_interface", + srcs = glob([ + "src/zope/interface/*.py", + "src/zope/interface/common/*.py", + ]), + imports = [ + "src", + ], + visibility = [ + "//visibility:public", + ], +) diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py index 62a6229c5d..555149c820 100755 --- a/tools/run_tests/sanity/check_bazel_workspace.py +++ b/tools/run_tests/sanity/check_bazel_workspace.py @@ -35,6 +35,11 @@ git_submodule_hashes = { } _BAZEL_TOOLCHAINS_DEP_NAME = 'com_github_bazelbuild_bazeltoolchains' +_TWISTED_TWISTED_DEP_NAME = 'com_github_twisted_twisted' +_YAML_PYYAML_DEP_NAME = 'com_github_yaml_pyyaml' +_TWISTED_INCREMENTAL_DEP_NAME = 'com_github_twisted_incremental' +_ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME = 'com_github_zopefoundation_zope_interface' +_TWISTED_CONSTANTLY_DEP_NAME = 'com_github_twisted_constantly' _GRPC_DEP_NAMES = [ 'boringssl', @@ -46,6 +51,20 @@ _GRPC_DEP_NAMES = [ 'com_github_cares_cares', 'com_google_absl', _BAZEL_TOOLCHAINS_DEP_NAME, + _TWISTED_TWISTED_DEP_NAME, + _YAML_PYYAML_DEP_NAME, + _TWISTED_INCREMENTAL_DEP_NAME, + _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME, + _TWISTED_CONSTANTLY_DEP_NAME, +] + +_GRPC_BAZEL_ONLY_DEPS = [ + _BAZEL_TOOLCHAINS_DEP_NAME, + _TWISTED_TWISTED_DEP_NAME, + _YAML_PYYAML_DEP_NAME, + _TWISTED_INCREMENTAL_DEP_NAME, + _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME, + _TWISTED_CONSTANTLY_DEP_NAME, ] @@ -70,7 +89,8 @@ class BazelEvalState(object): return [] def archive(self, **args): - if args['name'] == _BAZEL_TOOLCHAINS_DEP_NAME: + assert self.names_and_urls.get(args['name']) is None + if args['name'] in _GRPC_BAZEL_ONLY_DEPS: self.names_and_urls[args['name']] = 'dont care' return self.names_and_urls[args['name']] = args['url'] @@ -82,8 +102,10 @@ with open(os.path.join('bazel', 'grpc_deps.bzl'), 'r') as f: eval_state = BazelEvalState(names_and_urls) bazel_file = f.read() -# grpc_deps.bzl only defines 'grpc_deps', add this to call it +# grpc_deps.bzl only defines 'grpc_deps' and 'grpc_test_only_deps', add these +# lines to call them. bazel_file += '\ngrpc_deps()\n' +bazel_file += '\ngrpc_test_only_deps()\n' build_rules = { 'native': eval_state, } @@ -92,11 +114,12 @@ for name in _GRPC_DEP_NAMES: assert name in names_and_urls.keys() assert len(_GRPC_DEP_NAMES) == len(names_and_urls.keys()) -# bazeltoolschains is an exception to this sanity check, -# we don't require that there is a corresponding git module. -names_without_bazeltoolchains = names_and_urls.keys() -names_without_bazeltoolchains.remove(_BAZEL_TOOLCHAINS_DEP_NAME) -archive_urls = [names_and_urls[name] for name in names_without_bazeltoolchains] +# There are some "bazel-only" deps that are exceptions to this sanity check, +# we don't require that there is a corresponding git module for these. +names_without_bazel_only_deps = names_and_urls.keys() +for dep_name in _GRPC_BAZEL_ONLY_DEPS: + names_without_bazel_only_deps.remove(dep_name) +archive_urls = [names_and_urls[name] for name in names_without_bazel_only_deps] workspace_git_hashes = { re.search(git_hash_pattern, url).group() for url in archive_urls |