aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2018-01-25 09:43:10 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-25 09:44:37 -0800
commitada0c370c2a3ea484925bc4e7d927b015bc4ad92 (patch)
tree6bc7e13f9f02349ac5d89cc360eecc1b6cb3cd49 /tools
parent240ba9b3ee49d53251dc2e09a780b11962fe31cb (diff)
http_archive: work around #2700
Move the print statement about the used BUILD file earlier in the _http_archive_impl function, so that the BUILD file is accessed before we call out to the network for the first time. In this way, we avoid fetching the same file twice in a single build. Change-Id: I2b9be4e6a00da2de0cde56896d84c0ba9721456d PiperOrigin-RevId: 183251555
Diffstat (limited to 'tools')
-rw-r--r--tools/build_defs/repo/http.bzl13
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/build_defs/repo/http.bzl b/tools/build_defs/repo/http.bzl
index 23fb41ddf2..e8e57f2a0a 100644
--- a/tools/build_defs/repo/http.bzl
+++ b/tools/build_defs/repo/http.bzl
@@ -50,12 +50,23 @@ def _http_archive_impl(ctx):
if ctx.attr.build_file and ctx.attr.build_file_content:
ctx.fail("Only one of build_file and build_file_content can be provided.")
+ # These print statement is not only for debug, but it also ensures the file
+ # is referenced before the download is started; this is necessary till a
+ # proper fix for https://github.com/bazelbuild/bazel/issues/2700 is
+ # implemented. A proper could, e.g., be to ensure that all ctx.path of
+ # all the lables provided as arguments are present before the implementation
+ # function is called the first time.
+ if ctx.attr.build_file:
+ print("ctx.attr.build_file %s, path %s" %
+ (str(ctx.attr.build_file), ctx.path(ctx.attr.build_file)))
+ for patchfile in ctx.attr.patches:
+ print("patch file %s, path %s" % (patchfile, ctx.path(patchfile)))
+
ctx.download_and_extract(ctx.attr.urls, "", ctx.attr.sha256, ctx.attr.type,
ctx.attr.strip_prefix)
_patch(ctx)
ctx.file("WORKSPACE", "workspace(name = \"{name}\")\n".format(name=ctx.name))
if ctx.attr.build_file:
- print("ctx.attr.build_file %s" % str(ctx.attr.build_file))
ctx.symlink(ctx.attr.build_file, "BUILD")
elif ctx.attr.build_file_content:
ctx.file("BUILD", ctx.attr.build_file_content)