Skip to content

Commit 3a471aa

Browse files
authored
Update bazel setup and dependencies (#48)
1 parent 22160af commit 3a471aa

File tree

5 files changed

+72
-172
lines changed

5 files changed

+72
-172
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.19.2
1+
4.0.0

WORKSPACE

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
load(
1919
"//:repositories.bzl",
2020
"absl_repositories",
21-
"protobuf_repositories",
22-
"googletest_repositories",
2321
"googleapis_repositories",
22+
"googletest_repositories",
23+
"protobuf_repositories",
2424
)
2525

2626
absl_repositories()
@@ -30,3 +30,20 @@ protobuf_repositories()
3030
googletest_repositories()
3131

3232
googleapis_repositories()
33+
34+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
35+
36+
protobuf_deps()
37+
38+
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
39+
40+
rules_proto_dependencies()
41+
42+
rules_proto_toolchains()
43+
44+
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
45+
46+
switched_rules_by_language(
47+
name = "com_google_googleapis_imports",
48+
cc = True,
49+
)

repositories.bzl

Lines changed: 20 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1919
ABSEIL_COMMIT = "99477fa9f1e89a7d8253c8aeee331864710d080c"
2020
ABSEIL_SHA256 = "495e8e1c481018126b2a84bfe36e273907ce282b135e7d161e138e463d295f3d"
2121

22-
def absl_repositories(bind=True):
22+
def absl_repositories(bind = True):
2323
http_archive(
2424
name = "com_google_absl",
2525
strip_prefix = "abseil-cpp-" + ABSEIL_COMMIT,
@@ -92,64 +92,34 @@ cc_library(
9292
build_file_content = BUILD,
9393
)
9494

95+
PROTOBUF_COMMIT = "3.10.1" # Oct 29, 2019
96+
PROTOBUF_SHA256 = "6adf73fd7f90409e479d6ac86529ade2d45f50494c5c10f539226693cb8fe4f7"
9597

96-
BAZEL_SKYLIB_RELEASE = "0.8.0"
97-
BAZEL_SKYLIB_SHA256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e"
98-
99-
PROTOBUF_COMMIT = "3.9.0" # July 10, 2019
100-
PROTOBUF_SHA256 = "2ee9dcec820352671eb83e081295ba43f7a4157181dad549024d7070d079cf65"
101-
102-
def protobuf_repositories(bind=True):
103-
zlib_repositories(bind)
104-
105-
http_archive(
106-
name = "bazel_skylib",
107-
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/" + BAZEL_SKYLIB_RELEASE + "/bazel-skylib." + BAZEL_SKYLIB_RELEASE + ".tar.gz"],
108-
sha256 = BAZEL_SKYLIB_SHA256,
109-
)
98+
RULES_PROTO_SHA = "97d8af4dc474595af3900dd85cb3a29ad28cc313"
99+
RULES_PROTO_SHA256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208"
110100

101+
def protobuf_repositories(bind = True):
111102
http_archive(
112103
name = "com_google_protobuf",
113104
strip_prefix = "protobuf-" + PROTOBUF_COMMIT,
114105
url = "https://github.com/google/protobuf/archive/v" + PROTOBUF_COMMIT + ".tar.gz",
115106
sha256 = PROTOBUF_SHA256,
116107
)
117108

118-
if bind:
119-
native.bind(
120-
name = "protoc",
121-
actual = "@com_google_protobuf//:protoc",
122-
)
123-
124-
native.bind(
125-
name = "protobuf",
126-
actual = "@com_google_protobuf//:protobuf",
127-
)
128-
129-
native.bind(
130-
name = "cc_wkt_protos",
131-
actual = "@com_google_protobuf//:cc_wkt_protos",
132-
)
133-
134-
native.bind(
135-
name = "cc_wkt_protos_genproto",
136-
actual = "@com_google_protobuf//:cc_wkt_protos_genproto",
137-
)
138-
139-
native.bind(
140-
name = "protobuf_compiler",
141-
actual = "@com_google_protobuf//:protoc_lib",
142-
)
143-
144-
native.bind(
145-
name = "protobuf_clib",
146-
actual = "@com_google_protobuf//:protoc_lib",
147-
)
109+
http_archive(
110+
name = "rules_proto",
111+
sha256 = RULES_PROTO_SHA256,
112+
strip_prefix = "rules_proto-" + RULES_PROTO_SHA,
113+
urls = [
114+
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/" + RULES_PROTO_SHA + ".tar.gz",
115+
"https://github.com/bazelbuild/rules_proto/archive/" + RULES_PROTO_SHA + ".tar.gz",
116+
],
117+
)
148118

149119
GOOGLETEST_COMMIT = "43863938377a9ea1399c0596269e0890b5c5515a"
150120
GOOGLETEST_SHA256 = "7c8ece456ad588c30160429498e108e2df6f42a30888b3ec0abf5d9792d9d3a0"
151121

152-
def googletest_repositories(bind=True):
122+
def googletest_repositories(bind = True):
153123
BUILD = """
154124
# Copyright 2016 Google Inc. All Rights Reserved.
155125
#
@@ -235,100 +205,13 @@ cc_library(
235205
actual = "@googletest_git//:googletest_prod",
236206
)
237207

238-
GOOGLEAPIS_COMMIT = "32a10f69e2c9ce15bba13ab1ff928bacebb25160" # May 20, 2019
239-
GOOGLEAPIS_SHA256 = "6861efa8619579e06e70dd4765cdf6cef1ecad6a1a2026ad750541e99552bf71"
240-
241-
def googleapis_repositories(protobuf_repo="@com_google_protobuf//", bind=True):
242-
BUILD = """
243-
# Copyright 2016 Google Inc. All Rights Reserved.
244-
#
245-
# Licensed under the Apache License, Version 2.0 (the "License");
246-
# you may not use this file except in compliance with the License.
247-
# You may obtain a copy of the License at
248-
#
249-
# http://www.apache.org/licenses/LICENSE-2.0
250-
#
251-
# Unless required by applicable law or agreed to in writing, software
252-
# distributed under the License is distributed on an "AS IS" BASIS,
253-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
254-
# See the License for the specific language governing permissions and
255-
# limitations under the License.
256-
#
257-
################################################################################
258-
#
259-
260-
licenses(["notice"])
261-
262-
load("{0}:protobuf.bzl", "cc_proto_library")
263-
264-
exports_files(glob(["google/**"]))
265-
266-
cc_proto_library(
267-
name = "http_api_protos",
268-
srcs = [
269-
"google/api/annotations.proto",
270-
"google/api/http.proto",
271-
],
272-
default_runtime = "//external:protobuf",
273-
protoc = "//external:protoc",
274-
visibility = ["//visibility:public"],
275-
deps = ["{0}:cc_wkt_protos"],
276-
)
277-
278-
cc_proto_library(
279-
name = "service_config",
280-
srcs = [
281-
"google/api/auth.proto",
282-
"google/api/backend.proto",
283-
"google/api/billing.proto",
284-
"google/api/consumer.proto",
285-
"google/api/context.proto",
286-
"google/api/control.proto",
287-
"google/api/documentation.proto",
288-
"google/api/endpoint.proto",
289-
"google/api/label.proto",
290-
"google/api/launch_stage.proto",
291-
"google/api/log.proto",
292-
"google/api/logging.proto",
293-
"google/api/metric.proto",
294-
"google/api/experimental/experimental.proto",
295-
"google/api/experimental/authorization_config.proto",
296-
"google/api/monitored_resource.proto",
297-
"google/api/monitoring.proto",
298-
"google/api/resource.proto",
299-
"google/api/quota.proto",
300-
"google/api/service.proto",
301-
"google/api/source_info.proto",
302-
"google/api/system_parameter.proto",
303-
"google/api/usage.proto",
304-
],
305-
include = ".",
306-
visibility = ["//visibility:public"],
307-
deps = [
308-
":http_api_protos",
309-
"//external:cc_wkt_protos",
310-
],
311-
protoc = "//external:protoc",
312-
default_runtime = "//external:protobuf",
313-
)
314-
""".format(protobuf_repo)
208+
GOOGLEAPIS_COMMIT = "1d5522ad1056f16a6d593b8f3038d831e64daeea" # Sept 03, 2020
209+
GOOGLEAPIS_SHA256 = "cd13e547cffaad217c942084fd5ae0985a293d0cce3e788c20796e5e2ea54758"
315210

211+
def googleapis_repositories(bind = True):
316212
http_archive(
317-
name = "googleapis_git",
318-
patch_cmds = ["find . -type f -name '*BUILD*' | xargs rm"],
213+
name = "com_google_googleapis",
319214
strip_prefix = "googleapis-" + GOOGLEAPIS_COMMIT,
320215
url = "https://github.com/googleapis/googleapis/archive/" + GOOGLEAPIS_COMMIT + ".tar.gz",
321-
build_file_content = BUILD,
322216
sha256 = GOOGLEAPIS_SHA256,
323217
)
324-
325-
if bind:
326-
native.bind(
327-
name = "service_config",
328-
actual = "@googleapis_git//:service_config",
329-
)
330-
331-
native.bind(
332-
name = "http_api_protos",
333-
actual = "@googleapis_git//:http_api_protos",
334-
)

0 commit comments

Comments
 (0)