Skip to content

Commit 39c3fc9

Browse files
committed
bazel: Allow to distdir all dependencies
To use --distdir option of Bazel (which allows to use previously fetched tarballs instead of downloading dependencies during build), all dependencies should use http instead of git and need to have sha256 sums specified. Signed-off-by: Michal Rostecki <[email protected]>
1 parent c1eb06d commit 39c3fc9

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

repositories.bzl

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,28 @@
1414
#
1515
################################################################################
1616
#
17+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
18+
19+
ABSEIL_COMMIT = "99477fa9f1e89a7d8253c8aeee331864710d080c"
20+
ABSEIL_SHA256 = "495e8e1c481018126b2a84bfe36e273907ce282b135e7d161e138e463d295f3d"
21+
1722
def absl_repositories(bind=True):
18-
native.git_repository(
23+
http_archive(
1924
name = "com_google_absl",
20-
commit = "99477fa9f1e89a7d8253c8aeee331864710d080c",
21-
remote = "https://github.com/abseil/abseil-cpp",
25+
strip_prefix = "abseil-cpp-" + ABSEIL_COMMIT,
26+
url = "https://github.com/abseil/abseil-cpp/archive/" + ABSEIL_COMMIT + ".tar.gz",
27+
sha256 = ABSEIL_SHA256,
2228
)
2329

30+
PROTOBUF_COMMIT = "106ffc04be1abf3ff3399f54ccf149815b287dd9" # v3.5.1
31+
PROTOBUF_SHA256 = "ebc5f911ae580234da9cbcff03b841395bd97861efc82f67a165c5c3d366f2c6"
32+
2433
def protobuf_repositories(bind=True):
25-
native.git_repository(
34+
http_archive(
2635
name = "protobuf_git",
27-
commit = "106ffc04be1abf3ff3399f54ccf149815b287dd9", # v3.5.1
28-
remote = "https://github.com/google/protobuf.git",
36+
strip_prefix = "protobuf-" + PROTOBUF_COMMIT,
37+
url = "https://github.com/google/protobuf/archive/" + PROTOBUF_COMMIT + ".tar.gz",
38+
sha256 = PROTOBUF_SHA256,
2939
)
3040

3141
if bind:
@@ -59,6 +69,8 @@ def protobuf_repositories(bind=True):
5969
actual = "@protobuf_git//:protoc_lib",
6070
)
6171

72+
GOOGLETEST_COMMIT = "43863938377a9ea1399c0596269e0890b5c5515a"
73+
GOOGLETEST_SHA256 = "7c8ece456ad588c30160429498e108e2df6f42a30888b3ec0abf5d9792d9d3a0"
6274

6375
def googletest_repositories(bind=True):
6476
BUILD = """
@@ -122,11 +134,12 @@ cc_library(
122134
visibility = ["//visibility:public"],
123135
)
124136
"""
125-
native.new_git_repository(
137+
http_archive(
126138
name = "googletest_git",
139+
strip_prefix = "googletest-" + GOOGLETEST_COMMIT,
127140
build_file_content = BUILD,
128-
commit = "43863938377a9ea1399c0596269e0890b5c5515a",
129-
remote = "https://github.com/google/googletest.git",
141+
url = "https://github.com/google/googletest/archive/" + GOOGLETEST_COMMIT + ".tar.gz",
142+
sha256 = GOOGLETEST_SHA256,
130143
)
131144

132145
if bind:
@@ -145,6 +158,9 @@ cc_library(
145158
actual = "@googletest_git//:googletest_prod",
146159
)
147160

161+
GOOGLEAPIS_COMMIT = "5c6df0cd18c6a429eab739fb711c27f6e1393366" # May 14, 2017
162+
GOOGLEAPIS_SHA256 = "c6ce26246232c0f3e78d3a30f087444ec01c8ee64b34d058bfcd4f0f4a387a0b"
163+
148164
def googleapis_repositories(protobuf_repo="@protobuf_git//", bind=True):
149165
BUILD = """
150166
# Copyright 2016 Google Inc. All Rights Reserved.
@@ -242,11 +258,12 @@ cc_proto_library(
242258
)
243259
""".format(protobuf_repo)
244260

245-
native.new_git_repository(
261+
http_archive(
246262
name = "googleapis_git",
247-
commit = "5c6df0cd18c6a429eab739fb711c27f6e1393366", # May 14, 2017
248-
remote = "https://github.com/googleapis/googleapis.git",
263+
strip_prefix = "googleapis-" + GOOGLEAPIS_COMMIT,
264+
url = "https://github.com/googleapis/googleapis/archive/" + GOOGLEAPIS_COMMIT + ".tar.gz",
249265
build_file_content = BUILD,
266+
sha256 = GOOGLEAPIS_SHA256,
250267
)
251268

252269
if bind:

0 commit comments

Comments
 (0)