# Rust Rules
## Overview These build rules are used for building [Rust][rust] projects with Bazel. [rust]: http://www.rust-lang.org/ ## Setup To use the Rust rules, add the following to your `WORKSPACE` file to add the external repositories for the Rust toolchain: ```python load("@bazel_tools//tools/build_rules/rust:rust.bzl", "rust_repositories") rust_repositories() ``` ## Roadmap * Add `rust_toolchain` rule to make it easy to use a custom Rust toolchain. * Add tool for taking `Cargo.toml` and generating a `WORKSPACE` file with workspace rules for pulling external dependencies. * Improve expressiveness of features and support for [Cargo's feature groups](http://doc.crates.io/manifest.html#the-[features]-section). * Add `cargo_crate` workspace rule for pulling crates from [Cargo](https://crates.io/). ## rust_library ```python rust_library(name, srcs, deps, data, crate_features, rustc_flags) ```Attributes | |
---|---|
name |
Name, required
A unique name for this rule. This name will also be used as the name of the library crate built by this rule. |
srcs |
List of labels, required
List of Rust
If |
crate_root |
Label, optional
The file that will be passed to
If |
deps |
List of labels, optional
List of other libraries to be linked to this library target.
These can be either other |
data |
List of labels, optional
List of files used by this rule at runtime.
This attribute can be used to specify any data files that are embedded
into the library, such as via the
|
crate_features |
List of strings, optional
List of features to enable for this crate.
Features are defined in the code using the
|
rustc_flags |
List of strings, optional
List of compiler flags passed to |
Attributes | |
---|---|
name |
Name, required
A unique name for this rule. This name will also be used as the name of the binary crate built by this rule. |
srcs |
List of labels, required
List of Rust
If |
crate_root |
Label, optional
The file that will be passed to
If |
deps |
List of labels, optional
List of other libraries to be linked to this library target.
These must be |
data |
List of labels, optional
List of files used by this rule at runtime.
This attribute can be used to specify any data files that are embedded
into the library, such as via the
|
crate_features |
List of strings, optional
List of features to enable for this crate.
Features are defined in the code using the
|
rustc_flags |
List of strings, optional
List of compiler flags passed to |
Attributes | |
---|---|
name |
Name, required
A unique name for this rule. This name will also be used as the name of the binary test crate built by this rule. |
srcs |
List of labels, required
List of Rust
If |
crate_root |
Label, optional
The file that will be passed to
If |
deps |
List of labels, optional
List of other libraries to be linked to this test target.
These must be |
data |
List of labels, optional
List of files used by this rule at runtime.
This attribute can be used to specify any data files that are embedded
into the library, such as via the
|
crate_features |
List of strings, optional
List of features to enable for this crate.
Features are defined in the code using the
|
rustc_flags |
List of strings, optional
List of compiler flags passed to |
Attributes | |
---|---|
name |
Name, required
A unique name for this rule. This name will also be used as the name of the binary test crate built by this rule. |
srcs |
List of labels, required
List of Rust
If |
crate_root |
Label, optional
The file that will be passed to
If |
deps |
List of labels, optional
List of other libraries to be linked to this test target.
These must be |
data |
List of labels, optional
List of files used by this rule at runtime.
This attribute can be used to specify any data files that are embedded
into the library, such as via the
|
crate_features |
List of strings, optional
List of features to enable for this crate.
Features are defined in the code using the
|
rustc_flags |
List of strings, optional
List of compiler flags passed to |
Attribute | Description |
---|---|
name |
Name, required
A unique name for this rule. |
dep |
Label, required
The label of the target to generate code documentation for.
|
markdown_css |
List of Labels, optional
CSS files to include via |
html_in_header |
Label, optional
File to add to |
html_before_content |
Label, optional
File to add in |
html_after_content |
Label, optional
File to add in |
Attribute | Description |
---|---|
name |
Name, required
A unique name for this rule. |
dep |
Label, required
The label of the target to run documentation tests for.
|