mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 00:19:58 +01:00
Simplify tf_vendored repo rule.
PiperOrigin-RevId: 814099609
This commit is contained in:
parent
2a8dcaf97e
commit
239c89159c
|
|
@ -5,8 +5,8 @@ load("//third_party:repo.bzl", "tf_vendored")
|
|||
load("//third_party/tf_runtime:workspace.bzl", tf_runtime = "repo")
|
||||
|
||||
def workspace():
|
||||
tf_vendored(name = "local_xla", relpath = "third_party/xla")
|
||||
tf_vendored(name = "local_tsl", relpath = "third_party/xla/third_party/tsl")
|
||||
tf_vendored(name = "local_xla", path = "third_party/xla")
|
||||
tf_vendored(name = "local_tsl", path = "third_party/xla/third_party/tsl")
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_closure",
|
||||
|
|
|
|||
19
third_party/repo.bzl
vendored
19
third_party/repo.bzl
vendored
|
|
@ -140,21 +140,16 @@ def tf_http_archive(name, sha256, urls, **kwargs):
|
|||
**kwargs
|
||||
)
|
||||
|
||||
def _tf_vendored_impl(repository_ctx):
|
||||
parent_path = repository_ctx.path(repository_ctx.attr.parent).dirname
|
||||
|
||||
# get_child doesn't allow slashes. Yes this is silly. bazel_skylib paths
|
||||
# doesn't work with path objects.
|
||||
relpath_parts = repository_ctx.attr.relpath.split("/")
|
||||
vendored_path = parent_path
|
||||
for part in relpath_parts:
|
||||
vendored_path = vendored_path.get_child(part)
|
||||
repository_ctx.symlink(vendored_path, ".")
|
||||
def _tf_vendored_impl(ctx):
|
||||
ctx.symlink(ctx.path(ctx.attr._root).dirname.get_child(ctx.attr.path), ".")
|
||||
|
||||
tf_vendored = repository_rule(
|
||||
implementation = _tf_vendored_impl,
|
||||
doc = "Similar to local_repository, but path is relative to the root of the " +
|
||||
"repository, not the root of the workspace.",
|
||||
attrs = {
|
||||
"parent": attr.label(default = "//:WORKSPACE"),
|
||||
"relpath": attr.string(),
|
||||
"_root": attr.label(default = "//:unused"),
|
||||
"path": attr.string(),
|
||||
},
|
||||
local = True,
|
||||
)
|
||||
|
|
|
|||
19
third_party/xla/third_party/repo.bzl
vendored
19
third_party/xla/third_party/repo.bzl
vendored
|
|
@ -138,21 +138,16 @@ def tf_http_archive(name, sha256, urls, **kwargs):
|
|||
**kwargs
|
||||
)
|
||||
|
||||
def _tf_vendored_impl(repository_ctx):
|
||||
parent_path = repository_ctx.path(repository_ctx.attr.parent).dirname
|
||||
|
||||
# get_child doesn't allow slashes. Yes this is silly. bazel_skylib paths
|
||||
# doesn't work with path objects.
|
||||
relpath_parts = repository_ctx.attr.relpath.split("/")
|
||||
vendored_path = parent_path
|
||||
for part in relpath_parts:
|
||||
vendored_path = vendored_path.get_child(part)
|
||||
repository_ctx.symlink(vendored_path, ".")
|
||||
def _tf_vendored_impl(ctx):
|
||||
ctx.symlink(ctx.path(ctx.attr._root).dirname.get_child(ctx.attr.path), ".")
|
||||
|
||||
tf_vendored = repository_rule(
|
||||
implementation = _tf_vendored_impl,
|
||||
doc = "Similar to local_repository, but path is relative to the root of the " +
|
||||
"repository, not the root of the workspace.",
|
||||
attrs = {
|
||||
"parent": attr.label(default = "//:WORKSPACE"),
|
||||
"relpath": attr.string(),
|
||||
"_root": attr.label(default = "//:unused"),
|
||||
"path": attr.string(),
|
||||
},
|
||||
local = True,
|
||||
)
|
||||
|
|
|
|||
2
third_party/xla/workspace4.bzl
vendored
2
third_party/xla/workspace4.bzl
vendored
|
|
@ -6,7 +6,7 @@ load("//third_party:repo.bzl", "tf_vendored")
|
|||
# buildifier: disable=unnamed-macro
|
||||
def workspace():
|
||||
# Declares @tsl
|
||||
tf_vendored(name = "tsl", relpath = "third_party/tsl")
|
||||
tf_vendored(name = "tsl", path = "third_party/tsl")
|
||||
|
||||
# Alias so it can be loaded without assigning to a different symbol to prevent
|
||||
# shadowing previous loads and trigger a buildifier warning.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user