Label instance l, the string representation str(l) has the property that Label(str(l)) == l, regardless of where the Label() call occurs.
When passed as positional arguments to print() or fail(), Label use a string representation optimized for human readability instead. This representation uses an apparent repository name from the perspective of the main repository if possible.
Members
Label
Label object, in the context of the package where the calling .bzl source file lives. If the given value is already a Label, it is returned unchanged.
For macros, a related function, native.package_relative_label(), converts the input into a Label in the context of the package currently being constructed. Use that function to mimic the string-to-label conversion that is automatically done by label-valued rule attributes.
Parameters
ParameterDescriptioninputstring; or Label;
required
The input label string or Label object. If a Label object is passed, it’s returned as is.
name
package
relative
--+incompatible_enable_deprecated_label_apis
Deprecated. This method behaves surprisingly when used with an argument containing an apparent repo name. Prefer Label.same_package_label(), native.package_relative_label(), or Label() instead.
Resolves a label that is either absolute (starts with //) or relative to the current package. If this label is in a remote repository, the argument will be resolved relative to that repository. If the argument contains a repository name, the current label is ignored and the argument is returned as-is, except that the repository name is rewritten if it is in the current repository mapping. Reserved labels will also be returned as-is.
For example:
{'@other' : '@remapped'}, then the following remapping will take place:
Parameters
ParameterDescriptionrelNamestring;
required
The label that will be resolved relative to this one.
repo_name
@). For instance,
same_package_label
Parameters
ParameterDescriptiontarget_namestring;
required
The target name of the new label.
workspace_name
--+incompatible_enable_deprecated_label_apis
Deprecated. The field name “workspace name” is a misnomer here; use the identically-behaving Label.repo_name instead.
The canonical name of the repository containing the target referred to by this label, without any leading at-signs ( @). For instance,