blob: 58eb2d5730d8cec8249e0789f1b25c3d65c10bd8 [file] [log] [blame] [edit]
<!DOCTYPE HTML>
<html lang="en" class="light sidebar-visible" dir="ltr">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>crate_universe (WORKSPACE) - rules_rust</title>
<!-- Custom HTML head -->
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<link rel="icon" href="favicon.svg">
<link rel="shortcut icon" href="favicon.png">
<link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/general.css">
<link rel="stylesheet" href="css/chrome.css">
<link rel="stylesheet" href="css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="highlight.css">
<link rel="stylesheet" href="tomorrow-night.css">
<link rel="stylesheet" href="ayu-highlight.css">
<!-- Custom theme stylesheets -->
<!-- Provide site root to javascript -->
<script>
var path_to_root = "";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
</script>
<!-- Start loading toc.js asap -->
<script src="toc.js"></script>
</head>
<body>
<div id="body-container">
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
const html = document.documentElement;
html.classList.remove('light')
html.classList.add(theme);
html.classList.add("js");
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<!-- populated by js -->
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
<noscript>
<iframe class="sidebar-iframe-outer" src="toc.html"></iframe>
</noscript>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">rules_rust</h1>
<div class="right-buttons">
<a href="print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
<a href="https://github.com/bazelbuild/rules_rust" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-github"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
<h1 id="crate-universe"><a class="header" href="#crate-universe">Crate Universe</a></h1>
<p>Crate Universe is a set of Bazel rule for generating Rust targets using Cargo.</p>
<p>This doc describes using crate_universe from a WORKSPACE file.</p>
<p>If you're using bzlmod, please see <a href="crate_universe_bzlmod.html">the bzlmod equivalent of this doc</a>.</p>
<h2 id="setup"><a class="header" href="#setup">Setup</a></h2>
<p>After loading <code>rules_rust</code> in your workspace, set the following to begin using <code>crate_universe</code>:</p>
<pre><code class="language-python">load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies()
</code></pre>
<p>Note that if the current version of <code>rules_rust</code> is not a release artifact, you may need to set additional
flags such as <a href="#crate_universe_dependencies-bootstrap"><code>bootstrap = True</code></a> on the <code>crate_universe_dependencies</code>
call above or <a href="#crates_repository-generator_urls">crates_repository::generator_urls</a> in uses of <code>crates_repository</code>.</p>
<h2 id="rules"><a class="header" href="#rules">Rules</a></h2>
<ul>
<li><a href="#crates_repository">crates_repository</a></li>
<li><a href="#crates_vendor">crates_vendor</a></li>
</ul>
<h2 id="utility-macros"><a class="header" href="#utility-macros">Utility Macros</a></h2>
<ul>
<li><a href="#crate_universe_dependencies">crate_universe_dependencies</a></li>
<li><a href="#crateannotation">crate.annotation</a></li>
<li><a href="#crateselect">crate.select</a></li>
<li><a href="#cratespec">crate.spec</a></li>
<li><a href="#crateworkspace_member">crate.workspace_member</a></li>
<li><a href="#render_config">render_config</a></li>
<li><a href="#splicing_config">splicing_config</a></li>
</ul>
<h2 id="workflows"><a class="header" href="#workflows">Workflows</a></h2>
<p>The <a href="#crates_repository"><code>crates_repository</code></a> rule (the primary repository rule of <code>rules_rust</code>'s cargo support) supports a number of different
ways users can express and organize their dependencies. The most common are listed below though there are more to be found in
the <a href="https://github.com/bazelbuild/rules_rust/tree/main/examples/crate_universe">./examples/crate_universe</a> directory.</p>
<h3 id="cargo-workspaces"><a class="header" href="#cargo-workspaces">Cargo Workspaces</a></h3>
<p>One of the simpler ways to wire up dependencies would be to first structure your project into a <a href="https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html">Cargo workspace</a>.
The <code>crates_repository</code> rule can ingest a root <code>Cargo.toml</code> file and generate dependencies from there.</p>
<pre><code class="language-python">load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
crates_repository(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
lockfile = "//:Cargo.Bazel.lock",
manifests = ["//:Cargo.toml"],
)
load("@crate_index//:defs.bzl", "crate_repositories")
crate_repositories()
</code></pre>
<p>The generated <code>crates_repository</code> contains helper macros which make collecting dependencies for Bazel targets simpler.
Notably, the <code>all_crate_deps</code> and <code>aliases</code> macros (see <a href="#dependencies-api">Dependencies API</a>) commonly allow the
<code>Cargo.toml</code> files to be the single source of truth for dependencies. Since these macros come from the generated
repository, the dependencies and alias definitions they return will automatically update BUILD targets.</p>
<pre><code class="language-python">load("@crate_index//:defs.bzl", "aliases", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
rust_library(
name = "lib",
aliases = aliases(),
deps = all_crate_deps(
normal = True,
),
proc_macro_deps = all_crate_deps(
proc_macro = True,
),
)
rust_test(
name = "unit_test",
crate = ":lib",
aliases = aliases(
normal_dev = True,
proc_macro_dev = True,
),
deps = all_crate_deps(
normal_dev = True,
),
proc_macro_deps = all_crate_deps(
proc_macro_dev = True,
),
)
</code></pre>
<h3 id="direct-packages"><a class="header" href="#direct-packages">Direct Packages</a></h3>
<p>In cases where Rust targets have heavy interractions with other Bazel targests (<a href="https://docs.bazel.build/versions/main/be/c-cpp.html">Cc</a>, <a href="https://rules-proto-grpc.com/en/latest/lang/rust.html">Proto</a>, etc.),
maintaining <code>Cargo.toml</code> files may have deminishing returns as things like <a href="https://rust-analyzer.github.io/">rust-analyzer</a> begin to be confused
about missing targets or environment variables defined only in Bazel. In workspaces like this, it may be desirable
to have a "Cargo free" setup. <code>crates_repository</code> supports this through the <code>packages</code> attribute.</p>
<pre><code class="language-python">load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository", "render_config")
crates_repository(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
lockfile = "//:Cargo.Bazel.lock",
packages = {
"async-trait": crate.spec(
version = "0.1.51",
),
"mockall": crate.spec(
version = "0.10.2",
),
"tokio": crate.spec(
version = "1.12.0",
),
},
# Setting the default package name to `""` forces the use of the macros defined in this repository
# to always use the root package when looking for dependencies or aliases. This should be considered
# optional as the repository also exposes alises for easy access to all dependencies.
render_config = render_config(
default_package_name = ""
),
)
load("@crate_index//:defs.bzl", "crate_repositories")
crate_repositories()
</code></pre>
<p>Consuming dependencies may be more ergonomic in this case through the aliases defined in the new repository.</p>
<pre><code class="language-python">load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
rust_library(
name = "lib",
deps = [
"@crate_index//:tokio",
],
proc_macro_deps = [
"@crate_index//:async-trait",
],
)
rust_test(
name = "unit_test",
crate = ":lib",
deps = [
"@crate_index//:mockall",
],
)
</code></pre>
<h3 id="binary-dependencies"><a class="header" href="#binary-dependencies">Binary dependencies</a></h3>
<p>Neither of the above approaches supports depending on binary-only packages.</p>
<p>In order to depend on a Cargo package that contains binaries and no library, you
will need to do one of the following:</p>
<ul>
<li>
<p>Fork the package to add an empty lib.rs, which makes the package visible to
Cargo metadata and compatible with the above approaches;</p>
</li>
<li>
<p>Or handwrite your own build target for the binary, use <code>http_archive</code> to
import its source code, and use <code>crates_repository</code> to make build targets for
its dependencies. This is demonstrated below using the <code>rustfilt</code> crate as an
example.</p>
</li>
</ul>
<pre><code class="language-python"># in WORKSPACE.bazel
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rustfilt",
build_file = "//rustfilt:BUILD.rustfilt.bazel",
sha256 = "c8d748b182c8f95224336d20dcc5609598af612581ce60cfb29da4dc8d0091f2",
strip_prefix = "rustfilt-0.2.1",
type = "tar.gz",
urls = ["https://static.crates.io/crates/rustfilt/rustfilt-0.2.1.crate"],
)
load("@rules_rust//crate_universe:defs.bzl", "crates_repository")
crates_repository(
name = "rustfilt_deps",
cargo_lockfile = "//rustfilt:Cargo.lock",
manifests = ["@rustfilt//:Cargo.toml"],
)
load("@rustfilt_deps//:defs.bzl", rustfilt_deps = "crate_repositories")
rustfilt_deps()
</code></pre>
<pre><code class="language-python"># in rustfilt/BUILD.rustfilt.bazel
load("@rules_rust//rust:defs.bzl", "rust_binary")
rust_binary(
name = "rustfilt",
srcs = glob(["src/**/*.rs"]),
edition = "2018",
deps = [
"@rustfilt_deps//:clap",
"@rustfilt_deps//:lazy_static",
"@rustfilt_deps//:regex",
"@rustfilt_deps//:rustc-demangle",
],
)
</code></pre>
<p>If you use either <code>crates_repository</code> or <code>crates_vendor</code> to depend on a Cargo
package that contains <em>both</em> a library crate <em>and</em> binaries, by default only the
library gets made available to Bazel. To generate Bazel targets for the binary
crates as well, you must opt in to it with an annotation on the package:</p>
<pre><code class="language-python">load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "crate")
crates_repository(
name = "crate_index",
annotations = {
"thepackage": [crate.annotation(
gen_binaries = True,
# Or, to expose just a subset of the package's binaries by name:
gen_binaries = ["rustfilt"],
)],
},
# Or, to expose every binary of every package:
generate_binaries = True,
...
)
</code></pre>
<h2 id="dependencies-api"><a class="header" href="#dependencies-api">Dependencies API</a></h2>
<p>After rendering dependencies, convenience macros may also be generated to provide
convenient accessors to larger sections of the dependency graph.</p>
<ul>
<li><a href="#aliases">aliases</a></li>
<li><a href="#crate_deps">crate_deps</a></li>
<li><a href="#all_crate_deps">all_crate_deps</a></li>
<li><a href="#crate_repositories">crate_repositories</a></li>
</ul>
<h2 id="building-crates-with-complicated-dependencies"><a class="header" href="#building-crates-with-complicated-dependencies">Building crates with complicated dependencies</a></h2>
<p>Some crates have build.rs scripts which are complicated to run. Typically these build C++ (or other languages), or attempt to find pre-installed libraries on the build machine.</p>
<p>There are a few approaches to making sure these run:</p>
<h3 id="some-things-work-without-intervention"><a class="header" href="#some-things-work-without-intervention">Some things work without intervention</a></h3>
<p>Some build scripts will happily run without any support needed.</p>
<p>rules_rust already supplies a configured C++ toolchain as input to build script execution, and sets variables like <code>CC</code>, <code>CXX</code>, <code>LD</code>, <code>LDFLAGS</code>, etc as needed. Many crates which invoke a compiler with the default environment, or forward these env vars, will Just Work (e.g. if using <a href="https://github.com/rust-lang/cc-rs"><code>cc-rs</code></a>).</p>
<p>rules_rust is open to PRs which make build scripts more likely to work by default with intervention assuming they're broadly applicable (e.g. setting extra widely-known env vars is probably fine, wiring up additional toolchains like <code>cmake</code> that aren't present by default for most Bazel users probably isn't).</p>
<h3 id="supplying-extra-tools-to-build"><a class="header" href="#supplying-extra-tools-to-build">Supplying extra tools to build</a></h3>
<p>Some build scripts can be made to work by pulling in some extra files and making them available to the build script.</p>
<p>Commonly this is done by passing the file to the <code>build_script_data</code> annotation for the crate, and using <code>build_script_env</code> to tell the build script where the file is. That env var may often use <code>$(execroot)</code> to get the path to the label, or <code>$${pwd}/</code> as a prefix if the path given is relative to the execroot (as will frequently happen when using a toolchain).A</p>
<p>There is an example of this in the "complicated dependencies" section of https://github.com/bazelbuild/rules_rust/blob/main/examples/crate_universe/WORKSPACE.bazel which builds libz-ng-sys.</p>
<h3 id="building-with-bazel-and-supplying-via-an-override"><a class="header" href="#building-with-bazel-and-supplying-via-an-override">Building with Bazel and supplying via an override</a></h3>
<p>Some build scripts have hooks to allow replacing parts that are complicated to build with output prepared by Bazel.</p>
<p>We can use those hooks by specifying paths (generally using the <code>build_script_data</code> and <code>build_script_env</code> annotations) and pointing them at labels which Bazel will then build. These env vars may often use <code>$(execroot)</code> to get the path to the label, or <code>$${pwd}/</code> as a prefix if the path given is relative to the execroot (as will frequently happen when using a toolchain).</p>
<p>There is an example of this in the "complicated dependencies" section of https://github.com/bazelbuild/rules_rust/blob/main/examples/crate_universe/WORKSPACE.bazel which builds boring-sys.</p>
<hr />
<hr />
<p><a id="crates_vendor"></a></p>
<h2 id="crates_vendor"><a class="header" href="#crates_vendor">crates_vendor</a></h2>
<pre>
crates_vendor(<a href="#crates_vendor-name">name</a>, <a href="#crates_vendor-annotations">annotations</a>, <a href="#crates_vendor-bazel">bazel</a>, <a href="#crates_vendor-buildifier">buildifier</a>, <a href="#crates_vendor-cargo_bazel">cargo_bazel</a>, <a href="#crates_vendor-cargo_config">cargo_config</a>, <a href="#crates_vendor-cargo_lockfile">cargo_lockfile</a>,
<a href="#crates_vendor-generate_binaries">generate_binaries</a>, <a href="#crates_vendor-generate_build_scripts">generate_build_scripts</a>, <a href="#crates_vendor-generate_target_compatible_with">generate_target_compatible_with</a>, <a href="#crates_vendor-manifests">manifests</a>,
<a href="#crates_vendor-mode">mode</a>, <a href="#crates_vendor-packages">packages</a>, <a href="#crates_vendor-render_config">render_config</a>, <a href="#crates_vendor-repository_name">repository_name</a>, <a href="#crates_vendor-splicing_config">splicing_config</a>,
<a href="#crates_vendor-supported_platform_triples">supported_platform_triples</a>, <a href="#crates_vendor-vendor_path">vendor_path</a>)
</pre>
<p>A rule for defining Rust dependencies (crates) and writing targets for them to the current workspace.
This rule is useful for users whose workspaces are expected to be consumed in other workspaces as the
rendered <code>BUILD</code> files reduce the number of workspace dependencies, allowing for easier loads. This rule
handles all the same <a href="#workflows">workflows</a> <code>crate_universe</code> rules do.</p>
<p>Example:</p>
<p>Given the following workspace structure:</p>
<pre><code class="language-text">[workspace]/
WORKSPACE
BUILD
Cargo.toml
3rdparty/
BUILD
src/
main.rs
</code></pre>
<p>The following is something that'd be found in <code>3rdparty/BUILD</code>:</p>
<pre><code class="language-python">load("@rules_rust//crate_universe:defs.bzl", "crates_vendor", "crate")
crates_vendor(
name = "crates_vendor",
annotations = {
"rand": [crate.annotation(
default_features = False,
features = ["small_rng"],
)],
},
cargo_lockfile = "//:Cargo.Bazel.lock",
manifests = ["//:Cargo.toml"],
mode = "remote",
vendor_path = "crates",
tags = ["manual"],
)
</code></pre>
<p>The above creates a target that can be run to write <code>BUILD</code> files into the <code>3rdparty</code>
directory next to where the target is defined. To run it, simply call:</p>
<pre><code class="language-shell">bazel run //3rdparty:crates_vendor
</code></pre>
<p><a id="#crates_vendor_repinning_updating_dependencies"></a></p>
<h3 id="repinning--updating-dependencies"><a class="header" href="#repinning--updating-dependencies">Repinning / Updating Dependencies</a></h3>
<p>Repinning dependencies is controlled by both the <code>CARGO_BAZEL_REPIN</code> environment variable or the <code>--repin</code>
flag to the <code>crates_vendor</code> binary. To update dependencies, simply add the flag ro your <code>bazel run</code> invocation.</p>
<pre><code class="language-shell">bazel run //3rdparty:crates_vendor -- --repin
</code></pre>
<p>Under the hood, <code>--repin</code> will trigger a <a href="https://doc.rust-lang.org/cargo/commands/cargo-update.html">cargo update</a>
call against the generated workspace. The following table describes how to control particular values passed to the
<code>cargo update</code> command.</p>
<div class="table-wrapper"><table><thead><tr><th>Value</th><th>Cargo command</th></tr></thead><tbody>
<tr><td>Any of [<code>true</code>, <code>1</code>, <code>yes</code>, <code>on</code>, <code>workspace</code>]</td><td><code>cargo update --workspace</code></td></tr>
<tr><td>Any of [<code>full</code>, <code>eager</code>, <code>all</code>]</td><td><code>cargo update</code></td></tr>
<tr><td><code>package_name</code></td><td><code>cargo upgrade --package package_name</code></td></tr>
<tr><td><code>package_name@1.2.3</code></td><td><code>cargo upgrade --package package_name --precise 1.2.3</code></td></tr>
</tbody></table>
</div>
<p><strong>ATTRIBUTES</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Type</th><th style="text-align: left">Mandatory</th><th style="text-align: left">Default</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crates_vendor-name"></a>name</td><td style="text-align: left">A unique name for this target.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels#target-names">Name</a></td><td style="text-align: left">required</td><td style="text-align: left"></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-annotations"></a>annotations</td><td style="text-align: left">Extra settings to apply to crates. See <a href="#crateannotation">crate.annotation</a>.</td><td style="text-align: left"><a href="https://bazel.build/rules/lib/dict">Dictionary: String -&gt; List of strings</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>{}</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-bazel"></a>bazel</td><td style="text-align: left">The path to a bazel binary used to locate the output_base for the current workspace.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-buildifier"></a>buildifier</td><td style="text-align: left">The path to a <a href="https://github.com/bazelbuild/buildtools/blob/5.0.1/buildifier/README.md">buildifier</a> binary used to format generated BUILD files.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>"@rules_rust//crate_universe/private/vendor:buildifier"</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-cargo_bazel"></a>cargo_bazel</td><td style="text-align: left">The cargo-bazel binary to use for vendoring. If this attribute is not set, then a <code>CARGO_BAZEL_GENERATOR_PATH</code> action env will be used.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>"@@cargo_bazel_bootstrap//:binary"</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-cargo_config"></a>cargo_config</td><td style="text-align: left">A <a href="https://doc.rust-lang.org/cargo/reference/config.html">Cargo configuration</a> file.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-cargo_lockfile"></a>cargo_lockfile</td><td style="text-align: left">The path to an existing <code>Cargo.lock</code> file</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-generate_binaries"></a>generate_binaries</td><td style="text-align: left">Whether to generate <code>rust_binary</code> targets for all the binary crates in every package. By default only the <code>rust_library</code> targets are generated.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-generate_build_scripts"></a>generate_build_scripts</td><td style="text-align: left">Whether or not to generate <a href="https://doc.rust-lang.org/cargo/reference/build-scripts.html">cargo build scripts</a> by default.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-generate_target_compatible_with"></a>generate_target_compatible_with</td><td style="text-align: left">DEPRECATED: Moved to <code>render_config</code>.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-manifests"></a>manifests</td><td style="text-align: left">A list of Cargo manifests (<code>Cargo.toml</code> files).</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">List of labels</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>[]</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-mode"></a>mode</td><td style="text-align: left">Flags determining how crates should be vendored. <code>local</code> is where crate source and BUILD files are written to the repository. <code>remote</code> is where only BUILD files are written and repository rules used to fetch source code.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>"remote"</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-packages"></a>packages</td><td style="text-align: left">A set of crates (packages) specifications to depend on. See <a href="#crate.spec">crate.spec</a>.</td><td style="text-align: left"><a href="https://bazel.build/rules/lib/dict">Dictionary: String -&gt; String</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>{}</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-render_config"></a>render_config</td><td style="text-align: left">The configuration flags to use for rendering. Use <code>//crate_universe:defs.bzl\%render_config</code> to generate the value for this field. If unset, the defaults defined there will be used.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>""</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-repository_name"></a>repository_name</td><td style="text-align: left">The name of the repository to generate for <code>remote</code> vendor modes. If unset, the label name will be used</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>""</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-splicing_config"></a>splicing_config</td><td style="text-align: left">The configuration flags to use for splicing Cargo maniests. Use <code>//crate_universe:defs.bzl\%rsplicing_config</code> to generate the value for this field. If unset, the defaults defined there will be used.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>""</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-supported_platform_triples"></a>supported_platform_triples</td><td style="text-align: left">A set of all platform triples to consider when generating dependencies.</td><td style="text-align: left">List of strings</td><td style="text-align: left">optional</td><td style="text-align: left"><code>["aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", "aarch64-linux-android", "aarch64-pc-windows-msvc", "aarch64-unknown-fuchsia", "aarch64-unknown-linux-gnu", "aarch64-unknown-nixos-gnu", "aarch64-unknown-nto-qnx710", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-apple-darwin", "i686-linux-android", "i686-pc-windows-msvc", "i686-unknown-freebsd", "i686-unknown-linux-gnu", "powerpc-unknown-linux-gnu", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-none-elf", "s390x-unknown-linux-gnu", "thumbv7em-none-eabi", "thumbv8m.main-none-eabi", "wasm32-unknown-unknown", "wasm32-wasi", "wasm32-wasip1", "x86_64-apple-darwin", "x86_64-apple-ios", "x86_64-linux-android", "x86_64-pc-windows-msvc", "x86_64-unknown-freebsd", "x86_64-unknown-fuchsia", "x86_64-unknown-linux-gnu", "x86_64-unknown-nixos-gnu", "x86_64-unknown-none"]</code></td></tr>
<tr><td style="text-align: left"><a id="crates_vendor-vendor_path"></a>vendor_path</td><td style="text-align: left">The path to a directory to write files into. Absolute paths will be treated as relative to the workspace root</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>"crates"</code></td></tr>
</tbody></table>
</div>
<p><a id="aliases"></a></p>
<h2 id="aliases"><a class="header" href="#aliases">aliases</a></h2>
<pre>
aliases(<a href="#aliases-normal">normal</a>, <a href="#aliases-normal_dev">normal_dev</a>, <a href="#aliases-proc_macro">proc_macro</a>, <a href="#aliases-proc_macro_dev">proc_macro_dev</a>, <a href="#aliases-build">build</a>, <a href="#aliases-build_proc_macro">build_proc_macro</a>, <a href="#aliases-package_name">package_name</a>)
</pre>
<p>Produces a map of Crate alias names to their original label</p>
<p>If no dependency kinds are specified, <code>normal</code> and <code>proc_macro</code> are used by default.
Setting any one flag will otherwise determine the contents of the returned dict.</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="aliases-normal"></a>normal</td><td style="text-align: left">If True, normal dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="aliases-normal_dev"></a>normal_dev</td><td style="text-align: left">If True, normal dev dependencies will be included in the output list..</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="aliases-proc_macro"></a>proc_macro</td><td style="text-align: left">If True, proc_macro dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="aliases-proc_macro_dev"></a>proc_macro_dev</td><td style="text-align: left">If True, dev proc_macro dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="aliases-build"></a>build</td><td style="text-align: left">If True, build dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="aliases-build_proc_macro"></a>build_proc_macro</td><td style="text-align: left">If True, build proc_macro dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="aliases-package_name"></a>package_name</td><td style="text-align: left">The package name of the set of dependencies to look up. Defaults to <code>native.package_name()</code> when unset.</td><td style="text-align: left"><code>None</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>dict: The aliases of all associated packages</p>
<p><a id="all_crate_deps"></a></p>
<h2 id="all_crate_deps"><a class="header" href="#all_crate_deps">all_crate_deps</a></h2>
<pre>
all_crate_deps(<a href="#all_crate_deps-normal">normal</a>, <a href="#all_crate_deps-normal_dev">normal_dev</a>, <a href="#all_crate_deps-proc_macro">proc_macro</a>, <a href="#all_crate_deps-proc_macro_dev">proc_macro_dev</a>, <a href="#all_crate_deps-build">build</a>, <a href="#all_crate_deps-build_proc_macro">build_proc_macro</a>,
<a href="#all_crate_deps-package_name">package_name</a>)
</pre>
<p>Finds the fully qualified label of all requested direct crate dependencies for the package where this macro is called.</p>
<p>If no parameters are set, all normal dependencies are returned. Setting any one flag will
otherwise impact the contents of the returned list.</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="all_crate_deps-normal"></a>normal</td><td style="text-align: left">If True, normal dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="all_crate_deps-normal_dev"></a>normal_dev</td><td style="text-align: left">If True, normal dev dependencies will be included in the output list..</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="all_crate_deps-proc_macro"></a>proc_macro</td><td style="text-align: left">If True, proc_macro dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="all_crate_deps-proc_macro_dev"></a>proc_macro_dev</td><td style="text-align: left">If True, dev proc_macro dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="all_crate_deps-build"></a>build</td><td style="text-align: left">If True, build dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="all_crate_deps-build_proc_macro"></a>build_proc_macro</td><td style="text-align: left">If True, build proc_macro dependencies are included in the output list.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="all_crate_deps-package_name"></a>package_name</td><td style="text-align: left">The package name of the set of dependencies to look up. Defaults to <code>native.package_name()</code> when unset.</td><td style="text-align: left"><code>None</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>list: A list of labels to generated rust targets (str)</p>
<p><a id="crate.annotation"></a></p>
<h2 id="crateannotation"><a class="header" href="#crateannotation">crate.annotation</a></h2>
<pre>
crate.annotation(<a href="#crate.annotation-version">version</a>, <a href="#crate.annotation-additive_build_file">additive_build_file</a>, <a href="#crate.annotation-additive_build_file_content">additive_build_file_content</a>, <a href="#crate.annotation-alias_rule">alias_rule</a>,
<a href="#crate.annotation-build_script_compile_data">build_script_compile_data</a>, <a href="#crate.annotation-build_script_data">build_script_data</a>, <a href="#crate.annotation-build_script_tools">build_script_tools</a>,
<a href="#crate.annotation-build_script_data_glob">build_script_data_glob</a>, <a href="#crate.annotation-build_script_deps">build_script_deps</a>, <a href="#crate.annotation-build_script_env">build_script_env</a>,
<a href="#crate.annotation-build_script_proc_macro_deps">build_script_proc_macro_deps</a>, <a href="#crate.annotation-build_script_rundir">build_script_rundir</a>, <a href="#crate.annotation-build_script_rustc_env">build_script_rustc_env</a>,
<a href="#crate.annotation-build_script_toolchains">build_script_toolchains</a>, <a href="#crate.annotation-compile_data">compile_data</a>, <a href="#crate.annotation-compile_data_glob">compile_data_glob</a>, <a href="#crate.annotation-crate_features">crate_features</a>, <a href="#crate.annotation-data">data</a>,
<a href="#crate.annotation-data_glob">data_glob</a>, <a href="#crate.annotation-deps">deps</a>, <a href="#crate.annotation-extra_aliased_targets">extra_aliased_targets</a>, <a href="#crate.annotation-gen_binaries">gen_binaries</a>, <a href="#crate.annotation-disable_pipelining">disable_pipelining</a>,
<a href="#crate.annotation-gen_build_script">gen_build_script</a>, <a href="#crate.annotation-patch_args">patch_args</a>, <a href="#crate.annotation-patch_tool">patch_tool</a>, <a href="#crate.annotation-patches">patches</a>, <a href="#crate.annotation-proc_macro_deps">proc_macro_deps</a>, <a href="#crate.annotation-rustc_env">rustc_env</a>,
<a href="#crate.annotation-rustc_env_files">rustc_env_files</a>, <a href="#crate.annotation-rustc_flags">rustc_flags</a>, <a href="#crate.annotation-shallow_since">shallow_since</a>, <a href="#crate.annotation-override_targets">override_targets</a>)
</pre>
<p>A collection of extra attributes and settings for a particular crate</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crate.annotation-version"></a>version</td><td style="text-align: left">The version or semver-conditions to match with a crate. The wildcard <code>*</code> matches any version, including prerelease versions.</td><td style="text-align: left"><code>"*"</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-additive_build_file"></a>additive_build_file</td><td style="text-align: left">A file containing extra contents to write to the bottom of generated BUILD files.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-additive_build_file_content"></a>additive_build_file_content</td><td style="text-align: left">Extra contents to write to the bottom of generated BUILD files.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-alias_rule"></a>alias_rule</td><td style="text-align: left">Alias rule to use instead of <code>native.alias()</code>. Overrides <a href="#render_config">render_config</a>'s 'default_alias_rule'.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_compile_data"></a>build_script_compile_data</td><td style="text-align: left">A list of labels to add to a crate's <code>cargo_build_script::compile_data</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_data"></a>build_script_data</td><td style="text-align: left">A list of labels to add to a crate's <code>cargo_build_script::data</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_tools"></a>build_script_tools</td><td style="text-align: left">A list of labels to add to a crate's <code>cargo_build_script::tools</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_data_glob"></a>build_script_data_glob</td><td style="text-align: left">A list of glob patterns to add to a crate's <code>cargo_build_script::data</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_deps"></a>build_script_deps</td><td style="text-align: left">A list of labels to add to a crate's <code>cargo_build_script::deps</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_env"></a>build_script_env</td><td style="text-align: left">Additional environment variables to set on a crate's <code>cargo_build_script::env</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_proc_macro_deps"></a>build_script_proc_macro_deps</td><td style="text-align: left">A list of labels to add to a crate's <code>cargo_build_script::proc_macro_deps</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_rundir"></a>build_script_rundir</td><td style="text-align: left">An override for the build script's rundir attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_rustc_env"></a>build_script_rustc_env</td><td style="text-align: left">Additional environment variables to set on a crate's <code>cargo_build_script::env</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-build_script_toolchains"></a>build_script_toolchains</td><td style="text-align: left">A list of labels to set on a crates's <code>cargo_build_script::toolchains</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-compile_data"></a>compile_data</td><td style="text-align: left">A list of labels to add to a crate's <code>rust_library::compile_data</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-compile_data_glob"></a>compile_data_glob</td><td style="text-align: left">A list of glob patterns to add to a crate's <code>rust_library::compile_data</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-crate_features"></a>crate_features</td><td style="text-align: left">A list of strings to add to a crate's <code>rust_library::crate_features</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-data"></a>data</td><td style="text-align: left">A list of labels to add to a crate's <code>rust_library::data</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-data_glob"></a>data_glob</td><td style="text-align: left">A list of glob patterns to add to a crate's <code>rust_library::data</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-deps"></a>deps</td><td style="text-align: left">A list of labels to add to a crate's <code>rust_library::deps</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-extra_aliased_targets"></a>extra_aliased_targets</td><td style="text-align: left">A list of targets to add to the generated aliases in the root crate_universe repository.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-gen_binaries"></a>gen_binaries</td><td style="text-align: left">As a list, the subset of the crate's bins that should get <code>rust_binary</code> targets produced. Or <code>True</code> to generate all, <code>False</code> to generate none.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-disable_pipelining"></a>disable_pipelining</td><td style="text-align: left">If True, disables pipelining for library targets for this crate.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-gen_build_script"></a>gen_build_script</td><td style="text-align: left">An authorative flag to determine whether or not to produce <code>cargo_build_script</code> targets for the current crate.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-patch_args"></a>patch_args</td><td style="text-align: left">The <code>patch_args</code> attribute of a Bazel repository rule. See <a href="https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_args">http_archive.patch_args</a></td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-patch_tool"></a>patch_tool</td><td style="text-align: left">The <code>patch_tool</code> attribute of a Bazel repository rule. See <a href="https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_tool">http_archive.patch_tool</a></td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-patches"></a>patches</td><td style="text-align: left">The <code>patches</code> attribute of a Bazel repository rule. See <a href="https://docs.bazel.build/versions/main/repo/http.html#http_archive-patches">http_archive.patches</a></td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-proc_macro_deps"></a>proc_macro_deps</td><td style="text-align: left">A list of labels to add to a crate's <code>rust_library::proc_macro_deps</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-rustc_env"></a>rustc_env</td><td style="text-align: left">Additional variables to set on a crate's <code>rust_library::rustc_env</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-rustc_env_files"></a>rustc_env_files</td><td style="text-align: left">A list of labels to set on a crate's <code>rust_library::rustc_env_files</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-rustc_flags"></a>rustc_flags</td><td style="text-align: left">A list of strings to set on a crate's <code>rust_library::rustc_flags</code> attribute.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-shallow_since"></a>shallow_since</td><td style="text-align: left">An optional timestamp used for crates originating from a git repository instead of a crate registry. This flag optimizes fetching the source code.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.annotation-override_targets"></a>override_targets</td><td style="text-align: left">A dictionary of alternate targets to use when something depends on this crate to allow the parent repo to provide its own version of this dependency. Keys can be <code>proc-marco</code>, <code>custom-build</code>, <code>lib</code>, <code>bin</code>.</td><td style="text-align: left"><code>None</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>string: A json encoded string containing the specified version and separately all other inputs.</p>
<p><a id="crate.select"></a></p>
<h2 id="crateselect"><a class="header" href="#crateselect">crate.select</a></h2>
<pre>
crate.select(<a href="#crate.select-common">common</a>, <a href="#crate.select-selects">selects</a>)
</pre>
<p>A Starlark Select for <code>crate.annotation()</code>.</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crate.select-common"></a>common</td><td style="text-align: left">A value that applies to all configurations.</td><td style="text-align: left">none</td></tr>
<tr><td style="text-align: left"><a id="crate.select-selects"></a>selects</td><td style="text-align: left">A dict of <code>target_triple</code> to values.</td><td style="text-align: left">none</td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>struct: A struct representing the Starlark Select.</p>
<p><a id="crate.spec"></a></p>
<h2 id="cratespec"><a class="header" href="#cratespec">crate.spec</a></h2>
<pre>
crate.spec(<a href="#crate.spec-package">package</a>, <a href="#crate.spec-version">version</a>, <a href="#crate.spec-artifact">artifact</a>, <a href="#crate.spec-lib">lib</a>, <a href="#crate.spec-default_features">default_features</a>, <a href="#crate.spec-features">features</a>, <a href="#crate.spec-git">git</a>, <a href="#crate.spec-branch">branch</a>, <a href="#crate.spec-tag">tag</a>, <a href="#crate.spec-rev">rev</a>)
</pre>
<p>A constructor for a crate dependency.</p>
<p>See <a href="https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html">specifying dependencies</a> in the Cargo book for more details.</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crate.spec-package"></a>package</td><td style="text-align: left">The explicit name of the package (used when attempting to alias a crate).</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-version"></a>version</td><td style="text-align: left">The exact version of the crate. Cannot be used with <code>git</code>.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-artifact"></a>artifact</td><td style="text-align: left">Set to "bin" to pull in a binary crate as an artifact dependency. Requires a nightly Cargo.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-lib"></a>lib</td><td style="text-align: left">If using <code>artifact = "bin"</code>, additionally setting <code>lib = True</code> declares a dependency on both the package's library and binary, as opposed to just the binary.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-default_features"></a>default_features</td><td style="text-align: left">Maps to the <code>default-features</code> flag.</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-features"></a>features</td><td style="text-align: left">A list of features to use for the crate</td><td style="text-align: left"><code>[]</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-git"></a>git</td><td style="text-align: left">The Git url to use for the crate. Cannot be used with <code>version</code>.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-branch"></a>branch</td><td style="text-align: left">The git branch of the remote crate. Tied with the <code>git</code> param. Only one of branch, tag or rev may be specified. Specifying <code>rev</code> is recommended for fully-reproducible builds.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-tag"></a>tag</td><td style="text-align: left">The git tag of the remote crate. Tied with the <code>git</code> param. Only one of branch, tag or rev may be specified. Specifying <code>rev</code> is recommended for fully-reproducible builds.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crate.spec-rev"></a>rev</td><td style="text-align: left">The git revision of the remote crate. Tied with the <code>git</code> param. Only one of branch, tag or rev may be specified.</td><td style="text-align: left"><code>None</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>string: A json encoded string of all inputs</p>
<p><a id="crate.workspace_member"></a></p>
<h2 id="crateworkspace_member"><a class="header" href="#crateworkspace_member">crate.workspace_member</a></h2>
<pre>
crate.workspace_member(<a href="#crate.workspace_member-version">version</a>, <a href="#crate.workspace_member-sha256">sha256</a>)
</pre>
<p>Define information for extra workspace members</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crate.workspace_member-version"></a>version</td><td style="text-align: left">The semver of the crate to download. Must be an exact version.</td><td style="text-align: left">none</td></tr>
<tr><td style="text-align: left"><a id="crate.workspace_member-sha256"></a>sha256</td><td style="text-align: left">The sha256 checksum of the <code>.crate</code> file.</td><td style="text-align: left"><code>None</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>string: A json encoded string of all inputs</p>
<p><a id="crate_deps"></a></p>
<h2 id="crate_deps"><a class="header" href="#crate_deps">crate_deps</a></h2>
<pre>
crate_deps(<a href="#crate_deps-deps">deps</a>, <a href="#crate_deps-package_name">package_name</a>)
</pre>
<p>Finds the fully qualified label of the requested crates for the package where this macro is called.</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crate_deps-deps"></a>deps</td><td style="text-align: left">The desired list of crate targets.</td><td style="text-align: left">none</td></tr>
<tr><td style="text-align: left"><a id="crate_deps-package_name"></a>package_name</td><td style="text-align: left">The package name of the set of dependencies to look up. Defaults to <code>native.package_name()</code>.</td><td style="text-align: left"><code>None</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>list: A list of labels to generated rust targets (str)</p>
<p><a id="crate_repositories"></a></p>
<h2 id="crate_repositories"><a class="header" href="#crate_repositories">crate_repositories</a></h2>
<pre>
crate_repositories()
</pre>
<p>A macro for defining repositories for all generated crates.</p>
<p><strong>RETURNS</strong></p>
<p>A list of repos visible to the module through the module extension.</p>
<p><a id="crate_universe_dependencies"></a></p>
<h2 id="crate_universe_dependencies"><a class="header" href="#crate_universe_dependencies">crate_universe_dependencies</a></h2>
<pre>
crate_universe_dependencies(<a href="#crate_universe_dependencies-rust_version">rust_version</a>, <a href="#crate_universe_dependencies-bootstrap">bootstrap</a>, <a href="#crate_universe_dependencies-kwargs">kwargs</a>)
</pre>
<p>Define dependencies of the <code>cargo-bazel</code> Rust target</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crate_universe_dependencies-rust_version"></a>rust_version</td><td style="text-align: left">The version of rust to use when generating dependencies.</td><td style="text-align: left"><code>"1.82.0"</code></td></tr>
<tr><td style="text-align: left"><a id="crate_universe_dependencies-bootstrap"></a>bootstrap</td><td style="text-align: left">If true, a <code>cargo_bootstrap_repository</code> target will be generated.</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="crate_universe_dependencies-kwargs"></a>kwargs</td><td style="text-align: left">Arguments to pass through to cargo_bazel_bootstrap.</td><td style="text-align: left">none</td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.</p>
<p><a id="render_config"></a></p>
<h2 id="render_config"><a class="header" href="#render_config">render_config</a></h2>
<pre>
render_config(<a href="#render_config-build_file_template">build_file_template</a>, <a href="#render_config-crate_label_template">crate_label_template</a>, <a href="#render_config-crate_repository_template">crate_repository_template</a>,
<a href="#render_config-crates_module_template">crates_module_template</a>, <a href="#render_config-default_alias_rule">default_alias_rule</a>, <a href="#render_config-default_package_name">default_package_name</a>,
<a href="#render_config-generate_target_compatible_with">generate_target_compatible_with</a>, <a href="#render_config-platforms_template">platforms_template</a>, <a href="#render_config-regen_command">regen_command</a>, <a href="#render_config-vendor_mode">vendor_mode</a>,
<a href="#render_config-generate_rules_license_metadata">generate_rules_license_metadata</a>)
</pre>
<p>Various settings used to configure rendered outputs</p>
<p>The template parameters each support a select number of format keys. A description of each key
can be found below where the supported keys for each template can be found in the parameter docs</p>
<div class="table-wrapper"><table><thead><tr><th>key</th><th>definition</th></tr></thead><tbody>
<tr><td><code>name</code></td><td>The name of the crate. Eg <code>tokio</code></td></tr>
<tr><td><code>repository</code></td><td>The rendered repository name for the crate. Directly relates to <code>crate_repository_template</code>.</td></tr>
<tr><td><code>triple</code></td><td>A platform triple. Eg <code>x86_64-unknown-linux-gnu</code></td></tr>
<tr><td><code>version</code></td><td>The crate version. Eg <code>1.2.3</code></td></tr>
<tr><td><code>target</code></td><td>The library or binary target of the crate</td></tr>
<tr><td><code>file</code></td><td>The basename of a file</td></tr>
</tbody></table>
</div>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="render_config-build_file_template"></a>build_file_template</td><td style="text-align: left">The base template to use for BUILD file names. The available format keys are [<code>{name}</code>, {version}`].</td><td style="text-align: left"><code>"//:BUILD.{name}-{version}.bazel"</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-crate_label_template"></a>crate_label_template</td><td style="text-align: left">The base template to use for crate labels. The available format keys are [<code>{repository}</code>, <code>{name}</code>, <code>{version}</code>, <code>{target}</code>].</td><td style="text-align: left"><code>"@{repository}__{name}-{version}//:{target}"</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-crate_repository_template"></a>crate_repository_template</td><td style="text-align: left">The base template to use for Crate label repository names. The available format keys are [<code>{repository}</code>, <code>{name}</code>, <code>{version}</code>].</td><td style="text-align: left"><code>"{repository}__{name}-{version}"</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-crates_module_template"></a>crates_module_template</td><td style="text-align: left">The pattern to use for the <code>defs.bzl</code> and <code>BUILD.bazel</code> file names used for the crates module. The available format keys are [<code>{file}</code>].</td><td style="text-align: left"><code>"//:{file}"</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-default_alias_rule"></a>default_alias_rule</td><td style="text-align: left">Alias rule to use when generating aliases for all crates. Acceptable values are 'alias', 'dbg'/'fastbuild'/'opt' (transitions each crate's <code>compilation_mode</code>) or a string representing a rule in the form '&lt;label to .bzl&gt;:<rule>' that takes a single label parameter 'actual'. See '@crate_index//:alias_rules.bzl' for an example.</td><td style="text-align: left"><code>"alias"</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-default_package_name"></a>default_package_name</td><td style="text-align: left">The default package name to use in the rendered macros. This affects the auto package detection of things like <code>all_crate_deps</code>.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-generate_target_compatible_with"></a>generate_target_compatible_with</td><td style="text-align: left">Whether to generate <code>target_compatible_with</code> annotations on the generated BUILD files. This catches a <code>target_triple</code>being targeted that isn't declared in <code>supported_platform_triples</code>.</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-platforms_template"></a>platforms_template</td><td style="text-align: left">The base template to use for platform names. See <a href="https://docs.bazel.build/versions/main/platforms.html">platforms documentation</a>. The available format keys are [<code>{triple}</code>].</td><td style="text-align: left"><code>"@rules_rust//rust/platform:{triple}"</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-regen_command"></a>regen_command</td><td style="text-align: left">An optional command to demonstrate how generated files should be regenerated.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-vendor_mode"></a>vendor_mode</td><td style="text-align: left">An optional configuration for rendirng content to be rendered into repositories.</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="render_config-generate_rules_license_metadata"></a>generate_rules_license_metadata</td><td style="text-align: left">Whether to generate rules license metedata</td><td style="text-align: left"><code>False</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>string: A json encoded struct to match the Rust <code>config::RenderConfig</code> struct</p>
<p><a id="splicing_config"></a></p>
<h2 id="splicing_config"><a class="header" href="#splicing_config">splicing_config</a></h2>
<pre>
splicing_config(<a href="#splicing_config-resolver_version">resolver_version</a>)
</pre>
<p>Various settings used to configure Cargo manifest splicing behavior.</p>
<p><strong>PARAMETERS</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Default Value</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="splicing_config-resolver_version"></a>resolver_version</td><td style="text-align: left">The <a href="https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions">resolver version</a> to use in generated Cargo manifests. This flag is <strong>only</strong> used when splicing a manifest from direct package definitions. See <code>crates_repository::packages</code>.</td><td style="text-align: left"><code>"2"</code></td></tr>
</tbody></table>
</div>
<p><strong>RETURNS</strong></p>
<p>str: A json encoded string of the parameters provided</p>
<p><a id="crates_repository"></a></p>
<h2 id="crates_repository"><a class="header" href="#crates_repository">crates_repository</a></h2>
<pre>
crates_repository(<a href="#crates_repository-name">name</a>, <a href="#crates_repository-annotations">annotations</a>, <a href="#crates_repository-cargo_config">cargo_config</a>, <a href="#crates_repository-cargo_lockfile">cargo_lockfile</a>, <a href="#crates_repository-generate_binaries">generate_binaries</a>,
<a href="#crates_repository-generate_build_scripts">generate_build_scripts</a>, <a href="#crates_repository-generate_target_compatible_with">generate_target_compatible_with</a>, <a href="#crates_repository-generator">generator</a>,
<a href="#crates_repository-generator_sha256s">generator_sha256s</a>, <a href="#crates_repository-generator_urls">generator_urls</a>, <a href="#crates_repository-isolated">isolated</a>, <a href="#crates_repository-lockfile">lockfile</a>, <a href="#crates_repository-manifests">manifests</a>, <a href="#crates_repository-packages">packages</a>, <a href="#crates_repository-quiet">quiet</a>,
<a href="#crates_repository-render_config">render_config</a>, <a href="#crates_repository-repin_instructions">repin_instructions</a>, <a href="#crates_repository-repo_mapping">repo_mapping</a>, <a href="#crates_repository-rust_toolchain_cargo_template">rust_toolchain_cargo_template</a>,
<a href="#crates_repository-rust_toolchain_rustc_template">rust_toolchain_rustc_template</a>, <a href="#crates_repository-rust_version">rust_version</a>, <a href="#crates_repository-splicing_config">splicing_config</a>,
<a href="#crates_repository-supported_platform_triples">supported_platform_triples</a>)
</pre>
<p>A rule for defining and downloading Rust dependencies (crates). This rule
handles all the same <a href="#workflows">workflows</a> <code>crate_universe</code> rules do.</p>
<p>Environment Variables:</p>
<div class="table-wrapper"><table><thead><tr><th>variable</th><th>usage</th></tr></thead><tbody>
<tr><td><code>CARGO_BAZEL_GENERATOR_SHA256</code></td><td>The sha256 checksum of the file located at <code>CARGO_BAZEL_GENERATOR_URL</code></td></tr>
<tr><td><code>CARGO_BAZEL_GENERATOR_URL</code></td><td>The URL of a cargo-bazel binary. This variable takes precedence over attributes and can use <code>file://</code> for local paths</td></tr>
<tr><td><code>CARGO_BAZEL_ISOLATED</code></td><td>An authorative flag as to whether or not the <code>CARGO_HOME</code> environment variable should be isolated from the host configuration</td></tr>
<tr><td><code>CARGO_BAZEL_REPIN</code></td><td>An indicator that the dependencies represented by the rule should be regenerated. <code>REPIN</code> may also be used. See <a href="#repinning--updating-dependencies">Repinning / Updating Dependencies</a> for more details.</td></tr>
<tr><td><code>CARGO_BAZEL_REPIN_ONLY</code></td><td>A comma-delimited allowlist for rules to execute repinning. Can be useful if multiple instances of the repository rule are used in a Bazel workspace, but repinning should be limited to one of them.</td></tr>
</tbody></table>
</div>
<p>Example:</p>
<p>Given the following workspace structure:</p>
<pre><code class="language-text">[workspace]/
WORKSPACE.bazel
BUILD.bazel
Cargo.toml
Cargo.Bazel.lock
src/
main.rs
</code></pre>
<p>The following is something that'd be found in the <code>WORKSPACE</code> file:</p>
<pre><code class="language-python">load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "crate")
crates_repository(
name = "crate_index",
annotations = {
"rand": [crate.annotation(
default_features = False,
features = ["small_rng"],
)],
},
cargo_lockfile = "//:Cargo.Bazel.lock",
lockfile = "//:cargo-bazel-lock.json",
manifests = ["//:Cargo.toml"],
# Should match the version represented by the currently registered `rust_toolchain`.
rust_version = "1.60.0",
)
</code></pre>
<p>The above will create an external repository which contains aliases and macros for accessing
Rust targets found in the dependency graph defined by the given manifests.</p>
<p><strong>NOTE</strong>: The <code>cargo_lockfile</code> and <code>lockfile</code> must be manually created. The rule unfortunately does not yet create
it on its own. When initially setting up this rule, an empty file should be created and then
populated by repinning dependencies.</p>
<h3 id="repinning--updating-dependencies-1"><a class="header" href="#repinning--updating-dependencies-1">Repinning / Updating Dependencies</a></h3>
<p>Dependency syncing and updating is done in the repository rule which means it's done during the
analysis phase of builds. As mentioned in the environments variable table above, the <code>CARGO_BAZEL_REPIN</code>
(or <code>REPIN</code>) environment variables can be used to force the rule to update dependencies and potentially
render a new lockfile. Given an instance of this repository rule named <code>crate_index</code>, the easiest way to
repin dependencies is to run:</p>
<pre><code class="language-shell">CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index
</code></pre>
<p>This will result in all dependencies being updated for a project. The <code>CARGO_BAZEL_REPIN</code> environment variable
can also be used to customize how dependencies are updated. The following table shows translations from environment
variable values to the equivilant <a href="https://doc.rust-lang.org/cargo/commands/cargo-update.html">cargo update</a> command
that is called behind the scenes to update dependencies.</p>
<div class="table-wrapper"><table><thead><tr><th>Value</th><th>Cargo command</th></tr></thead><tbody>
<tr><td>Any of [<code>true</code>, <code>1</code>, <code>yes</code>, <code>on</code>, <code>workspace</code>]</td><td><code>cargo update --workspace</code></td></tr>
<tr><td>Any of [<code>full</code>, <code>eager</code>, <code>all</code>]</td><td><code>cargo update</code></td></tr>
<tr><td><code>package_name</code></td><td><code>cargo upgrade --package package_name</code></td></tr>
<tr><td><code>package_name@1.2.3</code></td><td><code>cargo upgrade --package package_name@1.2.3</code></td></tr>
<tr><td><code>package_name@1.2.3=4.5.6</code></td><td><code>cargo upgrade --package package_name@1.2.3 --precise=4.5.6</code></td></tr>
</tbody></table>
</div>
<p>If the <code>crates_repository</code> is used multiple times in the same Bazel workspace (e.g. for multiple independent
Rust workspaces), it may additionally be useful to use the <code>CARGO_BAZEL_REPIN_ONLY</code> environment variable, which
limits execution of the repinning to one or multiple instances of the <code>crates_repository</code> rule via a comma-delimited
allowlist:</p>
<pre><code class="language-shell">CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_index
</code></pre>
<p><strong>ATTRIBUTES</strong></p>
<div class="table-wrapper"><table><thead><tr><th style="text-align: left">Name</th><th style="text-align: left">Description</th><th style="text-align: left">Type</th><th style="text-align: left">Mandatory</th><th style="text-align: left">Default</th></tr></thead><tbody>
<tr><td style="text-align: left"><a id="crates_repository-name"></a>name</td><td style="text-align: left">A unique name for this repository.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels#target-names">Name</a></td><td style="text-align: left">required</td><td style="text-align: left"></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-annotations"></a>annotations</td><td style="text-align: left">Extra settings to apply to crates. See <a href="#crateannotation">crate.annotation</a>.</td><td style="text-align: left"><a href="https://bazel.build/rules/lib/dict">Dictionary: String -&gt; List of strings</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>{}</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-cargo_config"></a>cargo_config</td><td style="text-align: left">A <a href="https://doc.rust-lang.org/cargo/reference/config.html">Cargo configuration</a> file</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-cargo_lockfile"></a>cargo_lockfile</td><td style="text-align: left">The path used to store the <code>crates_repository</code> specific <a href="https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html">Cargo.lock</a> file. In the case that your <code>crates_repository</code> corresponds directly with an existing <code>Cargo.toml</code> file which has a paired <code>Cargo.lock</code> file, that <code>Cargo.lock</code> file should be used here, which will keep the versions used by cargo and bazel in sync.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">required</td><td style="text-align: left"></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-generate_binaries"></a>generate_binaries</td><td style="text-align: left">Whether to generate <code>rust_binary</code> targets for all the binary crates in every package. By default only the <code>rust_library</code> targets are generated.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>False</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-generate_build_scripts"></a>generate_build_scripts</td><td style="text-align: left">Whether or not to generate <a href="https://doc.rust-lang.org/cargo/reference/build-scripts.html">cargo build scripts</a> by default.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-generate_target_compatible_with"></a>generate_target_compatible_with</td><td style="text-align: left">DEPRECATED: Moved to <code>render_config</code>.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-generator"></a>generator</td><td style="text-align: left">The absolute label of a generator. Eg. <code>@cargo_bazel_bootstrap//:cargo-bazel</code>. This is typically used when bootstrapping</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>""</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-generator_sha256s"></a>generator_sha256s</td><td style="text-align: left">Dictionary of <code>host_triple</code> -&gt; <code>sha256</code> for a <code>cargo-bazel</code> binary.</td><td style="text-align: left"><a href="https://bazel.build/rules/lib/dict">Dictionary: String -&gt; String</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>{}</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-generator_urls"></a>generator_urls</td><td style="text-align: left">URL template from which to download the <code>cargo-bazel</code> binary. <code>{host_triple}</code> and will be filled in according to the host platform.</td><td style="text-align: left"><a href="https://bazel.build/rules/lib/dict">Dictionary: String -&gt; String</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>{}</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-isolated"></a>isolated</td><td style="text-align: left">If true, <code>CARGO_HOME</code> will be overwritten to a directory within the generated repository in order to prevent other uses of Cargo from impacting having any effect on the generated targets produced by this rule. For users who either have multiple <code>crate_repository</code> definitions in a WORKSPACE or rapidly re-pin dependencies, setting this to false may improve build times. This variable is also controled by <code>CARGO_BAZEL_ISOLATED</code> environment variable.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-lockfile"></a>lockfile</td><td style="text-align: left">The path to a file to use for reproducible renderings. If set, this file must exist within the workspace (but can be empty) before this rule will work.</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">Label</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>None</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-manifests"></a>manifests</td><td style="text-align: left">A list of Cargo manifests (<code>Cargo.toml</code> files).</td><td style="text-align: left"><a href="https://bazel.build/concepts/labels">List of labels</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>[]</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-packages"></a>packages</td><td style="text-align: left">A set of crates (packages) specifications to depend on. See <a href="#crate.spec">crate.spec</a>.</td><td style="text-align: left"><a href="https://bazel.build/rules/lib/dict">Dictionary: String -&gt; String</a></td><td style="text-align: left">optional</td><td style="text-align: left"><code>{}</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-quiet"></a>quiet</td><td style="text-align: left">If stdout and stderr should not be printed to the terminal.</td><td style="text-align: left">Boolean</td><td style="text-align: left">optional</td><td style="text-align: left"><code>True</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-render_config"></a>render_config</td><td style="text-align: left">The configuration flags to use for rendering. Use <code>//crate_universe:defs.bzl\%render_config</code> to generate the value for this field. If unset, the defaults defined there will be used.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>""</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-repin_instructions"></a>repin_instructions</td><td style="text-align: left">Instructions to re-pin the repository if required. Many people have wrapper scripts for keeping dependencies up to date, and would like to point users to that instead of the default.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>""</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-repo_mapping"></a>repo_mapping</td><td style="text-align: left">In <code>WORKSPACE</code> context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>).<br><br>This attribute is <em>not</em> supported in <code>MODULE.bazel</code> context (when invoking a repository rule inside a module extension's implementation function).</td><td style="text-align: left"><a href="https://bazel.build/rules/lib/dict">Dictionary: String -&gt; String</a></td><td style="text-align: left">optional</td><td style="text-align: left"></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template</td><td style="text-align: left">The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template</td><td style="text-align: left">The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'cargo.exe') will be replaced in the string if present.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-rust_version"></a>rust_version</td><td style="text-align: left">The version of Rust the currently registered toolchain is using. Eg. <code>1.56.0</code>, or <code>nightly/2021-09-08</code></td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>"1.82.0"</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-splicing_config"></a>splicing_config</td><td style="text-align: left">The configuration flags to use for splicing Cargo maniests. Use <code>//crate_universe:defs.bzl\%rsplicing_config</code> to generate the value for this field. If unset, the defaults defined there will be used.</td><td style="text-align: left">String</td><td style="text-align: left">optional</td><td style="text-align: left"><code>""</code></td></tr>
<tr><td style="text-align: left"><a id="crates_repository-supported_platform_triples"></a>supported_platform_triples</td><td style="text-align: left">A set of all platform triples to consider when generating dependencies.</td><td style="text-align: left">List of strings</td><td style="text-align: left">optional</td><td style="text-align: left"><code>["aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", "aarch64-linux-android", "aarch64-pc-windows-msvc", "aarch64-unknown-fuchsia", "aarch64-unknown-linux-gnu", "aarch64-unknown-nixos-gnu", "aarch64-unknown-nto-qnx710", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-apple-darwin", "i686-linux-android", "i686-pc-windows-msvc", "i686-unknown-freebsd", "i686-unknown-linux-gnu", "powerpc-unknown-linux-gnu", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-none-elf", "s390x-unknown-linux-gnu", "thumbv7em-none-eabi", "thumbv8m.main-none-eabi", "wasm32-unknown-unknown", "wasm32-wasi", "wasm32-wasip1", "x86_64-apple-darwin", "x86_64-apple-ios", "x86_64-linux-android", "x86_64-pc-windows-msvc", "x86_64-unknown-freebsd", "x86_64-unknown-fuchsia", "x86_64-unknown-linux-gnu", "x86_64-unknown-nixos-gnu", "x86_64-unknown-none"]</code></td></tr>
</tbody></table>
</div>
<p><strong>ENVIRONMENT VARIABLES</strong></p>
<p>This repository rule depends on the following environment variables:</p>
<ul>
<li><code>CARGO_BAZEL_GENERATOR_URL</code></li>
<li><code>CARGO_BAZEL_GENERATOR_SHA256</code></li>
<li><code>CARGO_BAZEL_REPIN</code></li>
<li><code>REPIN</code></li>
<li><code>CARGO_BAZEL_REPIN_ONLY</code></li>
<li><code>CARGO_BAZEL_ISOLATED</code></li>
<li><code>CARGO_BAZEL_DEBUG</code></li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="crate_universe_bzlmod.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="upstream_tooling.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="crate_universe_bzlmod.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="upstream_tooling.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script>
window.playground_copyable = true;
</script>
<script src="elasticlunr.min.js"></script>
<script src="mark.min.js"></script>
<script src="searcher.js"></script>
<script src="clipboard.min.js"></script>
<script src="highlight.js"></script>
<script src="book.js"></script>
<!-- Custom JS scripts -->
</div>
</body>
</html>