-
Notifications
You must be signed in to change notification settings - Fork 397
/
Copy pathworkspace0.bzl
245 lines (221 loc) · 9.08 KB
/
workspace0.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Load dependencies needed to use the google-cloud-cpp libraries."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def gl_cpp_workspace0(name = None):
"""Loads dependencies need to compile the google-cloud-cpp libraries.
Application developers can call this function from their WORKSPACE file
to obtain all the necessary dependencies for google-cloud-cpp, including
gRPC and its dependencies. This function only loads dependencies that
have not been previously loaded, allowing application developers to
override the version of the dependencies they want to use.
Note that some dependencies have their own `*_deps()` function. These
functions can only be called after load()-ing the right .bzl file. Bazel
does not permit interleaving load() and function calls in the same function
or even the same `.bzl` file. Only the project's `WORKSPACE` file can
interleave these calls.
To workaround this limitation in Bazel we offer a series of helpers that can
be loaded and called in sequence:
```
http_archive(name = "google_cloud_cpp", ...)
load("@google_cloud_cpp//bazel:workspace0.bzl", "gl_cpp_workspace0")
gl_cpp_workspace0()
load("@google_cloud_cpp//bazel:workspace1.bzl", "gl_cpp_workspace1")
gl_cpp_workspace1()
load("@google_cloud_cpp//bazel:workspace2.bzl", "gl_cpp_workspace2")
gl_cpp_workspace2()
load("@google_cloud_cpp//bazel:workspace3.bzl", "gl_cpp_workspace3")
gl_cpp_workspace3()
load("@google_cloud_cpp//bazel:workspace4.bzl", "gl_cpp_workspace4")
gl_cpp_workspace4()
load("@google_cloud_cpp//bazel:workspace5.bzl", "gl_cpp_workspace5")
gl_cpp_workspace5()
```
Args:
name: Unused. It is conventional to provide a `name` argument to all
workspace functions.
"""
# Load platforms, we use it directly
maybe(
http_archive,
name = "platforms",
urls = [
"https://github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz",
],
sha256 = "29742e87275809b5e598dc2f04d86960cc7a55b3067d97221c9abbc9926bff0f",
)
# Load rules_cc, used by googletest
maybe(
http_archive,
name = "rules_cc",
urls = [
"https://github.com/bazelbuild/rules_cc/releases/download/0.1.1/rules_cc-0.1.1.tar.gz",
],
sha256 = "712d77868b3152dd618c4d64faaddefcc5965f90f5de6e6dd1d5ddcd0be82d42",
strip_prefix = "rules_cc-0.1.1",
)
# protobuf requires this
maybe(
http_archive,
name = "bazel_skylib",
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
],
)
# The version of `rules_apple` loaded by gRPC is too old for Bazel 7.
maybe(
http_archive,
name = "build_bazel_rules_apple",
urls = [
"https://github.com/bazelbuild/rules_apple/releases/download/3.17.1/rules_apple.3.17.1.tar.gz",
],
sha256 = "f7dbce3717772fc5cb864930d18f96aa4e443b0d3dc713b13fbd45e502c55ce0",
)
# Load Abseil
maybe(
http_archive,
name = "com_google_absl",
urls = [
"https://github.com/abseil/abseil-cpp/archive/20240722.1.tar.gz",
],
sha256 = "40cee67604060a7c8794d931538cb55f4d444073e556980c88b6c49bb9b19bb7",
strip_prefix = "abseil-cpp-20240722.1",
)
# Load a version of googletest that we know works. This is needed to create
# //:.*mocks targets, which are public.
maybe(
http_archive,
name = "com_google_googletest",
urls = [
"https://github.com/google/googletest/archive/v1.15.2.tar.gz",
],
sha256 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926",
strip_prefix = "googletest-1.15.2",
)
# Load the googleapis dependency.
maybe(
http_archive,
name = "com_google_googleapis",
urls = [
"https://github.com/googleapis/googleapis/archive/280725e991516d4a0f136268faf5aa6d32d21b54.tar.gz",
],
sha256 = "5a9450cf1ad1187c82a2b5cdff53e4d584b6d45292b5f71b504083acb03ad7d0",
strip_prefix = "googleapis-280725e991516d4a0f136268faf5aa6d32d21b54",
build_file = Label("//bazel:googleapis.BUILD"),
# Scaffolding for patching googleapis after download. For example:
# patches = ["googleapis.patch"]
# NOTE: This should only be used while developing with a new
# protobuf message. No changes to `patches` should ever be
# committed to the main branch.
patch_tool = "patch",
patch_args = ["-p1"],
patches = [],
)
# Load protobuf.
maybe(
http_archive,
name = "com_google_protobuf",
urls = [
"https://github.com/protocolbuffers/protobuf/archive/v29.3.tar.gz",
],
sha256 = "008a11cc56f9b96679b4c285fd05f46d317d685be3ab524b2a310be0fbad987e",
strip_prefix = "protobuf-29.3",
)
# Load BoringSSL. This could be automatically loaded by gRPC. But as of
# 2023-02-01 the version loaded by gRPC-1.51 does not compile with Clang-15.
maybe(
http_archive,
name = "boringssl",
urls = [
# Use https://github.com/google/boringssl instead of
# https://boringssl.googlesource.com/boringssl as the
# former has a (more) consistent sha256.
"https://github.com/google/boringssl/archive/82a53d8c902f940eb1310f76a0b96c40c67f632f.tar.gz",
],
sha256 = "c25e5c1ac36fa6709b2fd9095584228d48e9f82bcf97d8cd868bcbe796f90ba5",
strip_prefix = "boringssl-82a53d8c902f940eb1310f76a0b96c40c67f632f",
)
# Load gRPC and its dependencies, using a similar pattern to this function.
maybe(
http_archive,
name = "com_github_grpc_grpc",
urls = [
"https://github.com/grpc/grpc/archive/v1.69.0.tar.gz",
],
sha256 = "cd256d91781911d46a57506978b3979bfee45d5086a1b6668a3ae19c5e77f8dc",
strip_prefix = "grpc-1.69.0",
)
# We use the cc_proto_library() rule from @com_google_protobuf, which
# assumes that grpc_cpp_plugin and grpc_lib are in the //external: module
native.bind(
name = "grpc_cpp_plugin",
actual = "@com_github_grpc_grpc//src/compiler:grpc_cpp_plugin",
)
native.bind(
name = "grpc_lib",
actual = "@com_github_grpc_grpc//:grpc++",
)
# We need libcurl for the Google Cloud Storage client.
maybe(
http_archive,
name = "com_github_curl_curl",
urls = [
"https://curl.haxx.se/download/curl-7.69.1.tar.gz",
],
sha256 = "01ae0c123dee45b01bbaef94c0bc00ed2aec89cb2ee0fd598e0d302a6b5e0a98",
strip_prefix = "curl-7.69.1",
build_file = Label("//bazel:curl.BUILD"),
)
# We need the nlohmann_json library
maybe(
http_archive,
name = "com_github_nlohmann_json",
urls = [
"https://github.com/nlohmann/json/archive/v3.11.3.tar.gz",
],
sha256 = "0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406",
strip_prefix = "json-3.11.3",
)
# Load google/crc32c, a library to efficiently compute CRC32C checksums.
maybe(
http_archive,
name = "com_github_google_crc32c",
urls = [
"https://github.com/google/crc32c/archive/1.1.2.tar.gz",
],
sha256 = "ac07840513072b7fcebda6e821068aa04889018f24e10e46181068fb214d7e56",
strip_prefix = "crc32c-1.1.2",
build_file = Label("//bazel:crc32c.BUILD"),
patch_tool = "patch",
patch_args = ["-p1"],
patches = [Label("//bazel:configure_template.bzl.patch")],
)
# Open Telemetry
maybe(
http_archive,
name = "io_opentelemetry_cpp",
urls = [
"https://github.com/open-telemetry/opentelemetry-cpp/archive/v1.19.0.tar.gz",
],
sha256 = "e0330194b72f2fe4c0ce3ece06b02dc4aa0ab491eb75bf42c6f5e283912e468c",
strip_prefix = "opentelemetry-cpp-1.19.0",
repo_mapping = {
"@curl": "@com_github_curl_curl",
"@com_github_google_benchmark": "@com_github_benchmark",
"@github_nlohmann_json": "@com_github_nlohmann_json",
},
)