diff --git a/tensorflow/workspace3.bzl b/tensorflow/workspace3.bzl index f2364cf5d57..adabcc54fc5 100644 --- a/tensorflow/workspace3.bzl +++ b/tensorflow/workspace3.bzl @@ -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", diff --git a/third_party/repo.bzl b/third_party/repo.bzl index 226f8799392..05907086249 100644 --- a/third_party/repo.bzl +++ b/third_party/repo.bzl @@ -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, ) diff --git a/third_party/xla/third_party/repo.bzl b/third_party/xla/third_party/repo.bzl index 7049c585c68..326276e11d9 100644 --- a/third_party/xla/third_party/repo.bzl +++ b/third_party/xla/third_party/repo.bzl @@ -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, ) diff --git a/third_party/xla/workspace4.bzl b/third_party/xla/workspace4.bzl index db1df366808..446c70dab32 100644 --- a/third_party/xla/workspace4.bzl +++ b/third_party/xla/workspace4.bzl @@ -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.