I'm defining some custom rules and macros in a .bzl file in a workspace that others are supposed to import as an archive into their own projects.
In one of the macros, I need to add a dependency on a target which is hosted in the same workspace. If I refer to it as `//foo/bar`, I get an error as Bazel is looking for that target in the main workspace, which is not my workspace.
I'm currently referring to it as `my_workspace@//foo/bar`, which works but is flimsy as it only works if my workspace is being imported under that very name.
IS there any way to make that reference relative to the workspace in which it is defined?
Thanks,
=py=
--
You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/qNuyIu-akq8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/727e965b-41fb-4e70-b5cc-b5fc1ca2a9cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Right now my WORKSPACE file is empty. How do I add a name in there? Nothing stands out in https://docs.bazel.build/versions/master/be/workspace.html.
--
You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/qNuyIu-akq8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/a1bbca13-1659-4552-a507-573e40c3b465%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/c5465b31-7669-4c81-b61e-4cc3cdf416b5%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/a1d735a1-9aa6-4055-ad99-3ff2c14eaf3c%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/2ad61753-7a35-4a67-bd16-1ffa3078049e%40googlegroups.com.
Short on time so I’d advise you manually craft two very small repositories and check it out there.
Maybe the local repository indeed has a different behavior.
--
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-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAOfK4wUjFW%3DZ2LqhCknT%3DukUAs0RtnyqZJX%2BPeHygDvofhiN7A%40mail.gmail.com.
Thanks for the exhaustive answer! Very enlightening. I have two questions, see inline.
On Monday, June 18, 2018 at 5:30:45 AM UTC-7, Dmitry Lomov wrote:
> Sorry for late reply, and our docs are not awesome.
> TL;DR: here (https://fuchsia-review.googlesource.com/c/scripts/+/165123/1/sdk/bazel/base/build_defs/fidl_cc.bzl#b133)
>
>
> This line
> "@fuchsia_sdk//pkg/fidl_cpp",
>
> needs to read
>
> Label("@fuchsia_sdk//pkg/fidl_cpp",relative_to_caller_repository = True)
Can it just be Label("//pkg/fidl_cpp",relative_to_caller_repository = True) without the @fuchsia_sdk, since it's relative to the caller?
>
> (https://docs.bazel.build/versions/master/skylark/lib/Label.html#Label, we need to improve the docs and undeprecate this arg).
>
relative_to_caller_repository is marked as deprecated there. Still fine to use it?
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/136a2f20-fb93-4939-a98f-43bf660a1953%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Monday, June 18, 2018 at 5:45:49 AM UTC-7, Dmitry Lomov wrote:
> On Mon, Jun 18, 2018 at 2:40 PM, pylaligand via bazel-discuss <bazel-...@googlegroups.com> wrote:
> Thanks for the exhaustive answer! Very enlightening. I have two questions, see inline.
>
>
>
>
>
> On Monday, June 18, 2018 at 5:30:45 AM UTC-7, Dmitry Lomov wrote:
>
> > Sorry for late reply, and our docs are not awesome.
>
> > TL;DR: here (https://fuchsia-review.googlesource.com/c/scripts/+/165123/1/sdk/bazel/base/build_defs/fidl_cc.bzl#b133)
>
> >
>
> >
>
> > This line
>
> > "@fuchsia_sdk//pkg/fidl_cpp",
>
> >
>
> > needs to read
>
> >
>
> > Label("@fuchsia_sdk//pkg/fidl_cpp",relative_to_caller_repository = True)
>
>
>
> Can it just be Label("//pkg/fidl_cpp",relative_to_caller_repository = True) without the @fuchsia_sdk, since it's relative to the caller?
>
>
>
> Yes! Sorry, my mistake.
I just gave this a try and still got an error:
BUILD:7:1: no such package 'pkg/fidl_cpp': BUILD file not found on package path and referenced by '//fidl-cc:cc'
It looks like //pkg/fidl_cpp is still being searched for in the main repo.
I also noticed in the Label doc:
"When relative_to_caller_repository is True and the calling thread is a rule's implementation function, then a repo-relative label //foo:bar is resolved relative to the rule's repository."
It mentions the calling thread of a rule's implementation function, which I supposed is different from the macro thread.
I tried setting the attribute to False... and it worked. It looks like using an explicit Label is all I needed.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/306e4014-37b5-4228-ac90-e1f6972c3c7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.