third_party/repo: add TF_SYSTEM_LIBS to unbundle deps
Signed-off-by: Jason Zaman <jason@perfinion.com>
This commit is contained in:
parent
59bfc71a71
commit
4910a2bb53
43
third_party/repo.bzl
vendored
43
third_party/repo.bzl
vendored
@ -35,6 +35,15 @@ def _get_env_var(ctx, name):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Checks if we should use the system lib instead of the bundled one
|
||||||
|
def _use_system_lib(ctx, name):
|
||||||
|
syslibenv = _get_env_var(ctx, "TF_SYSTEM_LIBS")
|
||||||
|
if syslibenv:
|
||||||
|
for n in syslibenv.strip().split(","):
|
||||||
|
if n.strip() == name:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
# Executes specified command with arguments and calls 'fail' if it exited with
|
# Executes specified command with arguments and calls 'fail' if it exited with
|
||||||
# non-zero code
|
# non-zero code
|
||||||
def _execute_and_check_ret_code(repo_ctx, cmd_and_args):
|
def _execute_and_check_ret_code(repo_ctx, cmd_and_args):
|
||||||
@ -75,17 +84,28 @@ def _tf_http_archive(ctx):
|
|||||||
"Even if you don't have permission to mirror the file, please " +
|
"Even if you don't have permission to mirror the file, please " +
|
||||||
"put the correctly formatted mirror URL there anyway, because " +
|
"put the correctly formatted mirror URL there anyway, because " +
|
||||||
"someone will come along shortly thereafter and mirror the file.")
|
"someone will come along shortly thereafter and mirror the file.")
|
||||||
ctx.download_and_extract(
|
|
||||||
ctx.attr.urls,
|
use_syslib = _use_system_lib(ctx, ctx.attr.name)
|
||||||
"",
|
if not use_syslib:
|
||||||
ctx.attr.sha256,
|
ctx.download_and_extract(
|
||||||
ctx.attr.type,
|
ctx.attr.urls,
|
||||||
ctx.attr.strip_prefix)
|
"",
|
||||||
if ctx.attr.delete:
|
ctx.attr.sha256,
|
||||||
_apply_delete(ctx, ctx.attr.delete)
|
ctx.attr.type,
|
||||||
if ctx.attr.patch_file != None:
|
ctx.attr.strip_prefix)
|
||||||
_apply_patch(ctx, ctx.attr.patch_file)
|
if ctx.attr.delete:
|
||||||
if ctx.attr.build_file != None:
|
_apply_delete(ctx, ctx.attr.delete)
|
||||||
|
if ctx.attr.patch_file != None:
|
||||||
|
_apply_patch(ctx, ctx.attr.patch_file)
|
||||||
|
|
||||||
|
if use_syslib and ctx.attr.system_build_file != None:
|
||||||
|
# Use BUILD.bazel to avoid conflict with third party projects with
|
||||||
|
# BUILD or build (directory) underneath.
|
||||||
|
ctx.template("BUILD.bazel", ctx.attr.system_build_file, {
|
||||||
|
"%prefix%": ".." if _repos_are_siblings() else "external",
|
||||||
|
}, False)
|
||||||
|
|
||||||
|
elif ctx.attr.build_file != None:
|
||||||
# Use BUILD.bazel to avoid conflict with third party projects with
|
# Use BUILD.bazel to avoid conflict with third party projects with
|
||||||
# BUILD or build (directory) underneath.
|
# BUILD or build (directory) underneath.
|
||||||
ctx.template("BUILD.bazel", ctx.attr.build_file, {
|
ctx.template("BUILD.bazel", ctx.attr.build_file, {
|
||||||
@ -102,6 +122,7 @@ tf_http_archive = repository_rule(
|
|||||||
"delete": attr.string_list(),
|
"delete": attr.string_list(),
|
||||||
"patch_file": attr.label(),
|
"patch_file": attr.label(),
|
||||||
"build_file": attr.label(),
|
"build_file": attr.label(),
|
||||||
|
"system_build_file": attr.label(),
|
||||||
})
|
})
|
||||||
"""Downloads and creates Bazel repos for dependencies.
|
"""Downloads and creates Bazel repos for dependencies.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user