23 os.chdir(os.path.join(os.path.dirname(sys.argv[0]),
'../../..'))
25 git_hash_pattern = re.compile(
'[0-9a-f]{40}')
28 git_submodules = subprocess.check_output(
30 git_submodule_hashes = {
31 re.search(git_hash_pattern, s).
group()
for s
in git_submodules
34 _BAZEL_SKYLIB_DEP_NAME =
'bazel_skylib'
35 _BAZEL_TOOLCHAINS_DEP_NAME =
'bazel_toolchains'
36 _BAZEL_COMPDB_DEP_NAME =
'bazel_compdb'
37 _TWISTED_TWISTED_DEP_NAME =
'com_github_twisted_twisted'
38 _YAML_PYYAML_DEP_NAME =
'com_github_yaml_pyyaml'
39 _TWISTED_INCREMENTAL_DEP_NAME =
'com_github_twisted_incremental'
40 _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME =
'com_github_zopefoundation_zope_interface'
41 _TWISTED_CONSTANTLY_DEP_NAME =
'com_github_twisted_constantly'
44 'upb',
'boringssl',
'zlib',
'com_google_protobuf',
'com_google_googletest',
45 'rules_cc',
'com_github_google_benchmark',
'com_github_cares_cares',
46 'com_google_absl',
'io_opencensus_cpp',
'envoy_api', _BAZEL_SKYLIB_DEP_NAME,
47 _BAZEL_TOOLCHAINS_DEP_NAME, _BAZEL_COMPDB_DEP_NAME,
48 _TWISTED_TWISTED_DEP_NAME, _YAML_PYYAML_DEP_NAME,
49 _TWISTED_INCREMENTAL_DEP_NAME, _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME,
50 _TWISTED_CONSTANTLY_DEP_NAME,
'io_bazel_rules_go',
51 'build_bazel_rules_apple',
'build_bazel_apple_support',
52 'com_github_libuv_libuv',
'com_googlesource_code_re2',
'bazel_gazelle',
53 'opencensus_proto',
'com_envoyproxy_protoc_gen_validate',
54 'com_google_googleapis',
'com_google_libprotobuf_mutator',
55 'com_github_cncf_udpa'
58 _GRPC_BAZEL_ONLY_DEPS = [
63 _BAZEL_SKYLIB_DEP_NAME,
64 _BAZEL_TOOLCHAINS_DEP_NAME,
65 _BAZEL_COMPDB_DEP_NAME,
66 _TWISTED_TWISTED_DEP_NAME,
67 _YAML_PYYAML_DEP_NAME,
68 _TWISTED_INCREMENTAL_DEP_NAME,
69 _ZOPEFOUNDATION_ZOPE_INTERFACE_DEP_NAME,
70 _TWISTED_CONSTANTLY_DEP_NAME,
72 'build_bazel_rules_apple',
73 'build_bazel_apple_support',
74 'com_googlesource_code_re2',
77 'com_envoyproxy_protoc_gen_validate',
78 'com_google_googleapis',
79 'com_google_libprotobuf_mutator'
85 def __init__(self, names_and_urls, overridden_name=None):
99 if self.overridden_name:
100 return [self.overridden_name]
105 if args[
'name']
in _GRPC_BAZEL_ONLY_DEPS:
108 url = args.get(
'url',
None)
112 url =
' '.join(args[
'urls'])
117 if args[
'name']
in _GRPC_BAZEL_ONLY_DEPS:
127 with open(os.path.join(
'bazel',
'grpc_deps.bzl'),
'r')
as f:
130 bazel_file = f.read()
134 bazel_file +=
'\ngrpc_deps()\n'
135 bazel_file +=
'\ngrpc_test_only_deps()\n'
137 'native': eval_state,
138 'http_archive':
lambda **args: eval_state.http_archive(**args),
139 'load':
lambda a, b:
None,
140 'git_repository':
lambda **args: eval_state.git_repository(**args),
141 'grpc_python_deps':
lambda:
None,
143 exec((bazel_file), build_rules)
144 for name
in _GRPC_DEP_NAMES:
145 assert name
in list(names_and_urls.keys())
146 assert len(_GRPC_DEP_NAMES) ==
len(list(names_and_urls.keys()))
150 names_without_bazel_only_deps = list(names_and_urls.keys())
151 for dep_name
in _GRPC_BAZEL_ONLY_DEPS:
152 names_without_bazel_only_deps.remove(dep_name)
153 archive_urls = [names_and_urls[name]
for name
in names_without_bazel_only_deps]
154 workspace_git_hashes = {
155 re.search(git_hash_pattern, url).
group()
for url
in archive_urls
157 if len(workspace_git_hashes) == 0:
158 print(
"(Likely) parse error, did not find any bazel git dependencies.")
165 if len(workspace_git_hashes - git_submodule_hashes) > 0:
167 "Found discrepancies between git submodules and Bazel WORKSPACE dependencies"
169 print((
"workspace_git_hashes: %s" % workspace_git_hashes))
170 print((
"git_submodule_hashes: %s" % git_submodule_hashes))
171 print((
"workspace_git_hashes - git_submodule_hashes: %s" %
172 (workspace_git_hashes - git_submodule_hashes)))
176 for name
in _GRPC_DEP_NAMES:
177 names_and_urls_with_overridden_name = {}
179 overridden_name=name)
182 'http_archive':
lambda **args: state.http_archive(**args),
183 'load':
lambda a, b:
None,
184 'git_repository':
lambda **args: state.git_repository(**args),
185 'grpc_python_deps':
lambda *args, **kwargs:
None,
187 exec((bazel_file), rules)
188 assert name
not in list(names_and_urls_with_overridden_name.keys())