$ cat /tmp/x/repo/WORKSPACE
local_repository(
name = "foo",
path = "/tmp/x/bar",
)
$ cat /tmp/x/repo/sub1/foo.bzl
def _impl(ctx):
src = ctx.file.src
print("basename=(%s)" % src.basename)
print("dirname=(%s)" % src.dirname)
print("extension=(%s)" % src.extension)
print("is_source=(%s)" % src.is_source)
print("owner=(%s)" % src.owner)
print("path=(%s)" % src.path)
print("root=(%s)" % src.root)
print("root.path=(%s)" % src.root.path)
print("short_path=(%s)" % src.short_path)
ctx.actions.do_nothing(mnemonic="foo")
foo = rule(
implementation = _impl,
attrs = {"src": attr.label(allow_files=True, single_file=True)},
)
$ cat /tmp/x/repo/sub1/BUILD
load(":foo.bzl", "foo")
foo(name = "foo", src = "@foo//sub2")
$ cat /tmp/x/bar/sub2/BUILD
genrule(
name = "sub2",
outs = ["sub2.txt"],
cmd = "echo $@ > $@",
visibility = ["//visibility:public"],
)
$ bazel build //sub1:foo |& grep DEBUG DEBUG: /tmp/x/repo/sub1/foo.bzl:3:3: basename=(sub2.txt) DEBUG: /tmp/x/repo/sub1/foo.bzl:4:3: dirname=(bazel-out/k8-fastbuild/genfiles/external/foo/sub2) DEBUG: /tmp/x/repo/sub1/foo.bzl:5:3: extension=(txt) DEBUG: /tmp/x/repo/sub1/foo.bzl:6:3: is_source=(False) DEBUG: /tmp/x/repo/sub1/foo.bzl:7:3: owner=(@foo//sub2:sub2) DEBUG: /tmp/x/repo/sub1/foo.bzl:8:3: path=(bazel-out/k8-fastbuild/genfiles/external/foo/sub2/sub2.txt) DEBUG: /tmp/x/repo/sub1/foo.bzl:9:3: root=(<derived root>) DEBUG: /tmp/x/repo/sub1/foo.bzl:10:3: root.path=(bazel-out/k8-fastbuild/genfiles) DEBUG: /tmp/x/repo/sub1/foo.bzl:11:3: short_path=(../foo/sub2/sub2.txt)
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAP4t0yiRFp62Lkzb7%3DhHYQEBkviYXQ1kpCfLqotmssre40Gifw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.