In Bazel, targets are referred by labels.
Bazel labels have the following format:
@repoName//packageName:target
For example, in the following packages found in myRepo
:
myRepo
├── WORKSPACE
├── package1
│ └── BUILD
│ └── src
└── package2
├── BUILD
└── src
a target called myTarget
in package1/BUILD
can be labeled as as @myRepo//package1:myTarget
globally.
If referenced from the same repo, for example from package2/BUILD
, then the @myRepo
prefix can be omitted and you can use //package1:myTarget
.
If referenced from the same package, for example in another target from package1/BUILD
, then the package name can be omitted and you can use :myTarget
. The colon can also be omitted if it does not create confusion with a name. Such short form labels should not be confused with the names. Labels start with '//' or ':'. But names never do. For example, the name of the first package is package1
but its label is //package1
.
Reference: https://docs.bazel.build/versions/master/build-ref.html