From 37f7bfbce884700295e6348506154be3a30f1457 Mon Sep 17 00:00:00 2001 From: Jason Zaman Date: Thu, 6 Sep 2018 22:01:10 +0800 Subject: third_party/repo: add system_link_files third_party_http_archive has a link_files attr, add a similar system_link_files attr that is only used when the system libraries are enabled. Also add it to tf_http_archive. Signed-off-by: Jason Zaman --- third_party/repo.bzl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'third_party') diff --git a/third_party/repo.bzl b/third_party/repo.bzl index 7d1aa5dce9..6e30618d39 100644 --- a/third_party/repo.bzl +++ b/third_party/repo.bzl @@ -119,6 +119,10 @@ def _tf_http_archive(ctx): "%prefix%": ".." if _repos_are_siblings() else "external", }, False) + if use_syslib: + for internal_src, external_dest in ctx.attr.system_link_files.items(): + ctx.symlink(Label(internal_src), ctx.path(external_dest)) + tf_http_archive = repository_rule( implementation = _tf_http_archive, attrs = { @@ -130,6 +134,7 @@ tf_http_archive = repository_rule( "patch_file": attr.label(), "build_file": attr.label(), "system_build_file": attr.label(), + "system_link_files": attr.string_dict(), }, environ = [ "TF_SYSTEM_LIBS", @@ -180,7 +185,16 @@ def _third_party_http_archive(ctx): _apply_patch(ctx, ctx.attr.patch_file) ctx.symlink(Label(ctx.attr.build_file), buildfile_path) + link_dict = dict() + if use_syslib: + link_dict.update(ctx.attr.system_link_files) + for internal_src, external_dest in ctx.attr.link_files.items(): + # if syslib and link exists in both, use the system one + if external_dest not in link_dict.values(): + link_dict[internal_src] = external_dest + + for internal_src, external_dest in link_dict.items(): ctx.symlink(Label(internal_src), ctx.path(external_dest)) # Downloads and creates Bazel repos for dependencies. @@ -201,6 +215,7 @@ third_party_http_archive = repository_rule( "system_build_file": attr.string(mandatory = False), "patch_file": attr.label(), "link_files": attr.string_dict(), + "system_link_files": attr.string_dict(), }, environ = [ "TF_SYSTEM_LIBS", -- cgit v1.2.3