<html devsite>
<head>
  <meta name="project_path" value="/_project.yaml">
  <meta name="book_path" value="/versions/6.0.0/_book.yaml">
</head>
<body>

<h1 class="page-title" id="modules.Label">Label</h1>

<!-- {% raw %} -->

A BUILD target identifier.

<h2>Members</h2>
<ul>
    <li>
    <a href="#Label">Label</a>
  </li>
      <li>
    <a href="#name">name</a>
  </li>
      <li>
    <a href="#package">package</a>
  </li>
      <li>
    <a href="#relative">relative</a>
  </li>
      <li>
    <a href="#workspace_name">workspace_name</a>
  </li>
      <li>
    <a href="#workspace_root">workspace_root</a>
  </li>
  </ul>

      <h2 id="Label">Label</h2>
        <p><pre class="rule-signature"><a class="anchor" href="Label.html">Label</a> Label(label_string)</pre></p>

    Creates a Label referring to a BUILD target. Use this function when you want to give a default value for the label attributes of a rule or when referring to a target via an absolute label from a macro. The argument must refer to an absolute label. The repo part of the label (or its absence) is interpreted in the context of the repo where this Label() call appears. Example: <br><pre class=language-python>Label("//tools:default")</pre>

          <!-- hide-from-toc is a class used by DevSite for the public Bazel site
      (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
      <h3 class="hide-from-toc">Parameters</h3>
      <table class="table table-bordered table-condensed table-params">
        <colgroup>
          <col class="col-param">
          <col class="param-description">
        </colgroup>
        <thead>
          <tr>
            <th>Parameter</th>
            <th>Description</th>
          </tr>
        </thead>
        <tbody>
                  <tr>
            <td id="Label.label_string">
              <code>label_string</code>
            </td>
            <td>
                                     required<br/>
                          the label string.
            </td>
          </tr>
                </tbody>
      </table>

        <h2 id="name">name</h2>
        <p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> Label.name</pre></p>

    The name of this label within the package. For instance:<br><pre class=language-python>Label("//pkg/foo:abc").name == "abc"</pre>


        <h2 id="package">package</h2>
        <p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> Label.package</pre></p>

    The package part of this label. For instance:<br><pre class=language-python>Label("//pkg/foo:abc").package == "pkg/foo"</pre>


        <h2 id="relative">relative</h2>
        <p><pre class="rule-signature"><a class="anchor" href="Label.html">Label</a> Label.relative(relName)</pre></p>

    Resolves a label that is either absolute (starts with <code>//</code>) 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.<br>For example:<br><pre class=language-python>
Label("//foo/bar:baz").relative(":quux") == Label("//foo/bar:quux")
Label("//foo/bar:baz").relative("//wiz:quux") == Label("//wiz:quux")
Label("@repo//foo/bar:baz").relative("//wiz:quux") == Label("@repo//wiz:quux")
Label("@repo//foo/bar:baz").relative("//visibility:public") == Label("//visibility:public")
Label("@repo//foo/bar:baz").relative("@other//wiz:quux") == Label("@other//wiz:quux")
</pre><p>If the repository mapping passed in is <code>{'@other' : '@remapped'}</code>, then the following remapping will take place:<br><pre class=language-python>
Label("@repo//foo/bar:baz").relative("@other//wiz:quux") == Label("@remapped//wiz:quux")
</pre>

          <!-- hide-from-toc is a class used by DevSite for the public Bazel site
      (https://developers.google.com/devsite/reference/styles/headings#hide_headings_from_the_toc) -->
      <h3 class="hide-from-toc">Parameters</h3>
      <table class="table table-bordered table-condensed table-params">
        <colgroup>
          <col class="col-param">
          <col class="param-description">
        </colgroup>
        <thead>
          <tr>
            <th>Parameter</th>
            <th>Description</th>
          </tr>
        </thead>
        <tbody>
                  <tr>
            <td id="relative.relName">
              <code>relName</code>
            </td>
            <td>
                                     required<br/>
                          The label that will be resolved relative to this one.
            </td>
          </tr>
                </tbody>
      </table>

        <h2 id="workspace_name">workspace_name</h2>
        <p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> Label.workspace_name</pre></p>

    The repository part of this label. For instance, <pre class=language-python>Label("@foo//bar:baz").workspace_name == "foo"</pre>


        <h2 id="workspace_root">workspace_root</h2>
        <p><pre class="rule-signature"><a class="anchor" href="string.html">string</a> Label.workspace_root</pre></p>

    Returns the execution root for the workspace of this label, relative to the execroot. For instance:<br><pre class=language-python>Label("@repo//pkg/foo:abc").workspace_root == "external/repo"</pre>



</body>
</html>

<!-- {% endraw %} -->
