blob: 0a275b642bf780fbd0481ebe5d6000bbc2b68fc6 [file] [log] [blame]
<html devsite>
<head>
<meta name="project_path" value="/_project.yaml">
<meta name="book_path" value="/versions/6.1.0/_book.yaml">
</head>
<body>
<h1 class="page-title" id="modules.Target">Target</h1>
<!-- {% raw %} -->
The BUILD target for a dependency. Appears in the fields of <code><a href='ctx.html#attr'>ctx.attr</a></code> corresponding to <a href='https://bazel.build/versions/6.1.0/rules/rules#dependency_attributes'>dependency attributes</a> (<code><a href='attr.html#label'>label</a></code> or <code><a href='attr.html#label_list'>label_list</a></code>). Has the following fields:
<ul>
<li><h3 id='modules.Target.label'>label</h3>
<code><a href='Label.html'>Label</a> Target.label</code><br/>
The identifier of the target.</li>
<li><h3 id='modules.Target.files'>files</h3>
<code><a href='depset.html'>depset</a> Target.files </code><br/>
The set of <code><a href='File.html'>File</a></code>s in the default outputs for this target. Equivalent to <code><a href='DefaultInfo.html#files'>target[DefaultInfo].files</a></code>.</li>
<li><h3 id='modules.Target.aspect_ids'>aspect_ids</h3>
<code><a href='list.html'>list</a> Target.aspect_ids </code><br/>
The list of <code><a href='ctx.html#aspect_ids'>aspect_ids</a></code> applied to this target.</li>
<li><h3 id='modules.Target.providers'>Providers</h3>
The <a href='https://bazel.build/versions/6.1.0/rules/rules#providers'>providers</a> of a rule target can be accessed by type using index notation (<code>target[DefaultInfo]</code>). The presence of providers can be checked using the <code>in</code> operator (<code>SomeInfo in target</code>).<br/>
<br/>
If the rule's implementation function returns a <code><a href='struct.html'>struct</a></code> instead of a list of <code><a href='Provider.html'>Provider</a></code> instances, the struct's fields can be accessed via the corresponding fields of the <code>Target</code> (<code>target.some_legacy_info</code>). This behavior <a href='https://bazel.build/versions/6.1.0/rules/rules#migrating_from_legacy_providers'>is deprecated</a>.</li>
</ul>
</body>
</html>
<!-- {% endraw %} -->