Trevor Hickey
Trevor Hickey

Reputation: 37806

Can I provide a relative deps path in my bazel target?

When I specify build rules in bazel, my dependencies are either full paths (from the root of the repo), or just the target name (since its in the same directory):

cc_binary(
    name = "program",
    srcs = ["main.cpp"],
    deps = ["//a/full/path/to/the/library:lib",
            "foo"]
)

Assume I'm writing a build rule from directory "the".
I was hoping to do something like this:

cc_binary(
    name = "program",
    srcs = ["main.cpp"],
    deps = ["library:lib",
            "foo"]
)

This does not seem to be possible. Is there some kind of way, where I can specify the target deeper starting from the location of the BUILD file?

Upvotes: 5

Views: 7469

Answers (1)

Ittai
Ittai

Reputation: 5915

You cannot.

Relative labels cannot be used to refer to targets in other packages; the repository identifier and package name must always be specified in this case.

From Bazel labels documentation

Upvotes: 6

Related Questions