From 7a723e745f38bb6de9d14d75759f0aa51c60bb7e Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Thu, 23 Jun 2022 15:10:37 -0700 Subject: [PATCH] "resolve" Bazel label before download_and_extract to avoid redownloading each times. https://github.com/bazelbuild/bazel/issues/10515 PiperOrigin-RevId: 456870895 --- third_party/repo.bzl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/third_party/repo.bzl b/third_party/repo.bzl index 795f0b00b98..bda9e9518b4 100644 --- a/third_party/repo.bzl +++ b/third_party/repo.bzl @@ -54,6 +54,15 @@ def _tf_http_archive_impl(ctx): # See also https://github.com/bazelbuild/bazel/issues/10515. link_dict = _get_link_dict(ctx, ctx.attr.link_files, ctx.attr.build_file) + # For some reason, we need to "resolve" labels once before the + # download_and_extract otherwise it'll invalidate and re-download the + # archive each time. + # https://github.com/bazelbuild/bazel/issues/10515 + patch_files = ctx.attr.patch_file + for patch_file in patch_files: + if patch_file: + ctx.path(Label(patch_file)) + if _use_system_lib(ctx, ctx.attr.name): link_dict.update(_get_link_dict( ctx = ctx, @@ -67,7 +76,6 @@ def _tf_http_archive_impl(ctx): type = ctx.attr.type, stripPrefix = ctx.attr.strip_prefix, ) - patch_files = ctx.attr.patch_file if patch_files: for patch_file in patch_files: patch_file = ctx.path(Label(patch_file)) if patch_file else None