This module provides a single place for all aspects, rules, and macros that are meant to have stardoc generated documentation.
Rules
crate_universe
A rule for downloading Rust dependencies (crates).
WARNING: This rule experimental and subject to change without warning.
Environment Variables:
REPIN
: Re-pin the lockfile if set (useful for repinning deps from multiple rulesets).RULES_RUST_REPIN
: Re-pin the lockfile if set (useful for only repinning Rust deps).RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE
: Override URL to use to download resolver binary- for local paths use a
file://
URL.
- for local paths use a
RULES_RUST_CRATE_UNIVERSE_RESOLVER_URL_OVERRIDE_SHA256
: An optional sha256 value for the binary at the override url location.
name
A unique name for this repository.
cargo_toml_files
A list of Cargo manifests (Cargo.toml
files).
crate_registry_template
A template for where to download crates from for the default crate registry. This must contain {version}
and {crate}
templates.
lockfile
The path to a file which stores pinned information about the generated dependency graph. this target must be a file and will be updated by the repository rule when the REPIN
environment variable is set. If this is not set, dependencies will be re-resolved more often, setting this allows caching resolves, but will error if the cache is stale.
overrides
Mapping of crate name to specification overrides. See crate.override for more details.
packages
A list of crate specifications. See crate.spec for more details.
repo_mapping
A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.
For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
).
resolver_download_url_template
URL template from which to download the resolver binary. {host_triple} and {extension} will be filled in according to the host platform.
resolver_sha256s
Dictionary of host_triple -> sha256 for resolver binary.
supported_targets
A list of supported platform triples to consider when resoliving dependencies.
Macros and Functions
crate.spec
A simple crate definition for use in the crate_universe
rule.
WARNING: This rule experimental and subject to change without warning.
Example:
load("@rules_rust//crate_universe:defs.bzl", "crate_universe", "crate")
crate_universe(
name = "spec_example",
packages = [
crate.spec(
name = "lazy_static",
semver = "=1.4",
),
],
)
name
The name of the crate as it would appear in a crate registry.
semver
The desired version (semver) of the crate
features
A list of desired features.
crate.override
A map of overrides for a particular crate
WARNING: This rule experimental and subject to change without warning.
Example:
load("@rules_rust//crate_universe:defs.bzl", "crate_universe", "crate")
crate_universe(
name = "override_example",
# [...]
overrides = {
"tokio": crate.override(
extra_rustc_env_vars = {
"MY_ENV_VAR": "MY_ENV_VALUE",
},
extra_build_script_env_vars = {
"MY_BUILD_SCRIPT_ENV_VAR": "MY_ENV_VALUE",
},
extra_bazel_deps = {
# Extra dependencies are per target. They are additive.
"cfg(unix)": ["@somerepo//:foo"], # cfg() predicate.
"x86_64-apple-darwin": ["@somerepo//:bar"], # Specific triple.
"cfg(all())": ["@somerepo//:baz"], # Applies to all targets ("regular dependency").
},
extra_build_script_bazel_deps = {
# Extra dependencies are per target. They are additive.
"cfg(unix)": ["@buildscriptdep//:foo"],
"x86_64-apple-darwin": ["@buildscriptdep//:bar"],
"cfg(all())": ["@buildscriptdep//:baz"],
},
extra_bazel_data_deps = {
# ...
},
extra_build_script_bazel_data_deps = {
# ...
},
),
},
)
extra_bazel_data_deps
Targets to add to the data
attribute
of the generated target (eg: rust_library.data).
extra_bazel_deps
Targets to add to the deps
attribute
of the generated target (eg: rust_library.deps).
extra_build_script_bazel_data_deps
Targets to add to the
data attribute of the generated
cargo_build_script
target.
extra_build_script_bazel_deps
Targets to add to the
deps attribute of the generated
cargo_build_script
target.
extra_build_script_env_vars
Environment variables to add to the
build_script_env
attribute of the generated cargo_build_script
target.
extra_rustc_env_vars
Environment variables to add to the rustc_env
attribute for the generated target (eg: rust_library.rustc_env).
features_to_remove
A list of features to remove from a generated target.