tree: fd930f1d26ebd1ab340ef7eed259fbe9e2c62a7f [path history] [tgz]
  1. alchemy_crates/
  2. examples/
  3. ide_support/
  4. module_extension/
  5. patches/
  6. BUILD.bazel
  7. README.md
  8. repositories.bzl
  9. rust_prebuilt.bzl
  10. toolchains.bzl
toolchains/rust/README.md

Working with rust

Our rust toolchain is very different from cargo, and fits into bazel's norms.

Creating a new 1st-party crate

Similar to any other language, create a .rs file, and then create a rust_library/binary target which lists that file as it's srcs.

Adding dependencies on crates

1st-party crates

Add the corresponding target to your deps.

3rd-party crates

Add a dep on @crates//:<crate name> (for chromeos) or @alchemy-crates//:<crate name> (for infra).

If the crate doesn't exist, or if the version needs to be updated, then:

@alchemy-crates

Modify the //rules_cros/toolchains/rust/alchemy_crates/Cargo.toml, then cd to the directory that contains it and run cargo update --workspace to update the lockfile.

@crates

Modify //third_party/rust_crates/projects/.../Cargo.toml, then run third_party/rust_crates/vendor.py.